diff --git a/packages/light-react/src/Accounts/AccountsList/AccountsList.js b/packages/light-react/src/Accounts/AccountsList/AccountsList.js index f3d42635af07685fe46d62238e122768b1bcbc70..532135d6b4387c1f6b97f894736dcc0235ddd67e 100644 --- a/packages/light-react/src/Accounts/AccountsList/AccountsList.js +++ b/packages/light-react/src/Accounts/AccountsList/AccountsList.js @@ -8,6 +8,7 @@ import { AccountCard, Header } from 'light-ui'; import { accountsInfo$, defaultAccount$ } from '@parity/light.js'; import { inject, observer } from 'mobx-react'; import light from 'light-hoc'; +import { Redirect } from 'react-router-dom'; import Health from '../../Health'; @@ -64,6 +65,10 @@ class AccountsList extends Component { render () { const { accountsInfo } = this.props; + if (accountsInfo && !Object.keys(accountsInfo).length) { + return ; + } + return (
- Back - + // Show back button if: + // - we already have some accounts, so we can go back to AccountsList + // - or the step is >1 + (step > 1 || + (accountsInfo && Object.keys(accountsInfo).length > 0)) && ( + + Back + + ) } title={

{isImport ? 'Import account' : 'Create a new account'}

diff --git a/packages/light-react/src/App/App.js b/packages/light-react/src/App/App.js index e9c33fcd0e7efdea812ffec667a1a0834cad2856..86c5d507ce47ed9ccc5346e44fcb523950fe003c 100644 --- a/packages/light-react/src/App/App.js +++ b/packages/light-react/src/App/App.js @@ -51,22 +51,22 @@ class App extends Component { */ renderScreen () { const { - onboardingStore: { isOnboarding }, + onboardingStore: { isFirstRun }, healthStore: { health: { status } } } = this.props; + if (isFirstRun) { + return
; + } + return (
- {/* If we are onboarding, then never show the Overlay. On the other hand, if - we're not onboarding, show the Overlay whenever we have an issue. */} - {!isOnboarding && status !== STATUS.GOOD && } + {status !== STATUS.GOOD && } - {/* We redirect to Onboarding if necessary, or by default to our - homepage which is Tokens */} + {/* The next line is the hoempage */} - {isOnboarding && } diff --git a/packages/light-react/src/Onboarding/Onboarding.js b/packages/light-react/src/Onboarding/Onboarding.js index b5f74c8a4b5433571c11650af19ce91d5ab50f29..aa2edcc2c13f9361ecd6990b9c7ad73fe985d8c6 100644 --- a/packages/light-react/src/Onboarding/Onboarding.js +++ b/packages/light-react/src/Onboarding/Onboarding.js @@ -4,8 +4,8 @@ // SPDX-License-Identifier: MIT import React, { Component } from 'react'; +import { FormField, Header } from 'light-ui'; import { inject, observer } from 'mobx-react'; -import { Link } from 'react-router-dom'; import Health from '../Health'; @@ -15,24 +15,38 @@ class Onboarding extends Component { handleFirstRun = () => { // Not first run anymore after clicking Accept this.props.onboardingStore.setIsFirstRun(false); - this.props.history.push('/'); }; render () { - const { - onboardingStore: { hasAccounts } - } = this.props; return (
- This is the onboarding page.
- {hasAccounts ? ( - - Accept terms of use - - ) : ( - Create account - )} - +
Terms of Use} /> + +
+
+ + } + label="Please read carefully Fether Wallet's Terms of Use" + /> +
+
+ +
); } diff --git a/packages/light-react/src/Tokens/Tokens.js b/packages/light-react/src/Tokens/Tokens.js index 52ff2bcee18a31fd89d4fa9f1ebd335607151ce3..1e848df92778aa3c5e443b1a19d77cd9e59b0234 100644 --- a/packages/light-react/src/Tokens/Tokens.js +++ b/packages/light-react/src/Tokens/Tokens.js @@ -7,7 +7,7 @@ import React, { PureComponent } from 'react'; import { AccountHeader } from 'light-ui'; import { accountsInfo$, defaultAccount$ } from '@parity/light.js'; import light from 'light-hoc'; -import { Link } from 'react-router-dom'; +import { Link, Redirect } from 'react-router-dom'; import Health from '../Health'; import TokensList from './TokensList'; @@ -24,6 +24,12 @@ class Tokens extends PureComponent { location: { state } } = this.props; + // If the accountsInfo object is empty (i.e. no accounts), then we redirect + // to the accounts page to create an account + if (accountsInfo && !Object.keys(accountsInfo).length) { + return ; + } + // The address is defaultAccount, but if we are coming from the accounts // page, then the address is also put inside the route state, for faster // access. diff --git a/packages/light-react/src/assets/sass/shared/_form.scss b/packages/light-react/src/assets/sass/shared/_form.scss index 5980bbd9e8da350bd6fef73ab2634df0d6c9d293..2b9ca8dda738e3aa2849389006a355afcddfa134 100644 --- a/packages/light-react/src/assets/sass/shared/_form.scss +++ b/packages/light-react/src/assets/sass/shared/_form.scss @@ -91,6 +91,10 @@ &.-lg { height: 8rem; } + + &.-xlg { + height: 12rem; + } } } diff --git a/packages/light-react/src/stores/createAccountStore.js b/packages/light-react/src/stores/createAccountStore.js index 47e6898a0986e6bc9ebd72ee3951c2c9e9579371..1ea1fd9632db6a376911ecde44bfb481d02aee49 100644 --- a/packages/light-react/src/stores/createAccountStore.js +++ b/packages/light-react/src/stores/createAccountStore.js @@ -34,7 +34,7 @@ class CreateAccountStore { saveAccountToParity = () => { return this.api.parity .newAccountFromPhrase(this.phrase, this.password) - .then(address => this.api.parity.setAccountName(this.address, this.name)) + .then(() => this.api.parity.setAccountName(this.address, this.name)) .then(() => this.api.parity.setAccountMeta(this.address, { timestamp: Date.now() diff --git a/packages/light-react/src/stores/onboardingStore.js b/packages/light-react/src/stores/onboardingStore.js index fc878ecd0776eba963fff0271b9ded565c7e2b8b..b2c1799a91083347aebbee474d31175e5b491283 100644 --- a/packages/light-react/src/stores/onboardingStore.js +++ b/packages/light-react/src/stores/onboardingStore.js @@ -3,9 +3,7 @@ // // SPDX-License-Identifier: MIT -import { accountsInfo$ } from '@parity/light.js'; -import { action, computed, observable } from 'mobx'; -import { map } from 'rxjs/operators'; +import { action, observable } from 'mobx'; import store from 'store'; import LS_PREFIX from './utils/lsPrefix'; @@ -13,7 +11,6 @@ import LS_PREFIX from './utils/lsPrefix'; const LS_KEY = `${LS_PREFIX}::firstRun`; class OnboardingStore { - @observable hasAccounts; // If the user has at least 1 account or not @observable isFirstRun; // If it's the 1st time the user is running the app constructor () { @@ -25,31 +22,8 @@ class OnboardingStore { } else { this.setIsFirstRun(isFirstRun); } - - accountsInfo$() - .pipe(map(accounts => Object.keys(accounts).length > 0)) - .subscribe(this.setHasAccounts); - } - - /** - * We show the onboarding process if: - * - either it's the 1st time the user runs this app - * - or the user has 0 account - */ - @computed - get isOnboarding () { - // If either of the two is undefined, then it means we're still fetching. - // This doesn't count as onboarding. - return this.hasAccounts === undefined || this.isFirstRun === undefined - ? false - : !this.hasAccounts || this.isFirstRun; } - @action - setHasAccounts = hasAccounts => { - this.hasAccounts = hasAccounts; - }; - @action setIsFirstRun = isFirstRun => { this.isFirstRun = isFirstRun;