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

feat(explorer): display only the top 10 validators in homepage #4575

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Changes from all 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 @@ -3,9 +3,18 @@
// SPDX-License-Identifier: Apache-2.0

import { useIotaClientQuery } from '@iota/dapp-kit';
import { PlaceholderTable, TableCard } from '~/components/ui';
import { Link, PlaceholderTable, TableCard } from '~/components/ui';
import { generateValidatorsTableColumns } from '~/lib/ui';
import { InfoBox, InfoBoxStyle, InfoBoxType, Panel, Title } from '@iota/apps-ui-kit';
import {
Button,
ButtonSize,
ButtonType,
InfoBox,
InfoBoxStyle,
InfoBoxType,
Panel,
Title,
} from '@iota/apps-ui-kit';
import { ErrorBoundary } from '../error-boundary/ErrorBoundary';
import { Warning } from '@iota/ui-icons';

Expand All @@ -19,6 +28,9 @@ type TopValidatorsCardProps = {
export function TopValidatorsCard({ limit, showIcon }: TopValidatorsCardProps): JSX.Element {
const { data, isPending, isSuccess, isError } = useIotaClientQuery('getLatestIotaSystemState');

const topActiveValidators =
data?.activeValidators.slice(0, limit || NUMBER_OF_VALIDATORS) ?? [];

const tableColumns = generateValidatorsTableColumns({
atRiskValidators: [],
validatorEvents: [],
Expand All @@ -42,26 +54,33 @@ export function TopValidatorsCard({ limit, showIcon }: TopValidatorsCardProps):

return (
<Panel>
<Title title="Top Validators" />

<div className="p-md">
{isPending && (
<PlaceholderTable
rowCount={limit || NUMBER_OF_VALIDATORS}
rowHeight="13px"
colHeadings={['Name', 'Address', 'Stake']}
/>
)}
<div className="relative">
<div className="absolute right-0 mr-4 mt-2">
<Link to="/validators">
<Button
type={ButtonType.Secondary}
size={ButtonSize.Small}
text="View All"
/>
</Link>
</div>
<Title title="Top Validators" />

{isSuccess && (
<ErrorBoundary>
<TableCard
data={data.activeValidators}
columns={tableColumns}
viewAll="/validators"
<div className="p-md">
{isPending && (
<PlaceholderTable
rowCount={limit || NUMBER_OF_VALIDATORS}
rowHeight="13px"
colHeadings={['Name', 'Address', 'Stake']}
/>
</ErrorBoundary>
)}
)}

{isSuccess && (
<ErrorBoundary>
<TableCard data={topActiveValidators} columns={tableColumns} />
</ErrorBoundary>
)}
</div>
</div>
</Panel>
);
Expand Down
Loading