diff --git a/src/components/DashboardPage/EmptyState.js b/src/components/DashboardPage/EmptyState.js index 0d3726ca..e71476e8 100644 --- a/src/components/DashboardPage/EmptyState.js +++ b/src/components/DashboardPage/EmptyState.js @@ -8,6 +8,8 @@ import { compose } from 'redux' import { translate } from 'react-i18next' import { push } from 'react-router-redux' +import { MODAL_ADD_ACCOUNTS } from 'config/constants' + import { openModal } from 'reducers/modals' import type { T } from 'types/common' @@ -50,7 +52,7 @@ class EmptyState extends PureComponent { padded primary style={{ width: 120 }} - onClick={() => openModal('importAccounts')} + onClick={() => openModal(MODAL_ADD_ACCOUNTS)} > {t('app:emptyState.dashboard.buttons.addAccount')} diff --git a/src/components/MainSideBar/index.js b/src/components/MainSideBar/index.js index 28c8c5c8..5e0bc619 100644 --- a/src/components/MainSideBar/index.js +++ b/src/components/MainSideBar/index.js @@ -13,7 +13,7 @@ import type { Account } from '@ledgerhq/live-common/lib/types' import type { T } from 'types/common' import type { UpdateStatus } from 'reducers/update' -import { MODAL_RECEIVE, MODAL_SEND } from 'config/constants' +import { MODAL_RECEIVE, MODAL_SEND, MODAL_ADD_ACCOUNTS } from 'config/constants' import { accountsSelector } from 'reducers/accounts' import { openModal } from 'reducers/modals' @@ -70,7 +70,7 @@ class MainSideBar extends PureComponent { handleOpenReceiveModal = () => this.props.openModal(MODAL_RECEIVE) handleClickManager = () => this.push('/manager') handleClickExchange = () => this.push('/exchange') - handleOpenImportModal = () => this.props.openModal('importAccounts') + handleOpenImportModal = () => this.props.openModal(MODAL_ADD_ACCOUNTS) render() { const { t, accounts, location, updateStatus } = this.props @@ -78,7 +78,7 @@ class MainSideBar extends PureComponent { const addAccountButton = ( ) diff --git a/src/components/modals/ImportAccounts/AccountRow.js b/src/components/modals/AddAccounts/AccountRow.js similarity index 100% rename from src/components/modals/ImportAccounts/AccountRow.js rename to src/components/modals/AddAccounts/AccountRow.js diff --git a/src/components/modals/ImportAccounts/index.js b/src/components/modals/AddAccounts/index.js similarity index 86% rename from src/components/modals/ImportAccounts/index.js rename to src/components/modals/AddAccounts/index.js index ddac622a..ca712357 100644 --- a/src/components/modals/ImportAccounts/index.js +++ b/src/components/modals/AddAccounts/index.js @@ -10,6 +10,7 @@ import SyncSkipUnderPriority from 'components/SyncSkipUnderPriority' import type { Currency, Account } from '@ledgerhq/live-common/lib/types' +import { MODAL_ADD_ACCOUNTS } from 'config/constants' import type { T, Device } from 'types/common' import { getCurrentDevice } from 'reducers/devices' @@ -29,7 +30,7 @@ import StepFinish from './steps/04-step-finish' const createSteps = ({ t }: { t: T }) => [ { id: 'chooseCurrency', - label: t('app:importAccounts.breadcrumb.informations'), + label: t('app:addAccounts.breadcrumb.informations'), component: StepChooseCurrency, footer: StepChooseCurrencyFooter, onBack: null, @@ -37,7 +38,7 @@ const createSteps = ({ t }: { t: T }) => [ }, { id: 'connectDevice', - label: t('app:importAccounts.breadcrumb.connectDevice'), + label: t('app:addAccounts.breadcrumb.connectDevice'), component: StepConnectDevice, footer: StepConnectDeviceFooter, onBack: ({ transitionTo }: StepProps) => transitionTo('chooseCurrency'), @@ -45,7 +46,7 @@ const createSteps = ({ t }: { t: T }) => [ }, { id: 'import', - label: t('app:importAccounts.breadcrumb.import'), + label: t('app:addAccounts.breadcrumb.import'), component: StepImport, footer: StepImportFooter, onBack: ({ transitionTo }: StepProps) => transitionTo('chooseCurrency'), @@ -53,7 +54,7 @@ const createSteps = ({ t }: { t: T }) => [ }, { id: 'finish', - label: t('app:importAccounts.breadcrumb.finish'), + label: t('app:addAccounts.breadcrumb.finish'), component: StepFinish, footer: null, onBack: null, @@ -91,7 +92,7 @@ export type StepProps = { isAppOpened: boolean, transitionTo: StepId => void, setState: any => void, - onClickImport: void => Promise, + onClickAdd: void => Promise, onCloseModal: void => void, // scan process @@ -122,7 +123,7 @@ const INITIAL_STATE = { scanStatus: 'idle', } -class ImportAccounts extends PureComponent { +class AddAccounts extends PureComponent { state = INITIAL_STATE STEPS = createSteps({ t: this.props.t, @@ -136,24 +137,24 @@ class ImportAccounts extends PureComponent { this.setState(nextState) } - handleClickImport = async () => { + handleClickAdd = async () => { const { addAccount } = this.props const { scannedAccounts, checkedAccountsIds } = this.state const accountsIdsMap = checkedAccountsIds.reduce((acc, cur) => { acc[cur] = true return acc }, {}) - const accountsToImport = scannedAccounts.filter(account => accountsIdsMap[account.id] === true) - for (let i = 0; i < accountsToImport.length; i++) { + const accountsToAdd = scannedAccounts.filter(account => accountsIdsMap[account.id] === true) + for (let i = 0; i < accountsToAdd.length; i++) { await idleCallback() - addAccount(accountsToImport[i]) + addAccount(accountsToAdd[i]) } this.transitionTo('finish') } handleCloseModal = () => { const { closeModal } = this.props - closeModal('importAccounts') + closeModal(MODAL_ADD_ACCOUNTS) } render() { @@ -172,7 +173,7 @@ class ImportAccounts extends PureComponent { const step = this.STEPS[stepIndex] if (!step) { - throw new Error(`ImportAccountsModal: step ${stepId} doesn't exists`) + throw new Error(`AddAccountsModal: step ${stepId} doesn't exists`) } const { component: StepComponent, footer: StepFooter, hideFooter, onBack } = step @@ -187,7 +188,7 @@ class ImportAccounts extends PureComponent { scanStatus, err, isAppOpened, - onClickImport: this.handleClickImport, + onClickAdd: this.handleClickAdd, onCloseModal: this.handleCloseModal, transitionTo: this.transitionTo, setState: (...args) => this.setState(...args), @@ -195,14 +196,14 @@ class ImportAccounts extends PureComponent { return ( this.setState({ ...INITIAL_STATE })} render={({ onClose }) => ( onBack(stepProps) : void 0}> - {t('app:importAccounts.title')} + {t('app:addAccounts.title')} @@ -226,7 +227,7 @@ export default compose( mapDispatchToProps, ), translate(), -)(ImportAccounts) +)(AddAccounts) function idleCallback() { return new Promise(resolve => window.requestIdleCallback(resolve)) diff --git a/src/components/modals/ImportAccounts/steps/01-step-choose-currency.js b/src/components/modals/AddAccounts/steps/01-step-choose-currency.js similarity index 100% rename from src/components/modals/ImportAccounts/steps/01-step-choose-currency.js rename to src/components/modals/AddAccounts/steps/01-step-choose-currency.js diff --git a/src/components/modals/ImportAccounts/steps/02-step-connect-device.js b/src/components/modals/AddAccounts/steps/02-step-connect-device.js similarity index 95% rename from src/components/modals/ImportAccounts/steps/02-step-connect-device.js rename to src/components/modals/AddAccounts/steps/02-step-connect-device.js index ef05d478..2b89a929 100644 --- a/src/components/modals/ImportAccounts/steps/02-step-connect-device.js +++ b/src/components/modals/AddAccounts/steps/02-step-connect-device.js @@ -19,7 +19,7 @@ function StepConnectDevice({ t, currency, currentDevice, setState }: StepProps) - + {`You're about to import your `} {`${currency.name} (${ currency.ticker diff --git a/src/components/modals/ImportAccounts/steps/03-step-import.js b/src/components/modals/AddAccounts/steps/03-step-import.js similarity index 91% rename from src/components/modals/ImportAccounts/steps/03-step-import.js rename to src/components/modals/AddAccounts/steps/03-step-import.js index bd723ca4..528d1d7c 100644 --- a/src/components/modals/ImportAccounts/steps/03-step-import.js +++ b/src/components/modals/AddAccounts/steps/03-step-import.js @@ -160,7 +160,7 @@ class StepImport extends PureComponent { fontSize={2} style={{ textTransform: 'uppercase' }} > - {t('app:importAccounts.accountToImportSubtitle', { + {t('app:addAccounts.accountToImportSubtitle', { count: importableAccounts.length, })} @@ -170,8 +170,8 @@ class StepImport extends PureComponent { fontSize={3} > {isAllSelected - ? t('app:importAccounts.unselectAll') - : t('app:importAccounts.selectAll')} + ? t('app:addAccounts.unselectAll') + : t('app:addAccounts.selectAll')} )} @@ -211,7 +211,7 @@ class StepImport extends PureComponent { fontSize={2} style={{ textTransform: 'uppercase' }} > - {t('app:importAccounts.createNewAccount')} + {t('app:addAccounts.createNewAccount')} { )} @@ -256,7 +256,7 @@ export const LoadingRow = styled(Box).attrs({ export const StepImportFooter = ({ scanStatus, - onClickImport, + onClickAdd, checkedAccountsIds, scannedAccounts, t, @@ -266,30 +266,30 @@ export const StepImportFooter = ({ return account && account.operations.length === 0 }) - const willImportAccounts = checkedAccountsIds.some(id => { + const willAddAccounts = checkedAccountsIds.some(id => { const account = scannedAccounts.find(a => a.id === id) return account && account.operations.length > 0 }) - const importedAccountsCount = checkedAccountsIds.filter(id => { + const addedAccountsCount = checkedAccountsIds.filter(id => { const account = scannedAccounts.find(acc => acc.id === id) return account && account.operations.length > 0 }).length const ctaWording = - willCreateAccount && willImportAccounts - ? `${t('app:importAccounts.cta.create')} / ${t('app:importAccounts.cta.import', { - count: importedAccountsCount, + willCreateAccount && willAddAccounts + ? `${t('app:addAccounts.cta.create')} / ${t('app:addAccounts.cta.import', { + count: addedAccountsCount, })}` : willCreateAccount - ? t('app:importAccounts.cta.create') - : t('app:importAccounts.cta.import', { count: importedAccountsCount }) + ? t('app:addAccounts.cta.create') + : t('app:addAccounts.cta.import', { count: addedAccountsCount }) return ( diff --git a/src/components/modals/ImportAccounts/steps/04-step-finish.js b/src/components/modals/AddAccounts/steps/04-step-finish.js similarity index 100% rename from src/components/modals/ImportAccounts/steps/04-step-finish.js rename to src/components/modals/AddAccounts/steps/04-step-finish.js diff --git a/src/components/modals/index.js b/src/components/modals/index.js index 0c0f3bd0..2f942504 100644 --- a/src/components/modals/index.js +++ b/src/components/modals/index.js @@ -1,5 +1,5 @@ export Debug from './Debug' -export ImportAccounts from './ImportAccounts' +export AddAccounts from './AddAccounts' export OperationDetails from './OperationDetails' export Receive from './Receive' export Send from './Send' diff --git a/src/config/constants.js b/src/config/constants.js index 8d8940d6..4cbd1cf2 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -19,7 +19,7 @@ export const CHECK_UPDATE_DELAY = 5e3 export const DEVICE_DISCONNECT_DEBOUNCE = intFromEnv('LEDGER_DEVICE_DISCONNECT_DEBOUNCE', 500) -export const MODAL_ADD_ACCOUNT = 'MODAL_ADD_ACCOUNT' +export const MODAL_ADD_ACCOUNTS = 'MODAL_ADD_ACCOUNTS' export const MODAL_OPERATION_DETAILS = 'MODAL_OPERATION_DETAILS' export const MODAL_RECEIVE = 'MODAL_RECEIVE' export const MODAL_SEND = 'MODAL_SEND' diff --git a/static/i18n/en/app.yml b/static/i18n/en/app.yml index 02806506..49deffcf 100644 --- a/static/i18n/en/app.yml +++ b/static/i18n/en/app.yml @@ -116,7 +116,7 @@ exchange: genuinecheck: modal: title: Genuine check, bro -importAccounts: +addAccounts: title: Add accounts breadcrumb: informations: Informations diff --git a/static/i18n/fr/app.yml b/static/i18n/fr/app.yml index ec9d7aa5..fa72912c 100644 --- a/static/i18n/fr/app.yml +++ b/static/i18n/fr/app.yml @@ -117,7 +117,7 @@ exchange: genuinecheck: modal: title: Genuine check, bro -importAccounts: +addAccounts: title: Add accounts breadcrumb: informations: Informations