Add the 64+ payouts display (#2647)
* Add the 64+ payouts display * Re-add sorted filter for amount * Count adjust
This commit is contained in:
parent
f83e359e08
commit
b04cac4427
@ -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 {
|
||||
|
||||
27
packages/page-staking/src/MaxBadge.tsx
Normal file
27
packages/page-staking/src/MaxBadge.tsx
Normal file
@ -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<Props> | null {
|
||||
if (!numNominators || (numNominators < MAX_PAYOUTS)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Badge
|
||||
info='64+'
|
||||
type='brown'
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(MaxBadge);
|
||||
@ -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<Props> {
|
||||
function Status ({ isElected, numNominators, onlineCount, onlineMessage }: Props): React.ReactElement<Props> {
|
||||
return (
|
||||
<td className='together'>
|
||||
{isElected && (
|
||||
@ -28,6 +31,7 @@ function Status ({ isElected, onlineCount, onlineMessage }: Props): React.ReactE
|
||||
type='online'
|
||||
/>
|
||||
)}
|
||||
<MaxBadge numNominators={numNominators} />
|
||||
</td>
|
||||
);
|
||||
}
|
||||
|
||||
@ -153,6 +153,7 @@ function Address ({ address, className, filterName, hasQueries, isAuthor, isElec
|
||||
/>
|
||||
<Status
|
||||
isElected={isElected}
|
||||
numNominators={nominatedBy?.length}
|
||||
onlineCount={onlineCount}
|
||||
onlineMessage={onlineMessage}
|
||||
/>
|
||||
|
||||
@ -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}
|
||||
/>
|
||||
<td className='badge'>
|
||||
<MaxBadge numNominators={numNominators} />
|
||||
</td>
|
||||
<td className='number'>{formatNumber(rankOverall)}</td>
|
||||
<td className='address all'>
|
||||
<AddressSmall value={accountId} />
|
||||
|
||||
@ -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]}<Icon name={sortBy === header ? (sortFromMax ? 'chevron down' : 'chevron up') : 'minus'} /></>,
|
||||
`isClickable ${sortBy === header && 'ui--highlight--border'} number`,
|
||||
|
||||
@ -4,4 +4,6 @@
|
||||
|
||||
export const MAX_NOMINATIONS = 16;
|
||||
|
||||
export const MAX_PAYOUTS = 64;
|
||||
|
||||
export const STORE_FAVS_BASE = 'staking:favorites';
|
||||
|
||||
@ -37,8 +37,8 @@ function Overview ({ className }: Props): React.ReactElement<Props> {
|
||||
return (
|
||||
<div className={className}>
|
||||
<Summary
|
||||
approvalCount={info?.proposals.length}
|
||||
proposalCount={info?.approvals.length}
|
||||
approvalCount={info?.approvals.length}
|
||||
proposalCount={info?.proposals.length}
|
||||
/>
|
||||
<Button.Group>
|
||||
<ProposalCreate />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user