diff --git a/src/components/SettingsPage/RepairDeviceButton.js b/src/components/SettingsPage/RepairDeviceButton.js index 9e83f35e..6a913b79 100644 --- a/src/components/SettingsPage/RepairDeviceButton.js +++ b/src/components/SettingsPage/RepairDeviceButton.js @@ -5,7 +5,7 @@ import { translate } from 'react-i18next' import type { T } from 'types/common' import firmwareRepair from 'commands/firmwareRepair' import Button from 'components/base/Button' -import { ConfirmModal } from 'components/base/Modal' +import { RepairModal } from 'components/base/Modal' type Props = { t: T, @@ -32,7 +32,7 @@ class RepairDeviceButton extends PureComponent { close = () => { if (this.sub) this.sub.unsubscribe() - this.setState({ opened: false }) + this.setState({ opened: false, isLoading: false }) } action = () => { @@ -43,7 +43,7 @@ class RepairDeviceButton extends PureComponent { this.setState(patch) }, error: error => { - this.setState({ error, opened: false, isLoading: false }) + this.setState({ error, isLoading: false }) }, complete: () => { this.setState({ opened: false, isLoading: false }) @@ -54,17 +54,14 @@ class RepairDeviceButton extends PureComponent { render() { const { t } = this.props const { opened, isLoading, error, progress } = this.state - // @val basically I think we want to diverge from the traditional ConfirmModal to make our own version - // with the progress and the error cases handled. - console.log({ error, progress }) // eslint-disable-line no-console - // ^ TODO use error to pass in that custom thing + return ( - { onConfirm={this.action} isLoading={isLoading} title={t('settings.repairDevice.title')} - subTitle={t('common.areYouSure')} desc={t('settings.repairDevice.desc')} + confirmText={t('settings.repairDevice.button')} + progress={progress} + error={error} /> ) diff --git a/src/components/base/Modal/RepairModal.js b/src/components/base/Modal/RepairModal.js new file mode 100644 index 00000000..7f59dbb1 --- /dev/null +++ b/src/components/base/Modal/RepairModal.js @@ -0,0 +1,169 @@ +// @flow + +import React, { PureComponent } from 'react' +import { translate } from 'react-i18next' +import styled from 'styled-components' + +import type { T } from 'types/common' + +import { i } from 'helpers/staticPath' +import TrackPage from 'analytics/TrackPage' +import Button from 'components/base/Button' +import Box from 'components/base/Box' +import Text from 'components/base/Text' +import ProgressCircle from 'components/ProgressCircle' +import TranslatedError from 'components/TranslatedError' + +import { Modal, ModalContent, ModalBody, ModalTitle, ModalFooter } from './index' + +const Bullet = styled.span` + font-weight: 600; + color: #142533; +` + +const Separator = styled(Box).attrs({ + color: 'fog', +})` + height: 1px; + width: 100%; + background-color: currentColor; +` + +const ConnectStep = ({ t, desc }: { t: *, desc?: string }) => ( + + {desc ? ( + + {desc} + + ) : null} + + + {'1.'} + {t('manager.modal.mcuFirst')} + + {t('manager.modal.mcuFirst')} + + + + + {'2.'} + {t('manager.modal.mcuSecond')} + + {t('manager.modal.mcuFirst')} + + +) + +const FlashStep = ({ progress, t }: { progress: number, t: * }) => ( + <> + + + + + + {t(`manager.modal.steps.flash`)} + + + + + {t('manager.modal.mcuPin')} + + + +) + +const ErrorStep = ({ error }: { error: Error }) => ( + + + +) + +type Props = { + isOpened: boolean, + isDanger: boolean, + title: string, + subTitle?: string, + desc: string, + renderIcon?: Function, + confirmText?: string, + cancelText?: string, + onReject: Function, + onConfirm: Function, + t: T, + isLoading?: boolean, + analyticsName: string, + cancellable?: boolean, + progress: number, + error?: Error, +} + +class RepairModal extends PureComponent { + render() { + const { + cancellable, + isOpened, + title, + desc, + confirmText, + isDanger, + onReject, + onConfirm, + isLoading, + renderIcon, + t, + analyticsName, + progress, + error, + ...props + } = this.props + + const realConfirmText = confirmText || t('common.confirm') + + return ( + ( + + + {title} + {isLoading && progress > 0 ? ( + + ) : error ? ( + + ) : ( + + )} + + {!isLoading && ( + + )} + {error ? null : ( + + )} + + + )} + /> + ) + } +} + +export default translate()(RepairModal) diff --git a/src/components/base/Modal/index.js b/src/components/base/Modal/index.js index ca84f4fb..cad43fda 100644 --- a/src/components/base/Modal/index.js +++ b/src/components/base/Modal/index.js @@ -22,6 +22,7 @@ import GrowScroll from 'components/base/GrowScroll' export { default as ModalBody } from './ModalBody' export { default as ConfirmModal } from './ConfirmModal' +export { default as RepairModal } from './RepairModal' export { default as ModalTitle } from './ModalTitle' const springConfig = { diff --git a/static/i18n/en/app.json b/static/i18n/en/app.json index 633e2eba..3eb80cc6 100644 --- a/static/i18n/en/app.json +++ b/static/i18n/en/app.json @@ -262,7 +262,8 @@ "osu": "Installing OSU...", "flash-mcu": "MCU updating...", "flash-bootloader": "Bootloader updating...", - "firmware": "Firmware updating..." + "firmware": "Firmware updating...", + "flash": "Flashing your device..." }, "confirmIdentifier": "Verify the identifier", "confirmIdentifierText": "Verify that the identifier on your device is the same as the identifier below. Press the right button and enter your PIN code to confirm", @@ -296,8 +297,7 @@ "confirmAddress": { "title": "Verification", "action": "Verify address on device", - "text": "Please verify that the {{currencyName}} address shown on your device matches the one on your computer" - , + "text": "Please verify that the {{currencyName}} address shown on your device matches the one on your computer", "support": "Contact us" }, "receiveFunds": { @@ -359,7 +359,7 @@ "export": { "desc": "Import accounts on your Ledger Live Mobile app", "button": "Export", - "modal":{ + "modal": { "button": "Done", "title": "Scan to export to mobile", "listTitle": "To import accounts on your Ledger Live Mobile app:", @@ -643,7 +643,7 @@ "step2": { "title": "Did you save your recovery phrase by yourself?" }, - "step3":{ + "step3": { "title": "Is your Ledger device genuine?" }, "isGenuinePassed": "Your device is genuine", @@ -666,7 +666,7 @@ }, "setPassword": { "title": "Password lock (optional)", - "desc": "Set a password to prevent unauthorized access to Ledger Live data on your computer, including account names, transactions and public addresses", + "desc": "Set a password to prevent unauthorized access to Ledger Live data on your computer, including account names, transactions and public addresses", "disclaimer": { "note1": "Make sure to remember your password. Do not share it.", "note2": "Losing your password requires resetting Ledger Live and re-adding accounts.", @@ -903,4 +903,4 @@ "title": "Couldn’t load fee rates, please set manual fees" } } -} +} \ No newline at end of file