From 1d894522d518734aaa259b1c65c63c822d46463b Mon Sep 17 00:00:00 2001 From: NastiaS Date: Mon, 28 May 2018 16:35:22 +0200 Subject: [PATCH] onboarding polishes --- .../Onboarding/OnboardingBreadcrumb.js | 4 +- src/components/Onboarding/OnboardingFooter.js | 5 +- src/components/Onboarding/index.js | 11 +- src/components/Onboarding/steps/Analytics.js | 116 ++++++++++++------ .../Onboarding/steps/GenuineCheck.js | 72 ++++++----- src/components/Onboarding/steps/Init.js | 16 ++- src/icons/Recover.js | 16 +++ src/reducers/onboarding.js | 30 ++++- src/reducers/settings.js | 2 + static/i18n/en/onboarding.yml | 8 +- 10 files changed, 187 insertions(+), 93 deletions(-) create mode 100644 src/icons/Recover.js diff --git a/src/components/Onboarding/OnboardingBreadcrumb.js b/src/components/Onboarding/OnboardingBreadcrumb.js index d45746fb..e3137645 100644 --- a/src/components/Onboarding/OnboardingBreadcrumb.js +++ b/src/components/Onboarding/OnboardingBreadcrumb.js @@ -18,7 +18,7 @@ type Props = { function OnboardingBreadcrumb(props: Props) { const { onboarding } = props - const { stepName, isGenuineFail } = onboarding + const { stepName, genuine } = onboarding const filteredSteps = onboarding.steps .filter(step => !step.external) @@ -29,7 +29,7 @@ function OnboardingBreadcrumb(props: Props) { return ( diff --git a/src/components/Onboarding/OnboardingFooter.js b/src/components/Onboarding/OnboardingFooter.js index 922e3423..384f360b 100644 --- a/src/components/Onboarding/OnboardingFooter.js +++ b/src/components/Onboarding/OnboardingFooter.js @@ -22,14 +22,15 @@ type Props = { t: T, nextStep: () => void, prevStep: () => void, + isContinueDisabled?: boolean, } -const OnboardingFooter = ({ t, nextStep, prevStep, ...props }: Props) => ( +const OnboardingFooter = ({ t, nextStep, prevStep, isContinueDisabled, ...props }: Props) => ( - diff --git a/src/components/Onboarding/index.js b/src/components/Onboarding/index.js index 1efdff9d..fca172f2 100644 --- a/src/components/Onboarding/index.js +++ b/src/components/Onboarding/index.js @@ -14,7 +14,8 @@ import { nextStep, prevStep, jumpStep, - setGenuineCheckFail, + // setGenuineCheckFail, + updateGenuineCheck, isLedgerNano, } from 'reducers/onboarding' import { getCurrentDevice } from 'reducers/devices' @@ -80,9 +81,11 @@ export type StepProps = { nextStep: Function, jumpStep: Function, finish: Function, + saveSettings: Function, // savePassword: Function, getDeviceInfo: Function, - setGenuineCheckFail: Function, + // setGenuineCheckFail: Function, + updateGenuineCheck: Function, isLedgerNano: Function, } @@ -116,7 +119,8 @@ class Onboarding extends PureComponent { const stepProps: StepProps = { t, onboarding, - setGenuineCheckFail, + // setGenuineCheckFail, + updateGenuineCheck, isLedgerNano, prevStep, nextStep, @@ -124,6 +128,7 @@ class Onboarding extends PureComponent { finish: this.finish, // savePassword: this.savePassword, getDeviceInfo: this.getDeviceInfo, + saveSettings, } return ( diff --git a/src/components/Onboarding/steps/Analytics.js b/src/components/Onboarding/steps/Analytics.js index f46e1c76..9ebf8a24 100644 --- a/src/components/Onboarding/steps/Analytics.js +++ b/src/components/Onboarding/steps/Analytics.js @@ -1,7 +1,9 @@ // @flow -import React from 'react' +import React, { PureComponent } from 'react' import styled from 'styled-components' +import { connect } from 'react-redux' +import { saveSettings } from 'actions/settings' import Box from 'components/base/Box' import CheckBox from 'components/base/CheckBox' @@ -10,51 +12,87 @@ import OnboardingFooter from '../OnboardingFooter' import type { StepProps } from '..' -export default (props: StepProps) => { - const { nextStep, prevStep, t } = props - return ( - - - {t('onboarding:analytics.title')} - {t('onboarding:analytics.desc')} +const mapDispatchToProps = { saveSettings } - - - - - {t('onboarding:analytics.shareDiagnostics.title')} +type State = { + analyticsToggle: boolean, + termsConditionsToggle: boolean, +} +class Analytics extends PureComponent { + state = { + analyticsToggle: false, + termsConditionsToggle: false, + } + + handleAnalyticsToggle = isChecked => { + console.log('what is isChecked?: ', isChecked) + // if (isChecked) { + this.setState({ analyticsToggle: !this.state.analyticsToggle }) + this.props.saveSettings({ + shareAnalytics: isChecked, + }) + // } else { + // this.props.saveSettings({ + // shareAnalytics: false, + // }) + // } + } + handleTermsToggle = isChecked => { + this.setState({ termsConditionsToggle: !this.state.termsConditionsToggle }) + } + render() { + const { nextStep, prevStep, t, saveSettings } = this.props + console.log('what is saveSettings!!??: ', saveSettings) + const { analyticsToggle, termsConditionsToggle } = this.state + + console.log('what is analyticsToggle: ', analyticsToggle) + return ( + + + {t('onboarding:analytics.title')} + {t('onboarding:analytics.desc')} + + + + + + {t('onboarding:analytics.shareAnalytics.title')} + + {t('onboarding:analytics.shareAnalytics.desc')} - {t('onboarding:analytics.shareDiagnostics.desc')} - - - - - - - - - {t('onboarding:analytics.shareDiagnostics.title')} + + - {t('onboarding:analytics.shareDiagnostics.desc')} - - - - - + + + + + {t('onboarding:analytics.termsConditions.title')} + + {t('onboarding:analytics.termsConditions.desc')} + + + + + + + - - - ) + ) + } } +export default connect(null, mapDispatchToProps)(Analytics) + export const AnalyticsText = styled(Box).attrs({ ff: 'Open Sans|Regular', fontSize: 3, diff --git a/src/components/Onboarding/steps/GenuineCheck.js b/src/components/Onboarding/steps/GenuineCheck.js index 4ed6fcb5..5d8994f4 100644 --- a/src/components/Onboarding/steps/GenuineCheck.js +++ b/src/components/Onboarding/steps/GenuineCheck.js @@ -1,13 +1,14 @@ // @flow import React, { PureComponent, Fragment } from 'react' +import { shell } from 'electron' import { connect } from 'react-redux' import styled from 'styled-components' import { radii } from 'styles/theme' import type { T } from 'types/common' -import { setGenuineCheckFail } from 'reducers/onboarding' +import { updateGenuineCheck } from 'reducers/onboarding' import Box, { Card } from 'components/base/Box' import Button from 'components/base/Button' @@ -23,25 +24,25 @@ import { Title, Description, IconOptionRow } from '../helperComponents' import type { StepProps } from '..' import OnboardingFooter from '../OnboardingFooter' -const mapDispatchToProps = { setGenuineCheckFail } +const mapDispatchToProps = { updateGenuineCheck } type State = { - pinStepPass: boolean | null, - phraseStepPass: boolean | null, cachedPinStepButton: string, - cachedPhraseStepButton: string, + cachedRecoveryStepButton: string, isGenuineCheckModalOpened: boolean, - isDeviceGenuine: boolean, +} + +const INITIAL_STATE = { + cachedPinStepButton: '', + cachedRecoveryStepButton: '', + isGenuineCheckModalOpened: false, } class GenuineCheck extends PureComponent { state = { - pinStepPass: null, - phraseStepPass: null, - cachedPinStepButton: '', - cachedPhraseStepButton: '', - isGenuineCheckModalOpened: false, - isDeviceGenuine: false, + ...INITIAL_STATE, + cachedPinStepButton: this.props.onboarding.genuine.pinStepPass ? 'yes' : '', + cachedRecoveryStepButton: this.props.onboarding.genuine.recoveryStepPass ? 'yes' : '', } getButtonLabel() { @@ -61,15 +62,21 @@ class GenuineCheck extends PureComponent { } handleButtonPass = (item: Object, step: string) => { - this.setState({ [`${step}`]: item.pass }) + this.props.updateGenuineCheck({ [`${step}`]: item.pass }) if (step === 'pinStepPass') { this.setState({ cachedPinStepButton: item.key }) } else { - this.setState({ cachedPhraseStepButton: item.key }) + this.setState({ cachedRecoveryStepButton: item.key }) } if (!item.pass) { - this.props.setGenuineCheckFail(true) + this.setState(INITIAL_STATE) + this.props.updateGenuineCheck({ + isGenuineFail: true, + recoveryStepPass: false, + pinStepPass: false, + isDeviceGenuine: false, + }) } } @@ -79,15 +86,19 @@ class GenuineCheck extends PureComponent { handleGenuineCheck = async isGenuine => { await new Promise(r => setTimeout(r, 1e3)) // let's wait a bit before closing modal this.handleCloseGenuineCheckModal() - this.setState({ isDeviceGenuine: isGenuine }) + this.props.updateGenuineCheck({ + isDeviceGenuine: isGenuine, + }) } redoGenuineCheck = () => { - this.props.setGenuineCheckFail(false) + this.props.updateGenuineCheck({ isGenuineFail: false }) } contactSupport = () => { - console.log('contact support coming later') + const contactSupportUrl = + 'https://support.ledgerwallet.com/hc/en-us/requests/new?ticket_form_id=248165' + shell.openExternal(contactSupportUrl) } renderGenuineFail = () => ( @@ -101,16 +112,10 @@ class GenuineCheck extends PureComponent { render() { const { nextStep, prevStep, t, onboarding } = this.props - const { - pinStepPass, - phraseStepPass, - cachedPinStepButton, - cachedPhraseStepButton, - isGenuineCheckModalOpened, - isDeviceGenuine, - } = this.state + const { genuine } = onboarding + const { cachedPinStepButton, cachedRecoveryStepButton, isGenuineCheckModalOpened } = this.state - if (onboarding.isGenuineFail) { + if (genuine.isGenuineFail) { return this.renderGenuineFail() } @@ -137,7 +142,7 @@ class GenuineCheck extends PureComponent { - + 2. @@ -148,13 +153,13 @@ class GenuineCheck extends PureComponent { this.handleButtonPass(item, 'phraseStepPass')} + activeKey={cachedRecoveryStepButton} + onChange={item => this.handleButtonPass(item, 'recoveryStepPass')} /> - + 3. @@ -166,10 +171,10 @@ class GenuineCheck extends PureComponent {