From f791f4ef38a5556b85bd603005708e52a10418a4 Mon Sep 17 00:00:00 2001 From: meriadec Date: Tue, 19 Jun 2018 11:43:23 +0200 Subject: [PATCH 1/2] Polishing onboarding genuine check states --- src/components/GenuineCheckModal/index.js | 5 +--- .../Onboarding/steps/GenuineCheck.js | 29 +++++++++++++++++-- src/components/Workflow/EnsureGenuine.js | 7 +++-- src/components/base/FakeLink.js | 7 +++-- static/i18n/en/onboarding.yml | 1 + 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/components/GenuineCheckModal/index.js b/src/components/GenuineCheckModal/index.js index 0005afed..8afe0b3b 100644 --- a/src/components/GenuineCheckModal/index.js +++ b/src/components/GenuineCheckModal/index.js @@ -19,9 +19,6 @@ type Props = { type State = {} class GenuineCheckStatus extends PureComponent<*> { - componentDidMount() { - this.sideEffect() - } componentDidUpdate() { this.sideEffect() } @@ -33,7 +30,7 @@ class GenuineCheckStatus extends PureComponent<*> { onGenuineCheckFailed, onGenuineCheckUnavailable, } = this.props - if (isGenuine !== undefined) { + if (isGenuine !== null) { if (isGenuine) { onGenuineCheckPass() } else { diff --git a/src/components/Onboarding/steps/GenuineCheck.js b/src/components/Onboarding/steps/GenuineCheck.js index eb03bd63..44bdd1f2 100644 --- a/src/components/Onboarding/steps/GenuineCheck.js +++ b/src/components/Onboarding/steps/GenuineCheck.js @@ -11,6 +11,7 @@ import type { T } from 'types/common' import { updateGenuineCheck } from 'reducers/onboarding' import Box from 'components/base/Box' +import FakeLink from 'components/base/FakeLink' import Button from 'components/base/Button' import RadioGroup from 'components/base/RadioGroup' import GenuineCheckModal from 'components/GenuineCheckModal' @@ -18,6 +19,7 @@ import GenuineCheckModal from 'components/GenuineCheckModal' import IconLedgerNanoError from 'icons/illustrations/LedgerNanoError' import IconLedgerBlueError from 'icons/illustrations/LedgerBlueError' import IconCheck from 'icons/Check' +import IconCross from 'icons/Cross' import { Title, @@ -88,7 +90,15 @@ class GenuineCheck extends PureComponent { handleOpenGenuineCheckModal = () => this.setState({ isGenuineCheckModalOpened: true }) handleCloseGenuineCheckModal = (cb?: Function) => - this.setState(state => ({ ...state, isGenuineCheckModalOpened: false }), () => cb && cb()) + this.setState( + state => ({ ...state, isGenuineCheckModalOpened: false }), + () => { + // FIXME: meh + if (cb && typeof cb === 'function') { + cb() + } + }, + ) handleGenuineCheckPass = () => { this.handleCloseGenuineCheckModal(() => { @@ -101,6 +111,7 @@ class GenuineCheck extends PureComponent { handleGenuineCheckFailed = () => { this.handleCloseGenuineCheckModal(() => { this.props.updateGenuineCheck({ + isGenuineFail: true, isDeviceGenuine: false, genuineCheckUnavailable: null, }) @@ -211,6 +222,20 @@ class GenuineCheck extends PureComponent { {t('onboarding:genuineCheck.isGenuinePassed')} + ) : genuine.genuineCheckUnavailable ? ( + + + + {t('onboarding:genuineCheck.isGenuineUnavailable')} + + {t('app:common.retry')} + + + ) : (