Skip to content

Commit a39c3ef

Browse files
Feat/pinning settings modal (#1539)
1 parent d4f8b3c commit a39c3ef

File tree

8 files changed

+77
-52
lines changed

8 files changed

+77
-52
lines changed

public/locales/en/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
"translationProjectIntro": "Add or improve translations and make IPFS better for everyone!",
1717
"translationProjectLink": "Join the IPFS Translation Project"
1818
},
19+
"pinningModal": {
20+
"title": "Select a pinning service provider.",
21+
"description": "Don’t see your pinning service provider? <1>Add a custom one.<1>"
22+
},
1923
"actions": {
2024
"addService": "Add Service",
2125
"edit": "Change",
22-
"close": "Close"
26+
"close": "Close",
27+
"cancel": "Cancel"
2328
},
2429
"edit": "Edit",
2530
"visitService": "Visit service",

src/bundles/pinning.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,18 @@ export default {
2727
autoUpload: 'PINS_ONLY',
2828
addedAt: new Date(1592491648691)
2929
}
30+
]),
31+
32+
selectAvailablePinningServices: () => ([
33+
{
34+
name: 'Pinata',
35+
icon: 'https://ipfs.io/ipfs/QmVYXV4urQNDzZpddW4zZ9PGvcAbF38BnKWSgch3aNeViW?filename=pinata.svg'
36+
}, {
37+
name: 'Infura',
38+
icon: 'https://ipfs.io/ipfs/QmTt6KeaNXyaaUBWn2zEG8RiMfPPPeMesXqnFWqqC5o6yc?filename=infura.png'
39+
}, {
40+
name: 'Eternum',
41+
icon: 'https://ipfs.io/ipfs/QmSrqJeuYrYDmSgAy3SeAyTsYMksNPfK5CSN91xk6BBnF9?filename=eternum.png'
42+
}
3043
])
3144
}

src/components/language-selector/language-modal/LanguageModal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const LanguageModal = ({ t, tReady, onLeave, link, className, ...props }) => {
1616

1717
return (
1818
<Modal {...props} className={className} onCancel={onLeave} style={{ maxWidth: '40em' }}>
19-
<ModalBody icon={SpeakerIcon}>
19+
<ModalBody Icon={SpeakerIcon}>
2020
<p className='charcoal w-80 center'>{t('languageModal.description')}</p>
2121
<div className='pa2 flex flex-wrap'>
2222
{ localesList.map((lang) =>
@@ -34,7 +34,7 @@ const LanguageModal = ({ t, tReady, onLeave, link, className, ...props }) => {
3434
</p>
3535
</ModalBody>
3636

37-
<ModalActions>
37+
<ModalActions justify="center">
3838
<Button className='ma2 tc' bg='bg-gray' onClick={onLeave}>{t('actions.close')}</Button>
3939
</ModalActions>
4040
</Modal>

src/components/modal/Modal.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,22 @@ ModalActions.defaultProps = {
1818
className: ''
1919
}
2020

21-
export const ModalBody = ({ className, icon, title, children, ...props }) => {
22-
icon = React.createElement(icon, {
23-
className: 'fill-gray w3'
24-
})
25-
26-
return (
27-
<div className={`ph2 pv3 tc ${className}`} {...props}>
21+
export const ModalBody = ({ className, Icon, title, children, ...props }) => (
22+
<div className={`ph2 pv3 tc ${className}`} {...props}>
23+
{ Icon && (
2824
<div className='center bg-snow br-100 flex justify-center items-center' style={{ width: '80px', height: '80px' }}>
29-
{icon}
25+
{<Icon className='fill-gray w3'/>}
3026
</div>
27+
)}
3128

32-
<p className='charcoal-muted fw5'>{title}</p>
29+
<p className='charcoal-muted fw5'>{title}</p>
3330

34-
{children}
35-
</div>
36-
)
37-
}
31+
{children}
32+
</div>
33+
)
3834

3935
ModalBody.propTypes = {
40-
icon: PropTypes.func.isRequired,
36+
Icon: PropTypes.func,
4137
title: PropTypes.oneOfType([
4238
PropTypes.string,
4339
PropTypes.node

src/components/pinning-manager/PinningManager.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ const ServiceCell = ({ rowData }) => {
104104
}
105105

106106
const SizeCell = ({ rowData }) => (
107-
<p className={ !rowData.totalSize && 'gray'}>{ !rowData.totalSize ? 'N/A' : filesize(rowData.totalSize || 0, {
107+
<p className={ !rowData.totalSize ? 'gray' : ''}>{ !rowData.totalSize ? 'N/A' : filesize(rowData.totalSize || 0, {
108108
round: rowData.totalSize >= 1000000000 ? 1 : 0, spacer: ''
109109
})}</p>
110110
)
111-
const BandwidthCell = ({ rowData }) => (<div className={!rowData.bandwidthUsed && 'gray'}>{rowData.bandwidthUsed || 'N/A'}</div>)
112-
const AutoUploadCell = ({ autoUpload, type, t }) => (
111+
const BandwidthCell = ({ rowData }) => (<div className={!rowData.bandwidthUsed ? 'gray' : ''}>{rowData.bandwidthUsed || 'N/A'}</div>)
112+
const AutoUploadCell = ({ autoUpload, t }) => (
113113
<div className="flex justify-between items-center">
114-
<div className={!autoUpload && 'gray'}>{ autoUpload ? t('autoUploadKeys.' + autoUpload) : 'N/A' }</div>
115-
{ type !== 'LOCAL' && (<OptionsCell t={t}/>) }
114+
<div className={!autoUpload ? 'gray' : ''}>{ autoUpload ? t('autoUploadKeys.' + autoUpload) : 'N/A' }</div>
115+
<OptionsCell t={t}/>
116116
</div>
117117
)
118118

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.pinningManagerModalContainer {
2+
display: grid;
3+
grid-template-columns: repeat(2, auto);
4+
grid-template-rows: repeat(2, auto);
5+
justify-content: center;
6+
}
7+
8+
.pinningManagerModalItem {
9+
padding-right: 64px;
10+
margin-right: 20px;
11+
}
Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,50 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import i18n, { localesList } from '../../../i18n'
4-
import { getLanguage } from '../../../lib/i18n'
3+
import { connect } from 'redux-bundler-react'
4+
import { withTranslation, Trans } from 'react-i18next'
5+
import './PinningManagerModal.css'
56

67
// Components
78
import { Modal, ModalBody, ModalActions } from '../../modal/Modal'
8-
import SpeakerIcon from '../../../icons/StrokeSpeaker'
99
import Button from '../../button/Button'
1010

11-
const LanguageModal = ({ t, tReady, onLeave, link, className, ...props }) => {
12-
const handleClick = (lang) => {
13-
i18n.changeLanguage(lang)
14-
onLeave()
15-
}
16-
11+
const PinningManagerModal = ({ t, onLeave, className, availablePinningServices, ...props }) => {
1712
return (
18-
<Modal {...props} className={className} onCancel={onLeave} style={{ maxWidth: '40em' }}>
19-
<ModalBody icon={SpeakerIcon}>
20-
<p className='charcoal w-80 center'>{t('languageModal.description')}</p>
21-
<div className='pa2 flex flex-wrap'>
22-
{ localesList.map((lang) =>
23-
<button
24-
key={`lang-${lang}`}
25-
className='pa2 w-33 flex nowrap bg-transparent bn outline-0 blue justify-center'
26-
onClick={() => handleClick(lang)}>
27-
{ getLanguage(lang) }
13+
<Modal {...props} className={className} onCancel={onLeave} style={{ maxWidth: '34em' }}>
14+
<ModalBody>
15+
<p>{ t('pinningModal.title') }</p>
16+
<div className='pa2 pinningManagerModalContainer'>
17+
{ availablePinningServices.map(({ icon, name }) => (
18+
<button className="flex items-center pinningManagerModalItem pa1 hoverable-button">
19+
<img className="mr3" src={icon} alt={name} width={42} height={42} style={{ objectFit: 'contain' }} />
20+
<p>{ name }</p>
2821
</button>
29-
)}
22+
))}
3023
</div>
31-
<p className='lh-copy charcoal f6'>
32-
{t('languageModal.translationProjectIntro')}<br/>
33-
<a href="https://www.transifex.com/ipfs/public/" rel="noopener noreferrer" target="_blank" className="link blue">{t('languageModal.translationProjectLink')}</a>
24+
<p>
25+
<Trans i18nKey="pinningModal.description" t={t}>
26+
Don’t see your pinning service provider? <a href={/* TODO: add action for custom add */ '/'}>Add a custom one.</a>
27+
</Trans>
3428
</p>
3529
</ModalBody>
3630

37-
<ModalActions>
38-
<Button className='ma2 tc' bg='bg-gray' onClick={onLeave}>{t('actions.close')}</Button>
31+
<ModalActions justify="center">
32+
<Button className='ma2 tc' bg='bg-gray' onClick={onLeave}>{t('actions.cancel')}</Button>
3933
</ModalActions>
4034
</Modal>
4135
)
4236
}
4337

44-
LanguageModal.propTypes = {
45-
onLeave: PropTypes.func.isRequired,
38+
PinningManagerModal.propTypes = {
4639
t: PropTypes.func.isRequired,
47-
tReady: PropTypes.bool
40+
onLeave: PropTypes.func.isRequired
4841
}
4942

50-
LanguageModal.defaultProps = {
43+
PinningManagerModal.defaultProps = {
5144
className: ''
5245
}
5346

54-
export default LanguageModal
47+
export default connect(
48+
'selectAvailablePinningServices',
49+
withTranslation('settings')(PinningManagerModal)
50+
)

src/reset.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ button.button-inside-focus:focus {
2424
button.button-inside-focus:focus > *:first-child {
2525
outline: 1px solid #bbb;
2626
}
27+
28+
button.hoverable-button:hover {
29+
background: #E8E9ED
30+
}

0 commit comments

Comments
 (0)