Don't allow re-{validate, nominate} with active 0 (#3080)

This commit is contained in:
Jaco Greeff 2020-06-28 21:23:33 +02:00 committed by GitHub
parent 3cd06b4fbe
commit d24d2882e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import { EraIndex } from '@polkadot/types/interfaces';
import { StakerState } from '@polkadot/react-hooks/types';
import { SortedTargets } from '../../types';
import React from 'react';
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';
import { AddressInfo, AddressMini, AddressSmall, Button, Menu, Popup, StakingBonded, StakingRedeemable, StakingUnbonding, TxButton } from '@polkadot/react-components';
import { useApi, useCall, useToggle } from '@polkadot/react-hooks';
@ -48,6 +48,13 @@ function Account ({ className = '', info: { controllerId, destination, destinati
const [isSettingsOpen, toggleSettings] = useToggle();
const [isUnbondOpen, toggleUnbond] = useToggle();
const [isValidateOpen, toggleValidate] = useToggle();
const [hasBonded, setHasBonded] = useState(false);
useEffect((): void => {
stakingAccount?.stakingLedger && setHasBonded(
!stakingAccount.stakingLedger.active.isEmpty
);
}, [stakingAccount]);
return (
<tr className={className}>
@ -176,7 +183,7 @@ function Account ({ className = '', info: { controllerId, destination, destinati
: (
<Button
icon='certificate'
isDisabled={!isOwnController || isDisabled}
isDisabled={!isOwnController || isDisabled || !hasBonded}
key='validate'
label={t<string>('Validate')}
onClick={toggleValidate}
@ -185,7 +192,7 @@ function Account ({ className = '', info: { controllerId, destination, destinati
}
<Button
icon='hand-paper'
isDisabled={!isOwnController || isDisabled}
isDisabled={!isOwnController || isDisabled || !hasBonded}
key='nominate'
label={t<string>('Nominate')}
onClick={toggleNominate}

View File

@ -256,7 +256,7 @@ function renderBalances (props: Props, allAccounts: string[], t: <T = string> (k
)}
{balanceDisplay.vested && balancesAll?.isVesting && (
<>
<Label label={t<string>('vesting')} />
<Label label={t<string>('vested')} />
<FormatBalance
className='result'
label={