From f76f1ab5941a0ec9fa3dbcb2eeae2c025efd90f1 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 27 May 2019 22:09:36 +0200 Subject: [PATCH] Account/Address create modals (#1221) * Account/Address create modals * Spacing * Account Create modal (& use by vanity) * Account Create & Import wired in --- packages/app-accounts/src/Overview.tsx | 82 +++++-- packages/app-accounts/src/Vanity/index.tsx | 25 +- packages/app-accounts/src/index.tsx | 25 +- .../src/{Creator.tsx => modals/Create.tsx} | 186 +++++++-------- .../src/{Restore.tsx => modals/Import.tsx} | 83 +++---- packages/app-accounts/src/types.ts | 6 + packages/app-address-book/src/index.tsx | 21 +- .../app-address-book/src/modals/Create.tsx | 221 ++++++++++++++++++ packages/app-address-book/src/types.ts | 6 + packages/ui-app/src/styles/semantic.css | 4 - 10 files changed, 464 insertions(+), 195 deletions(-) rename packages/app-accounts/src/{Creator.tsx => modals/Create.tsx} (76%) rename packages/app-accounts/src/{Restore.tsx => modals/Import.tsx} (70%) create mode 100644 packages/app-address-book/src/modals/Create.tsx diff --git a/packages/app-accounts/src/Overview.tsx b/packages/app-accounts/src/Overview.tsx index 152a60fc21..4835290edd 100644 --- a/packages/app-accounts/src/Overview.tsx +++ b/packages/app-accounts/src/Overview.tsx @@ -2,20 +2,30 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { ComponentProps } from './types'; +import { I18nProps } from '@polkadot/ui-app/types'; import { SubjectInfo } from '@polkadot/ui-keyring/observable/types'; +import { ComponentProps } from './types'; import React from 'react'; import styled from 'styled-components'; import accountObservable from '@polkadot/ui-keyring/observable/accounts'; import { withMulti, withObservable } from '@polkadot/ui-api'; +import { Button } from '@polkadot/ui-app'; +import CreateModal from './modals/Create'; +import ImportModal from './modals/Import'; import Account from './Account'; +import translate from './translate'; -type Props = ComponentProps & { +type Props = ComponentProps & I18nProps & { accounts?: SubjectInfo[] }; +type State = { + isCreateOpen: boolean, + isImportOpen: boolean +}; + const Wrapper = styled.div` .accounts { display: flex; @@ -29,37 +39,71 @@ const Wrapper = styled.div` } `; -class Overview extends React.PureComponent { - constructor (props: Props) { - super(props); - } +class Overview extends React.PureComponent { + state: State = { + isCreateOpen: false, + isImportOpen: false + }; render () { - const { accounts } = this.props; - - if (!accounts || Object.keys(accounts).length === 0) { - return null; - } + const { accounts, onStatusChange, t } = this.props; + const { isCreateOpen, isImportOpen } = this.state; return ( + +