From d7f57c9fd922834e5b6c0ca23a355d5d2a4fcac3 Mon Sep 17 00:00:00 2001 From: NastiaS Date: Thu, 24 May 2018 16:14:23 +0200 Subject: [PATCH] adding device type distinguishing, reusing radio group for buttons, updating icons, wording --- src/components/Onboarding/index.js | 10 +- .../Onboarding/steps/GenuineCheck.js | 154 ++++++------- .../Onboarding/steps/SelectDevice.js | 98 ++++++--- src/components/Onboarding/steps/SelectPIN.js | 74 +++++-- src/icons/onboarding/LedgerBlueError.js | 47 ++++ src/icons/onboarding/LedgerBlueSelectPIN.js | 47 ++++ src/icons/onboarding/LedgerNano.js | 30 ++- .../{SelectPIN.js => LedgerNanoSelectPIN.js} | 0 src/icons/onboarding/WriteSeed.js | 206 +++--------------- src/reducers/onboarding.js | 7 + static/i18n/en/onboarding.yml | 29 ++- 11 files changed, 373 insertions(+), 329 deletions(-) create mode 100644 src/icons/onboarding/LedgerBlueError.js create mode 100644 src/icons/onboarding/LedgerBlueSelectPIN.js rename src/icons/onboarding/{SelectPIN.js => LedgerNanoSelectPIN.js} (100%) diff --git a/src/components/Onboarding/index.js b/src/components/Onboarding/index.js index a3b5e1c5..5b6ccb3e 100644 --- a/src/components/Onboarding/index.js +++ b/src/components/Onboarding/index.js @@ -10,7 +10,13 @@ import type { T } from 'types/common' import type { OnboardingState } from 'reducers/onboarding' import { saveSettings } from 'actions/settings' -import { nextStep, prevStep, jumpStep, setGenuineCheckFail } from 'reducers/onboarding' +import { + nextStep, + prevStep, + jumpStep, + setGenuineCheckFail, + isLedgerNano, +} from 'reducers/onboarding' import { getCurrentDevice } from 'reducers/devices' // TODO: re-write it without auto lock, fixed width of the password modal, not dynamic titles @@ -77,6 +83,7 @@ export type StepProps = { savePassword: Function, getDeviceInfo: Function, setGenuineCheckFail: Function, + isLedgerNano: Function, } class Onboarding extends PureComponent { @@ -110,6 +117,7 @@ class Onboarding extends PureComponent { t, onboarding, setGenuineCheckFail, + isLedgerNano, prevStep, nextStep, jumpStep, diff --git a/src/components/Onboarding/steps/GenuineCheck.js b/src/components/Onboarding/steps/GenuineCheck.js index fa7f061a..f2ca39e2 100644 --- a/src/components/Onboarding/steps/GenuineCheck.js +++ b/src/components/Onboarding/steps/GenuineCheck.js @@ -1,9 +1,9 @@ // @flow -import React, { PureComponent } from 'react' +import React, { PureComponent, Fragment } from 'react' import { connect } from 'react-redux' import styled from 'styled-components' -import { radii, colors } from 'styles/theme' +import { radii } from 'styles/theme' import type { T } from 'types/common' @@ -11,8 +11,9 @@ import { setGenuineCheckFail } from 'reducers/onboarding' import Box, { Card } from 'components/base/Box' import Button from 'components/base/Button' -import IconCheck from 'icons/Check' +import RadioGroup from 'components/base/RadioGroup' import IconLedgerNanoError from 'icons/onboarding/LedgerNanoError' +import IconLedgerBlueError from 'icons/onboarding/LedgerBlueError' import { Title, Description, IconOptionRow } from '../helperComponents' @@ -24,18 +25,43 @@ const mapDispatchToProps = { setGenuineCheckFail } type State = { pinStepPass: boolean | null, phraseStepPass: boolean | null, + cachedPinStepButton: string, + cachedPhraseStepButton: string, } class GenuineCheck extends PureComponent { state = { pinStepPass: null, phraseStepPass: null, + cachedPinStepButton: '', + cachedPhraseStepButton: '', } - handleStepPass = (step: string, pass: boolean | null) => { - this.setState({ [`${step}`]: pass }) + getButtonLabel() { + const { t } = this.props + return [ + { + label: t('common:yes'), + key: 'yes', + pass: true, + }, + { + label: t('common:no'), + key: 'no', + pass: false, + }, + ] + } + + handleButtonPass = (item: Object, step: string) => { + this.setState({ [`${step}`]: item.pass }) + if (step === 'pinStepPass') { + this.setState({ cachedPinStepButton: item.key }) + } else { + this.setState({ cachedPhraseStepButton: item.key }) + } - if (typeof pass === 'boolean' && !pass) { + if (!item.pass) { this.props.setGenuineCheckFail(true) } } @@ -51,12 +77,13 @@ class GenuineCheck extends PureComponent { redoGenuineCheck={this.redoGenuineCheck} contactSupport={this.contactSupport} t={this.props.t} + isLedgerNano={this.props.onboarding.isLedgerNano} /> ) render() { const { nextStep, prevStep, t, onboarding } = this.props - const { pinStepPass, phraseStepPass } = this.state + const { pinStepPass, phraseStepPass, cachedPinStepButton, cachedPhraseStepButton } = this.state if (onboarding.isGenuineFail) { return this.renderGenuineFail() @@ -66,7 +93,7 @@ class GenuineCheck extends PureComponent { {t('onboarding:genuineCheck.title')} - {t('onboarding:genuineCheck.desc')} + {t('onboarding:genuineCheck.desc')} @@ -76,22 +103,16 @@ class GenuineCheck extends PureComponent { {t('onboarding:genuineCheck.steps.step2.desc')} - {!pinStepPass ? ( - - ) : ( - - - - )} + this.handleButtonPass(item, 'pinStepPass')} + /> - + 2. @@ -99,22 +120,16 @@ class GenuineCheck extends PureComponent { {t('onboarding:genuineCheck.steps.step2.desc')} - {!phraseStepPass ? ( - - ) : ( - - - - )} + this.handleButtonPass(item, 'phraseStepPass')} + /> - + 3. @@ -145,58 +160,42 @@ class GenuineCheck extends PureComponent { export default connect(null, mapDispatchToProps)(GenuineCheck) -export function ButtonCombo({ - handleStepPass, - step, - disabled, - t, -}: { - handleStepPass: any, - step: string, - disabled: boolean, - t: T, -}) { - return ( - - - - - ) -} // TODO extract to a separate file export function GenuineCheckFail({ redoGenuineCheck, contactSupport, + isLedgerNano, t, }: { redoGenuineCheck: () => void, contactSupport: () => void, + isLedgerNano: boolean, t: T, }) { return ( - + - {t('onboarding:genuineCheck.errorPage.ledgerNano.title')} - - {t('onboarding:genuineCheck.errorPage.ledgerNano.desc')} - - - - + {isLedgerNano ? ( + + {t('onboarding:genuineCheck.errorPage.ledgerNano.title')} + + {t('onboarding:genuineCheck.errorPage.ledgerNano.desc')} + + + + + + ) : ( + + {t('onboarding:genuineCheck.errorPage.ledgerBlue.title')} + + {t('onboarding:genuineCheck.errorPage.ledgerBlue.desc')} + + + + + + )}