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
feat: add delete environment action to env col dropdown on overview page
Scott Wilsonc83d1d4f2b11
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsxindex 48e54124c6..e02d092d31 100644--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx@@ -20,6 +20,7 @@ import { twMerge } from "tailwind-merge";import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";import { createNotification } from "@app/components/notifications";+import { ProjectPermissionCan } from "@app/components/permissions";import { CreateSecretRotationV2Modal } from "@app/components/secret-rotations-v2";import { DeleteSecretRotationV2Modal } from "@app/components/secret-rotations-v2/DeleteSecretRotationV2Modal";import { EditSecretRotationV2Modal } from "@app/components/secret-rotations-v2/EditSecretRotationV2Modal";@@ -94,6 +95,7 @@ import {useDeleteFolder,useDeleteSecretImport,useDeleteSecretV3,+ useDeleteWsEnvironment,useGetImportedSecretsAllEnvs,useGetOrCreateFolder,useGetWsTags,@@ -504,6 +506,7 @@ export const OverviewPage = () => {const deleteDynamicSecret = useDeleteDynamicSecret();const { mutateAsync: deleteSecretImport } = useDeleteSecretImport();const { mutate: updateSecretImport } = useUpdateSecretImport();+ const { mutateAsync: deleteWsEnvironment } = useDeleteWsEnvironment();const isSingleEnvView = visibleEnvs.length === 1;const singleEnvSlug = isSingleEnvView ? visibleEnvs[0].slug : "";@@ -544,7 +547,8 @@ export const OverviewPage = () => {"deleteDynamicSecret","snapshots","deleteSecretImport",- "addSecretImport"+ "addSecretImport",+ "deleteEnv"] as const);const handleViewCommitHistory = async (envSlug: string, preloadedFolderId?: string) => {@@ -782,6 +786,15 @@ export const OverviewPage = () => {}};+ const handleDeleteEnvironment = async () => {+ const { id } = popUp.deleteEnv.data as { id: string };+ if (!id) return;++ await deleteWsEnvironment({ projectId: currentProject.id, id });+ createNotification({ text: "Successfully removed environment", type: "success" });+ handlePopUpClose("deleteEnv");+ };+const handleSecretImportReorder: DragEndEvent = (event) => {if (event.canceled) return;const { source } = event.operation;@@ -1424,7 +1437,7 @@ export const OverviewPage = () => {/></UnstableTableHead>{visibleEnvs.length > 1 ? (- visibleEnvs?.map(({ name, slug }, index) => {+ visibleEnvs?.map(({ name, slug, id }, index) => {return (<UnstableTableHeadclassName="w-40 max-w-40 border-r p-0 text-center last:border-r-0"@@ -1513,6 +1526,33 @@ export const OverviewPage = () => {<GitCommitIcon />View Commit History</UnstableDropdownMenuItem>+ <ProjectPermissionCan+ I={ProjectPermissionActions.Delete}+ a={ProjectPermissionSub.Environments}+ >+ {(isAllowed) => (+ <Tooltip open={!isAllowed ? undefined : false}>+ <TooltipTrigger className="block w-full">+ <UnstableDropdownMenuItem+ isDisabled={!isAllowed}+ onClick={() =>+ handlePopUpOpen("deleteEnv", {+ name,+ slug,+ id+ })+ }+ >+ <TrashIcon />+ Delete Environment+ </UnstableDropdownMenuItem>+ </TooltipTrigger>+ <TooltipContent side="left">+ Access Restricted+ </TooltipContent>+ </Tooltip>+ )}+ </ProjectPermissionCan></UnstableDropdownMenuContent></UnstableDropdownMenu></UnstableTableHead>@@ -2017,6 +2057,32 @@ export const OverviewPage = () => {</AlertDialogFooter></AlertDialogContent></AlertDialog>+ <AlertDialog+ open={popUp.deleteEnv.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("deleteEnv", isOpen)}+ >+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogMedia>+ <TrashIcon />+ </AlertDialogMedia>+ <AlertDialogTitle>Delete Environment</AlertDialogTitle>+ <AlertDialogDescription>+ Are you sure you want to delete{" "}+ <span className="font-medium text-foreground">+ {(popUp?.deleteEnv?.data as { name: string })?.name}+ </span>+ ? This action is irreversible.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel>Cancel</AlertDialogCancel>+ <AlertDialogAction variant="danger" onClick={handleDeleteEnvironment}>+ Delete+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog></div>);};