diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx index 8800f5f61..9252d71a1 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx @@ -99,7 +99,7 @@ import { CreateSecretImportForm } from "./CreateSecretImportForm"; import { FolderForm } from "./FolderForm"; import { MoveSecretsModal } from "./MoveSecretsModal"; -type TParsedEnv = Record; +type TParsedEnv = { value: string; comments: string[]; secretPath?: string; secretKey: string }[]; type TParsedFolderEnv = Record< string, Record @@ -407,8 +407,8 @@ export const ActionBar = ({ } try { - const allUpdateSecrets: TParsedEnv = {}; - const allCreateSecrets: TParsedEnv = {}; + const allUpdateSecrets: TParsedEnv = []; + const allCreateSecrets: TParsedEnv = []; await Promise.all( Object.entries(envByPath).map(async ([folderPath, secrets]) => { @@ -439,7 +439,7 @@ export const ActionBar = ({ (_, i) => secretFolderKeys.slice(i * batchSize, (i + 1) * batchSize) ); - const existingSecretLookup: Record = {}; + const existingSecretLookup = new Set(); const processBatches = async () => { await secretBatches.reduce(async (previous, batch) => { @@ -453,7 +453,7 @@ export const ActionBar = ({ }); batchSecrets.forEach((secret) => { - existingSecretLookup[secret.secretKey] = true; + existingSecretLookup.add(`${normalizedPath}-${secret.secretKey}`); }); }, Promise.resolve()); }; @@ -467,18 +467,18 @@ export const ActionBar = ({ // Store the path with the secret for later batch processing const secretWithPath = { ...secretData, - secretPath: normalizedPath + secretPath: normalizedPath, + secretKey }; - if (existingSecretLookup[secretKey]) { - allUpdateSecrets[secretKey] = secretWithPath; + if (existingSecretLookup.has(`${normalizedPath}-${secretKey}`)) { + allUpdateSecrets.push(secretWithPath); } else { - allCreateSecrets[secretKey] = secretWithPath; + allCreateSecrets.push(secretWithPath); } }); }) ); - handlePopUpOpen("confirmUpload", { update: allUpdateSecrets, create: allCreateSecrets @@ -521,7 +521,7 @@ export const ActionBar = ({ const allPaths = new Set(); // Add paths from create secrets - Object.values(create || {}).forEach((secData) => { + create.forEach((secData) => { if (secData.secretPath && secData.secretPath !== secretPath) { allPaths.add(secData.secretPath); } @@ -577,8 +577,8 @@ export const ActionBar = ({ return Promise.resolve(); }, Promise.resolve()); - if (Object.keys(create || {}).length > 0) { - Object.entries(create).forEach(([secretKey, secData]) => { + if (create.length > 0) { + create.forEach((secData) => { // Use the stored secretPath or fall back to the current secretPath const path = secData.secretPath || secretPath; @@ -590,7 +590,7 @@ export const ActionBar = ({ type: SecretType.Shared, secretComment: secData.comments.join("\n"), secretValue: secData.value, - secretKey + secretKey: secData.secretKey }); }); @@ -606,8 +606,8 @@ export const ActionBar = ({ ); } - if (Object.keys(update || {}).length > 0) { - Object.entries(update).forEach(([secretKey, secData]) => { + if (update.length > 0) { + update.forEach((secData) => { // Use the stored secretPath or fall back to the current secretPath const path = secData.secretPath || secretPath; @@ -619,7 +619,7 @@ export const ActionBar = ({ type: SecretType.Shared, secretComment: secData.comments.join("\n"), secretValue: secData.value, - secretKey + secretKey: secData.secretKey }); }); @@ -1241,8 +1241,8 @@ export const ActionBar = ({
Your project already contains the following {updateSecretCount} secrets:
- {Object.keys((popUp?.confirmUpload?.data as TSecOverwriteOpt)?.update || {}) - ?.map((key) => key) + {(popUp?.confirmUpload?.data as TSecOverwriteOpt)?.update + ?.map((sec) => sec.secretKey) .join(", ")}