From 9ee5280adb8b2ff664c374c24aaa04fea4af72af Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 26 Mar 2019 10:16:59 +0100 Subject: [PATCH] Add bonding preferences (#842) --- .../app-staking/src/StakeList/Account.tsx | 181 ++++++++++-------- .../app-staking/src/StakeList/Bonding.tsx | 127 ++++++++++++ .../app-staking/src/StakeList/Nominating.tsx | 3 +- .../app-staking/src/StakeList/Preferences.tsx | 5 +- packages/app-staking/src/index.tsx | 12 +- packages/ui-app/src/TxButton.tsx | 5 +- 6 files changed, 237 insertions(+), 96 deletions(-) create mode 100644 packages/app-staking/src/StakeList/Bonding.tsx diff --git a/packages/app-staking/src/StakeList/Account.tsx b/packages/app-staking/src/StakeList/Account.tsx index 9e907dda7d..d3b08f202f 100644 --- a/packages/app-staking/src/StakeList/Account.tsx +++ b/packages/app-staking/src/StakeList/Account.tsx @@ -13,9 +13,10 @@ import { AccountId, Balance, Option, ValidatorPrefs } from '@polkadot/types'; import { AddressMini, AddressSummary, Button } from '@polkadot/ui-app'; import { withCalls } from '@polkadot/ui-api'; +import Bonding from './Bonding'; import Nominating from './Nominating'; import Preferences from './Preferences'; -import UnnominateButton from './UnnominateButton'; +// import UnnominateButton from './UnnominateButton'; import translate from '../translate'; type Props = ApiProps & I18nProps & { @@ -32,6 +33,7 @@ type Props = ApiProps & I18nProps & { }; type State = { + isBondingOpen: boolean, isNominateOpen: boolean, isPrefsOpen: boolean, nominee: AccountId | null @@ -39,6 +41,7 @@ type State = { class Account extends React.PureComponent { state: State = { + isBondingOpen: false, isNominateOpen: false, isPrefsOpen: false, nominee: null @@ -57,6 +60,7 @@ class Account extends React.PureComponent { return (
+ {this.renderBonding()} {this.renderNominating()} {this.renderPrefs()} { ); } + private renderBonding () { + const { accountId } = this.props; + const { isBondingOpen } = this.state; + + return ( + + ); + } + private renderNominee () { const { balanceArray } = this.props; const { nominee } = this.state; @@ -117,10 +134,6 @@ class Account extends React.PureComponent { const { intentions } = this.props; const { isNominateOpen } = this.state; - if (!isNominateOpen) { - return null; - } - return ( { const { accountId, staking_validatorPreferences } = this.props; const { isPrefsOpen } = this.state; - if (!isPrefsOpen) { - return null; - } - return ( { } private renderButtons () { - const { accountId, intentions, t } = this.props; - const { nominee } = this.state; - const isIntending = intentions.includes(accountId); - const canStake = !isIntending && !nominee; - - if (canStake) { - return ( - -