Add warning to bond, not send (#4656)

* Add warning to bond, not send

* Refresh update
This commit is contained in:
Jaco Greeff 2021-02-11 18:48:38 +01:00 committed by GitHub
parent c80d4f1afd
commit 9b9cc54724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 8 deletions

View File

@ -0,0 +1,21 @@
// Copyright 2017-2021 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React from 'react';
import { MarkWarning } from '@polkadot/react-components';
import { useTranslation } from './translate';
function ActionsBanner (): React.ReactElement<null> | null {
const { t } = useTranslation();
return (
<MarkWarning
className='warning centered'
content={t<string>('Use the account actions to create a new validator/nominator stash and bond it to participate in staking. Do not send funds directly via a transfer to a validator.')}
/>
);
}
export default React.memo(ActionsBanner);

View File

@ -3,6 +3,8 @@
import React from 'react';
import { MarkWarning } from '@polkadot/react-components';
import { useTranslation } from './translate';
interface Props {
@ -17,9 +19,10 @@ function ElectionBanner ({ isInElection }: Props): React.ReactElement<Props> | n
}
return (
<article className='warning centered'>
{t<string>('There is currently an ongoing election for new validator candidates. As such staking operations are not permitted.')}
</article>
<MarkWarning
className='warning centered'
content={t<string>('There is currently an ongoing election for new validator candidates. As such staking operations are not permitted.')}
/>
);
}

View File

@ -17,6 +17,7 @@ import { useAccounts, useApi, useAvailableSlashes, useCall, useFavorites, useOwn
import basicMd from './md/basic.md';
import Summary from './Overview/Summary';
import Actions from './Actions';
import ActionsBanner from './ActionsBanner';
import { STORE_FAVS_BASE } from './constants';
import Overview from './Overview';
import Payouts from './Payouts';
@ -158,6 +159,9 @@ function StakingApp ({ basePath, className = '' }: Props): React.ReactElement<Pr
ownStashes={ownStashes}
targets={targets}
/>
{basePath === pathname && hasAccounts && (ownStashes?.length === 0) && (
<ActionsBanner />
)}
<Overview
className={basePath === pathname ? '' : 'staking--hidden'}
favorites={favorites}

View File

@ -261,7 +261,7 @@ export default createGlobalStyle<Props & ThemeProps>(({ theme, uiHighlight }: Pr
&.mark {
margin: 0.5rem 0 0.5rem 2.25rem;
padding: 0.5rem 1rem;
padding: 0.5rem 1rem !important;
}
&.nomargin {

View File

@ -37,10 +37,12 @@ export function useOwnStashes (): [string, IsInKeyring][] | undefined {
const ownLedger = useCall<Option<StakingLedger>[]>(hasAccounts && api.query.staking?.ledger.multi, [allAccounts]);
return useMemo(
() => ownBonded && ownLedger
? getStashes(allAccounts, ownBonded, ownLedger)
: undefined,
[allAccounts, ownBonded, ownLedger]
() => hasAccounts
? ownBonded && ownLedger
? getStashes(allAccounts, ownBonded, ownLedger)
: undefined
: [],
[allAccounts, hasAccounts, ownBonded, ownLedger]
);
}