Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Past Election: Fix Blocktime link (#3168) #3808

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const PastElections = () => {
<>
<PastElectionsListHeaders $colLayout={PastElectionsColLayout}>
<SortHeader {...getSortProps('cycleId')}>Round</SortHeader>
<SortHeader {...getSortProps('updatedAt')}>Election ended at</SortHeader>
<SortHeader {...getSortProps('updatedAt')}>Election started at</SortHeader>
traumschule marked this conversation as resolved.
Show resolved Hide resolved
<ListHeader>Total staked</ListHeader>
<ListHeader>Revealed votes</ListHeader>
<ListHeader>Total candidates</ListHeader>
Expand Down
15 changes: 14 additions & 1 deletion packages/ui/src/common/components/BlockTime/BlockInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,23 @@ export interface BlockInfoProp {
block: Block
lessInfo?: boolean
inline?: boolean
noLink?: boolean
}

export const BlockInfo = ({ block, lessInfo, inline }: BlockInfoProp) => {
export const BlockInfo = ({ block, lessInfo, inline, noLink }: BlockInfoProp) => {
const [endpoints] = useNetworkEndpoints()

// TODO UN-DRY
if (noLink)
return (
<BlockInfoContainer lessInfo={lessInfo} inline={inline}>
<BlockIcon />
<span>
{lessInfo && 'Block'} {formatTokenValue(block.number)}
</span>
</BlockInfoContainer>
)
traumschule marked this conversation as resolved.
Show resolved Hide resolved

return (
<BlockLink
href={`https://polkadot.js.org/apps/?rpc=${endpoints.nodeRpcEndpoint}/ws-rpc#/explorer/query/${block.number}`}
Expand Down
23 changes: 13 additions & 10 deletions packages/ui/src/common/components/BlockTime/BlockTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,26 @@ export interface BlockTimeProps extends BlockTimeLayoutProps {
block: Block
dateLabel?: string
lessInfo?: boolean
noLink?: boolean
}

interface BlockTimeLayoutProps {
layout?: 'row' | 'column' | 'reverse' | 'reverse-start'
position?: 'start' | 'end'
}

export const BlockTime = React.memo(({ block, layout, dateLabel, lessInfo, position = 'start' }: BlockTimeProps) => (
<BlockTimeWrapper layout={layout} position={position}>
<AboutText>
{dateLabel && layout == 'row' && dateLabel + ': '}
{formatDateString(block.timestamp, layout === 'column' ? 's' : 'l')}
</AboutText>
{layout == 'row' && <Separator>{' | '}</Separator>}
<BlockInfo block={block} lessInfo={lessInfo} />
</BlockTimeWrapper>
))
export const BlockTime = React.memo(
({ block, layout, dateLabel, lessInfo, noLink, position = 'start' }: BlockTimeProps) => (
<BlockTimeWrapper layout={layout} position={position}>
<AboutText>
{dateLabel && layout == 'row' && dateLabel + ': '}
{formatDateString(block.timestamp, layout === 'column' ? 's' : 'l')}
</AboutText>
{layout == 'row' && <Separator>{' | '}</Separator>}
<BlockInfo block={block} lessInfo={lessInfo} noLink={noLink} />
traumschule marked this conversation as resolved.
Show resolved Hide resolved
</BlockTimeWrapper>
)
)

const Separator = styled.span`
font-size: inherit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@ export const PastElectionStats = ({
totalVotes,
}: PastElectionStatsProps) => (
<Statistics>
<StatisticItem title="Ended at">
<StatisticItem title="Started at">
traumschule marked this conversation as resolved.
Show resolved Hide resolved
{finishedAtBlock ? formatDateString(finishedAtBlock.timestamp) : '-'}
traumschule marked this conversation as resolved.
Show resolved Hide resolved
</StatisticItem>
<StatisticItem title="Election round" tooltipText="Lorem ipsum...">
<TextHuge bold>{cycleId} round</TextHuge>
<StatisticItem
title="Election round"
tooltipText="Refers to the on-chain election cycle enumeration."
tooltipLinkURL="https://joystream.gitbook.io/testnet-workspace/system/council#election"
tooltipLinkText="Read about election cycles"
>
<TextHuge bold>{cycleId}</TextHuge>
</StatisticItem>
<NumericValueStat title="Total candidates" value={totalCandidates} />
<StatsBlock>
<StatisticBar
title="Revealed votes"
tooltipText="Votes are kept anonymous and get revealed during the reveal period, after voting is complete. Only revealed votes are counted."
value={revealedVotes / totalVotes}
numerator={revealedVotes}
denominator={totalVotes + ' votes'}
value={revealedVotes ?? 0 / totalVotes ?? 0}
numerator={revealedVotes ?? 0}
denominator={totalVotes ?? 0 + ' votes'}
/>
</StatsBlock>
</Statistics>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const PastElectionsListRow = ({ election }: PastElectionsListRowProps) =>
>
<Info>#{election.cycleId}</Info>
{election.finishedAtBlock ? (
<BlockTime block={election.finishedAtBlock} layout="reverse-start" lessInfo />
<BlockTime block={election.finishedAtBlock} layout="reverse-start" lessInfo noLink />
) : (
<></>
)}
Expand Down