Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(frontend): migrate certificate export modal to v3 with compact PEM blocks
Devin AI27ab15cd03b2
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaCertModal.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaCertModal.tsxindex 113a88c482..8d29c42564 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaCertModal.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaCertModal.tsx@@ -1,4 +1,11 @@-import { Modal, ModalContent } from "@app/components/v2";+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogHeader,+ DialogTitle,+ PageLoader+} from "@app/components/v3";import { useGetCaCert } from "@app/hooks/api";import { UsePopUpState } from "@app/hooks/usePopUp";@@ -12,13 +19,17 @@ type Props = {export const CaCertModal = ({ popUp, handlePopUpToggle }: Props) => {const { data } = useGetCaCert((popUp?.caCert?.data as { caId: string })?.caId || "");return (- <Modal- isOpen={popUp?.caCert?.isOpen}+ <Dialog+ open={popUp?.caCert?.isOpen}onOpenChange={(isOpen) => {handlePopUpToggle("caCert", isOpen);}}>- <ModalContent title="CA Certificate">+ <DialogContent className="max-w-2xl">+ <DialogHeader>+ <DialogTitle>CA Certificate</DialogTitle>+ <DialogDescription>Copy or download the CA certificate and its chain.</DialogDescription>+ </DialogHeader>{data ? (<CertificateContentserialNumber={data.serialNumber}@@ -26,9 +37,11 @@ export const CaCertModal = ({ popUp, handlePopUpToggle }: Props) => {certificateChain={data.certificateChain}/>) : (- <div />+ <div className="py-8">+ <PageLoader />+ </div>)}- </ModalContent>- </Modal>+ </DialogContent>+ </Dialog>);};diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateCertModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateCertModal.tsxindex 57e164eb22..142ef7a075 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateCertModal.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateCertModal.tsx@@ -1,4 +1,11 @@-import { Modal, ModalContent } from "@app/components/v2";+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogHeader,+ DialogTitle,+ PageLoader+} from "@app/components/v3";import {ProjectPermissionCertificateActions,ProjectPermissionSub,@@ -62,13 +69,19 @@ export const CertificateCertModal = ({ popUp, handlePopUpToggle, applicationId }| undefined = bundleData ?? bodyData;return (- <Modal- isOpen={popUp?.certificateCert?.isOpen}+ <Dialog+ open={popUp?.certificateCert?.isOpen}onOpenChange={(isOpen) => {handlePopUpToggle("certificateCert", isOpen);}}>- <ModalContent title="Export Certificate">+ <DialogContent className="max-w-2xl">+ <DialogHeader>+ <DialogTitle>Export Certificate</DialogTitle>+ <DialogDescription>+ Copy or download the certificate and its key material.+ </DialogDescription>+ </DialogHeader>{data ? (<CertificateContentserialNumber={data.serialNumber}@@ -77,9 +90,11 @@ export const CertificateCertModal = ({ popUp, handlePopUpToggle, applicationId }privateKey={data.privateKey || undefined}/>) : (- <div />+ <div className="py-8">+ <PageLoader />+ </div>)}- </ModalContent>- </Modal>+ </DialogContent>+ </Dialog>);};diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateContent.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateContent.tsxindex 1f2d80b010..c01e5792b8 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateContent.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateContent.tsx@@ -1,8 +1,14 @@-import { faCheck, faCopy, faDownload } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import { useState } from "react";import FileSaver from "file-saver";+import { CheckIcon, CopyIcon, DownloadIcon, EyeIcon, EyeOffIcon } from "lucide-react";-import { IconButton, Tooltip } from "@app/components/v2";+import {+ IconButton,+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger+} from "@app/components/v3";import { useTimedReset } from "@app/hooks";type Props = {@@ -12,162 +18,128 @@ type Props = {privateKey?: string;};-export const CertificateContent = ({- serialNumber,- certificate,- certificateChain,- privateKey-}: Props) => {- const [copyTextSerialNumber, isCopyingSerialNumber, setCopyTextSerialNumber] =- useTimedReset<string>({- initialState: "Copy to clipboard"- });- const [copyTextCertificate, isCopyingCertificate, setCopyTextCertificate] = useTimedReset<string>(- {- initialState: "Copy to clipboard"- }- );- const [copyTextCertificateChain, isCopyingCertificateChain, setCopyTextCertificateChain] =- useTimedReset<string>({- initialState: "Copy to clipboard"- });+const downloadTxtFile = (filename: string, content: string) => {+ const blob = new Blob([content], { type: "text/plain;charset=utf-8" });+ FileSaver.saveAs(blob, filename);+};++const CopyAction = ({ value, label }: { value: string; label: string }) => {+ const [, isCopying, setCopyText] = useTimedReset<string>({+ initialState: "Copy to clipboard"+ });- const [copyTextCertificateSk, isCopyingCertificateSk, setCopyTextCertificateSk] =- useTimedReset<string>({- initialState: "Copy to clipboard"- });+ return (+ <Tooltip>+ <TooltipTrigger asChild>+ <IconButton+ aria-label={`Copy ${label}`}+ variant="ghost-muted"+ size="xs"+ onClick={() => {+ navigator.clipboard.writeText(value);+ setCopyText("Copied");+ }}+ >+ {isCopying ? <CheckIcon /> : <CopyIcon />}+ </IconButton>+ </TooltipTrigger>+ <TooltipContent>{isCopying ? "Copied" : `Copy ${label}`}</TooltipContent>+ </Tooltip>+ );+};- const downloadTxtFile = (filename: string, content: string) => {- const blob = new Blob([content], { type: "text/plain;charset=utf-8" });- FileSaver.saveAs(blob, filename);- };+const PemSection = ({+ title,+ value,+ filename,+ isSensitive+}: {+ title: string;+ value: string;+ filename: string;+ isSensitive?: boolean;+}) => {+ const [isVisible, setIsVisible] = useState(!isSensitive);+ const label = title.toLowerCase();return (- <div>- <h2 className="mb-4">Serial Number</h2>- <div className="mb-8 flex items-center justify-between rounded-md bg-foreground-inverse/[0.07] p-2 text-base text-muted-cool">- <p className="mr-4 break-all">{serialNumber}</p>- <Tooltip content={copyTextSerialNumber}>- <IconButton- ariaLabel="copy icon"- colorSchema="secondary"- className="group relative"- onClick={() => {- navigator.clipboard.writeText(serialNumber);- setCopyTextSerialNumber("Copied");- }}- >- <FontAwesomeIcon icon={isCopyingSerialNumber ? faCheck : faCopy} />- </IconButton>- </Tooltip>- </div>- <div className="mb-4 flex items-center justify-between">- <h2>Certificate Body</h2>- <div className="flex">- <Tooltip content={copyTextCertificate}>- <IconButton- ariaLabel="copy icon"- colorSchema="secondary"- className="group relative"- onClick={() => {- navigator.clipboard.writeText(certificate);- setCopyTextCertificate("Copied");- }}- >- <FontAwesomeIcon icon={isCopyingCertificate ? faCheck : faCopy} />- </IconButton>- </Tooltip>- <Tooltip content="Download">- <IconButton- ariaLabel="copy icon"- colorSchema="secondary"- className="group relative ml-2"- onClick={() => {- downloadTxtFile("cert.pem", certificate);- }}- >- <FontAwesomeIcon icon={faDownload} />- </IconButton>- </Tooltip>- </div>- </div>- <div className="mb-8 flex items-center justify-between rounded-md bg-foreground-inverse/[0.07] p-2 text-base text-muted-cool">- <p className="mr-4 break-all whitespace-pre-wrap">{certificate}</p>- </div>- {certificateChain && (- <>- <div className="mb-4 flex items-center justify-between">- <h2>Certificate Chain</h2>- <div className="flex">- <Tooltip content={copyTextCertificateChain}>+ <section>+ <div className="mb-2 flex items-center justify-between">+ <span className="text-sm font-medium text-foreground">{title}</span>+ <div className="flex items-center gap-1">+ {isSensitive && (+ <Tooltip>+ <TooltipTrigger asChild><IconButton- ariaLabel="copy icon"- colorSchema="secondary"- className="group relative"- onClick={() => {- navigator.clipboard.writeText(certificateChain);- setCopyTextCertificateChain("Copied");- }}+ aria-label={isVisible ? `Hide ${label}` : `Show ${label}`}+ variant="ghost-muted"+ size="xs"+ onClick={() => setIsVisible((prev) => !prev)}>- <FontAwesomeIcon icon={isCopyingCertificateChain ? faCheck : faCopy} />+ {isVisible ? <EyeOffIcon /> : <EyeIcon />}</IconButton>- </Tooltip>- <Tooltip content="Download">- <IconButton- ariaLabel="copy icon"- colorSchema="secondary"- className="group relative ml-2"- onClick={() => {- downloadTxtFile("chain.pem", certificateChain);- }}- >- <FontAwesomeIcon icon={faDownload} />- </IconButton>- </Tooltip>- </div>- </div>- <div className="mb-8 flex items-center justify-between rounded-md bg-foreground-inverse/[0.07] p-2 text-base text-muted-cool">- <p className="mr-4 break-all whitespace-pre-wrap">{certificateChain}</p>- </div>- </>+ </TooltipTrigger>+ <TooltipContent>{isVisible ? "Hide" : "Show"}</TooltipContent>+ </Tooltip>+ )}+ <CopyAction value={value} label={label} />+ <Tooltip>+ <TooltipTrigger asChild>+ <IconButton+ aria-label={`Download ${label}`}+ variant="ghost-muted"+ size="xs"+ onClick={() => downloadTxtFile(filename, value)}+ >+ <DownloadIcon />+ </IconButton>+ </TooltipTrigger>+ <TooltipContent>Download {filename}</TooltipContent>+ </Tooltip>+ </div>+ </div>+ {isVisible ? (+ <pre className="max-h-40 thin-scrollbar overflow-auto rounded-md border border-border bg-container px-3 py-2.5 font-mono text-xs leading-relaxed whitespace-pre text-foreground">+ {value}+ </pre>+ ) : (+ <div className="rounded-md border border-border bg-container px-3 py-2.5 font-mono text-xs text-muted select-none">+ ••••••••••••••••••••••••••••••••+ </div>)}- {privateKey && (- <>- <div className="mb-4 flex items-center justify-between">- <h2>Certificate Private Key</h2>- <div className="flex">- <Tooltip content={copyTextCertificateSk}>- <IconButton- ariaLabel="copy icon"- colorSchema="secondary"- className="group relative"- onClick={() => {- navigator.clipboard.writeText(privateKey);- setCopyTextCertificateSk("Copied");- }}- >- <FontAwesomeIcon icon={isCopyingCertificateSk ? faCheck : faCopy} />- </IconButton>- </Tooltip>- <Tooltip content={copyTextCertificateSk}>- <IconButton- ariaLabel="copy icon"- colorSchema="secondary"- className="group relative ml-2"- onClick={() => {- downloadTxtFile("private_key.txt", privateKey);- }}- >- <FontAwesomeIcon icon={faDownload} />- </IconButton>- </Tooltip>- </div>- </div>- <div className="mb-8 flex items-center justify-between rounded-md bg-foreground-inverse/[0.07] p-2 text-base text-muted-cool">- <p className="mr-4 break-all whitespace-pre-wrap">{privateKey}</p>+ </section>+ );+};++export const CertificateContent = ({+ serialNumber,+ certificate,+ certificateChain,+ privateKey+}: Props) => {+ return (+ <TooltipProvider>+ <div className="flex min-w-0 flex-col gap-5">+ <section>+ <span className="mb-2 block text-sm font-medium text-foreground">Serial Number</span>+ <div className="flex items-center justify-between gap-2 rounded-md border border-border bg-container py-1 pr-1 pl-3">+ <span className="font-mono text-xs break-all text-foreground">{serialNumber}</span>+ <CopyAction value={serialNumber} label="serial number" /></div>- </>- )}- </div>+ </section>+ <PemSection title="Certificate Body" value={certificate} filename="cert.pem" />+ {certificateChain && (+ <PemSection title="Certificate Chain" value={certificateChain} filename="chain.pem" />+ )}+ {privateKey && (+ <PemSection+ title="Private Key"+ value={privateKey}+ filename="private_key.pem"+ isSensitive+ />+ )}+ </div>+ </TooltipProvider>);};