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
improvement(project): redesign general settings (#8116)
Andrew Huangf16149a9b073
diff --git a/frontend/src/components/project/ProjectOverviewChangeSection.tsx b/frontend/src/components/project/ProjectOverviewChangeSection.tsxindex 72de82b57d..0399230ab6 100644--- a/frontend/src/components/project/ProjectOverviewChangeSection.tsx+++ b/frontend/src/components/project/ProjectOverviewChangeSection.tsx@@ -8,15 +8,20 @@ import { ProjectPermissionCan } from "@app/components/permissions";import {Button,Card,- CardAction,CardContent,+ CardDescription,+ CardFooter,CardHeader,CardTitle,+ CopyButton,Field,FieldError,FieldGroup,FieldLabel,Input,+ InputGroup,+ InputGroupAddon,+ InputGroupInput,TextArea} from "@app/components/v3";import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";@@ -31,20 +36,7 @@ const baseFormSchema = z.object({.optional()});-const formSchemaWithSlug = baseFormSchema.extend({- slug: z- .string()- .min(1, "Required")- .max(64, "Too long, maximum length is 64 characters")- .regex(- /^[a-z0-9]+(?:[_-][a-z0-9]+)*$/,- "Project slug can only contain lowercase letters and numbers, with optional single hyphens (-) or underscores (_) between words. Cannot start or end with a hyphen or underscore."- )-});-type BaseFormData = z.infer<typeof baseFormSchema>;-type FormDataWithSlug = z.infer<typeof formSchemaWithSlug>;-type Props = {showSlugField?: boolean;};@@ -52,78 +44,46 @@ type Props = {export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) => {const { currentProject } = useProject();const { mutateAsync, isPending } = useUpdateProject();- const { handleSubmit, control, reset, watch } = useForm<BaseFormData | FormDataWithSlug>({- resolver: zodResolver(showSlugField ? formSchemaWithSlug : baseFormSchema)- });-- const currentSlug = showSlugField ? watch("slug") : currentProject?.slug;+ const {+ handleSubmit,+ control,+ reset,+ formState: { isDirty }+ } = useForm<BaseFormData>({ resolver: zodResolver(baseFormSchema) });useEffect(() => {if (currentProject) {reset({name: currentProject.name,- description: currentProject.description ?? "",- ...(showSlugField && { slug: currentProject.slug })+ description: currentProject.description ?? ""});}- }, [currentProject, showSlugField]);+ }, [currentProject, reset]);- const onFormSubmit = async (data: BaseFormData | FormDataWithSlug) => {+ const onFormSubmit = async (data: BaseFormData) => {if (!currentProject?.id) return;await mutateAsync({projectId: currentProject.id,newProjectName: data.name,- newProjectDescription: data.description,- ...(showSlugField &&- "slug" in data && {- newSlug: data.slug !== currentProject.slug ? data.slug : undefined- })+ newProjectDescription: data.description});createNotification({text: "Successfully updated project overview",type: "success"});+ reset(data);};return (- <Card className="mb-6">- <CardHeader>- <CardTitle>Project Overview</CardTitle>- <CardAction className="flex flex-wrap gap-2">- <Button- variant="outline"- size="sm"- onClick={() => {- navigator.clipboard.writeText(currentSlug || "");- createNotification({- text: "Copied project slug to clipboard",- type: "success"- });- }}- title="Click to copy project slug"- >- Copy Project Slug- </Button>- <Button- variant="outline"- size="sm"- onClick={() => {- navigator.clipboard.writeText(currentProject?.id || "");- createNotification({- text: "Copied project ID to clipboard",- type: "success"- });- }}- title="Click to copy project ID"- >- Copy Project ID- </Button>- </CardAction>- </CardHeader>- <CardContent>- <form onSubmit={handleSubmit(onFormSubmit)} className="flex max-w-md flex-col gap-4">+ <form onSubmit={handleSubmit(onFormSubmit)} className="mb-6">+ <Card className="gap-0 overflow-hidden p-0">+ <CardHeader className="p-6">+ <CardTitle className="font-alliance">Project Overview</CardTitle>+ <CardDescription>Update your project name and description.</CardDescription>+ </CardHeader>+ <CardContent className="max-w-md px-6 pb-6"><FieldGroup><ProjectPermissionCanI={ProjectPermissionActions.Edit}@@ -139,7 +99,7 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) =id="project-name"placeholder="Project name"{...field}- disabled={!isAllowed}+ disabled={!isAllowed || isPending}isError={Boolean(error)}autoComplete="off"name="project-name"@@ -153,31 +113,31 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) =)}</ProjectPermissionCan>{showSlugField && (- <ProjectPermissionCan- I={ProjectPermissionActions.Edit}- a={ProjectPermissionSub.Project}- >- {(isAllowed) => (- <Controller- defaultValue=""- render={({ field, fieldState: { error } }) => (- <Field data-invalid={Boolean(error)}>- <FieldLabel htmlFor="project-slug">Project slug</FieldLabel>- <Input- id="project-slug"- placeholder="Project slug"- {...field}- disabled={!isAllowed}- isError={Boolean(error)}- />- <FieldError>{error?.message}</FieldError>- </Field>- )}- control={control}- name="slug"+ <Field>+ <FieldLabel htmlFor="project-slug">Project slug</FieldLabel>+ <InputGroup>+ <InputGroupInput id="project-slug" value={currentProject?.slug ?? ""} readOnly />+ <InputGroupAddon align="inline-end">+ <CopyButton value={currentProject?.slug ?? ""} ariaLabel="Copy project slug" />+ </InputGroupAddon>+ </InputGroup>+ </Field>+ )}+ {showSlugField && (+ <Field>+ <FieldLabel htmlFor="project-id">Project ID</FieldLabel>+ <InputGroup>+ <InputGroupInput+ id="project-id"+ value={currentProject?.id ?? ""}+ readOnly+ className="font-mono text-muted"/>- )}- </ProjectPermissionCan>+ <InputGroupAddon align="inline-end">+ <CopyButton value={currentProject?.id ?? ""} ariaLabel="Copy project ID" />+ </InputGroupAddon>+ </InputGroup>+ </Field>)}<ProjectPermissionCanI={ProjectPermissionActions.Edit}@@ -195,7 +155,7 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) ={...field}rows={3}className="resize-none"- disabled={!isAllowed}+ disabled={!isAllowed || isPending}isError={Boolean(error)}/><FieldError>{error?.message}</FieldError>@@ -207,15 +167,23 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) =)}</ProjectPermissionCan></FieldGroup>+ </CardContent>+ <CardFooter className="min-h-8 justify-end border-t border-neutral/15 bg-neutral/5 p-4"><ProjectPermissionCan I={ProjectPermissionActions.Edit} a={ProjectPermissionSub.Project}>{(isAllowed) => (- <Button variant="project" type="submit" isPending={isPending} isDisabled={!isAllowed}>- Save+ <Button+ variant="project"+ size="sm"+ type="submit"+ isPending={isPending}+ isDisabled={!isAllowed || !isDirty}+ >+ Save changes</Button>)}</ProjectPermissionCan>- </form>- </CardContent>- </Card>+ </CardFooter>+ </Card>+ </form>);};diff --git a/frontend/src/pages/project/SettingsPage/components/AuditLogsRetentionSection/AuditLogsRetentionSection.tsx b/frontend/src/pages/project/SettingsPage/components/AuditLogsRetentionSection/AuditLogsRetentionSection.tsxindex 8c524b9608..32d517c31c 100644--- a/frontend/src/pages/project/SettingsPage/components/AuditLogsRetentionSection/AuditLogsRetentionSection.tsx+++ b/frontend/src/pages/project/SettingsPage/components/AuditLogsRetentionSection/AuditLogsRetentionSection.tsx@@ -9,6 +9,7 @@ import {Card,CardContent,CardDescription,+ CardFooter,CardHeader,CardTitle,Field,@@ -88,17 +89,19 @@ export const AuditLogsRetentionSection = () => {const isAdmin = hasProjectRole(ProjectMembershipRole.Admin);return (<>- <Card className="mb-6">- <CardHeader>- <CardTitle>Audit Logs Retention</CardTitle>- <CardDescription>Set the number of days to keep your project audit logs.</CardDescription>- </CardHeader>- <CardContent>- <form- onSubmit={handleSubmit(handleAuditLogsRetentionSubmit)}- autoComplete="off"- className="flex flex-col items-start gap-4"- >+ <form+ onSubmit={handleSubmit(handleAuditLogsRetentionSubmit)}+ autoComplete="off"+ className="mb-6"+ >+ <Card className="gap-0 overflow-hidden p-0">+ <CardHeader className="p-6">+ <CardTitle className="font-alliance">Audit Logs Retention</CardTitle>+ <CardDescription>+ Set the number of days to keep your project audit logs.+ </CardDescription>+ </CardHeader>+ <CardContent className="max-w-xs px-6 pb-6"><Controllercontrol={control}defaultValue={0}@@ -119,17 +122,20 @@ export const AuditLogsRetentionSection = () => {</Field>)}/>+ </CardContent>+ <CardFooter className="min-h-8 justify-end border-t border-neutral/15 bg-neutral/5 p-4"><Buttonvariant="project"+ size="sm"type="submit"isPending={isSubmitting}isDisabled={!isAdmin || !isDirty}>- Save+ Save changes</Button>- </form>- </CardContent>- </Card>+ </CardFooter>+ </Card>+ </form><UpgradePlanModalisOpen={popUp.upgradePlan.isOpen}onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}diff --git a/frontend/src/pages/project/SettingsPage/components/DeleteProjectProtection/DeleteProjectProtection.tsx b/frontend/src/pages/project/SettingsPage/components/DeleteProjectProtection/DeleteProjectProtection.tsxdeleted file mode 100644index 65ec472008..0000000000--- a/frontend/src/pages/project/SettingsPage/components/DeleteProjectProtection/DeleteProjectProtection.tsx+++ /dev/null@@ -1,70 +0,0 @@-import { createNotification } from "@app/components/notifications";-import { ProjectPermissionCan } from "@app/components/permissions";-import {- Card,- CardContent,- CardHeader,- CardTitle,- Checkbox,- Field,- FieldContent,- FieldLabel-} from "@app/components/v3";-import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";-import { useUpdateProject } from "@app/hooks/api";--export const DeleteProjectProtection = () => {- const { projectId, currentProject } = useProject();-- const { mutateAsync, isPending } = useUpdateProject();-- const handleToggleDeleteProjectProtection = async (state: boolean) => {- await mutateAsync({- projectId,- hasDeleteProtection: state- });-- const text = `Successfully ${state ? "enabled" : "disabled"} delete protection`;- createNotification({- text,- type: "success"- });- };-- return (- <Card className="mb-6">- <CardHeader>- <CardTitle>Delete Protection</CardTitle>- </CardHeader>- <CardContent>- <ProjectPermissionCan I={ProjectPermissionActions.Edit} a={ProjectPermissionSub.Settings}>- {(isAllowed) => (- <Field- orientation="horizontal"- data-disabled={!isAllowed || isPending}- className="items-start"- >- <Checkbox- id="hasDeleteProtection"- variant="project"- isDisabled={!isAllowed || isPending}- isChecked={currentProject?.hasDeleteProtection ?? false}- onCheckedChange={(state) => {- if (state !== "indeterminate") {- handleToggleDeleteProjectProtection(state);- }- }}- />- <FieldContent>- <FieldLabel htmlFor="hasDeleteProtection" size="sm">- Protects the project from being deleted accidentally. While this option is- enabled, you can't delete the project.- </FieldLabel>- </FieldContent>- </Field>- )}- </ProjectPermissionCan>- </CardContent>- </Card>- );-};diff --git a/frontend/src/pages/project/SettingsPage/components/DeleteProjectProtection/index.tsx b/frontend/src/pages/project/SettingsPage/components/DeleteProjectProtection/index.tsxdeleted file mode 100644index 38761cf0a9..0000000000--- a/frontend/src/pages/project/SettingsPage/components/DeleteProjectProtection/index.tsx+++ /dev/null@@ -1 +0,0 @@-export { DeleteProjectProtection } from "./DeleteProjectProtection";diff --git a/frontend/src/pages/project/SettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx b/frontend/src/pages/project/SettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsxindex 204e56fe3e..f31b1c90ea 100644--- a/frontend/src/pages/project/SettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx+++ b/frontend/src/pages/project/SettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx@@ -1,9 +1,11 @@import { useNavigate } from "@tanstack/react-router";-import { TriangleAlert } from "lucide-react";+import { Trash2Icon } from "lucide-react";import { createNotification } from "@app/components/notifications";import { ProjectPermissionCan } from "@app/components/permissions";import {+ Alert,+ AlertDescription as AlertContent,AlertDialog,AlertDialogAction,AlertDialogCancel,@@ -12,13 +14,15 @@ import {AlertDialogDescription,AlertDialogFooter,AlertDialogHeader,- AlertDialogMedia,AlertDialogTitle,Button,Card,- CardContent,+ CardAction,+ CardDescription,+ CardFooter,CardHeader,CardTitle,+ Toggle,Tooltip,TooltipContent,TooltipTrigger@@ -31,7 +35,7 @@ import {useProjectPermission} from "@app/context";import { useToggle } from "@app/hooks";-import { useDeleteWorkspace, useLeaveProject } from "@app/hooks/api";+import { useDeleteWorkspace, useLeaveProject, useUpdateProject } from "@app/hooks/api";import { usePopUp } from "@app/hooks/usePopUp";const CONFIRM_KEYWORD = "confirm";@@ -52,6 +56,8 @@ export const DeleteProjectSection = () => {const [isLeaving, setIsLeaving] = useToggle();const deleteWorkspace = useDeleteWorkspace();const leaveProject = useLeaveProject();+ const { mutateAsync: updateProject, isPending: isUpdatingDeleteProtection } = useUpdateProject();+ const hasDeleteProtection = currentProject?.hasDeleteProtection ?? false;const handleDeleteWorkspaceSubmit = async () => {setIsDeleting.on();@@ -97,52 +103,134 @@ export const DeleteProjectSection = () => {}};+ const handleToggleDeleteProjectProtection = async (state: boolean) => {+ if (!currentProject) return;++ await updateProject({+ projectId: currentProject.id,+ hasDeleteProtection: state+ });++ createNotification({+ text: `Successfully ${state ? "enabled" : "disabled"} delete protection`,+ type: "success"+ });+ };+const leaveButton = (<Button+ size="sm"isPending={isLeaving}isDisabled={!isDirectMember}- variant="danger"+ variant="neutral"onClick={() => handlePopUpOpen("leaveWorkspace")}>{`Leave ${currentProject?.name}`}</Button>);+ const renderDeleteButton = (isAllowed: boolean) => {+ const isDisabled =+ !isAllowed || isDeleting || isUpdatingDeleteProtection || hasDeleteProtection;+ const deleteButton = (+ <Button+ size="sm"+ isPending={isDeleting}+ isDisabled={isDisabled}+ variant="danger"+ onClick={() => handlePopUpOpen("deleteWorkspace")}+ >+ <Trash2Icon />+ {`Delete ${currentProject?.name}`}+ </Button>+ );++ if (!isAllowed || (!hasDeleteProtection && !isUpdatingDeleteProtection)) return deleteButton;++ return (+ <Tooltip>+ <TooltipTrigger asChild>+ {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- focusable wrapper required so the tooltip explains why the inner button is disabled */}+ <span tabIndex={0}>{deleteButton}</span>+ </TooltipTrigger>+ <TooltipContent>+ {hasDeleteProtection+ ? "Disable delete protection before deleting this project."+ : "Updating delete protection."}+ </TooltipContent>+ </Tooltip>+ );+ };+return (- <Card className="mb-6">- <CardHeader>- <CardTitle>- <TriangleAlert className="size-4 text-danger" />- Danger Zone- </CardTitle>- </CardHeader>- <CardContent className="flex flex-wrap gap-4">- <ProjectPermissionCan I={ProjectPermissionActions.Delete} a={ProjectPermissionSub.Project}>- {(isAllowed) => (- <Button- isPending={isDeleting}- isDisabled={!isAllowed}- variant="danger"- onClick={() => handlePopUpOpen("deleteWorkspace")}+ <>+ <Card className="mb-6 gap-0 overflow-hidden p-0">+ <CardHeader className="p-6">+ <CardTitle className="font-alliance">Delete Protection</CardTitle>+ <CardDescription>Prevent this project from being accidentally deleted.</CardDescription>+ <CardAction className="@xs:self-center">+ <ProjectPermissionCan+ I={ProjectPermissionActions.Edit}+ a={ProjectPermissionSub.Settings}>- {`Delete ${currentProject?.name}`}- </Button>+ {(isAllowed) => (+ <Toggle+ id="hasDeleteProtection"+ variant="project"+ checked={hasDeleteProtection}+ disabled={!isAllowed || isUpdatingDeleteProtection}+ aria-label="Toggle delete protection"+ onCheckedChange={handleToggleDeleteProjectProtection}+ />+ )}+ </ProjectPermissionCan>+ </CardAction>+ </CardHeader>+ <CardFooter className="min-h-8 border-t border-neutral/15 bg-neutral/5 p-4 pl-6">+ <p className="text-sm text-muted">+ {hasDeleteProtection+ ? "Delete protection is enabled. Disable it before deleting this project."+ : "Delete protection is disabled. This project can be deleted by members with permission."}+ </p>+ </CardFooter>+ </Card>++ <Card className="mb-6 gap-0 overflow-hidden p-0">+ <CardHeader className="p-6">+ <CardTitle className="font-alliance">Leave Project</CardTitle>+ <CardDescription>Remove your access to this project and its contents.</CardDescription>+ </CardHeader>+ <CardFooter className="min-h-8 justify-end border-t border-neutral/15 bg-neutral/5 p-4">+ {isDirectMember ? (+ leaveButton+ ) : (+ <Tooltip>+ <TooltipTrigger asChild>+ {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- focusable wrapper required so the tooltip explains why the inner button is disabled */}+ <span tabIndex={0}>{leaveButton}</span>+ </TooltipTrigger>+ <TooltipContent>+ You're a member through a group. Leave the group to remove access.+ </TooltipContent>+ </Tooltip>)}- </ProjectPermissionCan>- {isDirectMember ? (- leaveButton- ) : (- <Tooltip>- <TooltipTrigger asChild>- {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- focusable wrapper required so the tooltip explains why the inner button is disabled */}- <span tabIndex={0}>{leaveButton}</span>- </TooltipTrigger>- <TooltipContent>- You're a member through a group. Leave the group to remove access.- </TooltipContent>- </Tooltip>- )}- </CardContent>+ </CardFooter>+ </Card>++ <Card className="mb-6 gap-0 overflow-hidden border-danger/25 p-0">+ <CardHeader className="p-6">+ <CardTitle className="font-alliance">Danger Zone</CardTitle>+ <CardDescription>Permanently delete this project and all of its data.</CardDescription>+ </CardHeader>+ <CardFooter className="min-h-8 justify-end border-t border-danger/15 bg-danger/5 p-4">+ <ProjectPermissionCan+ I={ProjectPermissionActions.Delete}+ a={ProjectPermissionSub.Project}+ >+ {renderDeleteButton}+ </ProjectPermissionCan>+ </CardFooter>+ </Card><AlertDialogopen={popUp.deleteWorkspace.isOpen}@@ -151,13 +239,14 @@ export const DeleteProjectSection = () => {><AlertDialogContent><AlertDialogHeader>- <AlertDialogMedia>- <TriangleAlert className="text-danger" />- </AlertDialogMedia><AlertDialogTitle>Are you sure you want to delete this project?</AlertDialogTitle>- <AlertDialogDescription>- Permanently delete {currentProject?.name} and all of its data. This action is not- reversible, so please be careful.+ <AlertDialogDescription asChild>+ <Alert variant="danger" appearance="borderless">+ <AlertContent>+ Permanently delete {currentProject?.name} and all of its data. This action is not+ reversible.+ </AlertContent>+ </Alert></AlertDialogDescription></AlertDialogHeader><AlertDialogConfirmationField@@ -189,13 +278,14 @@ export const DeleteProjectSection = () => {><AlertDialogContent><AlertDialogHeader>- <AlertDialogMedia>- <TriangleAlert className="text-danger" />- </AlertDialogMedia><AlertDialogTitle>Are you sure you want to leave this project?</AlertDialogTitle>- <AlertDialogDescription>- If you leave {currentProject?.name} you will lose access to the project and its- contents.+ <AlertDialogDescription asChild>+ <Alert variant="warning" appearance="borderless">+ <AlertContent>+ Leaving {currentProject?.name} removes your access to the project and its+ contents.+ </AlertContent>+ </Alert></AlertDialogDescription></AlertDialogHeader><AlertDialogConfirmationField@@ -207,7 +297,7 @@ export const DeleteProjectSection = () => {<AlertDialogFooter><AlertDialogCancel isDisabled={isLeaving}>Cancel</AlertDialogCancel><AlertDialogAction- variant="danger"+ variant="warning"isPending={isLeaving}onClick={(event) => {event.preventDefault();@@ -219,6 +309,6 @@ export const DeleteProjectSection = () => {</AlertDialogFooter></AlertDialogContent></AlertDialog>- </Card>+ </>);};diff --git a/frontend/src/pages/project/SettingsPage/components/ProjectGeneralTab/ProjectGeneralTab.tsx b/frontend/src/pages/project/SettingsPage/components/ProjectGeneralTab/ProjectGeneralTab.tsxindex 4fd324e81d..41e8107e09 100644--- a/frontend/src/pages/project/SettingsPage/components/ProjectGeneralTab/ProjectGeneralTab.tsx+++ b/frontend/src/pages/project/SettingsPage/components/ProjectGeneralTab/ProjectGeneralTab.tsx@@ -1,7 +1,6 @@import { ProjectOverviewChangeSection } from "@app/components/project/ProjectOverviewChangeSection";import { AuditLogsRetentionSection } from "../AuditLogsRetentionSection";-import { DeleteProjectProtection } from "../DeleteProjectProtection";import { DeleteProjectSection } from "../DeleteProjectSection";export const ProjectGeneralTab = () => {@@ -9,7 +8,6 @@ export const ProjectGeneralTab = () => {<div><ProjectOverviewChangeSection showSlugField /><AuditLogsRetentionSection />- <DeleteProjectProtection /><DeleteProjectSection /></div>);