diff --git a/packages/app-staking/src/Account/index.tsx b/packages/app-staking/src/Account/index.tsx index e7ea082c52..cb4b5d00e6 100644 --- a/packages/app-staking/src/Account/index.tsx +++ b/packages/app-staking/src/Account/index.tsx @@ -80,9 +80,11 @@ class Account extends React.PureComponent { name={name} value={accountId} identIconSize={96} + withAvailable withBonded withIndex={false} withNonce={false} + withUnlocking >
{this.renderButtons()} @@ -171,24 +173,6 @@ class Account extends React.PureComponent { ); } - // private renderUnbond () { - // const { accountId } = this.props; - // const { controllerId, isBondingOpen } = this.state; - - // if (!controllerId) { - // return null; - // } - - // return ( - // - // ); - // } - private renderNominee () { const { recentlyOffline, staking_nominators, t } = this.props; diff --git a/packages/ui-app/src/AddressSummary.tsx b/packages/ui-app/src/AddressSummary.tsx index ef552fae9e..63c7da3ca2 100644 --- a/packages/ui-app/src/AddressSummary.tsx +++ b/packages/ui-app/src/AddressSummary.tsx @@ -11,11 +11,13 @@ import { Nonce } from '@polkadot/ui-reactive'; import { withCalls } from '@polkadot/ui-api'; import BaseIdentityIcon from '@polkadot/ui-identicon'; +import AvailableDisplay from './Available'; import { classes, toShortAddress } from './util'; import BalanceDisplay from './Balance'; import BondedDisplay from './Bonded'; import IdentityIcon from './IdentityIcon'; import translate from './translate'; +import UnlockingDisplay from './Unlocking'; export type Props = I18nProps & { accounts_idAndIndex?: [AccountId?, AccountIndex?], @@ -23,17 +25,19 @@ export type Props = I18nProps & { bonded?: BN | Array, children?: React.ReactNode, extraInfo?: React.ReactNode, - name?: string, - value: AccountId | AccountIndex | Address | string | null, - withBalance?: boolean, - withBonded?: boolean, - withIndex?: boolean, identIconSize?: number, isShort?: boolean, + name?: string, session_validators?: Array, + value: AccountId | AccountIndex | Address | string | null, + withAvailable?: boolean, + withBalance?: boolean, + withBonded?: boolean, withCopy?: boolean, withIcon?: boolean, - withNonce?: boolean + withIndex?: boolean, + withNonce?: boolean, + withUnlocking?: boolean }; const DEFAULT_ADDR = '5'.padEnd(16, 'x'); @@ -53,9 +57,11 @@ class AddressSummary extends React.PureComponent { {this.renderIcon()} {this.renderAccountId()} {this.renderAccountIndex()} + {this.renderAvailable()} {this.renderBalance()} {this.renderBonded()} {this.renderNonce()} + {this.renderUnlocking()}
{this.renderChildren()} @@ -174,6 +180,41 @@ class AddressSummary extends React.PureComponent { ); } + protected renderAvailable () { + const { accounts_idAndIndex = [], t, value, withAvailable } = this.props; + const [_accountId] = accounts_idAndIndex; + const accountId = _accountId || value; + + if (!withAvailable || !accountId) { + return null; + } + + return ( + + ); + } + + protected renderUnlocking () { + const { accounts_idAndIndex = [], value, withUnlocking } = this.props; + const [_accountId] = accounts_idAndIndex; + const accountId = _accountId || value; + + if (!withUnlocking || !accountId) { + return null; + } + + return ( + + ); + } + protected renderIcon (className: string = 'ui--AddressSummary-icon', size?: number) { const { accounts_idAndIndex = [], identIconSize = 96, value, withIcon = true } = this.props; diff --git a/packages/ui-app/src/Available.tsx b/packages/ui-app/src/Available.tsx new file mode 100644 index 0000000000..e458f11a42 --- /dev/null +++ b/packages/ui-app/src/Available.tsx @@ -0,0 +1,36 @@ +// Copyright 2017-2019 @polkadot/ui-app 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 { BareProps } from './types'; + +import React from 'react'; +import { AccountId, AccountIndex, Address } from '@polkadot/types'; +import { Available } from '@polkadot/ui-reactive'; + +import { classes } from './util'; + +export type Props = BareProps & { + label?: string, + params?: AccountId | AccountIndex | Address | string | Uint8Array | null, + withLabel?: boolean +}; + +export default class AvailableDisplay extends React.PureComponent { + render () { + const { params, className, label, style } = this.props; + + if (!params) { + return null; + } + + return ( + + ); + } +} diff --git a/packages/ui-app/src/TxButton.tsx b/packages/ui-app/src/TxButton.tsx index c7b834c7fc..888a06ceb4 100644 --- a/packages/ui-app/src/TxButton.tsx +++ b/packages/ui-app/src/TxButton.tsx @@ -2,19 +2,20 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { SubmittableExtrinsic } from '@polkadot/api/promise/types'; +import { ApiProps } from '@polkadot/ui-api/types'; +import { assert, isFunction, isUndefined } from '@polkadot/util'; import { Index } from '@polkadot/types'; import { IExtrinsic } from '@polkadot/types/types'; -import { ApiProps } from '@polkadot/ui-api/types'; -import { SubmittableExtrinsic } from '@polkadot/api/promise/types'; import { QueueTx, QueueTx$ExtrinsicAdd, TxCallback } from './Status/types'; import React from 'react'; import { SubmittableResult } from '@polkadot/api'; import { withApi } from '@polkadot/ui-api'; -import { assert, isFunction, isUndefined } from '@polkadot/util'; -import { QueueConsumer } from './Status/Context'; import Button from './Button'; +import { Button$Sizes } from './Button/types'; +import { QueueConsumer } from './Status/Context'; type ConstructFn = () => Array; @@ -26,17 +27,20 @@ type InjectedProps = { type Props = ApiProps & { accountId?: string, accountNonce?: Index, - isPrimary?: boolean, + className?: string, + extrinsic?: IExtrinsic | SubmittableExtrinsic, + icon?: string, + iconSize?: Button$Sizes, isDisabled?: boolean, isNegative?: boolean, + isPrimary?: boolean, label: React.ReactNode, onClick?: () => any, onFailed?: TxCallback, onSuccess?: TxCallback, onUpdate?: TxCallback, params?: Array | ConstructFn, - tx?: string, - extrinsic?: IExtrinsic | SubmittableExtrinsic + tx?: string }; type InnerProps = Props & InjectedProps; @@ -52,17 +56,20 @@ class TxButtonInner extends React.PureComponent { } as State; render () { - const { accountId, isDisabled, isNegative, isPrimary, label } = this.props; + const { accountId, className, icon, iconSize , isDisabled, isNegative, isPrimary, label } = this.props; const { isSending } = this.state; return (