import { faCheck, faCopy, faDownload, faPencil } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import FileSaver from "file-saver"; import { ProjectPermissionCan } from "@app/components/permissions"; import { IconButton, Tooltip } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; import { useTimedReset } from "@app/hooks"; import { useGetSshCaById } from "@app/hooks/api"; import { caStatusToNameMap } from "@app/hooks/api/ca/constants"; import { certKeyAlgorithmToNameMap } from "@app/hooks/api/certificates/constants"; import { UsePopUpState } from "@app/hooks/usePopUp"; type Props = { caId: string; handlePopUpOpen: (popUpName: keyof UsePopUpState<["sshCa"]>, data?: object) => void; }; export const SshCaDetailsSection = ({ caId, handlePopUpOpen }: Props) => { const [copyTextId, isCopyingId, setCopyTextId] = useTimedReset({ initialState: "Copy ID to clipboard" }); const [downloadText, isDownloading, setDownloadText] = useTimedReset({ initialState: "Save public key" }); const { data: ca } = useGetSshCaById(caId); const downloadTxtFile = (filename: string, content: string) => { const blob = new Blob([content], { type: "text/plain;charset=utf-8" }); FileSaver.saveAs(blob, filename); }; return ca ? (

SSH CA Details

{(isAllowed) => { return ( { e.stopPropagation(); handlePopUpOpen("sshCa", { caId: ca.id }); }} > ); }}

SSH CA ID

{ca.id}

{ navigator.clipboard.writeText(ca.id); setCopyTextId("Copied"); }} >

Friendly Name

{ca.friendlyName}

Status

{caStatusToNameMap[ca.status]}

Key Algorithm

{certKeyAlgorithmToNameMap[ca.keyAlgorithm]}

Public Key

{ca.publicKey.substring(0, 20)}...

{ setDownloadText("Saved"); downloadTxtFile("ssh_ca.pub", ca.publicKey); }} >
) : (
); };