Skip to content

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

feat(frontend): migrate certificate export format modal to v3

Devin AI2b357420b367
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateExportModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateExportModal.tsx
index 93d86d4315..bc9d421573 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateExportModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateExportModal.tsx
@@ -1,19 +1,29 @@
import { useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
-import { faDownload } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
+import { DownloadIcon } from "lucide-react";
import { z } from "zod";
import {
Button,
- FormControl,
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ 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 { UsePopUpState } from "@app/hooks/usePopUp";
type Props = {
@@ -160,97 +170,124 @@ export const CertificateExportModal = ({ popUp, handlePopUpToggle, onFormatSelec
};
return (
- <Modal
- isOpen={popUp?.certificateExport?.isOpen}
+ <Dialog
+ open={popUp?.certificateExport?.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("certificateExport", isOpen);
}}
>
- <ModalContent title="Export Certificate">
- <form onSubmit={handleSubmit(onFormSubmit)}>
- <div className="space-y-4">
- <p className="text-sm text-muted-cool">
- Choose the format for exporting your certificate
- </p>
-
- <Controller
- control={control}
- name="format"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Export Format"
- helperText={
- field.value === "pem"
- ? "Privacy Enhanced Mail - Text-based certificate format"
- : "PKCS12 format - Binary keystore format compatible with Java applications"
- }
- isError={Boolean(error)}
- errorText={error?.message}
- >
- <Select className="w-full" value={field.value} onValueChange={field.onChange}>
- <SelectItem value="pem">PEM Format</SelectItem>
- <SelectItem value="pkcs12">PKCS12 Format</SelectItem>
- </Select>
- </FormControl>
- )}
- />
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Export Certificate</DialogTitle>
+ <DialogDescription>Choose the format for exporting your certificate.</DialogDescription>
+ </DialogHeader>
+ <form onSubmit={handleSubmit(onFormSubmit)} className="flex flex-col gap-4">
+ <Controller
+ control={control}
+ name="format"
+ render={({ field, fieldState: { error } }) => (
+ <Field data-invalid={Boolean(error)}>
+ <FieldLabel htmlFor="certificate-export-format">Export format</FieldLabel>
+ <Select value={field.value} onValueChange={field.onChange}>
+ <SelectTrigger
+ id="certificate-export-format"
+ isError={Boolean(error)}
+ className="w-full"
+ >
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ <SelectItem value="pem">PEM</SelectItem>
+ <SelectItem value="pkcs12">PKCS12</SelectItem>
+ </SelectContent>
+ </Select>
+ <FieldDescription>
+ {field.value === "pem"
+ ? "Privacy Enhanced Mail - Text-based certificate format"
+ : "PKCS12 format - Binary keystore format compatible with Java applications"}
+ </FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
- {selectedFormat === "pkcs12" && (
- <>
- <Controller
- control={control}
- name="pkcs12Password"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Keystore Password"
- helperText="Password to protect the PKCS12 keystore (minimum 6 characters)"
+ {selectedFormat === "pkcs12" && (
+ <>
+ <Controller
+ control={control}
+ name="pkcs12Password"
+ render={({ field, fieldState: { error } }) => (
+ <Field data-invalid={Boolean(error)}>
+ <FieldLabel htmlFor="certificate-export-pkcs12-password">
+ Keystore password
+ <span aria-hidden className="text-danger">
+ *
+ </span>
+ </FieldLabel>
+ <Input
+ {...field}
+ id="certificate-export-pkcs12-password"
+ type="password"
+ placeholder="Enter keystore password"
+ autoComplete="new-password"
+ aria-required
isError={Boolean(error)}
- errorText={error?.message}
- isRequired
- >
- <Input {...field} placeholder="Enter keystore password" type="password" />
- </FormControl>
- )}
- />
+ />
+ <FieldDescription>
+ Password to protect the PKCS12 keystore (minimum 6 characters)
+ </FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
- <Controller
- control={control}
- name="pkcs12Alias"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Certificate Alias"
- helperText="Friendly name for the certificate in the keystore"
+ <Controller
+ control={control}
+ name="pkcs12Alias"
+ render={({ field, fieldState: { error } }) => (
+ <Field data-invalid={Boolean(error)}>
+ <FieldLabel htmlFor="certificate-export-pkcs12-alias">
+ Certificate alias
+ <span aria-hidden className="text-danger">
+ *
+ </span>
+ </FieldLabel>
+ <Input
+ {...field}
+ id="certificate-export-pkcs12-alias"
+ placeholder="Enter certificate alias"
+ autoComplete="off"
+ aria-required
isError={Boolean(error)}
- errorText={error?.message}
- isRequired
- >
- <Input {...field} placeholder="Enter certificate alias" />
- </FormControl>
- )}
- />
- </>
- )}
+ />
+ <FieldDescription>
+ Friendly name for the certificate in the keystore
+ </FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ </>
+ )}
- <div className="flex justify-end space-x-2 pt-4">
- <Button
- variant="outline_bg"
- onClick={() => handlePopUpToggle("certificateExport", false)}
- >
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost" type="button">
Cancel
</Button>
- <Button
- type="submit"
- colorSchema="primary"
- leftIcon={<FontAwesomeIcon icon={faDownload} />}
- disabled={!(certificateId || serialNumber)}
- isLoading={isSubmitting}
- >
- Export {selectedFormat.toUpperCase()}
- </Button>
- </div>
- </div>
+ </DialogClose>
+ <Button
+ variant="project"
+ type="submit"
+ isPending={isSubmitting}
+ isDisabled={!(certificateId || serialNumber) || isSubmitting}
+ >
+ <DownloadIcon />
+ Export {selectedFormat.toUpperCase()}
+ </Button>
+ </DialogFooter>
</form>
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
);
};