diff --git a/packages/page-staking/src/Actions/Account/Nominate.tsx b/packages/page-staking/src/Actions/Account/Nominate.tsx index 16adff456c..6fa53ac879 100644 --- a/packages/page-staking/src/Actions/Account/Nominate.tsx +++ b/packages/page-staking/src/Actions/Account/Nominate.tsx @@ -9,7 +9,7 @@ import styled from 'styled-components'; import { AddressMini, InputAddressMulti, InputAddress, Modal, Static, Toggle, TxButton } from '@polkadot/react-components'; import { useFavorites } from '@polkadot/react-hooks'; -import { MAX_NOMINATIONS, STORE_FAVS_BASE } from '../../constants'; +import { MAX_NOMINATIONS, MAX_PAYOUTS, STORE_FAVS_BASE } from '../../constants'; import { useTranslation } from '../../translate'; interface Props { @@ -29,7 +29,15 @@ interface Selected { } function autoPick (targets: SortedTargets): string[] { - return (targets.validators || []).filter((_, index) => index < MAX_NOMINATIONS).map(({ key }) => key); + return (targets.validators || []).reduce((result: string[], { key, numNominators }): string[] => { + if (result.length < MAX_NOMINATIONS) { + if (numNominators && (numNominators < MAX_PAYOUTS)) { + result.push(key); + } + } + + return result; + }, []); } function initialPick (targets: SortedTargets): Selected { diff --git a/packages/page-staking/src/MaxBadge.tsx b/packages/page-staking/src/MaxBadge.tsx new file mode 100644 index 0000000000..cddaa479f3 --- /dev/null +++ b/packages/page-staking/src/MaxBadge.tsx @@ -0,0 +1,27 @@ +// Copyright 2017-2020 @polkadot/app-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 React from 'react'; +import { Badge } from '@polkadot/react-components'; + +import { MAX_PAYOUTS } from './constants'; + +interface Props { + numNominators?: number; +} + +function MaxBadge ({ numNominators }: Props): React.ReactElement | null { + if (!numNominators || (numNominators < MAX_PAYOUTS)) { + return null; + } + + return ( + + ); +} + +export default React.memo(MaxBadge); diff --git a/packages/page-staking/src/Overview/Address/Status.tsx b/packages/page-staking/src/Overview/Address/Status.tsx index 00797d4029..2ecf08f9f4 100644 --- a/packages/page-staking/src/Overview/Address/Status.tsx +++ b/packages/page-staking/src/Overview/Address/Status.tsx @@ -5,13 +5,16 @@ import React from 'react'; import { Badge, Icon } from '@polkadot/react-components'; +import MaxBadge from '../../MaxBadge'; + interface Props { isElected: boolean; + numNominators?: number; onlineCount?: false | number; onlineMessage?: boolean; } -function Status ({ isElected, onlineCount, onlineMessage }: Props): React.ReactElement { +function Status ({ isElected, numNominators, onlineCount, onlineMessage }: Props): React.ReactElement { return ( {isElected && ( @@ -28,6 +31,7 @@ function Status ({ isElected, onlineCount, onlineMessage }: Props): React.ReactE type='online' /> )} + ); } diff --git a/packages/page-staking/src/Overview/Address/index.tsx b/packages/page-staking/src/Overview/Address/index.tsx index 45591780a3..6f398a2925 100644 --- a/packages/page-staking/src/Overview/Address/index.tsx +++ b/packages/page-staking/src/Overview/Address/index.tsx @@ -153,6 +153,7 @@ function Address ({ address, className, filterName, hasQueries, isAuthor, isElec /> diff --git a/packages/page-staking/src/Targets/Validator.tsx b/packages/page-staking/src/Targets/Validator.tsx index 44d4965662..4aacfd8edb 100644 --- a/packages/page-staking/src/Targets/Validator.tsx +++ b/packages/page-staking/src/Targets/Validator.tsx @@ -1,6 +1,6 @@ // Copyright 2017-2020 @polkadot/app-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.v +// of the Apache-2.0 license. See the LICENSE file for details. import { ValidatorInfo } from '../types'; @@ -9,6 +9,7 @@ import { AddressSmall, Icon, Toggle } from '@polkadot/react-components'; import { FormatBalance } from '@polkadot/react-query'; import { formatNumber } from '@polkadot/util'; +import MaxBadge from '../MaxBadge'; import Favorite from '../Overview/Address/Favorite'; interface Props { @@ -39,6 +40,9 @@ function Validator ({ canSelect, info: { accountId, bondOther, bondOwn, bondTota isFavorite={isFavorite} toggleFavorite={toggleFavorite} /> + + + {formatNumber(rankOverall)} diff --git a/packages/page-staking/src/Targets/index.tsx b/packages/page-staking/src/Targets/index.tsx index aae5bbd039..1909d0d18c 100644 --- a/packages/page-staking/src/Targets/index.tsx +++ b/packages/page-staking/src/Targets/index.tsx @@ -89,7 +89,7 @@ function Targets ({ className, ownStashes, targets: { calcWith, lastReward, nomi ); const header = useMemo(() => [ - [t('validators'), 'start', 3], + [t('validators'), 'start', 4], ...['rankComm', 'rankBondTotal', 'rankBondOwn', 'rankBondOther', 'rankOverall'].map((header) => [ <>{labels[header]}, `isClickable ${sortBy === header && 'ui--highlight--border'} number`, diff --git a/packages/page-staking/src/constants.ts b/packages/page-staking/src/constants.ts index 46f86d0d9a..71d0b3f922 100644 --- a/packages/page-staking/src/constants.ts +++ b/packages/page-staking/src/constants.ts @@ -4,4 +4,6 @@ export const MAX_NOMINATIONS = 16; +export const MAX_PAYOUTS = 64; + export const STORE_FAVS_BASE = 'staking:favorites'; diff --git a/packages/page-treasury/src/Overview/index.tsx b/packages/page-treasury/src/Overview/index.tsx index 42800d747e..0c64b5ab0d 100644 --- a/packages/page-treasury/src/Overview/index.tsx +++ b/packages/page-treasury/src/Overview/index.tsx @@ -37,8 +37,8 @@ function Overview ({ className }: Props): React.ReactElement { return (