Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

PKI UI: improve CA details page

Carlos Monastyrski419bd7d9470d
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx
index c8224e0663..785ec69700 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx
@@ -3,21 +3,18 @@ import { subject } from "@casl/ability";
import { faChevronLeft } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link, useNavigate, useParams } from "@tanstack/react-router";
-import { twMerge } from "tailwind-merge";
+import { EllipsisIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
+import { AccessRestrictedBanner, DeleteActionModal, PageHeader } from "@app/components/v2";
import {
- AccessRestrictedBanner,
Button,
- DeleteActionModal,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
- PageHeader,
- Tooltip
-} from "@app/components/v2";
+ UnstableDropdownMenu,
+ UnstableDropdownMenuContent,
+ UnstableDropdownMenuItem,
+ UnstableDropdownMenuTrigger
+} from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
import {
ProjectPermissionCertificateAuthorityActions,
@@ -33,6 +30,7 @@ import { usePopUp } from "@app/hooks/usePopUp";
import { CaInstallCertModal } from "../CertificateAuthoritiesPage/components/CaInstallCertModal";
import { CaModal } from "../CertificateAuthoritiesPage/components/CaModal";
import {
+ CaCertDetailsSection,
CaCertificatesSection,
CaCrlsSection,
CaDetailsSection,
@@ -117,15 +115,14 @@ const Page = () => {
description="Manage certificate authority"
title={data.name}
>
- <DropdownMenu>
- <DropdownMenuTrigger asChild className="rounded-lg">
- <div className="hover:text-primary-400 data-[state=open]:text-primary-400">
- <Tooltip content="More options">
- <Button variant="outline_bg">More</Button>
- </Tooltip>
- </div>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="p-1">
+ <UnstableDropdownMenu>
+ <UnstableDropdownMenuTrigger asChild>
+ <Button variant="outline">
+ Options
+ <EllipsisIcon />
+ </Button>
+ </UnstableDropdownMenuTrigger>
+ <UnstableDropdownMenuContent align="end">
<ProjectPermissionCan
I={ProjectPermissionCertificateAuthorityActions.Delete}
a={subject(ProjectPermissionSub.CertificateAuthorities, {
@@ -133,28 +130,29 @@ const Page = () => {
})}
>
{(canDelete) => (
- <DropdownMenuItem
- className={twMerge(
- canDelete
- ? "hover:bg-red-500! hover:text-white!"
- : "pointer-events-none cursor-not-allowed opacity-50"
- )}
+ <UnstableDropdownMenuItem
+ variant="danger"
+ isDisabled={!canDelete}
onClick={() => handlePopUpOpen("deleteCa")}
- disabled={!canDelete}
>
Delete CA
- </DropdownMenuItem>
+ </UnstableDropdownMenuItem>
)}
</ProjectPermissionCan>
- </DropdownMenuContent>
- </DropdownMenu>
+ </UnstableDropdownMenuContent>
+ </UnstableDropdownMenu>
</PageHeader>
- <div className="flex">
- <div className="mr-4 w-96">
+ <div className="flex flex-col gap-5 lg:flex-row">
+ <div className="w-full lg:max-w-[24rem]">
<CaDetailsSection caId={data.id} handlePopUpOpen={handlePopUpOpen} />
+ <CaCertDetailsSection caId={data.id} />
</div>
- <div className="w-full">
- <CaCertificatesSection caId={data.id} caName={data.name} />
+ <div className="flex flex-1 flex-col gap-y-5">
+ <CaCertificatesSection
+ caId={data.id}
+ caName={data.name}
+ handlePopUpOpen={handlePopUpOpen}
+ />
<CaCrlsSection caId={data.id} />
</div>
</div>
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertDetailsSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertDetailsSection.tsx
new file mode 100644
index 0000000000..3ae18c672c
--- /dev/null
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertDetailsSection.tsx
@@ -0,0 +1,94 @@
+import {
+ Detail,
+ DetailGroup,
+ DetailLabel,
+ DetailValue,
+ UnstableCard,
+ UnstableCardContent,
+ UnstableCardHeader,
+ UnstableCardTitle
+} from "@app/components/v3";
+import { CaType, useGetCa } from "@app/hooks/api";
+import { TInternalCertificateAuthority } from "@app/hooks/api/ca/types";
+
+type Props = {
+ caId: string;
+};
+
+export const CaCertDetailsSection = ({ caId }: Props) => {
+ const { data } = useGetCa({
+ caId,
+ type: CaType.INTERNAL
+ });
+
+ const ca = data as TInternalCertificateAuthority;
+
+ if (!ca) {
+ return <div />;
+ }
+
+ const hasAnyDetails =
+ ca.configuration.commonName ||
+ ca.configuration.organization ||
+ ca.configuration.ou ||
+ ca.configuration.country ||
+ ca.configuration.province ||
+ ca.configuration.locality;
+
+ if (!hasAnyDetails) {
+ return null;
+ }
+
+ return (
+ <UnstableCard className="mt-4 w-full">
+ <UnstableCardHeader className="border-b">
+ <UnstableCardTitle>Certificate Details</UnstableCardTitle>
+ </UnstableCardHeader>
+ <UnstableCardContent>
+ <DetailGroup>
+ {ca.configuration.commonName && (
+ <Detail>
+ <DetailLabel>Common Name (CN)</DetailLabel>
+ <DetailValue>{ca.configuration.commonName}</DetailValue>
+ </Detail>
+ )}
+
+ {ca.configuration.organization && (
+ <Detail>
+ <DetailLabel>Organization (O)</DetailLabel>
+ <DetailValue>{ca.configuration.organization}</DetailValue>
+ </Detail>
+ )}
+
+ {ca.configuration.ou && (
+ <Detail>
+ <DetailLabel>Organizational Unit (OU)</DetailLabel>
+ <DetailValue>{ca.configuration.ou}</DetailValue>
+ </Detail>
+ )}
+
+ {ca.configuration.country && (
+ <Detail>
+ <DetailLabel>Country (C)</DetailLabel>
+ <DetailValue>{ca.configuration.country}</DetailValue>
+ </Detail>
+ )}
+
+ {ca.configuration.province && (
+ <Detail>
+ <DetailLabel>State/Province (ST)</DetailLabel>
+ <DetailValue>{ca.configuration.province}</DetailValue>
+ </Detail>
+ )}
+
+ {ca.configuration.locality && (
+ <Detail>
+ <DetailLabel>Locality (L)</DetailLabel>
+ <DetailValue>{ca.configuration.locality}</DetailValue>
+ </Detail>
+ )}
+ </DetailGroup>
+ </UnstableCardContent>
+ </UnstableCard>
+ );
+};
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertificatesSection/CaCertificatesSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertificatesSection/CaCertificatesSection.tsx
index 4502138e0e..1100049f48 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertificatesSection/CaCertificatesSection.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertificatesSection/CaCertificatesSection.tsx
@@ -1,29 +1,130 @@
+import { subject } from "@casl/ability";
+
+import { ProjectPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ UnstableCard,
+ UnstableCardAction,
+ UnstableCardContent,
+ UnstableCardHeader,
+ UnstableCardTitle
+} from "@app/components/v3";
+import { ProjectPermissionCertificateAuthorityActions, ProjectPermissionSub } from "@app/context";
+import { CaStatus, CaType, InternalCaType, useGetCa } from "@app/hooks/api";
+import { TInternalCertificateAuthority } from "@app/hooks/api/ca/types";
+import { UsePopUpState } from "@app/hooks/usePopUp";
+
import { CaCertificatesTable } from "./CaCertificatesTable";
type Props = {
caId: string;
caName: string;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["renewCa", "installCaCert", "generateRootCaCert"]>,
+ data?: object
+ ) => void;
};
-export const CaCertificatesSection = ({ caId, caName }: Props) => {
- return (
- <div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
- <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
- <h3 className="text-lg font-medium text-mineshaft-100">CA Certificates</h3>
- {/* <IconButton
- ariaLabel="copy icon"
- variant="plain"
- className="group relative"
- onClick={() => {
- // handlePopUpOpen("addIdentityToProject");
- }}
+export const CaCertificatesSection = ({ caId, caName, handlePopUpOpen }: Props) => {
+ const { data } = useGetCa({
+ caId,
+ type: CaType.INTERNAL
+ });
+
+ const ca = data as TInternalCertificateAuthority;
+
+ const renderActionButton = () => {
+ if (!ca) return null;
+
+ if (ca.status === CaStatus.ACTIVE) {
+ return (
+ <ProjectPermissionCan
+ I={ProjectPermissionCertificateAuthorityActions.IssueCACertificate}
+ a={subject(ProjectPermissionSub.CertificateAuthorities, { name: ca.name })}
>
- <FontAwesomeIcon icon={faPlus} />
- </IconButton> */}
- </div>
- <div className="py-4">
+ {(isAllowed) => (
+ <Button
+ isDisabled={!isAllowed}
+ variant="outline"
+ size="xs"
+ onClick={() => {
+ if (
+ ca.configuration.type === InternalCaType.INTERMEDIATE &&
+ !ca.configuration.parentCaId
+ ) {
+ handlePopUpOpen("installCaCert", {
+ caId: ca.id,
+ isParentCaExternal: true
+ });
+ return;
+ }
+
+ handlePopUpOpen("renewCa", {
+ caId: ca.id
+ });
+ }}
+ >
+ Renew CA
+ </Button>
+ )}
+ </ProjectPermissionCan>
+ );
+ }
+
+ if (ca.status === CaStatus.PENDING_CERTIFICATE) {
+ return (
+ <ProjectPermissionCan
+ I={ProjectPermissionCertificateAuthorityActions.Create}
+ a={subject(ProjectPermissionSub.CertificateAuthorities, { name: ca.name })}
+ >
+ {(isAllowed) => {
+ if (ca.configuration.type === InternalCaType.ROOT) {
+ return (
+ <Button
+ isDisabled={!isAllowed}
+ variant="outline"
+ size="xs"
+ onClick={() => {
+ handlePopUpOpen("generateRootCaCert", {
+ caId: ca.id
+ });
+ }}
+ >
+ Generate Certificate
+ </Button>
+ );
+ }
+ return (
+ <Button
+ isDisabled={!isAllowed}
+ variant="outline"
+ size="xs"
+ onClick={() => {
+ handlePopUpOpen("installCaCert", {
+ caId: ca.id
+ });
+ }}
+ >
+ Install CA Certificate
+ </Button>
+ );
+ }}
+ </ProjectPermissionCan>
+ );
+ }
+
+ return null;
+ };
+
+ return (
+ <UnstableCard className="w-full">
+ <UnstableCardHeader className="border-b">
+ <UnstableCardTitle>CA Certificates</UnstableCardTitle>
+ <UnstableCardAction>{renderActionButton()}</UnstableCardAction>
+ </UnstableCardHeader>
+ <UnstableCardContent>
<CaCertificatesTable caId={caId} caName={caName} />
- </div>
- </div>
+ </UnstableCardContent>
+ </UnstableCard>
);
};
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertificatesSection/CaCertificatesTable.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertificatesSection/CaCertificatesTable.tsx
index 1146ec0a3f..012769f288 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertificatesSection/CaCertificatesTable.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCertificatesSection/CaCertificatesTable.tsx
@@ -1,28 +1,26 @@
import { subject } from "@casl/ability";
-import { faCertificate, faEllipsis } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { faCertificate } from "@fortawesome/free-solid-svg-icons";
import * as x509 from "@peculiar/x509";
import { format } from "date-fns";
import FileSaver from "file-saver";
-import { twMerge } from "tailwind-merge";
+import { EllipsisIcon } from "lucide-react";
import { ProjectPermissionCan } from "@app/components/permissions";
+import { EmptyState, TableSkeleton } from "@app/components/v2";
import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
- EmptyState,
- Table,
- TableContainer,
- TableSkeleton,
- TBody,
- Td,
- Th,
- THead,
- Tr
-} from "@app/components/v2";
-import { Badge } from "@app/components/v3";
+ Badge,
+ UnstableDropdownMenu,
+ UnstableDropdownMenuContent,
+ UnstableDropdownMenuItem,
+ UnstableDropdownMenuTrigger,
+ UnstableIconButton,
+ UnstableTable,
+ UnstableTableBody,
+ UnstableTableCell,
+ UnstableTableHead,
+ UnstableTableHeader,
+ UnstableTableRow
+} from "@app/components/v3";
import { ProjectPermissionCertificateAuthorityActions, ProjectPermissionSub } from "@app/context";
import { useGetCaCerts } from "@app/hooks/api";
@@ -40,44 +38,44 @@ export const CaCertificatesTable = ({ caId, caName }: Props) => {
};
return (
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Th>CA Certificate #</Th>
- <Th>Not Before</Th>
- <Th>Not After</Th>
- <Th className="w-5" />
- </Tr>
- </THead>
- <TBody>
+ <>
+ <UnstableTable>
+ <UnstableTableHeader>
+ <UnstableTableRow>
+ <UnstableTableHead>CA Certificate #</UnstableTableHead>
+ <UnstableTableHead>Not Before</UnstableTableHead>
+ <UnstableTableHead>Not After</UnstableTableHead>
+ <UnstableTableHead className="w-5" />
+ </UnstableTableRow>
+ </UnstableTableHeader>
+ <UnstableTableBody>
{isPending && <TableSkeleton columns={4} innerKey="ca-certificates" />}
{!isPending &&
caCerts?.map?.((caCert, index) => {
const isLastItem = index === caCerts.length - 1;
const caCertObj = new x509.X509Certificate(caCert.certificate);
return (
- <Tr key={`ca-cert=${caCert.serialNumber}`}>
- <Td>
- <div className="flex items-center">
+ <UnstableTableRow key={`ca-cert=${caCert.serialNumber}`}>
+ <UnstableTableCell>
+ <div className="flex items-center gap-x-2">
CA Certificate {caCert.version}
- {isLastItem && (
- <Badge variant="info" className="ml-4">
- Current
- </Badge>
- )}
+ {isLastItem && <Badge variant="info">Current</Badge>}
</div>
- </Td>
- <Td>{format(new Date(caCertObj.notBefore), "yyyy-MM-dd")}</Td>
- <Td>{format(new Date(caCertObj.notAfter), "yyyy-MM-dd")}</Td>
- <Td>
- <DropdownMenu>
- <DropdownMenuTrigger asChild className="rounded-lg">
- <div className="hover:text-primary-400 data-[state=open]:text-primary-400">
- <FontAwesomeIcon size="sm" icon={faEllipsis} />
- </div>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="p-1">
+ </UnstableTableCell>
+ <UnstableTableCell>
+ {format(new Date(caCertObj.notBefore), "yyyy-MM-dd")}
+ </UnstableTableCell>
+ <UnstableTableCell>
+ {format(new Date(caCertObj.notAfter), "yyyy-MM-dd")}
+ </UnstableTableCell>
+ <UnstableTableCell>
+ <UnstableDropdownMenu>
+ <UnstableDropdownMenuTrigger asChild>
+ <UnstableIconButton variant="ghost" size="xs">
+ <EllipsisIcon />
+ </UnstableIconButton>
+ </UnstableDropdownMenuTrigger>
+ <UnstableDropdownMenuContent align="end">
<ProjectPermissionCan
I={ProjectPermissionCertificateAuthorityActions.Read}
a={subject(ProjectPermissionSub.CertificateAuthorities, {
@@ -85,18 +83,15 @@ export const CaCertificatesTable = ({ caId, caName }: Props) => {
})}
>
{(isAllowed) => (
- <DropdownMenuItem
- className={twMerge(
- !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
- )}
+ <UnstableDropdownMenuItem
+ isDisabled={!isAllowed}
onClick={(e) => {
e.stopPropagation();
downloadTxtFile("cert.pem", caCert.certificate);
}}
- disabled={!isAllowed}
>
Download CA Certificate
- </DropdownMenuItem>
+ </UnstableDropdownMenuItem>
)}
</ProjectPermissionCan>
<ProjectPermissionCan
@@ -106,34 +101,31 @@ export const CaCertificatesTable = ({ caId, caName }: Props) => {
})}
>
{(isAllowed) => (
- <DropdownMenuItem
- className={twMerge(
- !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
- )}
+ <UnstableDropdownMenuItem
+ isDisabled={!isAllowed}
onClick={(e) => {
e.stopPropagation();
downloadTxtFile("chain.pem", caCert.certificateChain);
}}
- disabled={!isAllowed}
>
Download CA Certificate Chain
- </DropdownMenuItem>
+ </UnstableDropdownMenuItem>
)}
</ProjectPermissionCan>
- </DropdownMenuContent>
- </DropdownMenu>
- </Td>
- </Tr>
+ </UnstableDropdownMenuContent>
+ </UnstableDropdownMenu>
+ </UnstableTableCell>
+ </UnstableTableRow>
);
})}
- </TBody>
- </Table>
+ </UnstableTableBody>
+ </UnstableTable>
{!isPending && !caCerts?.length && (
<EmptyState
title="This CA does not have any CA certificates installed"
icon={faCertificate}
/>
)}
- </TableContainer>
+ </>
);
};
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCrlsSection/CaCrlsSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCrlsSection/CaCrlsSection.tsx
index d5753b0f25..4aeff7d915 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCrlsSection/CaCrlsSection.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCrlsSection/CaCrlsSection.tsx
@@ -1,3 +1,10 @@
+import {
+ UnstableCard,
+ UnstableCardContent,
+ UnstableCardHeader,
+ UnstableCardTitle
+} from "@app/components/v3";
+
import { CaCrlsTable } from "./CaCrlsTable";
type Props = {
@@ -6,15 +13,13 @@ type Props = {
export const CaCrlsSection = ({ caId }: Props) => {
return (
- <div className="mt-4 w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
- <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
- <h3 className="text-lg font-medium text-mineshaft-100">
- CA Certificate Revocation Lists (CRLs)
- </h3>
- </div>
- <div className="py-4">
+ <UnstableCard className="w-full">
+ <UnstableCardHeader className="border-b">
+ <UnstableCardTitle>CA Certificate Revocation Lists (CRLs)</UnstableCardTitle>
+ </UnstableCardHeader>
+ <UnstableCardContent>
<CaCrlsTable caId={caId} />
- </div>
- </div>
+ </UnstableCardContent>
+ </UnstableCard>
);
};
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCrlsSection/CaCrlsTable.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCrlsSection/CaCrlsTable.tsx
index 77b96f3d60..35d97b7844 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCrlsSection/CaCrlsTable.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaCrlsSection/CaCrlsTable.tsx
@@ -1,22 +1,17 @@
-import { faCertificate, faFileDownload } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-// import * as x509 from "@peculiar/x509";
-// import { format } from "date-fns";
+import { faCertificate } from "@fortawesome/free-solid-svg-icons";
import FileSaver from "file-saver";
+import { ClipboardListIcon, DownloadIcon } from "lucide-react";
+import { EmptyState, TableSkeleton, Tooltip } from "@app/components/v2";
import {
- EmptyState,
- IconButton,
- Table,
- TableContainer,
- TableSkeleton,
- TBody,
- Td,
- Th,
- THead,
- Tooltip,
- Tr
-} from "@app/components/v2";
+ UnstableIconButton,
+ UnstableTable,
+ UnstableTableBody,
+ UnstableTableCell,
+ UnstableTableHead,
+ UnstableTableHeader,
+ UnstableTableRow
+} from "@app/components/v3";
import { useGetCaCrls } from "@app/hooks/api";
type Props = {
@@ -32,57 +27,59 @@ export const CaCrlsTable = ({ caId }: Props) => {
};
return (
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Th>Distribution Point URL</Th>
- {/* <Th>This Update</Th> */}
- {/* <Th>Next Update</Th> */}
- <Th className="w-5" />
- </Tr>
- </THead>
- <TBody>
- {isPending && <TableSkeleton columns={4} innerKey="ca-certificates" />}
+ <>
+ <UnstableTable>
+ <UnstableTableHeader>
+ <UnstableTableRow>
+ <UnstableTableHead>Distribution Point URL</UnstableTableHead>
+ <UnstableTableHead className="w-5" />
+ </UnstableTableRow>
+ </UnstableTableHeader>
+ <UnstableTableBody>
+ {isPending && <TableSkeleton columns={2} innerKey="ca-crls" />}
{!isPending &&
caCrls?.map(({ id, crl }) => {
- // const caCrlObj = new x509.X509Crl(crl);
return (
- <Tr key={`ca-crl-${id}`}>
- <Td>
- <div className="flex items-center">
- {`${window.origin}/api/v1/cert-manager/crl/${id}`}
- </div>
- </Td>
- {/* <Td>{format(new Date(caCrlObj.thisUpdate), "yyyy-MM-dd")}</Td> */}
- {/* <Td>
- {caCrlObj.nextUpdate
- ? format(new Date(caCrlObj.nextUpdate), "yyyy-MM-dd")
- : "-"}
- </Td> */}
- <Td>
+ <UnstableTableRow key={`ca-crl-${id}`}>
+ <UnstableTableCell className="flex items-center gap-x-2">
+ {`${window.origin}/api/v1/cert-manager/crl/${id}`}
+ <Tooltip content="Copy CRL URL">
+ <UnstableIconButton
+ variant="ghost"
+ size="xs"
+ onClick={(e) => {
+ e.stopPropagation();
+ navigator.clipboard.writeText(
+ `${window.origin}/api/v1/cert-manager/crl/${id}`
+ );
+ }}
+ >
+ <ClipboardListIcon className="text-label" />
+ </UnstableIconButton>
+ </Tooltip>
+ </UnstableTableCell>
+ <UnstableTableCell>
<Tooltip content="Download CRL">
- <IconButton
- ariaLabel="copy icon"
- variant="plain"
- className="group relative"
+ <UnstableIconButton
+ variant="ghost"
+ size="xs"
onClick={(e) => {
e.stopPropagation();
downloadTxtFile("crl.pem", crl);
}}
>
- <FontAwesomeIcon icon={faFileDownload} />
- </IconButton>
+ <DownloadIcon className="text-label" />
+ </UnstableIconButton>
</Tooltip>
- </Td>
- </Tr>
+ </UnstableTableCell>
+ </UnstableTableRow>
);
})}
- </TBody>
- </Table>
+ </UnstableTableBody>
+ </UnstableTable>
{!isPending && !caCrls?.length && (
<EmptyState title="This CA does not have any CRLs" icon={faCertificate} />
)}
- </TableContainer>
+ </>
);
};
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx
index 74fe3dff04..0e95a1aceb 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx
@@ -1,10 +1,21 @@
import { subject } from "@casl/ability";
-import { faCheck, faCopy, faPencil } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { format } from "date-fns";
+import { CheckIcon, ClipboardListIcon, PencilIcon } from "lucide-react";
import { ProjectPermissionCan } from "@app/components/permissions";
-import { Button, IconButton, Tooltip } from "@app/components/v2";
+import { Tooltip } from "@app/components/v2";
+import {
+ Badge,
+ Detail,
+ DetailGroup,
+ DetailLabel,
+ DetailValue,
+ UnstableCard,
+ UnstableCardAction,
+ UnstableCardContent,
+ UnstableCardHeader,
+ UnstableCardTitle,
+ UnstableIconButton
+} from "@app/components/v3";
import { ProjectPermissionCertificateAuthorityActions, ProjectPermissionSub } from "@app/context";
import { useTimedReset } from "@app/hooks";
import { CaStatus, CaType, InternalCaType, useGetCa } from "@app/hooks/api";
@@ -15,17 +26,27 @@ import { UsePopUpState } from "@app/hooks/usePopUp";
type Props = {
caId: string;
- handlePopUpOpen: (
- popUpName: keyof UsePopUpState<["ca", "renewCa", "installCaCert", "generateRootCaCert"]>,
- data?: object
- ) => void;
+ handlePopUpOpen: (popUpName: keyof UsePopUpState<["ca"]>, data?: object) => void;
+};
+
+const getStatusVariant = (status: CaStatus) => {
+ switch (status) {
+ case CaStatus.ACTIVE:
+ return "success";
+ case CaStatus.PENDING_CERTIFICATE:
+ return "warning";
+ case CaStatus.DISABLED:
+ return "danger";
+ default:
+ return "neutral";
+ }
};
export const CaDetailsSection = ({ caId, handlePopUpOpen }: Props) => {
- const [copyTextId, isCopyingId, setCopyTextId] = useTimedReset<string>({
+ const [, isCopyingId, setCopyTextId] = useTimedReset<string>({
initialState: "Copy ID to clipboard"
});
- const [copyTextParentId, isCopyingParentId, setCopyTextParentId] = useTimedReset<string>({
+ const [, isCopyingParentId, setCopyTextParentId] = useTimedReset<string>({
initialState: "Copy ID to clipboard"
});
@@ -36,206 +57,113 @@ export const CaDetailsSection = ({ caId, handlePopUpOpen }: Props) => {
const ca = data as TInternalCertificateAuthority;
- return ca ? (
- <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
- <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
- <h3 className="text-lg font-medium text-mineshaft-100">CA Details</h3>
- <ProjectPermissionCan
- I={ProjectPermissionCertificateAuthorityActions.Edit}
- a={subject(ProjectPermissionSub.CertificateAuthorities, { name: ca.name })}
- >
- {(isAllowed) => {
- return (
+ if (!ca) {
+ return <div />;
+ }
+
+ return (
+ <UnstableCard className="w-full">
+ <UnstableCardHeader className="border-b">
+ <UnstableCardTitle>CA Details</UnstableCardTitle>
+ <UnstableCardAction>
+ <ProjectPermissionCan
+ I={ProjectPermissionCertificateAuthorityActions.Edit}
+ a={subject(ProjectPermissionSub.CertificateAuthorities, { name: ca.name })}
+ >
+ {(isAllowed) => (
<Tooltip content="Edit CA">
- <IconButton
+ <UnstableIconButton
isDisabled={!isAllowed}
- ariaLabel="copy icon"
- variant="plain"
- className="group relative"
+ variant="outline"
+ size="xs"
onClick={(e) => {
e.stopPropagation();
- handlePopUpOpen("ca", {
- caId: ca.id
- });
+ handlePopUpOpen("ca", { caId: ca.id });
}}
>
- <FontAwesomeIcon icon={faPencil} />
- </IconButton>
+ <PencilIcon />
+ </UnstableIconButton>
</Tooltip>
- );
- }}
- </ProjectPermissionCan>
- </div>
- <div className="pt-4">
- <div className="mb-4">
- <p className="text-sm font-medium text-mineshaft-300">CA Type</p>
- <p className="text-sm text-mineshaft-300">{caTypeToNameMap[ca.configuration.type]}</p>
- </div>
- <div className="mb-4">
- <p className="text-sm font-medium text-mineshaft-300">CA ID</p>
- <div className="group flex align-top">
- <p className="text-sm text-mineshaft-300">{ca.id}</p>
- <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
- <Tooltip content={copyTextId}>
- <IconButton
- ariaLabel="copy icon"
- variant="plain"
- className="group relative ml-2"
+ )}
+ </ProjectPermissionCan>
+ </UnstableCardAction>
+ </UnstableCardHeader>
+ <UnstableCardContent>
+ <DetailGroup>
+ <Detail>
+ <DetailLabel>CA Type</DetailLabel>
+ <DetailValue>{caTypeToNameMap[ca.configuration.type]}</DetailValue>
+ </Detail>
+
+ <Detail>
+ <DetailLabel>CA ID</DetailLabel>
+ <DetailValue className="flex items-center gap-x-1">
+ <span className="break-all">{ca.id}</span>
+ <Tooltip content={isCopyingId ? "Copied" : "Copy ID to clipboard"}>
+ <UnstableIconButton
+ variant="ghost"
+ size="xs"
onClick={() => {
navigator.clipboard.writeText(ca.id);
setCopyTextId("Copied");
}}
>
- <FontAwesomeIcon icon={isCopyingId ? faCheck : faCopy} />
- </IconButton>
+ {isCopyingId ? <CheckIcon /> : <ClipboardListIcon className="text-label" />}
+ </UnstableIconButton>
</Tooltip>
- </div>
- </div>
- </div>
- {ca.configuration.type === InternalCaType.INTERMEDIATE &&
- ca.status !== CaStatus.PENDING_CERTIFICATE && (
- <div className="mb-4">
- <p className="text-sm font-medium text-mineshaft-300">Parent CA ID</p>
- <div className="group flex align-top">
- <p className="text-sm text-mineshaft-300">
- {ca.configuration.parentCaId
- ? ca.configuration.parentCaId
- : "N/A - External Parent CA"}
- </p>
- {ca.configuration.parentCaId && (
- <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100">
- <Tooltip content={copyTextParentId}>
- <IconButton
- ariaLabel="copy icon"
- variant="plain"
- className="group relative ml-2"
+ </DetailValue>
+ </Detail>
+
+ {ca.configuration.type === InternalCaType.INTERMEDIATE &&
+ ca.status !== CaStatus.PENDING_CERTIFICATE && (
+ <Detail>
+ <DetailLabel>Parent CA ID</DetailLabel>
+ <DetailValue className="flex items-center gap-x-1">
+ <span className="break-all">
+ {ca.configuration.parentCaId
+ ? ca.configuration.parentCaId
+ : "N/A - External Parent CA"}
+ </span>
+ {ca.configuration.parentCaId && (
+ <Tooltip content={isCopyingParentId ? "Copied" : "Copy ID to clipboard"}>
+ <UnstableIconButton
+ variant="ghost"
+ size="xs"
onClick={() => {
navigator.clipboard.writeText(ca.configuration.parentCaId as string);
setCopyTextParentId("Copied");
}}
>
- <FontAwesomeIcon icon={isCopyingParentId ? faCheck : faCopy} />
- </IconButton>
+ {isCopyingParentId ? (
+ <CheckIcon />
+ ) : (
+ <ClipboardListIcon className="text-label" />
+ )}
+ </UnstableIconButton>
</Tooltip>
- </div>
- )}
- </div>
- </div>
- )}
- <div className="mb-4">
- <p className="text-sm font-medium text-mineshaft-300">Name</p>
- <p className="text-sm text-mineshaft-300">{ca.name}</p>
- </div>
- <div className="mb-4">
- <p className="text-sm font-medium text-mineshaft-300">Status</p>
- <p className="text-sm text-mineshaft-300">{caStatusToNameMap[ca.status]}</p>
- </div>
- <div className="mb-4">
- <p className="text-sm font-medium text-mineshaft-300">Key Algorithm</p>
- <p className="text-sm text-mineshaft-300">
- {certKeyAlgorithmToNameMap[ca.configuration.keyAlgorithm]}
- </p>
- </div>
- <div className="mb-4">
- <p className="text-sm font-medium text-mineshaft-300">Max Path Length</p>
- <p className="text-sm text-mineshaft-300">{ca.configuration.maxPathLength ?? "-"}</p>
- </div>
- <div className="mb-4">
- <p className="text-sm font-medium text-mineshaft-300">Not Before</p>
- <p className="text-sm text-mineshaft-300">
- {ca.configuration.notBefore
- ? format(new Date(ca.configuration.notBefore), "yyyy-MM-dd")
- : "-"}
- </p>
- </div>
- <div className="mb-4">
- <p className="text-sm font-medium text-mineshaft-300">Not After</p>
- <p className="text-sm text-mineshaft-300">
- {ca.configuration.notAfter
- ? format(new Date(ca.configuration.notAfter), "yyyy-MM-dd")
- : "-"}
- </p>
- </div>
- {ca.status === CaStatus.ACTIVE && (
- <ProjectPermissionCan
- I={ProjectPermissionCertificateAuthorityActions.IssueCACertificate}
- a={subject(ProjectPermissionSub.CertificateAuthorities, { name: ca.name })}
- >
- {(isAllowed) => {
- return (
- <Button
- isDisabled={!isAllowed}
- className="mt-4 w-full"
- colorSchema="primary"
- type="submit"
- onClick={() => {
- if (
- ca.configuration.type === InternalCaType.INTERMEDIATE &&
- !ca.configuration.parentCaId
- ) {
- // intermediate CA with external parent CA
- handlePopUpOpen("installCaCert", {
- caId: ca.id,
- isParentCaExternal: true
- });
- return;
- }
+ )}
+ </DetailValue>
+ </Detail>
+ )}
- handlePopUpOpen("renewCa", {
- caId: ca.id
- });
- }}
- >
- Renew CA
- </Button>
- );
- }}
- </ProjectPermissionCan>
- )}
- {ca.status === CaStatus.PENDING_CERTIFICATE && (
- <ProjectPermissionCan
- I={ProjectPermissionCertificateAuthorityActions.Create}
- a={subject(ProjectPermissionSub.CertificateAuthorities, { name: ca.name })}
- >
- {(isAllowed) => {
- if (ca.configuration.type === InternalCaType.ROOT) {
- return (
- <Button
- isDisabled={!isAllowed}
- className="mt-4 w-full"
- colorSchema="primary"
- type="submit"
- onClick={() => {
- handlePopUpOpen("generateRootCaCert", {
- caId: ca.id
- });
- }}
- >
- Generate Certificate
- </Button>
- );
- }
- return (
- <Button
- isDisabled={!isAllowed}
- className="mt-4 w-full"
- colorSchema="primary"
- type="submit"
- onClick={() => {
- handlePopUpOpen("installCaCert", {
- caId: ca.id
- });
- }}
- >
- Install CA Certificate
- </Button>
- );
- }}
- </ProjectPermissionCan>
- )}
- </div>
- </div>
- ) : (
- <div />
+ <Detail>
+ <DetailLabel>Name</DetailLabel>
+ <DetailValue>{ca.name}</DetailValue>
+ </Detail>
+
+ <Detail>
+ <DetailLabel>Status</DetailLabel>
+ <DetailValue>
+ <Badge variant={getStatusVariant(ca.status)}>{caStatusToNameMap[ca.status]}</Badge>
+ </DetailValue>
+ </Detail>
+
+ <Detail>
+ <DetailLabel>Key Algorithm</DetailLabel>
+ <DetailValue>{certKeyAlgorithmToNameMap[ca.configuration.keyAlgorithm]}</DetailValue>
+ </Detail>
+ </DetailGroup>
+ </UnstableCardContent>
+ </UnstableCard>
);
};
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/index.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/index.tsx
index b13d5d74e0..4ee9a45b59 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/index.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/index.tsx
@@ -1,3 +1,4 @@
+export { CaCertDetailsSection } from "./CaCertDetailsSection";
export { CaCertificatesSection } from "./CaCertificatesSection/CaCertificatesSection";
export { CaCrlsSection } from "./CaCrlsSection";
export { CaDetailsSection } from "./CaDetailsSection";