Skip to content

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

Add endpoint to assign cert to applications

Carlos Monastyrski40b00c1cca60
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 1198f32edf..27a3165180 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -382,6 +382,7 @@ export enum EventType {
GET_CERT = "get-cert",
DELETE_CERT = "delete-cert",
REVOKE_CERT = "revoke-cert",
+ ASSIGN_CERT_TO_APPLICATION = "assign-cert-to-application",
GET_CERT_BODY = "get-cert-body",
GET_CERT_PRIVATE_KEY = "get-cert-private-key",
GET_CERT_BUNDLE = "get-cert-bundle",
@@ -2991,6 +2992,17 @@ interface RevokeCert {
};
}
+interface AssignCertToApplication {
+ type: EventType.ASSIGN_CERT_TO_APPLICATION;
+ metadata: {
+ certId: string;
+ cn: string;
+ serialNumber: string;
+ applicationId: string;
+ applicationName: string;
+ };
+}
+
interface GetCertBody {
type: EventType.GET_CERT_BODY;
metadata: {
@@ -6856,6 +6868,7 @@ export type Event =
| GetCert
| DeleteCert
| RevokeCert
+ | AssignCertToApplication
| GetCertBody
| GetCertPrivateKey
| GetCertBundle
diff --git a/backend/src/ee/services/permission/default-roles.ts b/backend/src/ee/services/permission/default-roles.ts
index bf764eb85c..b7a12a30fe 100644
--- a/backend/src/ee/services/permission/default-roles.ts
+++ b/backend/src/ee/services/permission/default-roles.ts
@@ -652,11 +652,7 @@ const buildMemberPermissionRules = () => {
);
can(
- [
- ProjectPermissionApplicationActions.Read,
- ProjectPermissionApplicationActions.List,
- ProjectPermissionApplicationActions.Create
- ],
+ [ProjectPermissionApplicationActions.Read, ProjectPermissionApplicationActions.List],
ProjectPermissionSub.Application
);
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index fd1e70e35a..c0ee9c4ac2 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2669,7 +2669,8 @@ export const registerRoutes = async (
pkiSyncQueue,
certificateAuthorityService,
resourceMetadataDAL,
- pkiAlertV2Queue
+ pkiAlertV2Queue,
+ pkiApplicationDAL
});
const digicertCaFns = DigiCertCertificateAuthorityFns({
diff --git a/backend/src/server/routes/v1/certificate-inventory-view-router.ts b/backend/src/server/routes/v1/certificate-inventory-view-router.ts
index bf890def04..7eda2ef0f7 100644
--- a/backend/src/server/routes/v1/certificate-inventory-view-router.ts
+++ b/backend/src/server/routes/v1/certificate-inventory-view-router.ts
@@ -35,6 +35,7 @@ const ValidColumns = [
"expiresAt",
"ca",
"profile",
+ "application",
"algorithm",
"source"
] as const;
diff --git a/backend/src/server/routes/v1/certificate-router.ts b/backend/src/server/routes/v1/certificate-router.ts
index 40d1f04291..d8e8ba1a20 100644
--- a/backend/src/server/routes/v1/certificate-router.ts
+++ b/backend/src/server/routes/v1/certificate-router.ts
@@ -1615,6 +1615,58 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
}
});
+ server.route({
+ method: "POST",
+ url: "/:id/application",
+ config: { rateLimit: writeLimit },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ schema: {
+ hide: false,
+ operationId: "assignCertificateToApplication",
+ tags: [ApiDocsTags.PkiCertificates],
+ description:
+ "Assign a certificate to an Application. Only certificates that aren't already attached to an Application can be assigned; once attached the binding cannot be moved.",
+ params: z.object({
+ id: z.string().uuid()
+ }),
+ body: z.object({
+ applicationId: z.string().uuid()
+ }),
+ response: {
+ 200: z.object({
+ certificate: CertificatesSchema
+ })
+ }
+ },
+ handler: async (req) => {
+ const { certificate, application } = await server.services.certificate.assignCertificateToApplication({
+ certificateId: req.params.id,
+ applicationId: req.body.applicationId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: certificate.projectId,
+ event: {
+ type: EventType.ASSIGN_CERT_TO_APPLICATION,
+ metadata: {
+ certId: certificate.id,
+ cn: certificate.commonName,
+ serialNumber: certificate.serialNumber,
+ applicationId: application.id,
+ applicationName: application.name
+ }
+ }
+ });
+
+ return { certificate };
+ }
+ });
+
server.route({
method: "GET",
url: "/:id/certificate",
diff --git a/backend/src/server/routes/v1/project-router.ts b/backend/src/server/routes/v1/project-router.ts
index 3798e79c02..dedca137e1 100644
--- a/backend/src/server/routes/v1/project-router.ts
+++ b/backend/src/server/routes/v1/project-router.ts
@@ -1345,7 +1345,8 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
hasPrivateKey: z.boolean(),
caName: z.string().nullable().optional(),
profileName: z.string().nullable().optional(),
- enrollmentType: z.string().nullable().optional()
+ enrollmentType: z.string().nullable().optional(),
+ applicationName: z.string().nullable().optional()
})
),
totalCount: z.number()
diff --git a/backend/src/services/certificate/certificate-dal.ts b/backend/src/services/certificate/certificate-dal.ts
index 65c9d271c3..e3ff419d90 100644
--- a/backend/src/services/certificate/certificate-dal.ts
+++ b/backend/src/services/certificate/certificate-dal.ts
@@ -490,6 +490,7 @@ export const certificateDALFactory = (db: TDbClient) => {
caName?: string | null;
profileName?: string | null;
enrollmentType?: string | null;
+ applicationName?: string | null;
};
const findWithPrivateKeyInfo = async (
@@ -511,11 +512,13 @@ export const certificateDALFactory = (db: TDbClient) => {
`${TableName.Certificate}.profileId`,
`${TableName.PkiCertificateProfile}.id`
)
+ .leftJoin(TableName.PkiApplication, `${TableName.Certificate}.applicationId`, `${TableName.PkiApplication}.id`)
.select(selectAllTableCols(TableName.Certificate))
.select(db.ref(`${TableName.CertificateSecret}.certId`).as("privateKeyRef"))
.select(db.ref("name").withSchema(TableName.CertificateAuthority).as("caName"))
.select(db.ref("slug").withSchema(TableName.PkiCertificateProfile).as("profileName"))
- .select(db.ref("enrollmentType").withSchema(TableName.PkiCertificateProfile).as("enrollmentType"));
+ .select(db.ref("enrollmentType").withSchema(TableName.PkiCertificateProfile).as("enrollmentType"))
+ .select(db.ref("name").withSchema(TableName.PkiApplication).as("applicationName"));
const {
friendlyName,
diff --git a/backend/src/services/certificate/certificate-service.ts b/backend/src/services/certificate/certificate-service.ts
index 4de72673c3..7dcee3921d 100644
--- a/backend/src/services/certificate/certificate-service.ts
+++ b/backend/src/services/certificate/certificate-service.ts
@@ -2,7 +2,7 @@
import { ForbiddenError, subject } from "@casl/ability";
import * as x509 from "@peculiar/x509";
-import { ActionProjectType } from "@app/db/schemas";
+import { ActionProjectType, ProjectMembershipRole } from "@app/db/schemas";
import { TCertificateAuthorityCrlDALFactory } from "@app/ee/services/certificate-authority-crl/certificate-authority-crl-dal";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
@@ -10,7 +10,7 @@ import {
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
import { crypto } from "@app/lib/crypto/cryptography";
-import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";
+import { BadRequestError, DatabaseError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { TCertificateBodyDALFactory } from "@app/services/certificate/certificate-body-dal";
import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";
@@ -24,6 +24,7 @@ import { TCertificateSyncDALFactory } from "@app/services/certificate-sync/certi
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { TPkiAlertV2QueueServiceFactory } from "@app/services/pki-alert-v2/pki-alert-v2-queue";
import { PkiAlertEventType } from "@app/services/pki-alert-v2/pki-alert-v2-types";
+import { TPkiApplicationDALFactory } from "@app/services/pki-application/pki-application-dal";
import { TPkiCollectionDALFactory } from "@app/services/pki-collection/pki-collection-dal";
import { TPkiCollectionItemDALFactory } from "@app/services/pki-collection/pki-collection-item-dal";
import { TPkiSyncDALFactory } from "@app/services/pki-sync/pki-sync-dal";
@@ -48,6 +49,7 @@ import {
CertExtendedKeyUsageOIDToName,
CertKeyUsage,
CertStatus,
+ TAssignCertToApplicationDTO,
TCertificateBasicConstraints,
TCertificateFingerprints,
TCertificateSubject,
@@ -64,8 +66,17 @@ import {
type TCertificateServiceFactoryDep = {
certificateDAL: Pick<
TCertificateDALFactory,
- "findOne" | "deleteById" | "update" | "find" | "transaction" | "create" | "findById" | "findWithFullDetails"
+ | "findOne"
+ | "deleteById"
+ | "update"
+ | "find"
+ | "transaction"
+ | "create"
+ | "findById"
+ | "findWithFullDetails"
+ | "updateById"
>;
+ pkiApplicationDAL: Pick<TPkiApplicationDALFactory, "findById">;
certificateSecretDAL: Pick<TCertificateSecretDALFactory, "findOne" | "create">;
certificateBodyDAL: Pick<TCertificateBodyDALFactory, "findOne" | "create">;
certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory, "findById" | "findByIdWithAssociatedCa">;
@@ -105,7 +116,8 @@ export const certificateServiceFactory = ({
pkiSyncQueue,
certificateAuthorityService,
resourceMetadataDAL,
- pkiAlertV2Queue
+ pkiAlertV2Queue,
+ pkiApplicationDAL
}: TCertificateServiceFactoryDep) => {
/**
* Return details for certificate with serial number [serialNumber]
@@ -974,6 +986,48 @@ export const certificateServiceFactory = ({
};
};
+ const assignCertificateToApplication = async ({
+ certificateId,
+ applicationId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TAssignCertToApplicationDTO) => {
+ const cert = await certificateDAL.findById(certificateId);
+ if (!cert) {
+ throw new NotFoundError({ message: `Certificate with id '${certificateId}' not found.` });
+ }
+
+ if (cert.applicationId) {
+ throw new BadRequestError({
+ message: "This certificate is already assigned to an Application and cannot be moved."
+ });
+ }
+
+ const application = await pkiApplicationDAL.findById(applicationId);
+ if (!application || application.projectId !== cert.projectId) {
+ throw new NotFoundError({ message: `Application with id '${applicationId}' not found in this project.` });
+ }
+
+ const { hasRole } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: cert.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.CertificateManager
+ });
+ if (!hasRole(ProjectMembershipRole.Admin)) {
+ throw new ForbiddenRequestError({
+ message: "Only project admins can assign certificates to an Application."
+ });
+ }
+
+ const [updatedCert] = await certificateDAL.update({ id: cert.id }, { applicationId });
+ return { certificate: updatedCert, application };
+ };
+
return {
getCert,
getCertPrivateKey,
@@ -982,6 +1036,7 @@ export const certificateServiceFactory = ({
getCertBody,
importCert,
getCertBundle,
- getCertPkcs12
+ getCertPkcs12,
+ assignCertificateToApplication
};
};
diff --git a/backend/src/services/certificate/certificate-types.ts b/backend/src/services/certificate/certificate-types.ts
index c06a25b8a3..a67e864351 100644
--- a/backend/src/services/certificate/certificate-types.ts
+++ b/backend/src/services/certificate/certificate-types.ts
@@ -133,6 +133,11 @@ export type TRevokeCertDTO = {
revocationReason: CrlReason;
} & Omit<TProjectPermission, "projectId">;
+export type TAssignCertToApplicationDTO = {
+ certificateId: string;
+ applicationId: string;
+} & Omit<TProjectPermission, "projectId">;
+
export type TGetCertBodyDTO = {
id?: string;
serialNumber?: string;
diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.ts
index 428b2e5c2d..8b3f1b880b 100644
--- a/backend/src/services/project/project-service.ts
+++ b/backend/src/services/project/project-service.ts
@@ -752,6 +752,26 @@ export const projectServiceFactory = ({
});
}
+ if (project.type === ProjectType.CertificateManager) {
+ const certManagerProjects = await projectDAL.find({
+ orgId: project.orgId,
+ type: ProjectType.CertificateManager
+ });
+ if (certManagerProjects.length <= 1) {
+ throw new BadRequestError({
+ message:
+ "Cannot delete the last Certificate Manager project in this organization. Create another Certificate Manager project first."
+ });
+ }
+ const org = await orgDAL.findOne({ id: project.orgId });
+ if (org?.defaultCertManagerProjectId === project.id) {
+ throw new BadRequestError({
+ message:
+ "Cannot delete the active Certificate Manager project. Set another project as active in Organization Settings → Certificate Manager first."
+ });
+ }
+ }
+
let lock: Awaited<ReturnType<typeof keyStore.acquireLock>> | undefined;
try {
lock = await keyStore.acquireLock([KeyStorePrefixes.ProjectDeleteLock(project.id)], 30_000, {
diff --git a/frontend/src/hooks/api/certManagerInstance/index.ts b/frontend/src/hooks/api/certManagerInstance/index.ts
index 8b6f5047a9..f1fc080a85 100644
--- a/frontend/src/hooks/api/certManagerInstance/index.ts
+++ b/frontend/src/hooks/api/certManagerInstance/index.ts
@@ -1,6 +1,7 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
+import { useOrganization } from "@app/context";
const BASE_URL = "/api/v1/cert-manager/instance";
@@ -19,17 +20,22 @@ export type TCertManagerInstanceState = {
export const certManagerInstanceKeys = {
all: ["cert-manager-instance"] as const,
- state: () => [...certManagerInstanceKeys.all, "state"] as const
+ state: (orgId: string) => [...certManagerInstanceKeys.all, "state", { orgId }] as const,
+ legacy: (orgId: string) => [...certManagerInstanceKeys.all, "legacy", { orgId }] as const
};
-export const useCertManagerInstanceState = () =>
- useQuery({
- queryKey: certManagerInstanceKeys.state(),
+export const useCertManagerInstanceState = () => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg.id;
+ return useQuery({
+ queryKey: certManagerInstanceKeys.state(orgId),
queryFn: async () => {
const { data } = await apiRequest.get<TCertManagerInstanceState>(BASE_URL);
return data;
- }
+ },
+ enabled: Boolean(orgId)
});
+};
export type TCertManagerLegacyInstance = TCertManagerInstanceProject & {
certificateCount: number;
@@ -43,16 +49,20 @@ export type TCertManagerLegacyInstancesResponse = {
instances: TCertManagerLegacyInstance[];
};
-export const useCertManagerLegacyInstances = () =>
- useQuery({
- queryKey: [...certManagerInstanceKeys.all, "legacy"] as const,
+export const useCertManagerLegacyInstances = () => {
+ const { currentOrg } = useOrganization();
+ const orgId = currentOrg.id;
+ return useQuery({
+ queryKey: certManagerInstanceKeys.legacy(orgId),
queryFn: async () => {
const { data } = await apiRequest.get<TCertManagerLegacyInstancesResponse>(
`${BASE_URL}/legacy`
);
return data;
- }
+ },
+ enabled: Boolean(orgId)
});
+};
export const useSetCertManagerActiveProject = () => {
const qc = useQueryClient();
diff --git a/frontend/src/hooks/api/certificates/index.tsx b/frontend/src/hooks/api/certificates/index.tsx
index 5b7837a5f4..d4bb24e8de 100644
--- a/frontend/src/hooks/api/certificates/index.tsx
+++ b/frontend/src/hooks/api/certificates/index.tsx
@@ -1,6 +1,7 @@
export { certKeyAlgorithmToNameMap, certSignatureAlgorithmToNameMap } from "./constants";
export { CertificateRequestStatus, CertKeyAlgorithm, CertSource, CertStatus } from "./enums";
export {
+ useAssignCertificateToApplication,
useDeleteCert,
useDownloadCertPkcs12,
useImportCertificate,
diff --git a/frontend/src/hooks/api/certificates/mutations.tsx b/frontend/src/hooks/api/certificates/mutations.tsx
index 62f6f9f460..523ee16b73 100644
--- a/frontend/src/hooks/api/certificates/mutations.tsx
+++ b/frontend/src/hooks/api/certificates/mutations.tsx
@@ -259,6 +259,29 @@ export const useUnifiedCertificateIssuance = () => {
});
};
+export const useAssignCertificateToApplication = () => {
+ const queryClient = useQueryClient();
+ return useMutation<TCertificate, object, { certificateId: string; applicationId: string }>({
+ mutationFn: async ({ certificateId, applicationId }) => {
+ const {
+ data: { certificate }
+ } = await apiRequest.post<{ certificate: TCertificate }>(
+ `/api/v1/cert-manager/certificates/${certificateId}/application`,
+ { applicationId }
+ );
+ return certificate;
+ },
+ onSuccess: (_, { certificateId }) => {
+ queryClient.invalidateQueries({
+ queryKey: certKeys.getCertificateById(certificateId)
+ });
+ queryClient.invalidateQueries({
+ queryKey: projectKeys.allProjectCertificates()
+ });
+ }
+ });
+};
+
export const useTriggerCertificateRequestValidation = () => {
const queryClient = useQueryClient();
return useMutation<TTriggerCertificateRequestValidationResponse, object, { requestId: string }>({
diff --git a/frontend/src/hooks/api/certificates/types.ts b/frontend/src/hooks/api/certificates/types.ts
index 6618516dd6..f52c9e9d3b 100644
--- a/frontend/src/hooks/api/certificates/types.ts
+++ b/frontend/src/hooks/api/certificates/types.ts
@@ -55,6 +55,8 @@ export type TCertificate = {
profileName?: string | null;
enrollmentType?: string | null;
caType?: "internal" | "external" | null;
+ applicationId?: string | null;
+ applicationName?: string | null;
source?: TCertificateSource;
discoveryMetadata?: {
issuerCommonName?: string;
diff --git a/frontend/src/layouts/PkiManagerLayout/components/ActiveInstancePicker.tsx b/frontend/src/layouts/PkiManagerLayout/components/ActiveInstancePicker.tsx
deleted file mode 100644
index 4610ead9bc..0000000000
--- a/frontend/src/layouts/PkiManagerLayout/components/ActiveInstancePicker.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-import { useState } from "react";
-
-import { createNotification } from "@app/components/notifications";
-import {
- Empty,
- EmptyDescription,
- EmptyHeader,
- EmptyTitle,
- PageLoader,
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue
-} from "@app/components/v3";
-import {
- useCertManagerLegacyInstances,
- useSetCertManagerActiveProject
-} from "@app/hooks/api/certManagerInstance";
-
-type Props = {
- onChanged?: () => void;
-};
-
-export const ActiveInstancePicker = ({ onChanged }: Props) => {
- const { data, isPending } = useCertManagerLegacyInstances();
- const setActive = useSetCertManagerActiveProject();
- const [pendingId, setPendingId] = useState<string | null>(null);
-
- if (isPending || !data) {
- return (
- <div className="h-32">
- <PageLoader lottieClassName="w-16" />
- </div>
- );
- }
-
- if (data.instances.length === 0) {
- return (
- <Empty className="border">
- <EmptyHeader>
- <EmptyTitle>No Certificate Manager instances</EmptyTitle>
- <EmptyDescription>
- Create a Certificate Manager project from the organization to get started.
- </EmptyDescription>
- </EmptyHeader>
- </Empty>
- );
- }
-
- const active = data.instances.find((i) => i.isActive);
-
- const handleChange = async (projectId: string) => {
- if (active?.id === projectId) return;
- const next = data.instances.find((i) => i.id === projectId);
- if (!next) return;
- setPendingId(projectId);
- try {
- await setActive.mutateAsync(projectId);
- createNotification({
- type: "success",
- text: `${next.name} is now the active Certificate Manager instance`
- });
- onChanged?.();
- } catch (err) {
- const detail = err instanceof Error ? err.message : "Failed to switch active instance.";
- createNotification({ type: "error", text: detail });
- } finally {
- setPendingId(null);
- }
- };
-
- return (
- <Select value={active?.id ?? ""} onValueChange={handleChange} disabled={Boolean(pendingId)}>
- <SelectTrigger className="w-full">
- <SelectValue placeholder="Select active instance" />
- </SelectTrigger>
- <SelectContent>
- {data.instances.map((i) => (
- <SelectItem key={i.id} value={i.id}>
- <div className="flex w-full items-center gap-2">
- <span className="font-medium">{i.name}</span>
- <span className="font-mono text-xs text-accent">{i.slug}</span>
- <span className="ml-auto text-xs text-muted">
- {i.certificateCount} cert{i.certificateCount === 1 ? "" : "s"} · {i.syncCount} sync
- {i.syncCount === 1 ? "" : "s"} · {i.alertCount} alert
- {i.alertCount === 1 ? "" : "s"}
- </span>
- </div>
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- );
-};
diff --git a/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx b/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx
index 89e818ba47..43d2626e3f 100644
--- a/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx
+++ b/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx
@@ -1,42 +1,13 @@
-import { useState } from "react";
-import { faCheck, faChevronDown, faWarning } from "@fortawesome/free-solid-svg-icons";
+import { faWarning } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { useNavigate, useParams } from "@tanstack/react-router";
+import { useParams } from "@tanstack/react-router";
-import { createNotification } from "@app/components/notifications";
-import { Button } from "@app/components/v2";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuSeparator,
- DropdownMenuTrigger
-} from "@app/components/v3";
-import { useOrgPermission } from "@app/context";
-import {
- OrgPermissionCertManagerActions,
- OrgPermissionSubjects
-} from "@app/context/OrgPermissionContext/types";
-import {
- useCertManagerInstanceState,
- useCertManagerLegacyInstances,
- useSetCertManagerActiveProject
-} from "@app/hooks/api/certManagerInstance";
+import { useCertManagerInstanceState } from "@app/hooks/api/certManagerInstance";
export const CertManagerInstanceBanner = () => {
- const params = useParams({ strict: false }) as { projectId?: string; orgId?: string };
- const { projectId, orgId } = params;
- const navigate = useNavigate();
+ const params = useParams({ strict: false }) as { projectId?: string };
+ const { projectId } = params;
const { data, isPending } = useCertManagerInstanceState();
- const { data: legacyData } = useCertManagerLegacyInstances();
- const setActive = useSetCertManagerActiveProject();
- const [pendingId, setPendingId] = useState<string | null>(null);
- const { permission } = useOrgPermission();
- const canManage = permission.can(
- OrgPermissionCertManagerActions.ManageInstance,
- OrgPermissionSubjects.CertManager
- );
if (isPending || !data || !data.isMultiInstance) return null;
@@ -48,79 +19,10 @@ export const CertManagerInstanceBanner = () => {
? `Your organization has ${otherCount} other Certificate Manager ${otherCount === 1 ? "project" : "projects"}, consolidate to a single project, multi-project Certificate Manager will be deprecated soon.`
: `Legacy Certificate Manager instance (active is ${activeProject?.name ?? "not set"}) — consolidate to a single instance, multi-project Certificate Manager will be deprecated soon.`;
- const handlePick = async (instanceId: string, name: string) => {
- if (instanceId === activeProject?.id) return;
- setPendingId(instanceId);
- try {
- await setActive.mutateAsync(instanceId);
- createNotification({
- type: "success",
- text: `${name} is now the active Certificate Manager instance`
- });
- if (orgId) {
- navigate({
- to: `/organizations/${orgId}/projects/cert-manager/${instanceId}/overview` as never
- } as never);
- }
- } catch (err) {
- const detail = err instanceof Error ? err.message : "Failed to switch active instance.";
- createNotification({ type: "error", text: detail });
- } finally {
- setPendingId(null);
- }
- };
-
return (
<div className="flex w-full items-center border-b border-yellow/50 bg-yellow/30 px-4 py-2 text-sm text-yellow-200">
<FontAwesomeIcon icon={faWarning} className="mr-2.5 text-base text-yellow" />
<span>{message}</span>
- {canManage && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- size="xs"
- variant="outline_bg"
- className="ml-auto"
- isLoading={Boolean(pendingId)}
- rightIcon={<FontAwesomeIcon icon={faChevronDown} className="ml-1.5" />}
- >
- Manage instances
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-[420px]">
- <DropdownMenuLabel>Switch active instance</DropdownMenuLabel>
- <DropdownMenuSeparator />
- {!legacyData || legacyData.instances.length === 0 ? (
- <div className="px-2 py-3 text-xs text-muted">No instances available.</div>
- ) : (
- legacyData.instances.map((i) => (
- <DropdownMenuItem
- key={i.id}
- onClick={() => handlePick(i.id, i.name)}
- isDisabled={Boolean(pendingId)}
- >
- <div className="flex w-full items-center gap-2">
- <div className="flex min-w-0 flex-1 flex-col">
- <div className="flex items-baseline gap-x-2">
- <span className="truncate font-medium">{i.name}</span>
- <span className="font-mono text-xs text-accent">{i.slug}</span>
- </div>
- <span className="text-xs text-muted">
- {i.certificateCount} cert{i.certificateCount === 1 ? "" : "s"} ·{" "}
- {i.syncCount} sync{i.syncCount === 1 ? "" : "s"} · {i.alertCount} alert
- {i.alertCount === 1 ? "" : "s"}
- </span>
- </div>
- {i.isActive && (
- <FontAwesomeIcon icon={faCheck} className="text-xs text-success" />
- )}
- </div>
- </DropdownMenuItem>
- ))
- )}
- </DropdownMenuContent>
- </DropdownMenu>
- )}
</div>
);
};
diff --git a/frontend/src/pages/cert-manager/ApplicationsPage/ApplicationsPage.tsx b/frontend/src/pages/cert-manager/ApplicationsPage/ApplicationsPage.tsx
index d884e0c6e4..edfd552f39 100644
--- a/frontend/src/pages/cert-manager/ApplicationsPage/ApplicationsPage.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationsPage/ApplicationsPage.tsx
@@ -32,6 +32,7 @@ import {
TooltipContent,
TooltipTrigger
} from "@app/components/v3";
+import { useProjectPermission } from "@app/context";
import {
TPkiApplication,
useDeletePkiApplication,
@@ -47,6 +48,8 @@ export const ApplicationsPage = () => {
const navigate = useNavigate();
const { data: applications, isPending } = useListPkiApplications();
const deleteApp = useDeletePkiApplication();
+ const { hasProjectRole } = useProjectPermission();
+ const canCreateApplication = hasProjectRole("admin");
const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
"application",
@@ -169,12 +172,14 @@ export const ApplicationsPage = () => {
<Card>
<CardHeader>
<CardTitle>Applications</CardTitle>
- <CardAction>
- <Button variant="project" onClick={() => handlePopUpOpen("application")}>
- <PlusIcon />
- Create Application
- </Button>
- </CardAction>
+ {canCreateApplication ? (
+ <CardAction>
+ <Button variant="project" onClick={() => handlePopUpOpen("application")}>
+ <PlusIcon />
+ Create Application
+ </Button>
+ </CardAction>
+ ) : null}
</CardHeader>
<CardContent>{renderApplications()}</CardContent>
</Card>
diff --git a/frontend/src/pages/cert-manager/ApplicationsPage/components/PkiApplicationModal.tsx b/frontend/src/pages/cert-manager/ApplicationsPage/components/PkiApplicationModal.tsx
index 7cde67f67f..962f913332 100644
--- a/frontend/src/pages/cert-manager/ApplicationsPage/components/PkiApplicationModal.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationsPage/components/PkiApplicationModal.tsx
@@ -105,7 +105,7 @@ export const PkiApplicationModal = ({ popUp, handlePopUpToggle }: Props) => {
<DialogDescription>
{editing
? "Update the Application's metadata. Changing the name will invalidate any deep links."
- : "Group the Profiles, members, and approval policies for one workload, like a service, environment, or team, so issuance and access are managed together."}
+ : "Group the profiles, members, and approval policies for one workload, like a service, environment, or team, so issuance and access are managed together."}
</DialogDescription>
</DialogHeader>
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/AssignCertificateToApplicationModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/AssignCertificateToApplicationModal.tsx
new file mode 100644
index 0000000000..87a17b0aca
--- /dev/null
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/AssignCertificateToApplicationModal.tsx
@@ -0,0 +1,109 @@
+import { useEffect, useState } from "react";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldContent,
+ FieldLabel,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue
+} from "@app/components/v3";
+import { useAssignCertificateToApplication } from "@app/hooks/api/certificates";
+import { useListPkiApplications } from "@app/hooks/api/pkiApplications";
+
+type Props = {
+ isOpen: boolean;
+ onClose: () => void;
+ certificateId: string;
+};
+
+export const AssignCertificateToApplicationModal = ({ isOpen, onClose, certificateId }: Props) => {
+ const [selectedApplicationId, setSelectedApplicationId] = useState<string>("");
+ const { data: applications = [], isPending } = useListPkiApplications(undefined, {
+ enabled: isOpen
+ });
+ const assign = useAssignCertificateToApplication();
+
+ useEffect(() => {
+ if (!isOpen) setSelectedApplicationId("");
+ }, [isOpen]);
+
+ const handleSubmit = async () => {
+ if (!selectedApplicationId) return;
+ try {
+ await assign.mutateAsync({ certificateId, applicationId: selectedApplicationId });
+ createNotification({ type: "success", text: "Certificate assigned to Application" });
+ onClose();
+ } catch (err) {
+ const detail = err instanceof Error ? err.message : "Failed to assign certificate.";
+ createNotification({ type: "error", text: detail });
+ }
+ };
+
+ return (
+ <Dialog open={isOpen} onOpenChange={(o) => !o && onClose()}>
+ <DialogContent className="max-w-md">
+ <DialogHeader>
+ <DialogTitle>Assign Certificate to Application</DialogTitle>
+ <DialogDescription>
+ This is a one-way operation, once assigned, the certificate cannot be moved to a
+ different Application.
+ </DialogDescription>
+ </DialogHeader>
+
+ <Field>
+ <FieldLabel>Application</FieldLabel>
+ <FieldContent>
+ <Select
+ value={selectedApplicationId}
+ onValueChange={setSelectedApplicationId}
+ disabled={isPending || applications.length === 0}
+ >
+ <SelectTrigger className="w-full">
+ <SelectValue
+ placeholder={
+ applications.length === 0
+ ? "No applications available"
+ : "Select an application"
+ }
+ />
+ </SelectTrigger>
+ <SelectContent>
+ {applications.map((app) => (
+ <SelectItem key={app.id} value={app.id}>
+ {app.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </FieldContent>
+ </Field>
+
+ <DialogFooter>
+ <Button type="button" variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ <Button
+ type="button"
+ variant="project"
+ isPending={assign.isPending}
+ isDisabled={!selectedApplicationId || assign.isPending}
+ onClick={handleSubmit}
+ >
+ Assign
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+};
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
index b0510e8d03..4efd0e4ee0 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
@@ -7,6 +7,7 @@ import {
ArrowDownIcon,
ArrowUpIcon,
BanIcon,
+ BoxIcon,
ClockIcon,
DownloadIcon,
EyeIcon,
@@ -85,6 +86,7 @@ import { useListWorkspaceCertificates } from "@app/hooks/api/projects";
import { UsePopUpState } from "@app/hooks/usePopUp";
import { ActiveFilterChips } from "./ActiveFilterChips";
+import { AssignCertificateToApplicationModal } from "./AssignCertificateToApplicationModal";
import {
getCertSourceLabel,
getCertValidUntilBadgeDetails,
@@ -232,7 +234,7 @@ export const CertificatesTable = ({
const navigate = useNavigate();
const { currentOrg } = useOrganization();
const { currentProject } = useProject();
- const { permission } = useProjectPermission();
+ const { permission, hasProjectRole } = useProjectPermission();
const canReadViews = permission.can(
ProjectPermissionActions.Read,
@@ -255,6 +257,7 @@ export const CertificatesTable = ({
const [visibleColumns, setVisibleColumns] = useState<Set<string>>(() =>
getDefaultVisibleColumns(projectId)
);
+ const [assignTargetId, setAssignTargetId] = useState<string | null>(null);
const { data: profilesData } = useListCertificateProfiles({
limit: 100
@@ -780,6 +783,9 @@ export const CertificatesTable = ({
{visibleColumns.has("profile") && (
<TableHead className="max-w-[120px] min-w-[80px]">Profile</TableHead>
)}
+ {visibleColumns.has("application") && (
+ <TableHead className="max-w-[140px] min-w-[80px]">Application</TableHead>
+ )}
{visibleColumns.has("algorithm") && (
<TableHead className="w-[90px]">Algorithm</TableHead>
)}
@@ -895,6 +901,11 @@ export const CertificatesTable = ({
{certificate.profileName || <EmptyCell />}
</TableCell>
)}
+ {visibleColumns.has("application") && (
+ <TableCell isTruncatable>
+ {certificate.applicationName || <EmptyCell />}
+ </TableCell>
+ )}
{visibleColumns.has("algorithm") && (
<TableCell>
<span className="text-xs">
@@ -1225,6 +1236,19 @@ export const CertificatesTable = ({
)}
</ProjectPermissionCan>
)}
+ {hasProjectRole("admin") &&
+ !certificate.applicationId &&
+ certificate.source !== CertSource.Discovered && (
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ setAssignTargetId(certificate.id);
+ }}
+ >
+ <BoxIcon />
+ Assign to Application
+ </DropdownMenuItem>
+ )}
{(() => {
const caType = caCapabilityMap[certificate.caId];
const supportsRevocation =
@@ -1338,6 +1362,14 @@ export const CertificatesTable = ({
}}
applicationId={applicationId}
/>
+
+ {assignTargetId ? (
+ <AssignCertificateToApplicationModal
+ isOpen={Boolean(assignTargetId)}
+ onClose={() => setAssignTargetId(null)}
+ certificateId={assignTargetId}
+ />
+ ) : null}
</div>
);
};
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/ColumnVisibilityToggle.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/ColumnVisibilityToggle.tsx
index 2ad475185b..83d5465d80 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/ColumnVisibilityToggle.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/ColumnVisibilityToggle.tsx
@@ -26,6 +26,7 @@ export const INVENTORY_COLUMNS: ColumnDef[] = [
{ key: "expiresAt", label: "Expires", defaultVisible: true },
{ key: "ca", label: "CA", defaultVisible: true },
{ key: "profile", label: "Profile", defaultVisible: true },
+ { key: "application", label: "Application", defaultVisible: false },
{ key: "algorithm", label: "Algorithm", defaultVisible: true },
{ key: "source", label: "Source", defaultVisible: false }
];
diff --git a/frontend/src/pages/middlewares/inject-org-details.tsx b/frontend/src/pages/middlewares/inject-org-details.tsx
index 3692bab8ec..fb3b630cb7 100644
--- a/frontend/src/pages/middlewares/inject-org-details.tsx
+++ b/frontend/src/pages/middlewares/inject-org-details.tsx
@@ -3,6 +3,7 @@ import { createFileRoute, isRedirect, redirect } from "@tanstack/react-router";
import SecurityClient from "@app/components/utilities/SecurityClient";
import { SessionStorageKeys } from "@app/const";
import { authKeys, fetchAuthToken, selectOrganization } from "@app/hooks/api/auth/queries";
+import { certManagerInstanceKeys } from "@app/hooks/api/certManagerInstance";
import { fetchOrganizationById, organizationKeys } from "@app/hooks/api/organization/queries";
import { projectKeys } from "@app/hooks/api/projects";
import { fetchUserOrgPermissions, roleQueryKeys } from "@app/hooks/api/roles/queries";
@@ -44,6 +45,7 @@ export const Route = createFileRoute("/_authenticate/_inject-org-details")({
context.queryClient.removeQueries({ queryKey: authKeys.getAuthToken });
context.queryClient.removeQueries({ queryKey: projectKeys.getAllUserProjects() });
context.queryClient.removeQueries({ queryKey: subOrganizationsQuery.allKey() });
+ context.queryClient.removeQueries({ queryKey: certManagerInstanceKeys.all });
await context.queryClient.fetchQuery({
queryKey: authKeys.getAuthToken,
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx
index 529da34976..f62d4afea6 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx
@@ -1,19 +1,282 @@
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@app/components/v3";
-import { ActiveInstancePicker } from "@app/layouts/PkiManagerLayout/components/ActiveInstancePicker";
+import { useEffect, useState } from "react";
+import { useQueryClient } from "@tanstack/react-query";
+import {
+ ArrowRightIcon,
+ BoxIcon,
+ MoreHorizontalIcon,
+ StarIcon,
+ Trash2Icon,
+ TriangleAlertIcon
+} from "lucide-react";
+
+import { createNotification } from "@app/components/notifications";
+import { DeleteActionModal } from "@app/components/v2";
+import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
+ Badge,
+ Button,
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ IconButton,
+ Item,
+ ItemContent,
+ ItemDescription,
+ ItemMedia,
+ ItemTitle,
+ PageLoader,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow
+} from "@app/components/v3";
+import { useOrgPermission } from "@app/context";
+import {
+ OrgPermissionCertManagerActions,
+ OrgPermissionSubjects
+} from "@app/context/OrgPermissionContext/types";
+import {
+ certManagerInstanceKeys,
+ TCertManagerLegacyInstance,
+ useCertManagerInstanceState,
+ useCertManagerLegacyInstances,
+ useSetCertManagerActiveProject
+} from "@app/hooks/api/certManagerInstance";
+import { useDeleteWorkspace } from "@app/hooks/api/projects";
export const OrgCertManagerTab = () => {
+ const queryClient = useQueryClient();
+ const { permission } = useOrgPermission();
+ const canManage = permission.can(
+ OrgPermissionCertManagerActions.ManageInstance,
+ OrgPermissionSubjects.CertManager
+ );
+
+ const { data: instanceState } = useCertManagerInstanceState();
+ const { data: legacyData, isPending } = useCertManagerLegacyInstances();
+ const setActive = useSetCertManagerActiveProject();
+ const deleteWorkspace = useDeleteWorkspace();
+
+ const instances = legacyData?.instances ?? [];
+ const isMultiInstance = Boolean(instanceState?.isMultiInstance);
+
+ const [pendingActive, setPendingActive] = useState<TCertManagerLegacyInstance | null>(null);
+ const [pendingDelete, setPendingDelete] = useState<TCertManagerLegacyInstance | null>(null);
+
+ useEffect(() => {
+ if (pendingDelete && !instances.find((i) => i.id === pendingDelete.id)) {
+ setPendingDelete(null);
+ }
+ if (pendingActive && !instances.find((i) => i.id === pendingActive.id)) {
+ setPendingActive(null);
+ }
+ }, [instances, pendingDelete, pendingActive]);
+
+ if (isPending) {
+ return (
+ <div className="h-32">
+ <PageLoader lottieClassName="w-16" />
+ </div>
+ );
+ }
+ if (instances.length <= 1) return null;
+
+ const active = instances.find((i) => i.isActive);
+
+ const handleConfirmActive = async () => {
+ if (!pendingActive) return;
+ try {
+ await setActive.mutateAsync(pendingActive.id);
+ createNotification({
+ type: "success",
+ text: `${pendingActive.name} is now the active Certificate Manager instance for the organization.`
+ });
+ setPendingActive(null);
+ } catch (err) {
+ const detail = err instanceof Error ? err.message : "Failed to switch active instance.";
+ createNotification({ type: "error", text: detail });
+ }
+ };
+
+ const handleConfirmDelete = async () => {
+ if (!pendingDelete) return;
+ try {
+ await deleteWorkspace.mutateAsync({ projectID: pendingDelete.id });
+ createNotification({
+ type: "success",
+ text: `${pendingDelete.name} has been deleted.`
+ });
+ await queryClient.invalidateQueries({ queryKey: certManagerInstanceKeys.all });
+ setPendingDelete(null);
+ } catch (err) {
+ const detail = err instanceof Error ? err.message : "Failed to delete project.";
+ createNotification({ type: "error", text: detail });
+ }
+ };
+
return (
- <Card>
- <CardHeader>
- <CardTitle>Certificate Manager</CardTitle>
- <CardDescription>
- Pick which Certificate Manager instance the product launches into. API requests without a
- projectId resolve to the active instance.
- </CardDescription>
- </CardHeader>
- <CardContent>
- <ActiveInstancePicker />
- </CardContent>
- </Card>
+ <>
+ {isMultiInstance && (
+ <Alert variant="warning" className="mb-4">
+ <TriangleAlertIcon />
+ <AlertTitle>Multi-project Certificate Manager will be deprecated soon</AlertTitle>
+ <AlertDescription>
+ Consolidate to a single Certificate Manager project for this organization. You can
+ change the active project below or delete projects you no longer need.
+ </AlertDescription>
+ </Alert>
+ )}
+ <Card>
+ <CardHeader>
+ <CardTitle>Certificate Manager</CardTitle>
+ <CardDescription>
+ Manage the Certificate Manager projects in this organization. The active project is the
+ one the product launches into and the one API requests without a projectId resolve to.
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead className="w-full">Project</TableHead>
+ <TableHead className="whitespace-nowrap">Status</TableHead>
+ <TableHead className="w-5" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {instances.map((instance) => (
+ <TableRow key={instance.id}>
+ <TableCell className="w-full">
+ <div className="flex items-center gap-x-2">
+ <BoxIcon className="size-4 shrink-0 text-project" />
+ <span className="font-mono">{instance.name}</span>
+ <span className="font-mono text-xs text-accent">{instance.slug}</span>
+ </div>
+ </TableCell>
+ <TableCell className="whitespace-nowrap">
+ {instance.isActive ? <Badge variant="success">Active</Badge> : null}
+ </TableCell>
+ <TableCell>
+ {canManage && !instance.isActive ? (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ aria-label={`Manage ${instance.name}`}
+ >
+ <MoreHorizontalIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="min-w-40" align="end" sideOffset={2}>
+ <DropdownMenuItem onClick={() => setPendingActive(instance)}>
+ <StarIcon />
+ Set as active
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ variant="danger"
+ onClick={() => setPendingDelete(instance)}
+ >
+ <Trash2Icon />
+ Delete project
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ ) : null}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </CardContent>
+ </Card>
+
+ <Dialog
+ open={Boolean(pendingActive)}
+ onOpenChange={(open) => {
+ if (!open) setPendingActive(null);
+ }}
+ >
+ <DialogContent className="max-w-md">
+ <DialogHeader>
+ <DialogTitle>Confirm change</DialogTitle>
+ <DialogDescription>
+ This changes the default Certificate Manager project for the entire organization.
+ </DialogDescription>
+ </DialogHeader>
+
+ <Alert variant="warning">
+ <TriangleAlertIcon />
+ <AlertDescription>
+ Every member in the organization will start landing on this project, and API requests
+ without a projectId will resolve to it.
+ </AlertDescription>
+ </Alert>
+
+ <div className="flex items-center gap-3 rounded-md border border-border bg-card px-3 py-3">
+ <Item variant="default" size="xs" className="flex-1 border-transparent p-0">
+ <ItemMedia>
+ <BoxIcon className="size-4 text-project" />
+ </ItemMedia>
+ <ItemContent>
+ <ItemTitle>{active?.name ?? "—"}</ItemTitle>
+ {active?.slug ? (
+ <ItemDescription className="font-mono">{active.slug}</ItemDescription>
+ ) : null}
+ </ItemContent>
+ </Item>
+ <ArrowRightIcon className="size-4 shrink-0 text-mineshaft-400" aria-hidden />
+ <Item variant="default" size="xs" className="flex-1 border-transparent p-0">
+ <ItemMedia>
+ <BoxIcon className="size-4 text-project" />
+ </ItemMedia>
+ <ItemContent>
+ <ItemTitle>{pendingActive?.name ?? "—"}</ItemTitle>
+ {pendingActive?.slug ? (
+ <ItemDescription className="font-mono">{pendingActive.slug}</ItemDescription>
+ ) : null}
+ </ItemContent>
+ </Item>
+ </div>
+
+ <DialogFooter>
+ <Button variant="ghost" onClick={() => setPendingActive(null)}>
+ Cancel
+ </Button>
+ <Button variant="project" isPending={setActive.isPending} onClick={handleConfirmActive}>
+ Confirm change
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+
+ <DeleteActionModal
+ isOpen={Boolean(pendingDelete)}
+ onChange={(open) => {
+ if (!open) setPendingDelete(null);
+ }}
+ title={`Delete ${pendingDelete?.name ?? "this project"}?`}
+ subTitle="This permanently deletes the Certificate Manager project, including its certificates, profiles, applications, and approval policies. This cannot be undone."
+ deleteKey={pendingDelete?.slug ?? "delete"}
+ onDeleteApproved={handleConfirmDelete}
+ buttonText="Delete project"
+ />
+ </>
);
};