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