This is an automated email from the ASF dual-hosted git repository. lahirujayathilake pushed a commit to branch ssh-access-ui in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
commit 856e3143442d71c58eac495fd5eece973f4ce4a8 Author: lahiruj <[email protected]> AuthorDate: Fri Nov 13 11:40:09 2026 -0500 Show serial, key and time left on the SSH access page --- .../components/GenerateCertificateDialog.tsx | 24 ++++++++----- .../core/signer/components/MyCertificates.tsx | 40 +++++++++++++++++++--- .../signer/components/RevokeCertificateDialog.tsx | 2 +- web/src/features/core/signer/status.ts | 9 +++++ 4 files changed, 60 insertions(+), 15 deletions(-) diff --git a/web/src/features/core/signer/components/GenerateCertificateDialog.tsx b/web/src/features/core/signer/components/GenerateCertificateDialog.tsx index e75f2655d..c6cb05ee7 100644 --- a/web/src/features/core/signer/components/GenerateCertificateDialog.tsx +++ b/web/src/features/core/signer/components/GenerateCertificateDialog.tsx @@ -90,20 +90,28 @@ export function GenerateCertificateDialog({ open, onOpenChange }: GenerateCertif if (!generate.isPending) onOpenChange(next); }} > - <DialogContent> + <DialogContent className="sm:max-w-lg"> {result ? ( <> <DialogHeader> <DialogTitle>Your certificate is ready</DialogTitle> <DialogDescription> - {result.principal}, valid until {formatUnixSeconds(result.valid_before)}. It is shown - only now. If you lose it, generate another. + Certificate {result.serial_number} for {result.principal}, valid until{" "} + {formatUnixSeconds(result.valid_before)}. It is shown only now. If you lose it, + generate another. </DialogDescription> </DialogHeader> - <div className="space-y-4 text-sm"> + <div className="min-w-0 space-y-4 text-sm"> <div className="space-y-1"> - <p className="font-medium">Certificate</p> - <CopyValue value={result.certificate} label="certificate" explicit /> + <div className="flex items-center justify-between"> + <p className="font-medium">Certificate</p> + <CopyValue value={result.certificate} label="certificate" explicit> + Copy + </CopyValue> + </div> + <pre className="max-h-32 overflow-y-auto whitespace-pre-wrap break-all rounded-md border bg-muted p-2 font-mono text-xs"> + {result.certificate} + </pre> </div> <ol className="list-decimal space-y-2 pl-5"> <li> @@ -151,9 +159,7 @@ export function GenerateCertificateDialog({ open, onOpenChange }: GenerateCertif </p> </div> {generate.error ? ( - <p className="text-sm text-[color:var(--custos-red-700)]"> - {refusalMessage(generate.error)} - </p> + <p className="text-sm text-destructive">{refusalMessage(generate.error)}</p> ) : null} <DialogFooter> <Button diff --git a/web/src/features/core/signer/components/MyCertificates.tsx b/web/src/features/core/signer/components/MyCertificates.tsx index e1b5f4e73..70dffc736 100644 --- a/web/src/features/core/signer/components/MyCertificates.tsx +++ b/web/src/features/core/signer/components/MyCertificates.tsx @@ -32,7 +32,9 @@ import type { Certificate } from "../schemas"; import { CERTIFICATE_STATUS_LABELS, type CertificateStatus, + formatUnixDate, formatUnixSeconds, + formatValidUntil, getCertificateStatus, statusBadgeVariantFromCertificateStatus, } from "../status"; @@ -61,19 +63,44 @@ export function MyCertificates() { ); const columns: Array<DataTableColumn<Certificate>> = [ + { + key: "serial", + header: "Serial", + cell: (row) => ( + <Link + href={`/ssh-access/${row.serial_number}`} + className="font-mono font-medium text-foreground hover:underline" + > + {row.serial_number} + </Link> + ), + }, + { + key: "key", + header: "Key", + cell: (row) => ( + <span className="font-mono text-xs text-muted-foreground" title={row.public_key_fingerprint}> + {row.public_key_fingerprint.slice(0, 14)}… + </span> + ), + }, { key: "issued", header: "Issued", cell: (row) => ( - <Link href={`/ssh-access/${row.serial_number}`} className="text-sm font-medium hover:underline"> - {formatUnixSeconds(row.issued_at)} - </Link> + <span className="text-sm" title={formatUnixSeconds(row.issued_at)}> + {formatUnixDate(row.issued_at)} + </span> ), }, { key: "validBefore", header: "Valid until", - cell: (row) => <span className="text-sm">{formatUnixSeconds(row.valid_before)}</span>, + cell: (row) => ( + <span className="text-sm" title={formatUnixSeconds(row.valid_before)}> + {formatValidUntil(row)} + </span> + ), }, { key: "status", @@ -91,11 +118,14 @@ export function MyCertificates() { { key: "actions", header: "", + align: "right", + interactive: true, cell: (row) => getCertificateStatus(row) === "active" ? ( <Button variant="outline" size="sm" + aria-label={`Revoke certificate ${row.serial_number}`} onClick={() => { setRevokeError(null); setRevoking(row); @@ -139,7 +169,7 @@ export function MyCertificates() { </div> {query.isLoading ? ( - <TableSkeleton rows={4} columns={5} /> + <TableSkeleton rows={4} columns={6} /> ) : query.error ? ( <ErrorState message={loadErrorMessage(query.error)} onRetry={() => query.refetch()} /> ) : filtered.length === 0 ? ( diff --git a/web/src/features/core/signer/components/RevokeCertificateDialog.tsx b/web/src/features/core/signer/components/RevokeCertificateDialog.tsx index 896a72b22..eaedd948c 100644 --- a/web/src/features/core/signer/components/RevokeCertificateDialog.tsx +++ b/web/src/features/core/signer/components/RevokeCertificateDialog.tsx @@ -102,7 +102,7 @@ export function RevokeCertificateDialog({ <span>{Math.max(0, 255 - reasonLength)} remaining</span> </div> </div> - {error ? <p className="text-sm text-[color:var(--custos-red-700)]">{error}</p> : null} + {error ? <p className="text-sm text-destructive">{error}</p> : null} <DialogFooter> <Button type="button" diff --git a/web/src/features/core/signer/status.ts b/web/src/features/core/signer/status.ts index 3b9350103..a763315b8 100644 --- a/web/src/features/core/signer/status.ts +++ b/web/src/features/core/signer/status.ts @@ -61,6 +61,15 @@ export function formatUnixDate(seconds: number): string { }); } +// Time left on an active certificate, otherwise its end date. Certificates last at most a day. +export function formatValidUntil(cert: Certificate, now: Date = new Date()): string { + if (getCertificateStatus(cert, now) !== "active") return formatUnixDate(cert.valid_before); + const left = cert.valid_before - Math.floor(now.getTime() / 1000); + if (left < 60) return "in less than a minute"; + if (left < 3600) return `in ${Math.floor(left / 60)} min`; + return `in ${Math.floor(left / 3600)}h ${Math.floor((left % 3600) / 60)}m`; +} + export function formatCertificateLifetime(cert: Certificate): string { const seconds = Math.max(0, cert.valid_before - cert.valid_after); const hours = Math.floor(seconds / 3600);
