Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
@ refactor(frontend): migrate encryption project settings to v3
andrewhuhh997046f1b559
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/EncryptionTab/EncryptionTab.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/EncryptionTab/EncryptionTab.tsxindex e22719c83d..a7074f56a5 100644--- a/frontend/src/pages/secret-manager/SettingsPage/components/EncryptionTab/EncryptionTab.tsx+++ b/frontend/src/pages/secret-manager/SettingsPage/components/EncryptionTab/EncryptionTab.tsx@@ -1,22 +1,34 @@import { ChangeEvent, useRef, useState } from "react";import { Controller, useForm } from "react-hook-form";-import { faUpload } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { zodResolver } from "@hookform/resolvers/zod";import FileSaver from "file-saver";+import { UploadIcon } from "lucide-react";import { z } from "zod";import { createNotification } from "@app/components/notifications";import { ProjectPermissionCan } from "@app/components/permissions";import {Button,- FormControl,- IconButton,- Modal,- ModalContent,+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+ Field,+ FieldError,+ FieldLabel,Select,- SelectItem-} from "@app/components/v2";+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue+} from "@app/components/v3";import {ProjectPermissionActions,ProjectPermissionSub,@@ -81,25 +93,30 @@ const BackupConfirmationModal = ({};return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent title="Create KMS backup">- <p className="mb-6 text-bunker-300">- In case of interruptions with your configured external KMS, you can load a backup to set- the project's KMS back to the default Infisical KMS.- </p>- <Button onClick={downloadKmsBackup} isLoading={isGeneratingBackup}>- Generate- </Button>- <Button- onClick={() => onOpenChange(false)}- colorSchema="secondary"- variant="plain"- className="ml-4"- >- Cancel- </Button>- </ModalContent>- </Modal>+ <Dialog open={isOpen} onOpenChange={onOpenChange}>+ <DialogContent className="max-w-lg">+ <DialogHeader>+ <DialogTitle>Create KMS Backup</DialogTitle>+ <DialogDescription>+ In case of interruptions with your configured external KMS, you can load a backup to set+ the project's KMS back to the default Infisical KMS.+ </DialogDescription>+ </DialogHeader>+ <DialogFooter>+ <Button variant="outline" onClick={() => onOpenChange(false)}>+ Cancel+ </Button>+ <Button+ variant="project"+ onClick={downloadKmsBackup}+ isPending={isGeneratingBackup}+ isDisabled={isGeneratingBackup}+ >+ Generate+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>);};@@ -119,6 +136,14 @@ const LoadBackupModal = ({const [backupContent, setBackupContent] = useState("");const [backupFileName, setBackupFileName] = useState("");+ const handleOpenChange = (state: boolean) => {+ if (!state) {+ setBackupContent("");+ setBackupFileName("");+ }+ onOpenChange(state);+ };+const uploadKmsBackup = async () => {if (!project || !org) {return;@@ -130,7 +155,7 @@ const LoadBackupModal = ({type: "success"});- onOpenChange(false);+ handleOpenChange(false);};const parseFile = (file?: File) => {@@ -163,53 +188,55 @@ const LoadBackupModal = ({};return (- <Modal- isOpen={isOpen}- onOpenChange={(state: boolean) => {- setBackupContent("");- setBackupFileName("");- onOpenChange(state);- }}- >- <ModalContent title="Load KMS backup">- <p className="mb-6 text-bunker-300">- By loading a backup, the project's KMS will be switched to the default Infisical KMS.- </p>- <div className="flex justify-center">- <input- id="fileSelect"- className="hidden"- type="file"- accept=".txt"- onChange={handleFileUpload}- ref={fileUploadRef}- />- <IconButton- className="p-10"- ariaLabel="upload-backup"- colorSchema="secondary"+ <Dialog open={isOpen} onOpenChange={handleOpenChange}>+ <DialogContent className="max-w-lg">+ <DialogHeader>+ <DialogTitle>Load KMS Backup</DialogTitle>+ <DialogDescription>+ By loading a backup, the project's KMS will be switched to the default Infisical+ KMS.+ </DialogDescription>+ </DialogHeader>+ <input+ id="fileSelect"+ className="hidden"+ type="file"+ accept=".txt"+ onChange={handleFileUpload}+ ref={fileUploadRef}+ />+ <div className="flex flex-col items-center gap-2 py-2">+ <Button+ type="button"+ variant="outline"onClick={() => {fileUploadRef?.current?.click();}}>- <FontAwesomeIcon icon={faUpload} size="3x" />- </IconButton>+ <UploadIcon className="size-4" />+ Choose backup file+ </Button>+ {backupFileName && (+ <span className="max-w-full truncate px-4 text-center text-sm text-muted">+ {backupFileName}+ </span>+ )}</div>- {backupFileName && (- <div className="mt-2 flex justify-center px-4 text-center">{backupFileName}</div>- )}- {backupContent && (+ <DialogFooter>+ <Button variant="outline" onClick={() => handleOpenChange(false)}>+ Cancel+ </Button><Button+ variant="project"onClick={uploadKmsBackup}- className="mt-10 w-fit"- disabled={isPending}- isLoading={isPending}+ isPending={isPending}+ isDisabled={!backupContent || isPending}>Continue</Button>- )}- </ModalContent>- </Modal>+ </DialogFooter>+ </DialogContent>+ </Dialog>);};@@ -254,73 +281,89 @@ export const EncryptionTab = () => {};return (- <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">- <div className="flex justify-between">- <h2 className="mb-2 flex-1 text-xl font-medium text-mineshaft-100">Key Management</h2>- {kmsKeyId !== INTERNAL_KMS_KEY_ID && (- <div className="space-x-2">- <Button colorSchema="secondary" onClick={() => handlePopUpOpen("loadBackup")}>- Load Backup- </Button>- <Button- colorSchema="secondary"- onClick={() => {- handlePopUpOpen("createBackupConfirmation");- }}- >- Create Backup- </Button>- </div>- )}- </div>-- <p className="mb-4 text-gray-400">- Select which Key Management System to use for encrypting your project data- </p>- <div className="mb-6 max-w-md">- <form onSubmit={handleSubmit(onUpdateProjectKms)}>- <ProjectPermissionCan I={ProjectPermissionActions.Edit} a={ProjectPermissionSub.Kms}>- {(isAllowed) => (- <Controller- render={({ field: { onChange, ...field }, fieldState: { error } }) => (- <FormControl errorText={error?.message} isError={Boolean(error)}>- <Select- {...field}- isDisabled={!isAllowed || isUpdatingProjectKms}- onValueChange={onChange}- isLoading={isUpdatingProjectKms}- className="w-3/4 bg-mineshaft-600"- >- <SelectItem value={INTERNAL_KMS_KEY_ID} key="kms-internal">- Default Infisical KMS- </SelectItem>- {externalKmsList?.map((kms) => (- <SelectItem value={kms.id} key={`kms-${kms.id}`}>- {kms.name}- </SelectItem>- ))}- </Select>- </FormControl>- )}- control={control}- name="kmsKeyId"- />- )}- </ProjectPermissionCan>- <ProjectPermissionCan I={ProjectPermissionActions.Edit} a={ProjectPermissionSub.Project}>- {(isAllowed) => (- <Button- colorSchema="secondary"- type="submit"- isDisabled={!isAllowed || isSubmitting || !isDirty}- isLoading={isSubmitting}- >- Save- </Button>+ <>+ <Card className="mb-6">+ <CardHeader>+ <div className="flex items-start justify-between gap-4">+ <div>+ <CardTitle>Key Management</CardTitle>+ <CardDescription>+ Select which Key Management System to use for encrypting your project data+ </CardDescription>+ </div>+ {kmsKeyId !== INTERNAL_KMS_KEY_ID && (+ <div className="flex gap-2">+ <Button variant="outline" onClick={() => handlePopUpOpen("loadBackup")}>+ Load backup+ </Button>+ <Button+ variant="outline"+ onClick={() => handlePopUpOpen("createBackupConfirmation")}+ >+ Create backup+ </Button>+ </div>)}- </ProjectPermissionCan>- </form>- </div>+ </div>+ </CardHeader>+ <CardContent>+ <form onSubmit={handleSubmit(onUpdateProjectKms)}>+ <ProjectPermissionCan I={ProjectPermissionActions.Edit} a={ProjectPermissionSub.Kms}>+ {(isAllowed) => (+ <Controller+ control={control}+ name="kmsKeyId"+ render={({ field: { onChange, value }, fieldState: { error } }) => (+ <Field className="max-w-md">+ <FieldLabel htmlFor="kmsKeyId">Key management system</FieldLabel>+ <Select+ value={value}+ onValueChange={onChange}+ disabled={!isAllowed || isUpdatingProjectKms}+ >+ <SelectTrigger+ id="kmsKeyId"+ className="w-full"+ aria-label="Key management system"+ >+ <SelectValue placeholder="Select a KMS" />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value={INTERNAL_KMS_KEY_ID} key="kms-internal">+ Default Infisical KMS+ </SelectItem>+ {externalKmsList?.map((kms) => (+ <SelectItem value={kms.id} key={`kms-${kms.id}`}>+ {kms.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <FieldError>{error?.message}</FieldError>+ </Field>+ )}+ />+ )}+ </ProjectPermissionCan>+ <ProjectPermissionCan+ I={ProjectPermissionActions.Edit}+ a={ProjectPermissionSub.Project}+ >+ {(isAllowed) => (+ <Button+ className="mt-4"+ variant="project"+ type="submit"+ isDisabled={!isAllowed || isSubmitting || !isDirty}+ isPending={isSubmitting}+ >+ Save+ </Button>+ )}+ </ProjectPermissionCan>+ </form>+ </CardContent>+ </Card><BackupConfirmationModalisOpen={popUp.createBackupConfirmation.isOpen}onOpenChange={(state: boolean) => handlePopUpToggle("createBackupConfirmation", state)}@@ -333,6 +376,6 @@ export const EncryptionTab = () => {org={currentOrg}workspace={currentProject}/>- </div>+ </>);};