From f3876d573a8b24ce8992643d5128abc056c5f169 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 7 Apr 2019 13:33:14 +0200 Subject: [PATCH] Show session key on controller, before anything (allow selection) (#906) * Show session key on the controller * Force session keys on controllers * Display session * Padding cleanups --- .../app-staking/src/Account/SessionKey.tsx | 20 +++++++--- packages/app-staking/src/Account/index.tsx | 39 ++++++++++++++----- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/packages/app-staking/src/Account/SessionKey.tsx b/packages/app-staking/src/Account/SessionKey.tsx index 161e2946c9..2ccd1d2f33 100644 --- a/packages/app-staking/src/Account/SessionKey.tsx +++ b/packages/app-staking/src/Account/SessionKey.tsx @@ -15,13 +15,16 @@ type Props = I18nProps & { onClose: () => void }; -type State = {}; +type State = { + sessionId?: string +}; class Key extends React.PureComponent { state: State = {}; render () { const { accountId, isOpen, onClose, t } = this.props; + const { sessionId } = this.state; if (!isOpen) { return null; @@ -45,10 +48,11 @@ class Key extends React.PureComponent { @@ -58,7 +62,8 @@ class Key extends React.PureComponent { } private renderContent () { - const { accountId, t } = this.props; + const { t } = this.props; + const { sessionId } = this.state; return ( <> @@ -69,14 +74,19 @@ class Key extends React.PureComponent { ); } + + private onChangeSession = (sessionId: string) => { + this.setState({ sessionId }); + } } export default translate(Key); diff --git a/packages/app-staking/src/Account/index.tsx b/packages/app-staking/src/Account/index.tsx index 871e57cc0e..22481e4d1b 100644 --- a/packages/app-staking/src/Account/index.tsx +++ b/packages/app-staking/src/Account/index.tsx @@ -91,6 +91,7 @@ class Account extends React.PureComponent {
{this.renderButtons()} {this.renderBondedId()} + {this.renderSessionId()} {this.renderStashId()} {this.renderNominee()} {this.renderNominators()} @@ -236,6 +237,24 @@ class Account extends React.PureComponent { ); } + private renderSessionId () { + const { sessionId } = this.state; + + if (!sessionId) { + return null; + } + + return ( +
+ + +
+ ); + } + private renderStashId () { const { stashId } = this.state; @@ -276,11 +295,11 @@ class Account extends React.PureComponent { private renderButtons () { const { accountId, intentions, t } = this.props; - const { sessionId, stashId } = this.state; + const { sessionId, bondedId, stashId } = this.state; const buttons = []; if (!stashId) { - if (sessionId) { + if (!bondedId) { buttons.push(