mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Merge pull request #4375 from Infisical/ENG-3516
Improve delete folder message
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionSub,
|
||||
useProjectPermission,
|
||||
useSubscription,
|
||||
useWorkspace
|
||||
} from "@app/context";
|
||||
import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
|
||||
@@ -51,6 +52,7 @@ export const SelectionPanel = ({
|
||||
usedBySecretSyncs = []
|
||||
}: Props) => {
|
||||
const { permission } = useProjectPermission();
|
||||
const { subscription } = useSubscription();
|
||||
|
||||
const { handlePopUpOpen, handlePopUpToggle, handlePopUpClose, popUp } = usePopUp([
|
||||
"bulkDeleteEntries",
|
||||
@@ -101,6 +103,16 @@ export const SelectionPanel = ({
|
||||
return "Do you want to delete the selected folders across environments?";
|
||||
};
|
||||
|
||||
const getDeleteModalSubTitle = () => {
|
||||
if (selectedFolderCount > 0) {
|
||||
if (subscription?.pitRecovery) {
|
||||
return "All selected folders and their contents will be removed. You can reverse this action by rolling back to a previous commit.";
|
||||
}
|
||||
return "All selected folders and their contents will be removed. Rolling back to a previous commit isn't available on your current plan. Upgrade to enable this feature.";
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const handleBulkDelete = async () => {
|
||||
let processedEntries = 0;
|
||||
|
||||
@@ -279,6 +291,7 @@ export const SelectionPanel = ({
|
||||
isOpen={popUp.bulkDeleteEntries.isOpen}
|
||||
deleteKey="delete"
|
||||
title={getDeleteModalTitle()}
|
||||
subTitle={getDeleteModalSubTitle()}
|
||||
onChange={(isOpen) => handlePopUpToggle("bulkDeleteEntries", isOpen)}
|
||||
onDeleteApproved={handleBulkDelete}
|
||||
formContent={
|
||||
|
||||
@@ -16,7 +16,7 @@ import { ProjectPermissionCan } from "@app/components/permissions";
|
||||
import { DeleteActionModal, IconButton, Modal, ModalContent } from "@app/components/v2";
|
||||
import { Tooltip } from "@app/components/v2/Tooltip/Tooltip";
|
||||
import { ROUTE_PATHS } from "@app/const/routes";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useSubscription } from "@app/context";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useDeleteFolder, useUpdateFolder } from "@app/hooks/api";
|
||||
import { PendingAction, TSecretFolder } from "@app/hooks/api/secretFolders/types";
|
||||
@@ -54,6 +54,7 @@ export const FolderListView = ({
|
||||
from: ROUTE_PATHS.SecretManager.SecretDashboardPage.id,
|
||||
select: (el) => el.secretPath
|
||||
});
|
||||
const { subscription } = useSubscription();
|
||||
|
||||
const { mutateAsync: updateFolder } = useUpdateFolder();
|
||||
const { mutateAsync: deleteFolder } = useDeleteFolder();
|
||||
@@ -319,6 +320,11 @@ export const FolderListView = ({
|
||||
isOpen={popUp.deleteFolder.isOpen}
|
||||
deleteKey={(popUp.deleteFolder?.data as TSecretFolder)?.name}
|
||||
title="Do you want to delete this folder?"
|
||||
subTitle={`This folder and all its contents will be removed. ${
|
||||
subscription?.pitRecovery
|
||||
? "You can reverse this action by rolling back to a previous commit."
|
||||
: "Rolling back to a previous commit isn't available on your current plan. Upgrade to enable this feature."
|
||||
}`}
|
||||
onChange={(isOpen) => handlePopUpToggle("deleteFolder", isOpen)}
|
||||
onDeleteApproved={handleFolderDelete}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user