From 37ad7cb3bffdd445885781f242c49ac70fbcb724 Mon Sep 17 00:00:00 2001 From: Joystream Stats Date: Sat, 5 Nov 2022 19:57:26 +0000 Subject: [PATCH 1/6] Past Elections cosmetics (#3168) - rebrand `ended at` to `started at` based on QN results - fix re-appearance of #2656 ('round') - election round tooltip with handbook link --- .../pages/Election/PastElections/PastElections.tsx | 2 +- .../election/pastElection/PastElectionStats.tsx | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx b/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx index 06e10b778a..c5ba2de1d1 100644 --- a/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx +++ b/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx @@ -48,7 +48,7 @@ export const PastElections = () => { <> Round - Election ended at + Election started at Total staked Revealed votes Total candidates diff --git a/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx b/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx index a38d3fbe38..e305e819e2 100644 --- a/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx +++ b/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx @@ -21,11 +21,16 @@ export const PastElectionStats = ({ totalVotes, }: PastElectionStatsProps) => ( - + {finishedAtBlock ? formatDateString(finishedAtBlock.timestamp) : '-'} - - {cycleId} round + + {cycleId} From b067a33cf3656e30c4de09bde0ed173c0033a378 Mon Sep 17 00:00:00 2001 From: Joystream Stats Date: Sat, 5 Nov 2022 20:40:35 +0000 Subject: [PATCH 2/6] `StatisticBar` Fixed: Received NaN for the `end` attribute --- .../components/election/pastElection/PastElectionStats.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx b/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx index e305e819e2..076ac597dc 100644 --- a/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx +++ b/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx @@ -37,9 +37,9 @@ export const PastElectionStats = ({ From 98082b89fd95eae1e84679badcd2de6225236d1d Mon Sep 17 00:00:00 2001 From: Joystream Stats Date: Sat, 5 Nov 2022 20:41:35 +0000 Subject: [PATCH 3/6] `BlockInfo` Fixed: cannot appear as a descendant of . - by passing `noLink` from PastElectionsListRow via BlockTime to BlockInfo --- .../common/components/BlockTime/BlockInfo.tsx | 15 +++++++++++- .../common/components/BlockTime/BlockTime.tsx | 23 +++++++++++-------- .../PastElectionsListRow.tsx | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/packages/ui/src/common/components/BlockTime/BlockInfo.tsx b/packages/ui/src/common/components/BlockTime/BlockInfo.tsx index a4c37a4442..a5fe0edfb0 100644 --- a/packages/ui/src/common/components/BlockTime/BlockInfo.tsx +++ b/packages/ui/src/common/components/BlockTime/BlockInfo.tsx @@ -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 ( + + + + {lessInfo && 'Block'} {formatTokenValue(block.number)} + + + ) + return ( ( - - - {dateLabel && layout == 'row' && dateLabel + ': '} - {formatDateString(block.timestamp, layout === 'column' ? 's' : 'l')} - - {layout == 'row' && {' | '}} - - -)) +export const BlockTime = React.memo( + ({ block, layout, dateLabel, lessInfo, noLink, position = 'start' }: BlockTimeProps) => ( + + + {dateLabel && layout == 'row' && dateLabel + ': '} + {formatDateString(block.timestamp, layout === 'column' ? 's' : 'l')} + + {layout == 'row' && {' | '}} + + + ) +) const Separator = styled.span` font-size: inherit; diff --git a/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx b/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx index 7db781f159..ac49a0206c 100644 --- a/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx +++ b/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx @@ -25,7 +25,7 @@ export const PastElectionsListRow = ({ election }: PastElectionsListRowProps) => > #{election.cycleId} {election.finishedAtBlock ? ( - + ) : ( <> )} From f2d90e3c42c1c590480d7d0bcf8b4ae49f0cff2f Mon Sep 17 00:00:00 2001 From: Joystream Stats Date: Wed, 9 Nov 2022 16:46:57 +0000 Subject: [PATCH 4/6] Move external block explorer Link on `BlockInfo` to tooltip --- .../common/components/BlockTime/BlockInfo.tsx | 36 ++++++++----------- .../common/components/BlockTime/BlockTime.tsx | 23 ++++++------ .../PastElectionsListRow.tsx | 2 +- 3 files changed, 26 insertions(+), 35 deletions(-) diff --git a/packages/ui/src/common/components/BlockTime/BlockInfo.tsx b/packages/ui/src/common/components/BlockTime/BlockInfo.tsx index a5fe0edfb0..94c4d98fba 100644 --- a/packages/ui/src/common/components/BlockTime/BlockInfo.tsx +++ b/packages/ui/src/common/components/BlockTime/BlockInfo.tsx @@ -3,6 +3,7 @@ import styled, { css } from 'styled-components' import { BlockIcon } from '@/common/components/icons' import { Link } from '@/common/components/Link' +import { Tooltip } from '@/common/components/Tooltip' import { TextSmall } from '@/common/components/typography' import { Colors } from '@/common/constants' import { useNetworkEndpoints } from '@/common/hooks/useNetworkEndpoints' @@ -13,35 +14,28 @@ export interface BlockInfoProp { block: Block lessInfo?: boolean inline?: boolean - noLink?: boolean } -export const BlockInfo = ({ block, lessInfo, inline, noLink }: BlockInfoProp) => { +export const BlockInfo = ({ block, lessInfo, inline }: BlockInfoProp) => { const [endpoints] = useNetworkEndpoints() - - // TODO UN-DRY - if (noLink) - return ( - - - - {lessInfo && 'Block'} {formatTokenValue(block.number)} - - - ) + const explorerURLBase = `https://polkadot.js.org/apps/?rpc=${endpoints.nodeRpcEndpoint}/ws-rpc#/explorer/query/` + const tooltipLinkURL = explorerURLBase + block.number + const tooltipText = Produced on {block.network} network. return ( - - + + - {formatTokenValue(block.number)} {lessInfo && 'block'} + {lessInfo && 'Block'} {formatTokenValue(block.number)} - {/* {!lessInfo && on {block.network} network} */} - - + + ) } diff --git a/packages/ui/src/common/components/BlockTime/BlockTime.tsx b/packages/ui/src/common/components/BlockTime/BlockTime.tsx index 1e1dfeb8d9..da725c6e2f 100644 --- a/packages/ui/src/common/components/BlockTime/BlockTime.tsx +++ b/packages/ui/src/common/components/BlockTime/BlockTime.tsx @@ -13,7 +13,6 @@ export interface BlockTimeProps extends BlockTimeLayoutProps { block: Block dateLabel?: string lessInfo?: boolean - noLink?: boolean } interface BlockTimeLayoutProps { @@ -21,18 +20,16 @@ interface BlockTimeLayoutProps { position?: 'start' | 'end' } -export const BlockTime = React.memo( - ({ block, layout, dateLabel, lessInfo, noLink, position = 'start' }: BlockTimeProps) => ( - - - {dateLabel && layout == 'row' && dateLabel + ': '} - {formatDateString(block.timestamp, layout === 'column' ? 's' : 'l')} - - {layout == 'row' && {' | '}} - - - ) -) +export const BlockTime = React.memo(({ block, layout, dateLabel, lessInfo, position = 'start' }: BlockTimeProps) => ( + + + {dateLabel && layout == 'row' && dateLabel + ': '} + {formatDateString(block.timestamp, layout === 'column' ? 's' : 'l')} + + {layout == 'row' && {' | '}} + + +)) const Separator = styled.span` font-size: inherit; diff --git a/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx b/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx index ac49a0206c..7db781f159 100644 --- a/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx +++ b/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx @@ -25,7 +25,7 @@ export const PastElectionsListRow = ({ election }: PastElectionsListRowProps) => > #{election.cycleId} {election.finishedAtBlock ? ( - + ) : ( <> )} From 5197f9c1bf4b4958284dcd932a5bf908571f5601 Mon Sep 17 00:00:00 2001 From: Joystream Stats Date: Fri, 9 Dec 2022 02:01:40 +0000 Subject: [PATCH 5/6] Sort by and show `PastElections` end block (#3168) --- .../src/app/pages/Election/PastElections/PastElections.tsx | 2 +- .../PastElectionsList/PastElectionsListRow.tsx | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx b/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx index c5ba2de1d1..003f87c108 100644 --- a/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx +++ b/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx @@ -48,7 +48,7 @@ export const PastElections = () => { <> Round - Election started at + Election ended at Total staked Revealed votes Total candidates diff --git a/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx b/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx index 7db781f159..af27169f2c 100644 --- a/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx +++ b/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx @@ -17,6 +17,7 @@ interface PastElectionsListRowProps { } export const PastElectionsListRow = ({ election }: PastElectionsListRowProps) => { + const endedAt = election.finishedAtBlock return ( to={generatePath(ElectionRoutes.pastElection, { id: election.id })} > #{election.cycleId} - {election.finishedAtBlock ? ( - - ) : ( - <> - )} + {endedAt ? : <>} From e52dd8f29f08888c86609881dd63e8a8519837f5 Mon Sep 17 00:00:00 2001 From: "l1.media" <31551045+traumschule@users.noreply.github.com> Date: Wed, 8 Feb 2023 22:07:20 +0000 Subject: [PATCH 6/6] Election `Ended at` label --- .../components/election/pastElection/PastElectionStats.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx b/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx index 3b7962dac0..7ba7eb2ac1 100644 --- a/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx +++ b/packages/ui/src/council/components/election/pastElection/PastElectionStats.tsx @@ -21,7 +21,7 @@ export const PastElectionStats = ({ totalVotes, }: PastElectionStatsProps) => ( - + {finishedAtBlock ? formatDateString(finishedAtBlock.timestamp) : '-'}