From 66eb434e3183f55f3afe4e40d7c450d555621ff2 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Mon, 3 Jun 2019 11:51:08 +0200 Subject: [PATCH] Direct link to account creation (#1266) * create link * comment --- packages/app-accounts/src/Overview.tsx | 14 ++++++++++---- packages/apps/src/overlays/Accounts.tsx | 2 +- packages/ui-app/src/types.ts | 5 ++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/app-accounts/src/Overview.tsx b/packages/app-accounts/src/Overview.tsx index ae074b622f..d88f05fcd1 100644 --- a/packages/app-accounts/src/Overview.tsx +++ b/packages/app-accounts/src/Overview.tsx @@ -26,10 +26,16 @@ type State = { }; class Overview extends React.PureComponent { - state: State = { - isCreateOpen: false, - isImportOpen: false - }; + constructor (props: Props) { + super(props); + + const { state : { isCreateOpen = false } = {} } = this.props.location; + + this.state = { + isCreateOpen, + isImportOpen: false + }; + } render () { const { accounts, onStatusChange, t } = this.props; diff --git a/packages/apps/src/overlays/Accounts.tsx b/packages/apps/src/overlays/Accounts.tsx index 2d39623342..e0a034fac9 100644 --- a/packages/apps/src/overlays/Accounts.tsx +++ b/packages/apps/src/overlays/Accounts.tsx @@ -64,7 +64,7 @@ class Accounts extends React.PureComponent { You don't have any accounts. Some features are currently hidden and will only become available once you have accounts. {' '} {t('Create an account now.')} diff --git a/packages/ui-app/src/types.ts b/packages/ui-app/src/types.ts index 1f6a2a455d..b6d5db31c1 100644 --- a/packages/ui-app/src/types.ts +++ b/packages/ui-app/src/types.ts @@ -5,6 +5,9 @@ import { WithTranslation } from 'react-i18next'; import { RpcRxInterface } from '@polkadot/rpc-rx/types'; import { ActionStatus } from '@polkadot/ui-app/Status/types'; +// location props passed by react-router from a link can contain a "state" object +// this is used for Account creation link to popup the account creation modal +import { LocationDescriptorObject } from 'history'; export type BareProps = { className?: string, @@ -15,7 +18,7 @@ export type BareProps = { export type AppProps = { basePath: string, - location: Location, + location: LocationDescriptorObject, onStatusChange: (status: ActionStatus) => void };