From 21f76ca0acd779a1ca72f433861ddab47607f995 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Wed, 1 May 2019 17:44:50 +0200 Subject: [PATCH] Add unbond button (#1057) * don't show 'Bond additionnal' if the stash already bond everything it could * add unbound button * clean up * clean up bis * linting * add comments + some more cleanup * add group active and total * refactor the isOpen props for all modals * conditionnaly call the renderer * revert isOpen changes * add comment regarding the modal loading choice --- packages/app-staking/src/Account/Unbond.tsx | 98 +++++++++++++++++++++ packages/app-staking/src/Account/index.tsx | 71 ++++++++++++--- packages/app-staking/src/Accounts.tsx | 1 - 3 files changed, 159 insertions(+), 11 deletions(-) create mode 100644 packages/app-staking/src/Account/Unbond.tsx diff --git a/packages/app-staking/src/Account/Unbond.tsx b/packages/app-staking/src/Account/Unbond.tsx new file mode 100644 index 0000000000..2968ac3b68 --- /dev/null +++ b/packages/app-staking/src/Account/Unbond.tsx @@ -0,0 +1,98 @@ +// Copyright 2017-2019 @polkadot/ui-staking authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { AccountId } from '@polkadot/types'; +import BN from 'bn.js'; +import { Button, InputAddress, InputBalance, Modal, TxButton } from '@polkadot/ui-app'; +import { I18nProps } from '@polkadot/ui-app/types'; +import React from 'react'; + +import translate from '../translate'; + +type Props = I18nProps & { + controllerId?: AccountId | null, + isOpen: boolean, + onClose: () => void +}; + +type State = { + maxUnbond?: BN +}; + +class Unbond extends React.PureComponent { + state: State = {}; + + render () { + const { controllerId, isOpen, onClose, t } = this.props; + const { maxUnbond } = this.state; + const canSubmit = !!maxUnbond && maxUnbond.gtn(0); + + if (!isOpen) { + return null; + } + + return ( + + {this.renderContent()} + + +