Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(ui): enable moving bulk-selected folders (#8411)

Andrew Huang70e06365043a
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/SelectionPanel.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/SelectionPanel.tsx
index ca8155ed04..9248698966 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/SelectionPanel.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/SelectionPanel.tsx
@@ -331,17 +331,25 @@ export const SelectionPanel = ({
const areFoldersSelected = Boolean(Object.keys(selectedEntries[EntryType.FOLDER]).length);
const areRotationsSelected = selectedRotationCount > 0;
- // folders are moved one at a time from the inline row action, so bulk move only handles
- // secrets and rotations
- const hasMovableSelection = selectedKeysCount > 0 || selectedRotationCount > 0;
- const shouldShowMove = shouldShowDelete && hasMovableSelection;
+ const canMoveSelectedFolders = Object.values(selectedEntries[EntryType.FOLDER]).some(
+ (folderRecord) =>
+ Object.keys(folderRecord).some(
+ (environment) =>
+ (visibleEnvs.length !== 1 || visibleEnvs[0].slug === environment) &&
+ permission.can(
+ ProjectPermissionActions.Delete,
+ subject(ProjectPermissionSub.SecretFolders, { environment, secretPath })
+ )
+ )
+ );
+ const shouldShowMove =
+ (shouldShowDelete && (selectedKeysCount > 0 || selectedRotationCount > 0)) ||
+ canMoveSelectedFolders;
- const isMoveDisabled = isHoneyTokenSelected || areFoldersSelected;
+ const isMoveDisabled = isHoneyTokenSelected;
let moveDisabledReason = "";
if (isHoneyTokenSelected) {
moveDisabledReason = "Moving honey tokens is not supported";
- } else if (areFoldersSelected) {
- moveDisabledReason = "Folders cannot be moved via multi-select";
}
const isDeleteDisabled = areRotationsSelected || isManagedSecretSelected;
@@ -602,7 +610,7 @@ export const SelectionPanel = ({
sourceSecretPath={secretPath}
secrets={selectedEntries[EntryType.SECRET]}
rotations={selectedEntries[EntryType.SECRET_ROTATION]}
- folders={{}}
+ folders={selectedEntries[EntryType.FOLDER]}
onComplete={resetSelectedEntries}
/>
<BulkTagDialog
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
index 95f86477b4..0f5e0a071b 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
@@ -912,20 +912,35 @@ const SingleEnvContent = ({
let isDestinationUpdated = true;
let isSourceUpdated = true;
+ let secretMoveSucceeded = false;
if (secretsToMove.length) {
- const result = await moveSecrets.mutateAsync({
- shouldOverwrite: data.shouldOverwrite,
- sourceEnvironment: sourceEnv.slug,
- sourceSecretPath,
- destinationEnvironment: data.environment,
- destinationSecretPath: selectedPath.secretPath,
- projectId,
- projectSlug,
- secretIds: secretsToMove.map((sec) => sec.id)
- });
- isDestinationUpdated = result.isDestinationUpdated;
- isSourceUpdated = result.isSourceUpdated;
+ try {
+ const result = await moveSecrets.mutateAsync({
+ shouldOverwrite: data.shouldOverwrite,
+ sourceEnvironment: sourceEnv.slug,
+ sourceSecretPath,
+ destinationEnvironment: data.environment,
+ destinationSecretPath: selectedPath.secretPath,
+ projectId,
+ projectSlug,
+ secretIds: secretsToMove.map((sec) => sec.id)
+ });
+ isDestinationUpdated = result.isDestinationUpdated;
+ isSourceUpdated = result.isSourceUpdated;
+ secretMoveSucceeded = true;
+ } catch (error) {
+ if (!foldersToMove.length && !rotationsToMove.length) throw error;
+ let message = (error as Error)?.message ?? "Failed to move selected secrets";
+ if (axios.isAxiosError(error)) {
+ const responseMessage = (error?.response?.data as { message?: string })?.message;
+ if (responseMessage) message = responseMessage;
+ }
+ createNotification({
+ type: "error",
+ text: `Failed to move selected secrets: ${message}`
+ });
+ }
}
const rotationFailures: { name: string; message: string }[] = [];
@@ -982,7 +997,7 @@ const SingleEnvContent = ({
}
}
- if (secretsToMove.length) {
+ if (secretMoveSucceeded) {
if (isDestinationUpdated && isSourceUpdated) {
createNotification({
type: "success",