Skip to content

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

improvement(cert-manager): migrate CA and certificate detail overlays to V3 (#8615)

Andrew Huangbff6c1651548
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx
index c9c8df2613..f0ec0ac0f8 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/CertAuthDetailsByIDPage.tsx
@@ -7,7 +7,6 @@ import { EllipsisIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal } from "@app/components/v2";
import {
Button,
DropdownMenu,
@@ -16,6 +15,7 @@ import {
DropdownMenuTrigger,
PageHeader
} from "@app/components/v3";
+import { DeleteConfirmDialog } from "@app/components/v3/platform";
import { ROUTE_PATHS } from "@app/const/routes";
import {
ProjectPermissionCertificateAuthorityActions,
@@ -198,15 +198,15 @@ const Page = () => {
<CaRenewalModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
<CaInstallCertModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
<CaGenerateRootCertModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.deleteCa.isOpen}
title={`Are you sure you want to remove the CA ${
(popUp?.deleteCa?.data as { dn: string })?.dn || ""
}?`}
- subTitle="This action will delete other CAs and certificates below it in your CA hierarchy."
- onChange={(isOpen) => handlePopUpToggle("deleteCa", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={onRemoveCaSubmit}
+ description="This action will delete other CAs and certificates below it in your CA hierarchy."
+ onOpenChange={(isOpen) => handlePopUpToggle("deleteCa", isOpen)}
+ confirmKey="confirm"
+ onConfirm={onRemoveCaSubmit}
/>
</div>
);
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx
index 9005012bc5..9fad3e6db1 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx
@@ -16,20 +16,11 @@ import {
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
-import {
- Button as ButtonV2,
- FormControl,
- Input,
- Modal,
- ModalClose,
- ModalContent,
- Switch as SwitchV2,
- Tooltip as TooltipV2
-} from "@app/components/v2";
import {
Alert,
AlertTitle,
Badge,
+ Button,
Card,
CardAction,
CardContent,
@@ -40,7 +31,19 @@ import {
DetailGroup,
DetailLabel,
DetailValue,
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
IconButton,
+ Input,
+ Toggle,
Tooltip,
TooltipContent,
TooltipTrigger
@@ -213,6 +216,7 @@ export const CaDetailsSection = ({ caId }: Props) => {
{showAutoRenewal && (
<CardAction>
<IconButton
+ aria-label="Edit renewal settings"
variant="outline"
size="xs"
onClick={() => handlePopUpToggle("editAutoRenewal", true)}
@@ -347,13 +351,14 @@ export const CaDetailsSection = ({ caId }: Props) => {
<DetailValue>
{autoRenewal.lastRenewalStatus === CaRenewalStatus.FAILED &&
autoRenewal.lastRenewalMessage ? (
- <TooltipV2
- position="right"
- content={autoRenewal.lastRenewalMessage}
- className="max-w-md break-words"
- >
- <Badge variant="danger">Failed</Badge>
- </TooltipV2>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge variant="danger">Failed</Badge>
+ </TooltipTrigger>
+ <TooltipContent side="right" className="max-w-md break-words">
+ {autoRenewal.lastRenewalMessage}
+ </TooltipContent>
+ </Tooltip>
) : (
<Badge
variant={(() => {
@@ -410,30 +415,31 @@ export const CaDetailsSection = ({ caId }: Props) => {
</CardContent>
</Card>
- <Modal
- isOpen={popUp.editAutoRenewal.isOpen}
+ <Dialog
+ open={popUp.editAutoRenewal.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("editAutoRenewal", isOpen);
if (!isOpen) reset();
}}
>
- <ModalContent title="Edit Renewal Settings">
- <form onSubmit={handleSubmit(onAutoRenewalSubmit)}>
+ <DialogContent isPending={isSubmitting}>
+ <DialogHeader>
+ <DialogTitle>Edit Renewal Settings</DialogTitle>
+ </DialogHeader>
+ <form className="flex flex-col gap-6" onSubmit={handleSubmit(onAutoRenewalSubmit)}>
<Controller
control={control}
name="autoRenewalEnabled"
render={({ field: { value, onChange } }) => (
- <FormControl>
- <SwitchV2
+ <Field orientation="horizontal">
+ <FieldLabel htmlFor="auto-renewal-enabled">Auto-Renewal</FieldLabel>
+ <Toggle
id="auto-renewal-enabled"
- className="bg-muted/80 shadow-inner data-[state=checked]:bg-success/80"
- thumbClassName="bg-surface-raised"
- isChecked={value}
+ variant="project"
+ checked={value}
onCheckedChange={onChange}
- >
- Auto-Renewal
- </SwitchV2>
- </FormControl>
+ />
+ </Field>
)}
/>
{watchEnabled && (
@@ -441,35 +447,37 @@ export const CaDetailsSection = ({ caId }: Props) => {
control={control}
name="autoRenewalDaysBeforeExpiry"
render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Days Before Expiry"
- errorText={error?.message}
- isError={Boolean(error)}
- helperText="Number of days before certificate expiry to trigger auto-renewal"
- >
- <Input {...field} type="number" min={1} max={365} />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="auto-renewal-days-before-expiry">
+ Days Before Expiry
+ </FieldLabel>
+ <Input
+ {...field}
+ id="auto-renewal-days-before-expiry"
+ type="number"
+ min={1}
+ max={365}
+ isError={Boolean(error)}
+ />
+ <FieldDescription>
+ Number of days before certificate expiry to trigger auto-renewal
+ </FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
)}
- <div className="flex w-full justify-between gap-4 pt-4">
- <ModalClose asChild>
- <ButtonV2 colorSchema="secondary" variant="plain">
- Cancel
- </ButtonV2>
- </ModalClose>
- <ButtonV2
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- type="submit"
- colorSchema="secondary"
- >
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </DialogClose>
+ <Button type="submit" variant="project" isPending={isSubmitting}>
Save
- </ButtonV2>
- </div>
+ </Button>
+ </DialogFooter>
</form>
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
</>
);
};
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaGenerateRootCertModal.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaGenerateRootCertModal.tsx
index 811b7c665b..0c0830ea16 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaGenerateRootCertModal.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaGenerateRootCertModal.tsx
@@ -5,13 +5,23 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Button,
- FormControl,
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
Input,
- Modal,
- ModalContent,
Select,
- SelectItem
-} from "@app/components/v2";
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue
+} from "@app/components/v3";
import { useGenerateCaCertificate } from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
@@ -96,76 +106,74 @@ export const CaGenerateRootCertModal = ({ popUp, handlePopUpToggle }: Props) =>
};
return (
- <Modal
- isOpen={popUp?.generateRootCaCert?.isOpen}
+ <Dialog
+ open={popUp?.generateRootCaCert?.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("generateRootCaCert", isOpen);
reset();
}}
>
- <ModalContent title="Generate Root CA Certificate">
- <form onSubmit={handleSubmit(onFormSubmit)}>
+ <DialogContent isPending={isSubmitting}>
+ <DialogHeader>
+ <DialogTitle>Generate Root CA Certificate</DialogTitle>
+ </DialogHeader>
+ <form className="flex flex-col gap-6" onSubmit={handleSubmit(onFormSubmit)}>
<Controller
control={control}
defaultValue=""
name="notAfter"
render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Valid Until"
- isError={Boolean(error)}
- errorText={error?.message}
- isRequired
- >
- <Input {...field} placeholder="YYYY-MM-DD" />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="generate-root-ca-not-after">
+ Valid Until <span className="text-danger">*</span>
+ </FieldLabel>
+ <Input
+ {...field}
+ id="generate-root-ca-not-after"
+ placeholder="YYYY-MM-DD"
+ isError={Boolean(error)}
+ />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
<Controller
control={control}
defaultValue="-1"
name="maxPathLength"
- render={({ field: { onChange, ...field }, fieldState: { error } }) => (
- <FormControl
- label="Max Path Length"
- isError={Boolean(error)}
- errorText={error?.message}
- helperText="Maximum depth of valid certificate paths"
- >
- <Select
- defaultValue={field.value}
- {...field}
- onValueChange={(e) => onChange(e)}
- className="w-full"
- >
- {[-1, 0, 1, 2, 3, 4].map((value) => (
- <SelectItem value={String(value)} key={`ca-max-path-length-${value}`}>
- {`${value}`}
- </SelectItem>
- ))}
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="generate-root-ca-max-path-length">Max Path Length</FieldLabel>
+ <Select value={value} onValueChange={onChange}>
+ <SelectTrigger id="generate-root-ca-max-path-length" className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ {[-1, 0, 1, 2, 3, 4].map((pathLength) => (
+ <SelectItem
+ value={String(pathLength)}
+ key={`ca-max-path-length-${pathLength}`}
+ >
+ {`${pathLength}`}
+ </SelectItem>
+ ))}
+ </SelectContent>
</Select>
- </FormControl>
+ <FieldDescription>Maximum depth of valid certificate paths</FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </DialogClose>
+ <Button type="submit" variant="project" isPending={isSubmitting}>
Generate Certificate
</Button>
- <Button
- colorSchema="secondary"
- variant="plain"
- onClick={() => handlePopUpToggle("generateRootCaCert", false)}
- >
- Cancel
- </Button>
- </div>
+ </DialogFooter>
</form>
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
);
};
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaRenewalModal.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaRenewalModal.tsx
index 689f65ec45..052cfe1f04 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaRenewalModal.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaRenewalModal.tsx
@@ -5,13 +5,23 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Button,
- FormControl,
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldError,
+ FieldLabel,
Input,
- Modal,
- ModalContent,
Select,
- SelectItem
-} from "@app/components/v2";
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue
+} from "@app/components/v3";
import {
CaRenewalType,
CaSigningConfigType,
@@ -38,40 +48,6 @@ const schema = z
export type FormData = z.infer<typeof schema>;
-type ExternalCaRenewalProps = {
- description: string;
- buttonLabel: string;
- onRenew: () => void;
- isRenewing: boolean;
- onCancel: () => void;
-};
-
-const ExternalCaRenewal = ({
- description,
- buttonLabel,
- onRenew,
- isRenewing,
- onCancel
-}: ExternalCaRenewalProps) => (
- <div>
- <p className="mb-4 text-sm text-label">{description}</p>
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- onClick={onRenew}
- isLoading={isRenewing}
- isDisabled={isRenewing}
- >
- {buttonLabel}
- </Button>
- <Button colorSchema="secondary" variant="plain" onClick={onCancel}>
- Cancel
- </Button>
- </div>
- </div>
-);
-
type Props = {
popUp: UsePopUpState<["renewCa"]>;
handlePopUpToggle: (popUpName: keyof UsePopUpState<["renewCa"]>, state?: boolean) => void;
@@ -186,51 +162,60 @@ export const CaRenewalModal = ({ popUp, handlePopUpToggle }: Props) => {
};
return (
- <Modal
- isOpen={popUp?.renewCa?.isOpen}
+ <Dialog
+ open={popUp?.renewCa?.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("renewCa", isOpen);
reset();
}}
>
- <ModalContent title="Renew CA">
- {isVenafi || isAdcs ? (
- <ExternalCaRenewal
- description={
- isVenafi
+ <DialogContent isPending={isSubmitting || isVenafiRenewing || isAdcsRenewing}>
+ <DialogHeader>
+ <DialogTitle>Renew CA</DialogTitle>
+ {(isVenafi || isAdcs) && (
+ <DialogDescription>
+ {isVenafi
? "This CA is configured to use Venafi TLS Protect Cloud for signing. Clicking renew will submit a new CSR to Venafi and install the renewed certificate."
- : "This CA is configured to use Azure ADCS for signing. Clicking renew will submit a new CSR to ADCS and install the renewed certificate."
- }
- buttonLabel={isVenafi ? "Renew via Venafi" : "Renew via ADCS"}
- onRenew={isVenafi ? onVenafiRenew : onAdcsRenew}
- isRenewing={isVenafi ? isVenafiRenewing : isAdcsRenewing}
- onCancel={() => handlePopUpToggle("renewCa", false)}
- />
+ : "This CA is configured to use Azure ADCS for signing. Clicking renew will submit a new CSR to ADCS and install the renewed certificate."}
+ </DialogDescription>
+ )}
+ </DialogHeader>
+ {isVenafi || isAdcs ? (
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </DialogClose>
+ <Button
+ variant="project"
+ onClick={isVenafi ? onVenafiRenew : onAdcsRenew}
+ isPending={isVenafi ? isVenafiRenewing : isAdcsRenewing}
+ >
+ {isVenafi ? "Renew via Venafi" : "Renew via ADCS"}
+ </Button>
+ </DialogFooter>
) : (
- <form onSubmit={handleSubmit(onFormSubmit)}>
+ <form className="flex flex-col gap-6" onSubmit={handleSubmit(onFormSubmit)}>
<Controller
control={control}
name="type"
defaultValue={CaRenewalType.EXISTING}
- render={({ field: { onChange, ...field }, fieldState: { error } }) => (
- <FormControl
- label="CA Renewal Method"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <Select
- defaultValue={field.value}
- {...field}
- onValueChange={(e) => onChange(e)}
- className="w-full"
- >
- {caRenewalTypes.map(({ label, value }) => (
- <SelectItem value={String(value || "")} key={label}>
- {label}
- </SelectItem>
- ))}
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="ca-renewal-type">CA Renewal Method</FieldLabel>
+ <Select value={value} onValueChange={onChange}>
+ <SelectTrigger id="ca-renewal-type" className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ {caRenewalTypes.map(({ label, value: renewalType }) => (
+ <SelectItem value={String(renewalType || "")} key={label}>
+ {label}
+ </SelectItem>
+ ))}
+ </SelectContent>
</Select>
- </FormControl>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
<Controller
@@ -238,37 +223,31 @@ export const CaRenewalModal = ({ popUp, handlePopUpToggle }: Props) => {
defaultValue=""
name="notAfter"
render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Valid Until"
- isError={Boolean(error)}
- errorText={error?.message}
- isRequired
- >
- <Input {...field} placeholder="YYYY-MM-DD" />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="ca-renewal-not-after">
+ Valid Until <span className="text-danger">*</span>
+ </FieldLabel>
+ <Input
+ {...field}
+ id="ca-renewal-not-after"
+ placeholder="YYYY-MM-DD"
+ isError={Boolean(error)}
+ />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </DialogClose>
+ <Button type="submit" variant="project" isPending={isSubmitting}>
Renew
</Button>
- <Button
- colorSchema="secondary"
- variant="plain"
- onClick={() => handlePopUpToggle("renewCa", false)}
- >
- Cancel
- </Button>
- </div>
+ </DialogFooter>
</form>
)}
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
);
};
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaSigningConfigSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaSigningConfigSection.tsx
index e726ea17c2..b0e0b5215f 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaSigningConfigSection.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaSigningConfigSection.tsx
@@ -1,5 +1,4 @@
import { Controller, useForm } from "react-hook-form";
-import { SingleValue } from "react-select";
import { subject } from "@casl/ability";
import { zodResolver } from "@hookform/resolvers/zod";
import { PencilIcon } from "lucide-react";
@@ -7,28 +6,38 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
-import {
- Button as ButtonV2,
- FilterableSelect,
- FormControl,
- Input,
- Modal,
- ModalClose,
- ModalContent
-} from "@app/components/v2";
import {
Badge,
+ Button,
Card,
CardAction,
CardContent,
CardDescription,
CardHeader,
CardTitle,
+ Combobox,
Detail,
DetailGroup,
DetailLabel,
DetailValue,
- IconButton
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
+ IconButton,
+ Input,
+ Sheet,
+ SheetClose,
+ SheetContent,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle
} from "@app/components/v3";
import {
ProjectPermissionCertificateAuthorityActions,
@@ -43,21 +52,17 @@ import {
useGetCaSigningConfig,
useUpdateCaSigningConfig
} from "@app/hooks/api";
-import {
- TAvailableAppConnection,
- useListAvailableAppConnections
-} from "@app/hooks/api/appConnections";
+import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";
import { useAdcsConnectionListCertificateTemplates } from "@app/hooks/api/appConnections/adcs";
import { useAzureAdcsConnectionListTemplates } from "@app/hooks/api/appConnections/azure-adcs";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import {
- TVenafiApplication,
- TVenafiIssuingTemplate,
useVenafiConnectionListApplications,
useVenafiConnectionListIssuingTemplates
} from "@app/hooks/api/appConnections/venafi";
import { TInternalCertificateAuthority } from "@app/hooks/api/ca/types";
import { usePopUp } from "@app/hooks/usePopUp";
+import { useConnectionCreation } from "@app/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/useConnectionCreation";
type Props = {
caId: string;
@@ -176,6 +181,7 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
control: azureAdcsControl,
handleSubmit: handleAzureAdcsSubmit,
reset: azureAdcsReset,
+ setValue: azureAdcsSetValue,
watch: azureAdcsWatch,
formState: { isSubmitting: isAzureAdcsSubmitting }
} = useForm<AzureAdcsEditFormData>({
@@ -203,6 +209,7 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
control: nativeAdcsControl,
handleSubmit: handleNativeAdcsSubmit,
reset: nativeAdcsReset,
+ setValue: nativeAdcsSetValue,
watch: nativeAdcsWatch,
formState: { isSubmitting: isNativeAdcsSubmitting }
} = useForm<NativeAdcsEditFormData>({
@@ -220,6 +227,23 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
enabled: !!selectedNativeAdcsConnectionId && popUp.editSigningConfig.isOpen
});
+ const venafiConnectionCreation = useConnectionCreation(AppConnection.Venafi, (connection) => {
+ setValue("appConnectionId", connection.id, { shouldDirty: true });
+ setValue("applicationId", "");
+ setValue("issuingTemplateId", "");
+ });
+ const azureAdcsConnectionCreation = useConnectionCreation(
+ AppConnection.AzureADCS,
+ (connection) => {
+ azureAdcsSetValue("appConnectionId", connection.id, { shouldDirty: true });
+ azureAdcsSetValue("template", "", { shouldDirty: true });
+ }
+ );
+ const nativeAdcsConnectionCreation = useConnectionCreation(AppConnection.ADCS, (connection) => {
+ nativeAdcsSetValue("appConnectionId", connection.id, { shouldDirty: true });
+ nativeAdcsSetValue("template", "", { shouldDirty: true });
+ });
+
if (!ca || ca.status === CaStatus.PENDING_CERTIFICATE || !signingConfig) {
return null;
}
@@ -347,15 +371,19 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
</Card>
{isAzureAdcs && (
- <Modal
- isOpen={popUp.editSigningConfig.isOpen}
+ <Sheet
+ open={popUp.editSigningConfig.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("editSigningConfig", isOpen);
if (!isOpen) azureAdcsReset();
}}
>
- <ModalContent title="Edit Signing Configuration" bodyClassName="overflow-visible">
+ <SheetContent size="form" isPending={isAzureAdcsSubmitting}>
+ <SheetHeader>
+ <SheetTitle>Edit Signing Configuration</SheetTitle>
+ </SheetHeader>
<form
+ className="flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto px-4 pt-4"
onSubmit={handleAzureAdcsSubmit(
async ({ appConnectionId, template, validityPeriod }: AzureAdcsEditFormData) => {
try {
@@ -385,48 +413,51 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
control={azureAdcsControl}
name="appConnectionId"
render={({ field: { onChange, value }, fieldState: { error } }) => (
- <FormControl
- label="Azure AD CS Connection"
- errorText={error?.message}
- isError={Boolean(error)}
- isRequired
- >
- <FilterableSelect
+ <Field>
+ <FieldLabel htmlFor="signing-config-azure-ad-cs-connection">
+ Azure AD CS Connection <span className="text-danger">*</span>
+ </FieldLabel>
+ <Combobox
+ isError={Boolean(error)}
+ isClearable={false}
+ id="signing-config-azure-ad-cs-connection"
+ creation={azureAdcsConnectionCreation}
isLoading={isAzureAdcsConnectionsPending}
value={(availableAzureAdcsConnections || []).find(
(conn) => conn.id === value
)}
- onChange={(option) => {
- const selected = option as SingleValue<TAvailableAppConnection>;
- onChange(selected?.id ?? "");
+ onValueChange={(selected) => {
+ onChange(selected.id);
+ azureAdcsSetValue("template", "", { shouldDirty: true });
}}
options={availableAzureAdcsConnections || []}
placeholder="Select an Azure AD CS connection..."
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.id}
/>
- </FormControl>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
<Controller
control={azureAdcsControl}
name="template"
render={({ field: { onChange, value }, fieldState: { error } }) => (
- <FormControl
- label="Certificate Template"
- errorText={error?.message}
- isError={Boolean(error)}
- isRequired
- >
- <FilterableSelect
+ <Field>
+ <FieldLabel htmlFor="signing-config-certificate-template">
+ Certificate Template <span className="text-danger">*</span>
+ </FieldLabel>
+ <Combobox
+ isError={Boolean(error)}
+ isClearable={false}
+ id="signing-config-certificate-template"
isLoading={isAzureAdcsTemplatesLoading && !!selectedAzureAdcsConnectionId}
isDisabled={!selectedAzureAdcsConnectionId}
value={
azureAdcsTemplates.find((t) => t === value) ? { label: value, value } : null
}
- onChange={(option) => {
- const selected = option as SingleValue<{ label: string; value: string }>;
- onChange(selected?.value ?? "");
+ onValueChange={(selected) => {
+ onChange(selected.value);
}}
options={azureAdcsTemplates.map((t) => ({ label: t, value: t }))}
placeholder={
@@ -437,53 +468,59 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
getOptionLabel={(option) => option.label}
getOptionValue={(option) => option.value}
/>
- </FormControl>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
<Controller
control={azureAdcsControl}
name="validityPeriod"
render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Validity Period (Days)"
- errorText={error?.message}
- isError={Boolean(error)}
- helperText="Number of days the certificate should be valid"
- >
- <Input {...field} type="number" placeholder="365" />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="signing-config-validity-period-days">
+ Validity Period (Days)
+ </FieldLabel>
+ <Input
+ id="signing-config-validity-period-days"
+ isError={Boolean(error)}
+ {...field}
+ type="number"
+ placeholder="365"
+ />
+ <FieldDescription>
+ Number of days the certificate should be valid
+ </FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
- <div className="flex w-full justify-between gap-4 pt-4">
- <ModalClose asChild>
- <ButtonV2 colorSchema="secondary" variant="plain">
- Cancel
- </ButtonV2>
- </ModalClose>
- <ButtonV2
- isLoading={isAzureAdcsSubmitting}
- isDisabled={isAzureAdcsSubmitting}
- type="submit"
- colorSchema="secondary"
- >
+ <SheetFooter className="-mx-4 justify-end">
+ <SheetClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </SheetClose>
+ <Button type="submit" variant="project" isPending={isAzureAdcsSubmitting}>
Save
- </ButtonV2>
- </div>
+ </Button>
+ </SheetFooter>
</form>
- </ModalContent>
- </Modal>
+ </SheetContent>
+ </Sheet>
)}
{isNativeAdcs && (
- <Modal
- isOpen={popUp.editSigningConfig.isOpen}
+ <Dialog
+ open={popUp.editSigningConfig.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("editSigningConfig", isOpen);
if (!isOpen) nativeAdcsReset();
}}
>
- <ModalContent title="Edit Signing Configuration" bodyClassName="overflow-visible">
+ <DialogContent isPending={isNativeAdcsSubmitting}>
+ <DialogHeader>
+ <DialogTitle>Edit Signing Configuration</DialogTitle>
+ </DialogHeader>
<form
+ className="flex flex-col gap-6"
onSubmit={handleNativeAdcsSubmit(
async ({ appConnectionId, template }: NativeAdcsEditFormData) => {
try {
@@ -512,40 +549,44 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
control={nativeAdcsControl}
name="appConnectionId"
render={({ field: { onChange, value }, fieldState: { error } }) => (
- <FormControl
- label="ADCS Connection"
- errorText={error?.message}
- isError={Boolean(error)}
- isRequired
- >
- <FilterableSelect
+ <Field>
+ <FieldLabel htmlFor="signing-config-adcs-connection">
+ ADCS Connection <span className="text-danger">*</span>
+ </FieldLabel>
+ <Combobox
+ isError={Boolean(error)}
+ isClearable={false}
+ id="signing-config-adcs-connection"
+ creation={nativeAdcsConnectionCreation}
isLoading={isNativeAdcsConnectionsPending}
value={(availableNativeAdcsConnections || []).find(
(conn) => conn.id === value
)}
- onChange={(option) => {
- const selected = option as SingleValue<TAvailableAppConnection>;
- onChange(selected?.id ?? "");
+ onValueChange={(selected) => {
+ onChange(selected.id);
+ nativeAdcsSetValue("template", "", { shouldDirty: true });
}}
options={availableNativeAdcsConnections || []}
placeholder="Select an ADCS connection..."
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.id}
/>
- </FormControl>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
<Controller
control={nativeAdcsControl}
name="template"
render={({ field: { onChange, value }, fieldState: { error } }) => (
- <FormControl
- label="Certificate Template"
- errorText={error?.message}
- isError={Boolean(error)}
- isRequired
- >
- <FilterableSelect
+ <Field>
+ <FieldLabel htmlFor="signing-config-certificate-template-2">
+ Certificate Template <span className="text-danger">*</span>
+ </FieldLabel>
+ <Combobox
+ isError={Boolean(error)}
+ isClearable={false}
+ id="signing-config-certificate-template-2"
isLoading={isNativeAdcsTemplatesLoading && !!selectedNativeAdcsConnectionId}
isDisabled={!selectedNativeAdcsConnectionId}
value={
@@ -553,9 +594,8 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
? { label: value, value }
: null
}
- onChange={(option) => {
- const selected = option as SingleValue<{ label: string; value: string }>;
- onChange(selected?.value ?? "");
+ onValueChange={(selected) => {
+ onChange(selected.value);
}}
options={nativeAdcsTemplates.map((t) => ({ label: t.name, value: t.name }))}
placeholder={
@@ -566,55 +606,58 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
getOptionLabel={(option) => option.label}
getOptionValue={(option) => option.value}
/>
- </FormControl>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
- <div className="flex w-full justify-between gap-4 pt-4">
- <ModalClose asChild>
- <ButtonV2 colorSchema="secondary" variant="plain">
- Cancel
- </ButtonV2>
- </ModalClose>
- <ButtonV2
- isLoading={isNativeAdcsSubmitting}
- isDisabled={isNativeAdcsSubmitting}
- type="submit"
- colorSchema="secondary"
- >
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </DialogClose>
+ <Button type="submit" variant="project" isPending={isNativeAdcsSubmitting}>
Save
- </ButtonV2>
- </div>
+ </Button>
+ </DialogFooter>
</form>
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
)}
{isVenafi && (
- <Modal
- isOpen={popUp.editSigningConfig.isOpen}
+ <Sheet
+ open={popUp.editSigningConfig.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("editSigningConfig", isOpen);
if (!isOpen) reset();
}}
>
- <ModalContent title="Edit Signing Configuration" bodyClassName="overflow-visible">
- <form onSubmit={handleSubmit(onEditSubmit)}>
+ <SheetContent size="form" isPending={isSubmitting}>
+ <SheetHeader>
+ <SheetTitle>Edit Signing Configuration</SheetTitle>
+ </SheetHeader>
+ <form
+ className="flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto px-4 pt-4"
+ onSubmit={handleSubmit(onEditSubmit)}
+ >
<Controller
control={control}
name="appConnectionId"
render={({ field: { onChange, value }, fieldState: { error } }) => (
- <FormControl
- label="Venafi Connection"
- errorText={error?.message}
- isError={Boolean(error)}
- isRequired
- >
- <FilterableSelect
+ <Field>
+ <FieldLabel htmlFor="signing-config-venafi-connection">
+ Venafi Connection <span className="text-danger">*</span>
+ </FieldLabel>
+ <Combobox
+ isError={Boolean(error)}
+ isClearable={false}
+ id="signing-config-venafi-connection"
+ creation={venafiConnectionCreation}
isLoading={isVenafiPending}
- value={(availableVenafiConnections || []).find((conn) => conn.id === value)}
- onChange={(option) => {
- const selected = option as SingleValue<TAvailableAppConnection>;
- onChange(selected?.id ?? "");
+ value={
+ (availableVenafiConnections || []).find((conn) => conn.id === value) ?? null
+ }
+ onValueChange={(selected) => {
+ onChange(selected.id);
setValue("applicationId", "");
setValue("issuingTemplateId", "");
}}
@@ -623,26 +666,27 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.id}
/>
- </FormControl>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
<Controller
control={control}
name="applicationId"
render={({ field: { onChange, value }, fieldState: { error } }) => (
- <FormControl
- label="Application"
- errorText={error?.message}
- isError={Boolean(error)}
- isRequired
- >
- <FilterableSelect
+ <Field>
+ <FieldLabel htmlFor="signing-config-application">
+ Application <span className="text-danger">*</span>
+ </FieldLabel>
+ <Combobox
+ isError={Boolean(error)}
+ isClearable={false}
+ id="signing-config-application"
isLoading={isApplicationsLoading && !!selectedConnectionId}
isDisabled={!selectedConnectionId}
- value={applications.find((app) => app.id === value)}
- onChange={(option) => {
- const selected = option as SingleValue<TVenafiApplication>;
- onChange(selected?.id ?? "");
+ value={applications.find((app) => app.id === value) ?? null}
+ onValueChange={(selected) => {
+ onChange(selected.id);
setValue("issuingTemplateId", "");
}}
options={applications}
@@ -654,26 +698,27 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.id}
/>
- </FormControl>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
<Controller
control={control}
name="issuingTemplateId"
render={({ field: { onChange, value }, fieldState: { error } }) => (
- <FormControl
- label="Issuing Template"
- errorText={error?.message}
- isError={Boolean(error)}
- isRequired
- >
- <FilterableSelect
+ <Field>
+ <FieldLabel htmlFor="signing-config-issuing-template">
+ Issuing Template <span className="text-danger">*</span>
+ </FieldLabel>
+ <Combobox
+ isError={Boolean(error)}
+ isClearable={false}
+ id="signing-config-issuing-template"
isLoading={isTemplatesLoading && !!selectedApplicationId}
isDisabled={!selectedApplicationId}
- value={issuingTemplates.find((tmpl) => tmpl.id === value)}
- onChange={(option) => {
- const selected = option as SingleValue<TVenafiIssuingTemplate>;
- onChange(selected?.id ?? "");
+ value={issuingTemplates.find((tmpl) => tmpl.id === value) ?? null}
+ onValueChange={(selected) => {
+ onChange(selected.id);
}}
options={issuingTemplates}
placeholder={
@@ -684,41 +729,43 @@ export const CaSigningConfigSection = ({ caId }: Props) => {
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.id}
/>
- </FormControl>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
<Controller
control={control}
name="validityPeriod"
render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Validity Period (Days)"
- errorText={error?.message}
- isError={Boolean(error)}
- helperText="Number of days the certificate should be valid"
- >
- <Input {...field} type="number" placeholder="365" />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="signing-config-validity-period-days-2">
+ Validity Period (Days)
+ </FieldLabel>
+ <Input
+ id="signing-config-validity-period-days-2"
+ isError={Boolean(error)}
+ {...field}
+ type="number"
+ placeholder="365"
+ />
+ <FieldDescription>
+ Number of days the certificate should be valid
+ </FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
- <div className="flex w-full justify-between gap-4 pt-4">
- <ModalClose asChild>
- <ButtonV2 colorSchema="secondary" variant="plain">
- Cancel
- </ButtonV2>
- </ModalClose>
- <ButtonV2
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- type="submit"
- colorSchema="secondary"
- >
+ <SheetFooter className="-mx-4 justify-end">
+ <SheetClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </SheetClose>
+ <Button type="submit" variant="project" isPending={isSubmitting}>
Save
- </ButtonV2>
- </div>
+ </Button>
+ </SheetFooter>
</form>
- </ModalContent>
- </Modal>
+ </SheetContent>
+ </Sheet>
)}
</>
);
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
index da9e893dd0..b49511c40f 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
@@ -7,7 +7,6 @@ import {
} from "@app/components/license/UpgradeGate";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal } from "@app/components/v2";
import {
Button,
Card,
@@ -18,6 +17,7 @@ import {
CardTitle,
DocumentationLinkBadge
} from "@app/components/v3";
+import { DeleteConfirmDialog } from "@app/components/v3/platform";
import {
ProjectPermissionCertificateAuthorityActions,
ProjectPermissionSub,
@@ -156,36 +156,36 @@ export const CaSection = () => {
{upgradeGate}
<CaInstallCertModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
<CaCertModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.deleteCa.isOpen}
title={`Are you sure you want to remove the CA ${
(popUp?.deleteCa?.data as { dn: string })?.dn || ""
}?`}
- subTitle={`This action will delete other CAs and certificates below it in your CA hierarchy.${
+ description={`This action will delete other CAs and certificates below it in your CA hierarchy.${
pendingDeleteHsmKeyLabel
? ` This CA's key on the HSM (label: ${pendingDeleteHsmKeyLabel}) is not removed automatically and will remain as an orphaned key.`
: ""
}`}
- onChange={(isOpen) => handlePopUpToggle("deleteCa", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={() => onRemoveCaSubmit((popUp?.deleteCa?.data as { caId: string })?.caId)}
+ onOpenChange={(isOpen) => handlePopUpToggle("deleteCa", isOpen)}
+ confirmKey="confirm"
+ onConfirm={() => onRemoveCaSubmit((popUp?.deleteCa?.data as { caId: string })?.caId)}
/>
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.caStatus.isOpen}
title={`Are you sure you want to ${
(popUp?.caStatus?.data as { status: string })?.status === CaStatus.ACTIVE
? "enable"
: "disable"
} the CA ${(popUp?.caStatus?.data as { dn: string })?.dn || ""}?`}
- subTitle={
+ description={
(popUp?.caStatus?.data as { status: string })?.status === CaStatus.ACTIVE
? "This action will allow the CA to start issuing certificates again."
: "This action will prevent the CA from issuing new certificates."
}
- onChange={(isOpen) => handlePopUpToggle("caStatus", isOpen)}
- buttonText="Confirm"
- deleteKey="confirm"
- onDeleteApproved={() =>
+ onOpenChange={(isOpen) => handlePopUpToggle("caStatus", isOpen)}
+ confirmLabel="Confirm"
+ confirmKey="confirm"
+ onConfirm={() =>
onUpdateCaStatus(popUp?.caStatus?.data as { caId: string; status: CaStatus })
}
/>
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx
index 6a28249faf..9e3c0175b4 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx
@@ -6,7 +6,6 @@ import {
} from "@app/components/license/UpgradeGate";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal } from "@app/components/v2";
import {
Button,
Card,
@@ -17,6 +16,7 @@ import {
CardTitle,
DocumentationLinkBadge
} from "@app/components/v3";
+import { DeleteConfirmDialog } from "@app/components/v3/platform";
import {
ProjectPermissionCertificateAuthorityActions,
ProjectPermissionSub,
@@ -121,37 +121,37 @@ export const ExternalCaSection = () => {
<ExternalCaTable handlePopUpOpen={handlePopUpOpen} />
</CardContent>
<ExternalCaModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.deleteCa.isOpen}
title={`Are you sure you want to remove the CA ${
(popUp?.deleteCa?.data as { dn: string })?.dn || ""
}?`}
- subTitle="This action will delete other CAs and certificates below it in your CA hierarchy."
- onChange={(isOpen) => handlePopUpToggle("deleteCa", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={() =>
+ description="This action will delete other CAs and certificates below it in your CA hierarchy."
+ onOpenChange={(isOpen) => handlePopUpToggle("deleteCa", isOpen)}
+ confirmKey="confirm"
+ onConfirm={() =>
onRemoveCaSubmit(
(popUp?.deleteCa?.data as { caId: string })?.caId,
(popUp?.deleteCa?.data as { type: CaType })?.type
)
}
/>
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.caStatus.isOpen}
title={`Are you sure you want to ${
(popUp?.caStatus?.data as { status: string })?.status === CaStatus.ACTIVE
? "enable"
: "disable"
} the CA ${(popUp?.caStatus?.data as { dn: string })?.dn || ""}?`}
- subTitle={
+ description={
(popUp?.caStatus?.data as { status: string })?.status === CaStatus.ACTIVE
? "This action will allow the CA to start issuing certificates again."
: "This action will prevent the CA from issuing new certificates."
}
- onChange={(isOpen) => handlePopUpToggle("caStatus", isOpen)}
- buttonText="Proceed"
- deleteKey="confirm"
- onDeleteApproved={() =>
+ onOpenChange={(isOpen) => handlePopUpToggle("caStatus", isOpen)}
+ confirmLabel="Proceed"
+ confirmKey="confirm"
+ onConfirm={() =>
onUpdateCaStatus(
popUp?.caStatus?.data as { caId: string; type: CaType; status: CaStatus }
)
diff --git a/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/CertificateDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/CertificateDetailsByIDPage.tsx
index f8856b9b57..aa675b163d 100644
--- a/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/CertificateDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/CertificateDetailsByIDPage.tsx
@@ -5,7 +5,6 @@ import { ChevronLeftIcon, EllipsisIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { getCertificateDisplayName } from "@app/components/utilities/certificateDisplayUtils";
-import { DeleteActionModal, EmptyState } from "@app/components/v2";
import {
AccessRestrictedDialog,
Button,
@@ -13,12 +12,16 @@ import {
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
+ Empty,
+ EmptyHeader,
+ EmptyTitle,
PageHeader,
PageLoader,
Tooltip,
TooltipContent,
TooltipTrigger
} from "@app/components/v3";
+import { DeleteConfirmDialog } from "@app/components/v3/platform";
import { ROUTE_PATHS } from "@app/const/routes";
import {
ProjectPermissionCertificateActions,
@@ -303,7 +306,13 @@ const Page = () => {
let pageBody: React.ReactNode = null;
if (!certificate) {
- pageBody = <EmptyState title="Error: Unable to find the certificate." className="py-12" />;
+ pageBody = (
+ <Empty className="border border-dashed">
+ <EmptyHeader>
+ <EmptyTitle>Error: Unable to find the certificate.</EmptyTitle>
+ </EmptyHeader>
+ </Empty>
+ );
} else if (!canReadCertificate) {
pageBody = (
<AccessRestrictedDialog
@@ -531,13 +540,13 @@ const Page = () => {
handlePopUpToggle={handlePopUpToggle}
applicationName={fromApplication}
/>
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.deleteCertificate.isOpen}
title="Are you sure you want to delete this certificate?"
- subTitle="This action cannot be undone. The certificate will be permanently deleted."
- onChange={(isOpen) => handlePopUpToggle("deleteCertificate", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={onDeleteCertificateSubmit}
+ description="This action cannot be undone. The certificate will be permanently deleted."
+ onOpenChange={(isOpen) => handlePopUpToggle("deleteCertificate", isOpen)}
+ confirmKey="confirm"
+ onConfirm={onDeleteCertificateSubmit}
/>
</div>
);
diff --git a/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateMetadataSection.tsx b/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateMetadataSection.tsx
index a0c90dda8b..a3c643b74d 100644
--- a/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateMetadataSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateMetadataSection.tsx
@@ -1,14 +1,14 @@
-import { useCallback, useEffect, useState } from "react";
-import { useForm } from "react-hook-form";
+import { useCallback, useEffect, useId, useState } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
import { subject } from "@casl/ability";
import { zodResolver } from "@hookform/resolvers/zod";
-import { PencilIcon } from "lucide-react";
+import { PencilIcon, PlusIcon, TrashIcon } from "lucide-react";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
-import { Button, Modal, ModalContent } from "@app/components/v2";
import {
Badge,
+ Button,
ButtonGroup,
Card,
CardAction,
@@ -16,7 +16,18 @@ import {
CardDescription,
CardHeader,
CardTitle,
- IconButton
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldError,
+ FieldLabel,
+ IconButton,
+ Input
} from "@app/components/v3";
import {
ProjectPermissionCertificateActions,
@@ -30,7 +41,6 @@ import {
PkiApplicationResourceActions,
PkiApplicationResourceSub
} from "@app/hooks/api/pkiApplications/types";
-import { MetadataForm } from "@app/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/MetadataForm";
type Props = {
certificateId: string;
@@ -52,6 +62,7 @@ export const CertificateMetadataSection = ({ certificateId }: Props) => {
const { data, isLoading } = useGetCertificateById(certificateId);
const { mutateAsync: updateMetadata } = useUpdateCertificate();
const [isModalOpen, setIsModalOpen] = useState(false);
+ const fieldId = useId();
const certificate = data?.certificate;
const metadata = certificate?.metadata || [];
@@ -86,6 +97,7 @@ export const CertificateMetadataSection = ({ certificateId }: Props) => {
metadata: metadata.length > 0 ? metadata : []
}
});
+ const metadataFields = useFieldArray({ control, name: "metadata" });
useEffect(() => {
if (metadata) {
@@ -142,6 +154,7 @@ export const CertificateMetadataSection = ({ certificateId }: Props) => {
<CardDescription>Custom key-value pairs attached to this certificate</CardDescription>
<CardAction>
<IconButton
+ aria-label="Edit certificate metadata"
variant="outline"
size="xs"
onClick={() => {
@@ -180,26 +193,78 @@ export const CertificateMetadataSection = ({ certificateId }: Props) => {
</CardContent>
</Card>
- <Modal isOpen={isModalOpen} onOpenChange={setIsModalOpen}>
- <ModalContent
- title="Edit Metadata"
- subTitle="Update metadata key-value pairs for this certificate."
- >
- <MetadataForm control={control} title="" />
- <div className="mt-4 flex justify-end gap-2">
- <Button variant="outline_bg" onClick={handleCancel}>
- Cancel
- </Button>
- <Button
- onClick={handleSubmit(onSubmit)}
- isLoading={formState.isSubmitting}
- isDisabled={formState.isSubmitting}
- >
- Save
- </Button>
- </div>
- </ModalContent>
- </Modal>
+ <Dialog open={isModalOpen} onOpenChange={setIsModalOpen}>
+ <DialogContent isPending={formState.isSubmitting}>
+ <DialogHeader>
+ <DialogTitle>Edit Metadata</DialogTitle>
+ <DialogDescription>
+ Update metadata key-value pairs for this certificate.
+ </DialogDescription>
+ </DialogHeader>
+ <form className="flex flex-col gap-6" onSubmit={handleSubmit(onSubmit)}>
+ <div className="flex flex-col gap-3">
+ {metadataFields.fields.length === 0 && (
+ <p className="text-sm text-muted">No metadata entries</p>
+ )}
+ {metadataFields.fields.map(({ id }, index) => (
+ <div key={id} className="flex items-start gap-2">
+ <Controller
+ control={control}
+ name={`metadata.${index}.key`}
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor={`${fieldId}-${id}-key`}>Key</FieldLabel>
+ <Input {...field} id={`${fieldId}-${id}-key`} isError={Boolean(error)} />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name={`metadata.${index}.value`}
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor={`${fieldId}-${id}-value`}>
+ Value <span className="font-normal text-muted">- Optional</span>
+ </FieldLabel>
+ <Input {...field} id={`${fieldId}-${id}-value`} isError={Boolean(error)} />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ <IconButton
+ aria-label="Remove metadata entry"
+ variant="ghost"
+ className="mt-6"
+ onClick={() => metadataFields.remove(index)}
+ >
+ <TrashIcon />
+ </IconButton>
+ </div>
+ ))}
+ <Button
+ variant="ghost"
+ size="sm"
+ className="self-start"
+ onClick={() => metadataFields.append({ key: "", value: "" })}
+ >
+ <PlusIcon />
+ Add Entry
+ </Button>
+ </div>
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost" onClick={handleCancel}>
+ Cancel
+ </Button>
+ </DialogClose>
+ <Button type="submit" variant="project" isPending={formState.isSubmitting}>
+ Save
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
</>
);
};
diff --git a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/CertificatePolicyDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/CertificatePolicyDetailsByIDPage.tsx
index 5bb21ccaf4..1f24daf9c4 100644
--- a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/CertificatePolicyDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/CertificatePolicyDetailsByIDPage.tsx
@@ -7,8 +7,8 @@ import { Link, useNavigate, useParams, useSearch } from "@tanstack/react-router"
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal } from "@app/components/v2";
import { PageHeader } from "@app/components/v3";
+import { DeleteConfirmDialog } from "@app/components/v3/platform";
import { ROUTE_PATHS } from "@app/const/routes";
import { useOrganization } from "@app/context";
import {
@@ -175,12 +175,13 @@ const Page = () => {
mode="edit"
/>
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={isDeleteModalOpen}
title={`Delete Certificate Policy ${policy.name}?`}
- onChange={(isOpen) => setIsDeleteModalOpen(isOpen)}
- deleteKey={policy.name}
- onDeleteApproved={handleDeleteConfirm}
+ description="This action is irreversible."
+ onOpenChange={(isOpen) => setIsDeleteModalOpen(isOpen)}
+ confirmKey={policy.name}
+ onConfirm={handleDeleteConfirm}
/>
</div>
) : null
diff --git a/frontend/src/pages/cert-manager/CertificateProfileDetailsByIDPage/CertificateProfileDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/CertificateProfileDetailsByIDPage/CertificateProfileDetailsByIDPage.tsx
index 1f0fa905b4..ef8207e0e1 100644
--- a/frontend/src/pages/cert-manager/CertificateProfileDetailsByIDPage/CertificateProfileDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/CertificateProfileDetailsByIDPage/CertificateProfileDetailsByIDPage.tsx
@@ -7,8 +7,8 @@ import { Link, useNavigate, useParams, useSearch } from "@tanstack/react-router"
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal } from "@app/components/v2";
import { PageHeader } from "@app/components/v3";
+import { DeleteConfirmDialog } from "@app/components/v3/platform";
import { ROUTE_PATHS } from "@app/const/routes";
import { useOrganization } from "@app/context";
import {
@@ -148,12 +148,13 @@ const Page = () => {
mode="edit"
/>
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={isDeleteModalOpen}
title={`Delete Certificate Profile ${profile.slug}?`}
- onChange={(isOpen) => setIsDeleteModalOpen(isOpen)}
- deleteKey={profile.slug}
- onDeleteApproved={handleDeleteConfirm}
+ description="This action is irreversible."
+ onOpenChange={(isOpen) => setIsDeleteModalOpen(isOpen)}
+ confirmKey={profile.slug}
+ onConfirm={handleDeleteConfirm}
/>
</div>
) : null
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
index 0b794e3001..7e25bb2606 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
@@ -2,7 +2,6 @@ import { ImportIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal } from "@app/components/v2";
import {
Button,
Card,
@@ -13,6 +12,7 @@ import {
CardTitle,
DocumentationLinkBadge
} from "@app/components/v3";
+import { DeleteConfirmDialog } from "@app/components/v3/platform";
import {
ProjectPermissionCertificateActions,
ProjectPermissionSub,
@@ -212,15 +212,15 @@ export const CertificatesSection = ({
handlePopUpToggle={handlePopUpToggle}
applicationName={applicationName}
/>
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.deleteCertificate.isOpen}
title={`Are you sure you want to remove the certificate ${
(popUp?.deleteCertificate?.data as { commonName: string })?.commonName || ""
}?`}
- subTitle="This action cannot be undone."
- onChange={(isOpen) => handlePopUpToggle("deleteCertificate", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={() =>
+ description="This action cannot be undone."
+ onOpenChange={(isOpen) => handlePopUpToggle("deleteCertificate", isOpen)}
+ confirmKey="confirm"
+ onConfirm={() =>
onRemoveCertificateSubmit(
(popUp?.deleteCertificate?.data as { certificateId: string })?.certificateId
)