Bounty DueBlocks (human time-first, aligned with UI) (#4651)
* Initial bounty re-align (table borders, font colors) * DueBlocks (align with UI counters, time first)
This commit is contained in:
parent
03a437c8fa
commit
6bcfabaaed
@ -4,14 +4,12 @@
|
||||
import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
|
||||
import type { BlockNumber, Bounty as BountyType, BountyIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { AddressSmall, Icon, LinkExternal } from '@polkadot/react-components';
|
||||
import { ThemeProps } from '@polkadot/react-components/types';
|
||||
import { BlockToTime, FormatBalance } from '@polkadot/react-query';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
import { FormatBalance } from '@polkadot/react-query';
|
||||
|
||||
import BountyActionMessage from './BountyNextActionInfo/BountyActionMessage';
|
||||
import { getProposalToDisplay } from './helpers/extendedStatuses';
|
||||
@ -20,6 +18,7 @@ import BountyExtraActions from './BountyExtraActions';
|
||||
import BountyInfos from './BountyInfos';
|
||||
import BountyStatusView from './BountyStatusView';
|
||||
import Curator from './Curator';
|
||||
import DueBlocks from './DueBlocks';
|
||||
import { useBountyStatus } from './hooks';
|
||||
import { bountyBorderColor, bountyLabelColor } from './theme';
|
||||
import { useTranslation } from './translate';
|
||||
@ -34,11 +33,6 @@ interface Props {
|
||||
proposals?: DeriveCollectiveProposal[];
|
||||
}
|
||||
|
||||
interface DueProps {
|
||||
dueBlocks: BN | undefined;
|
||||
until: 'update' | 'payout';
|
||||
}
|
||||
|
||||
const EMPTY_CELL = '-';
|
||||
|
||||
function Bounty ({ bestNumber, bounty, className = '', description, index, proposals }: Props): React.ReactElement<Props> {
|
||||
@ -93,18 +87,20 @@ function Bounty ({ bestNumber, bounty, className = '', description, index, propo
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{blocksUntilPayout
|
||||
? <DueBlocks
|
||||
{blocksUntilPayout && unlockAt && (
|
||||
<DueBlocks
|
||||
dueBlocks={blocksUntilPayout}
|
||||
until={'payout'}
|
||||
endBlock={unlockAt}
|
||||
label={t<string>('payout')}
|
||||
/>
|
||||
: ''}
|
||||
{blocksUntilUpdate
|
||||
? <DueBlocks
|
||||
)}
|
||||
{blocksUntilUpdate && updateDue && (
|
||||
<DueBlocks
|
||||
dueBlocks={blocksUntilUpdate}
|
||||
until={'update'}
|
||||
endBlock={updateDue}
|
||||
label={t<string>('update')}
|
||||
/>
|
||||
: ''}
|
||||
)}
|
||||
<BountyActionMessage
|
||||
bestNumber={bestNumber}
|
||||
blocksUntilUpdate={blocksUntilUpdate}
|
||||
@ -209,22 +205,6 @@ function Bounty ({ bestNumber, bounty, className = '', description, index, propo
|
||||
);
|
||||
}
|
||||
|
||||
function DueBlocks ({ dueBlocks, until }: DueProps): React.ReactElement<DueProps> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
{dueBlocks && dueBlocks.gtn(0) && (
|
||||
<>
|
||||
{t<string>('{{blocks}} blocks', { replace: { blocks: formatNumber(dueBlocks) } })}
|
||||
<BlockToTime blocks={dueBlocks}
|
||||
className='block-to-time'> until {until}</BlockToTime>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(styled(Bounty)(({ theme }: ThemeProps) => `
|
||||
.description-column {
|
||||
max-width: 200px;
|
||||
|
||||
31
packages/page-bounties/src/DueBlocks.tsx
Normal file
31
packages/page-bounties/src/DueBlocks.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2017-2021 @polkadot/app-bounties authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
|
||||
import { BlockToTime } from '@polkadot/react-query';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
interface Props {
|
||||
dueBlocks: BN;
|
||||
endBlock: BN;
|
||||
label: string;
|
||||
}
|
||||
|
||||
function DueBlocks ({ dueBlocks, endBlock, label }: Props): React.ReactElement<Props> {
|
||||
return (
|
||||
<>
|
||||
{dueBlocks.gtn(0) && (
|
||||
<>
|
||||
<BlockToTime blocks={dueBlocks}>
|
||||
({label})
|
||||
</BlockToTime>
|
||||
#{formatNumber(endBlock)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(DueBlocks);
|
||||
Loading…
Reference in New Issue
Block a user