From 1291a24e4ead76a183f2997076fab4a757768fd7 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 5 Dec 2017 10:44:34 +0100 Subject: [PATCH] Update FirstRun for UI-2 (#7195) * WIP * Update after @parity/ui update * Update to latest * Update semver for @parity * Update & -> & --- js/package-lock.json | 73 +++++-- js/package.json | 7 +- js/src/Application/application.js | 7 +- js/src/Application/store.js | 95 -------- js/src/FirstRun/TnC/tnc.js | 9 +- js/src/FirstRun/firstRun.js | 348 +++--------------------------- js/src/FirstRun/firstRun.spec.js | 34 +-- js/src/FirstRun/store.js | 42 ++++ 8 files changed, 135 insertions(+), 480 deletions(-) delete mode 100644 js/src/Application/store.js create mode 100644 js/src/FirstRun/store.js diff --git a/js/package-lock.json b/js/package-lock.json index fbd4467f0..356fe5deb 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -40,12 +40,6 @@ } } }, - "@parity/dapp-accounts": { - "version": "github:paritytech/dapp-accounts#ca55be1774563862e7b0cc72740d0747a60036b8", - "requires": { - "@parity/dapp-vaults": "github:paritytech/dapp-vaults#1bd5de3994227e6b733e7b3e985117a59f0ad638" - } - }, "@parity/dapp-console": { "version": "github:paritytech/dapp-console#f48baba86be6ee2f04ab208731c9529c7b6f92f8", "dev": true @@ -529,6 +523,18 @@ "integrity": "sha1-jgOPbdsUvXZa4fS1IW4SCUUR4NA=", "dev": true }, + "semantic-ui-react": { + "version": "0.76.0", + "resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-0.76.0.tgz", + "integrity": "sha512-CdiIT8n7ZwUlytZkYsQMnaVGmoIZI/mVs4lijvLcR568kcnlRkYYaFKhMLq5tFDQU6+QhdTD+8WebF7ov0Ql6Q==", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "classnames": "2.2.5", + "lodash": "4.17.4", + "prop-types": "15.6.0" + } + }, "webrtc-adapter": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/webrtc-adapter/-/webrtc-adapter-2.1.0.tgz", @@ -1027,6 +1033,26 @@ "integrity": "sha1-jgOPbdsUvXZa4fS1IW4SCUUR4NA=", "dev": true }, + "semantic-ui-react": { + "version": "0.76.0", + "resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-0.76.0.tgz", + "integrity": "sha512-CdiIT8n7ZwUlytZkYsQMnaVGmoIZI/mVs4lijvLcR568kcnlRkYYaFKhMLq5tFDQU6+QhdTD+8WebF7ov0Ql6Q==", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "classnames": "2.2.5", + "lodash": "4.17.4", + "prop-types": "15.6.0" + }, + "dependencies": { + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + } + } + }, "webrtc-adapter": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/webrtc-adapter/-/webrtc-adapter-2.1.0.tgz", @@ -1073,7 +1099,8 @@ "dev": true }, "@parity/dapp-vaults": { - "version": "github:paritytech/dapp-vaults#1bd5de3994227e6b733e7b3e985117a59f0ad638" + "version": "github:paritytech/dapp-vaults#1bd5de3994227e6b733e7b3e985117a59f0ad638", + "dev": true }, "@parity/dapp-web": { "version": "github:paritytech/dapp-web#6ea1fe0c7c0d01c43788dbf6a11d1573a443ce1d", @@ -1112,16 +1139,16 @@ } }, "@parity/plugin-signer-account": { - "version": "github:paritytech/plugin-signer-account#bd647f1163ca49fe52aedb7c69ae1bed6f1d14b7" + "version": "github:paritytech/plugin-signer-account#e151e3ca4e0d51aec93219df3661212cc15aa4cc" }, "@parity/plugin-signer-default": { - "version": "github:paritytech/plugin-signer-default#1440c8c750b3d824a5569f4302102ce64fc63b72" + "version": "github:paritytech/plugin-signer-default#0d596844063849f7b3cce8fa2d8f7cc56e8caa58" }, "@parity/plugin-signer-hardware": { - "version": "github:paritytech/plugin-signer-hardware#8fc74af1e700afb883ea4e09aeee96a3ca4f288f" + "version": "github:paritytech/plugin-signer-hardware#ae9c943baf177c15bf478429f26c169fea198ef8" }, "@parity/plugin-signer-qr": { - "version": "github:paritytech/plugin-signer-qr#fe2a63955c636399719ba2aa6c58710de6cb1b89" + "version": "github:paritytech/plugin-signer-qr#c16423de5b8a8f68ebd5f1e78e084fa959329a9f" }, "@parity/shared": { "version": "2.2.7", @@ -1182,9 +1209,9 @@ } }, "@parity/ui": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@parity/ui/-/ui-3.0.4.tgz", - "integrity": "sha512-/IS+6Qxr5HGAvdaB0xud9lU2c48Crg2dY7yzkb7V+99qvqYV/OAI31IffaBOt3UbLz/QWF+Da+ZOWT96eIVlAg==", + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@parity/ui/-/ui-3.0.7.tgz", + "integrity": "sha512-FkVb6DWja56uaNN+dG/hNH3c1P4hlA8Sg/e65b4hKyZe3PQP7Gko34wJ0IaP5FEeAWQC/yg0SgrQvc8CqPjeSg==", "requires": { "@parity/api": "2.1.5", "@parity/etherscan": "2.1.3", @@ -1252,6 +1279,17 @@ "requires": { "hoist-non-react-statics": "2.3.1" } + }, + "semantic-ui-react": { + "version": "0.76.0", + "resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-0.76.0.tgz", + "integrity": "sha512-CdiIT8n7ZwUlytZkYsQMnaVGmoIZI/mVs4lijvLcR568kcnlRkYYaFKhMLq5tFDQU6+QhdTD+8WebF7ov0Ql6Q==", + "requires": { + "babel-runtime": "6.26.0", + "classnames": "2.2.5", + "lodash": "4.17.4", + "prop-types": "15.5.10" + } } } }, @@ -15519,12 +15557,13 @@ } }, "semantic-ui-react": { - "version": "0.76.0", - "resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-0.76.0.tgz", - "integrity": "sha512-CdiIT8n7ZwUlytZkYsQMnaVGmoIZI/mVs4lijvLcR568kcnlRkYYaFKhMLq5tFDQU6+QhdTD+8WebF7ov0Ql6Q==", + "version": "0.77.0", + "resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-0.77.0.tgz", + "integrity": "sha512-lUnlpbIbMtse335kjZAw8ClulCQAUWDm77pw2yY754mL02PlTNYtZQanoGjhBFts41YHpg6ExK156J/9Ynb8IQ==", "requires": { "babel-runtime": "6.26.0", "classnames": "2.2.5", + "fbjs": "0.8.16", "lodash": "4.17.4", "prop-types": "15.5.10" } diff --git a/js/package.json b/js/package.json index e61eb03c6..2220e5e74 100644 --- a/js/package.json +++ b/js/package.json @@ -142,14 +142,13 @@ "yargs": "6.6.0" }, "dependencies": { - "@parity/api": "2.1.x", - "@parity/dapp-accounts": "paritytech/dapp-accounts", + "@parity/api": "~2.1.1", "@parity/plugin-signer-account": "paritytech/plugin-signer-account", "@parity/plugin-signer-default": "paritytech/plugin-signer-default", "@parity/plugin-signer-hardware": "paritytech/plugin-signer-hardware", "@parity/plugin-signer-qr": "paritytech/plugin-signer-qr", - "@parity/shared": "2.2.x", - "@parity/ui": "~3.0.4", + "@parity/shared": "~2.2.1", + "@parity/ui": "~3.0.7", "keythereum": "1.0.2", "lodash.flatten": "4.4.0", "lodash.omitby": "4.6.0", diff --git a/js/src/Application/application.js b/js/src/Application/application.js index e8015c948..5e7135fa5 100644 --- a/js/src/Application/application.js +++ b/js/src/Application/application.js @@ -36,7 +36,6 @@ import Status from '../Status'; import UpgradeParity from '../UpgradeParity'; import { appLogoDark as parityLogo } from '../config'; -import Store from './store'; import styles from './application.css'; const inFrame = window.parent !== window && window.parent.frames.length !== 0; @@ -54,7 +53,6 @@ class Application extends Component { pending: PropTypes.array } - store = new Store(this.context.api); hwstore = HardwareStore.get(this.context.api); upgradeStore = UpgradeStore.get(this.context.api); @@ -114,10 +112,7 @@ class Application extends Component { return (
- + diff --git a/js/src/Application/store.js b/js/src/Application/store.js deleted file mode 100644 index 9008997b8..000000000 --- a/js/src/Application/store.js +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import { action, observable } from 'mobx'; -import store from 'store'; - -const OLD_LS_FIRST_RUN_KEY = 'showFirstRun'; -const LS_FIRST_RUN_KEY = '_parity::showFirstRun'; - -export default class Store { - @observable firstrunVisible = false; - - constructor (api) { - // Migrate the old key to the new one - this._migrateStore(); - - this._api = api; - - // Show the first run the storage doesn't hold `false` value - const firstrunVisible = store.get(LS_FIRST_RUN_KEY) !== false; - - // Only check accounts if we might show the first run - if (firstrunVisible) { - api.transport.once('open', () => { - this._checkAccounts(); - }); - } else { - this.firstrunVisible = false; - } - } - - @action closeFirstrun = () => { - this.toggleFirstrun(false); - } - - @action toggleFirstrun = (visible = false) => { - this.firstrunVisible = visible; - - // There's no need to write to storage that the - // First Run should be visible - if (!visible) { - store.set(LS_FIRST_RUN_KEY, !!visible); - } - } - - /** - * Migrate the old LocalStorage key format - * to the new one - */ - _migrateStore () { - const oldValue = store.get(OLD_LS_FIRST_RUN_KEY); - const newValue = store.get(LS_FIRST_RUN_KEY); - - if (newValue === undefined && oldValue !== undefined) { - store.set(LS_FIRST_RUN_KEY, oldValue); - store.remove(OLD_LS_FIRST_RUN_KEY); - } - } - - _checkAccounts () { - return Promise - .all([ - this._api.parity.listVaults(), - this._api.parity.allAccountsInfo() - ]) - .then(([ vaults, info ]) => { - const accounts = Object.keys(info) - .filter((address) => info[address].uuid) - // In DEV mode, the empty phrase account is already added - .filter((address) => address.toLowerCase() !== '0x00a329c0648769a73afac7f9381e08fb43dbea72'); - - // Has accounts if any vaults or accounts - const hasAccounts = (accounts && accounts.length > 0) || (vaults && vaults.length > 0); - - // Show First Run if no accounts and no vaults - this.toggleFirstrun(!hasAccounts); - }) - .catch((error) => { - console.error('checkAccounts', error); - }); - } -} diff --git a/js/src/FirstRun/TnC/tnc.js b/js/src/FirstRun/TnC/tnc.js index 93199b5c3..654970db4 100644 --- a/js/src/FirstRun/TnC/tnc.js +++ b/js/src/FirstRun/TnC/tnc.js @@ -21,19 +21,16 @@ import ReactMarkdown from 'react-markdown'; import Checkbox from '@parity/ui/lib/Form/Checkbox'; +import tnc from './tnc.md'; + import styles from '../firstRun.css'; -let tnc = ''; - -if (process.env.NODE_ENV !== 'test') { - tnc = require('./tnc.md'); -} - export default function TnC ({ hasAccepted, onAccept }) { return (
, - , - , - , - , - -]; -const BUTTON_LABEL_NEXT = ( - -); @observer -class FirstRun extends Component { - static contextTypes = { - api: PropTypes.object.isRequired - } - - static propTypes = { - hasAccounts: PropTypes.bool.isRequired, - newError: PropTypes.func.isRequired, - onClose: PropTypes.func.isRequired, - visible: PropTypes.bool.isRequired - } - - createStore = new CreateStore(this.context.api, {}, true, false); - +export default class FirstRun extends Component { state = { - stage: 0, hasAcceptedTnc: false } - render () { - const { visible } = this.props; - const { stage } = this.state; + store = new Store(); - if (!visible) { + render () { + const { hasAcceptedTnc } = this.state; + + if (!this.store.visible) { return null; } return ( - { this.renderStage() } - - ); - } - - renderStage () { - const { stage, hasAcceptedTnc } = this.state; - - switch (stage) { - case 0: - return ( - - ); - case 1: - return ( - - ); - case 2: - return ( - - ); - case 3: - return ( - - ); - case 4: - return ( - - ); - case 5: - return ( - - ); - } - } - - renderDialogActions () { - const { hasAccounts } = this.props; - const { stage, hasAcceptedTnc } = this.state; - const { canCreate, phraseBackedUpError } = this.createStore; - - switch (stage) { - case 0: - return ( -