Skip to content

Commit

Permalink
[explorer] Implement updated designs for validator table (MystenLabs#…
Browse files Browse the repository at this point in the history
…3904)

* Implement updated designs for validator table

* Remove unused imports

* Prettier
  • Loading branch information
Jordan-Mysten authored Aug 10, 2022
1 parent e2740f5 commit 35468bf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import { useContext, useEffect, useState } from 'react';

import Longtext from '../../components/longtext/Longtext';
import TableCard from '../../components/table/TableCard';
import TabFooter from '../../components/tabs/TabFooter';
import Tabs from '../../components/tabs/Tabs';
import { NetworkContext } from '../../context';
import {
getTabFooter,
getValidatorState,
processValidators,
ValidatorLoadFail,
Expand Down Expand Up @@ -100,6 +98,16 @@ function TopValidatorsCard({ state }: { state: ValidatorState }): JSX.Element {
alttext={truncate(validator.address, 14)}
category={'addresses'}
isLink={true}
isCopyButton={false}
/>
),
pubkeyBytes: (
<Longtext
text={validator.pubkeyBytes}
alttext={truncate(validator.pubkeyBytes, 14)}
category={'addresses'}
isLink={false}
isCopyButton={false}
/>
),
})),
Expand All @@ -116,26 +124,27 @@ function TopValidatorsCard({ state }: { state: ValidatorState }): JSX.Element {
headerLabel: 'Address',
accessorKey: 'address',
},
{
headerLabel: 'Pubkey Bytes',
accessorKey: 'pubkeyBytes',
},
],
};

const tabsFooter = getTabFooter(validatorsData.length);

return (
<div className={styles.validators}>
<Tabs selected={0}>
<div title="Top Validators">
<TableCard tabledata={tableData} />
<TabFooter stats={tabsFooter.stats}>
{/* <TabFooter stats={tabsFooter.stats}>
<Longtext
text=""
category="validators"
isLink={true}
isCopyButton={false}
/*showIconButton={true}*/
alttext="More Validators"
/>
</TabFooter>
</TabFooter> */}
</div>
</Tabs>
</div>
Expand Down
4 changes: 4 additions & 0 deletions explorer/client/src/components/validator-map/ValidatorMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default function ValidatorMap() {
method: 'GET',
});

if (!res.ok) {
return [];
}

return res.json() as Promise<NodeList>;
});

Expand Down
16 changes: 15 additions & 1 deletion explorer/client/src/pages/validators/Validators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export function processValidators(set: Validator[]) {
return {
name: name,
address: av.fields.metadata.fields.sui_address,
pubkeyBytes: av.fields.metadata.fields.pubkey_bytes,
position: i + 1,
};
});
Expand All @@ -169,6 +170,7 @@ function ValidatorsPage({ state }: { state: ValidatorState }): JSX.Element {
data: validatorsData.map((validator) => {
return {
name: validator.name,
position: validator.position,
address: (
<Longtext
text={validator.address}
Expand All @@ -177,7 +179,15 @@ function ValidatorsPage({ state }: { state: ValidatorState }): JSX.Element {
isLink={true}
/>
),
position: validator.position,
pubkeyBytes: (
<Longtext
text={validator.pubkeyBytes}
alttext={truncate(validator.pubkeyBytes, 14)}
category={'addresses'}
isLink={false}
isCopyButton={false}
/>
),
};
}),
columns: [
Expand All @@ -193,6 +203,10 @@ function ValidatorsPage({ state }: { state: ValidatorState }): JSX.Element {
headerLabel: 'Address',
accessorKey: 'address',
},
{
headerLabel: 'Pubkey Bytes',
accessorKey: 'pubkeyBytes',
},
],
};

Expand Down

0 comments on commit 35468bf

Please sign in to comment.