From 8c63222c23aaea7c41e2b417b7c0ef1045cf2802 Mon Sep 17 00:00:00 2001 From: Harsh Pratap Singh Date: Mon, 5 Aug 2024 17:30:53 +0530 Subject: [PATCH 1/3] chore: add peerid in dashboard --- apps/guardian-ui/src/admin/FederationAdmin.tsx | 1 + .../dashboard/guardians/GuardiansCard.tsx | 17 +++++++++++++++-- apps/guardian-ui/src/languages/en.json | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/guardian-ui/src/admin/FederationAdmin.tsx b/apps/guardian-ui/src/admin/FederationAdmin.tsx index f33aa2bec..c284fe660 100644 --- a/apps/guardian-ui/src/admin/FederationAdmin.tsx +++ b/apps/guardian-ui/src/admin/FederationAdmin.tsx @@ -165,6 +165,7 @@ export const FederationAdmin: React.FC = () => { status={status} config={config} signedApiAnnouncements={signedApiAnnouncements} + ourPeer={ourPeer} /> {ourPeer && ( diff --git a/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx b/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx index 74931c75e..01811cd3f 100644 --- a/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx +++ b/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx @@ -9,18 +9,26 @@ import { import { StatusIndicator, Table, TableColumn, TableRow } from '@fedimint/ui'; import { useTranslation } from '@fedimint/utils'; -type TableKey = 'name' | 'status' | 'health' | 'lastContribution' | 'apiUrl'; +type TableKey = + | 'peerId' + | 'name' + | 'status' + | 'health' + | 'lastContribution' + | 'apiUrl'; interface Props { status: StatusResponse | undefined; config: ClientConfig | undefined; signedApiAnnouncements: Record; + ourPeer: { id: number; name: string } | undefined; } export const GuardiansCard: React.FC = ({ status, config, signedApiAnnouncements, + ourPeer, }) => { const { t } = useTranslation(); @@ -46,6 +54,10 @@ export const GuardiansCard: React.FC = ({ key: 'apiUrl', heading: t('federation-dashboard.guardians.api-url-label'), }, + { + key: 'peerId', + heading: t('federation-dashboard.guardians.peer-id-label'), + }, ], [t] ); @@ -62,6 +74,7 @@ export const GuardiansCard: React.FC = ({ if (endpoint) { peerDataArray.push({ key: id, + peerId: ourPeer?.id === numericId ? `${numericId} (You)` : numericId, name: endpoint.name, status: ( = ({ } } return peerDataArray; - }, [status, config, signedApiAnnouncements, t]); + }, [status, config, signedApiAnnouncements, t, ourPeer]); if (config && !rows.length) { return null; diff --git a/apps/guardian-ui/src/languages/en.json b/apps/guardian-ui/src/languages/en.json index 623b093b2..6aca30236 100644 --- a/apps/guardian-ui/src/languages/en.json +++ b/apps/guardian-ui/src/languages/en.json @@ -39,6 +39,7 @@ "block-count-label": "Consensus Block Height", "api-version-label": "API version", "consensus-version-label": "Consensus version", + "peer-id-label": "Peer ID", "session-info": { "session-height": "Session Height", "latest-session": "Latest Session" @@ -60,7 +61,8 @@ "health-issue": "Issue", "health-good": "Good", "last-contribution-label": "Last contribution block", - "api-url-label": "API URL" + "api-url-label": "API URL", + "peer-id-label": "Peer ID" }, "gateways": { "label": "Lightning Gateways", From d7b1ca8918293de0bdd60ec522ef3ecba4a1aab6 Mon Sep 17 00:00:00 2001 From: "kody.low" Date: Mon, 5 Aug 2024 11:19:36 -0700 Subject: [PATCH 2/3] refactor: id-name instead of separate column --- .../dashboard/guardians/GuardiansCard.tsx | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx b/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx index 01811cd3f..4f54b965a 100644 --- a/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx +++ b/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx @@ -9,13 +9,7 @@ import { import { StatusIndicator, Table, TableColumn, TableRow } from '@fedimint/ui'; import { useTranslation } from '@fedimint/utils'; -type TableKey = - | 'peerId' - | 'name' - | 'status' - | 'health' - | 'lastContribution' - | 'apiUrl'; +type TableKey = 'idName' | 'status' | 'health' | 'lastContribution' | 'apiUrl'; interface Props { status: StatusResponse | undefined; @@ -35,8 +29,8 @@ export const GuardiansCard: React.FC = ({ const columns: TableColumn[] = useMemo( () => [ { - key: 'name', - heading: t('federation-dashboard.guardians.name-label'), + key: 'idName', + heading: t('federation-dashboard.guardians.id-name-label'), }, { key: 'status', @@ -54,10 +48,6 @@ export const GuardiansCard: React.FC = ({ key: 'apiUrl', heading: t('federation-dashboard.guardians.api-url-label'), }, - { - key: 'peerId', - heading: t('federation-dashboard.guardians.peer-id-label'), - }, ], [t] ); @@ -74,8 +64,10 @@ export const GuardiansCard: React.FC = ({ if (endpoint) { peerDataArray.push({ key: id, - peerId: ourPeer?.id === numericId ? `${numericId} (You)` : numericId, - name: endpoint.name, + idName: + ourPeer?.id === numericId + ? `${numericId}: ${ourPeer.name} (You)` + : numericId, status: ( Date: Mon, 5 Aug 2024 11:27:36 -0700 Subject: [PATCH 3/3] fix: fix --- apps/guardian-ui/src/admin/FederationAdmin.tsx | 1 - .../src/components/dashboard/guardians/GuardiansCard.tsx | 9 ++------- apps/guardian-ui/src/languages/en.json | 5 ++--- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/guardian-ui/src/admin/FederationAdmin.tsx b/apps/guardian-ui/src/admin/FederationAdmin.tsx index c284fe660..f33aa2bec 100644 --- a/apps/guardian-ui/src/admin/FederationAdmin.tsx +++ b/apps/guardian-ui/src/admin/FederationAdmin.tsx @@ -165,7 +165,6 @@ export const FederationAdmin: React.FC = () => { status={status} config={config} signedApiAnnouncements={signedApiAnnouncements} - ourPeer={ourPeer} /> {ourPeer && ( diff --git a/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx b/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx index 4f54b965a..b2327d684 100644 --- a/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx +++ b/apps/guardian-ui/src/components/dashboard/guardians/GuardiansCard.tsx @@ -15,14 +15,12 @@ interface Props { status: StatusResponse | undefined; config: ClientConfig | undefined; signedApiAnnouncements: Record; - ourPeer: { id: number; name: string } | undefined; } export const GuardiansCard: React.FC = ({ status, config, signedApiAnnouncements, - ourPeer, }) => { const { t } = useTranslation(); @@ -64,10 +62,7 @@ export const GuardiansCard: React.FC = ({ if (endpoint) { peerDataArray.push({ key: id, - idName: - ourPeer?.id === numericId - ? `${numericId}: ${ourPeer.name} (You)` - : numericId, + idName: `${numericId}: ${endpoint.name}`, status: ( = ({ } } return peerDataArray; - }, [status, config, signedApiAnnouncements, t, ourPeer]); + }, [status, config, signedApiAnnouncements, t]); if (config && !rows.length) { return null; diff --git a/apps/guardian-ui/src/languages/en.json b/apps/guardian-ui/src/languages/en.json index 6aca30236..285780462 100644 --- a/apps/guardian-ui/src/languages/en.json +++ b/apps/guardian-ui/src/languages/en.json @@ -55,14 +55,13 @@ }, "guardians": { "label": "Other Guardians", - "name-label": "Name", + "id-name-label": "ID: Name", "status-label": "Connection Status", "health-label": "Health", "health-issue": "Issue", "health-good": "Good", "last-contribution-label": "Last contribution block", - "api-url-label": "API URL", - "peer-id-label": "Peer ID" + "api-url-label": "API URL" }, "gateways": { "label": "Lightning Gateways",