mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 07:27:58 +00:00
Merge pull request #4382 from Infisical/fix/replicate-duplicate
fix: resolved replication failing for duplicate
This commit is contained in:
+19
-19
@@ -99,7 +99,7 @@ import { CreateSecretImportForm } from "./CreateSecretImportForm";
|
|||||||
import { FolderForm } from "./FolderForm";
|
import { FolderForm } from "./FolderForm";
|
||||||
import { MoveSecretsModal } from "./MoveSecretsModal";
|
import { MoveSecretsModal } from "./MoveSecretsModal";
|
||||||
|
|
||||||
type TParsedEnv = Record<string, { value: string; comments: string[]; secretPath?: string }>;
|
type TParsedEnv = { value: string; comments: string[]; secretPath?: string; secretKey: string }[];
|
||||||
type TParsedFolderEnv = Record<
|
type TParsedFolderEnv = Record<
|
||||||
string,
|
string,
|
||||||
Record<string, { value: string; comments: string[]; secretPath?: string }>
|
Record<string, { value: string; comments: string[]; secretPath?: string }>
|
||||||
@@ -407,8 +407,8 @@ export const ActionBar = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const allUpdateSecrets: TParsedEnv = {};
|
const allUpdateSecrets: TParsedEnv = [];
|
||||||
const allCreateSecrets: TParsedEnv = {};
|
const allCreateSecrets: TParsedEnv = [];
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.entries(envByPath).map(async ([folderPath, secrets]) => {
|
Object.entries(envByPath).map(async ([folderPath, secrets]) => {
|
||||||
@@ -439,7 +439,7 @@ export const ActionBar = ({
|
|||||||
(_, i) => secretFolderKeys.slice(i * batchSize, (i + 1) * batchSize)
|
(_, i) => secretFolderKeys.slice(i * batchSize, (i + 1) * batchSize)
|
||||||
);
|
);
|
||||||
|
|
||||||
const existingSecretLookup: Record<string, boolean> = {};
|
const existingSecretLookup = new Set<string>();
|
||||||
|
|
||||||
const processBatches = async () => {
|
const processBatches = async () => {
|
||||||
await secretBatches.reduce(async (previous, batch) => {
|
await secretBatches.reduce(async (previous, batch) => {
|
||||||
@@ -453,7 +453,7 @@ export const ActionBar = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
batchSecrets.forEach((secret) => {
|
batchSecrets.forEach((secret) => {
|
||||||
existingSecretLookup[secret.secretKey] = true;
|
existingSecretLookup.add(`${normalizedPath}-${secret.secretKey}`);
|
||||||
});
|
});
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
};
|
};
|
||||||
@@ -467,18 +467,18 @@ export const ActionBar = ({
|
|||||||
// Store the path with the secret for later batch processing
|
// Store the path with the secret for later batch processing
|
||||||
const secretWithPath = {
|
const secretWithPath = {
|
||||||
...secretData,
|
...secretData,
|
||||||
secretPath: normalizedPath
|
secretPath: normalizedPath,
|
||||||
|
secretKey
|
||||||
};
|
};
|
||||||
|
|
||||||
if (existingSecretLookup[secretKey]) {
|
if (existingSecretLookup.has(`${normalizedPath}-${secretKey}`)) {
|
||||||
allUpdateSecrets[secretKey] = secretWithPath;
|
allUpdateSecrets.push(secretWithPath);
|
||||||
} else {
|
} else {
|
||||||
allCreateSecrets[secretKey] = secretWithPath;
|
allCreateSecrets.push(secretWithPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
handlePopUpOpen("confirmUpload", {
|
handlePopUpOpen("confirmUpload", {
|
||||||
update: allUpdateSecrets,
|
update: allUpdateSecrets,
|
||||||
create: allCreateSecrets
|
create: allCreateSecrets
|
||||||
@@ -521,7 +521,7 @@ export const ActionBar = ({
|
|||||||
const allPaths = new Set<string>();
|
const allPaths = new Set<string>();
|
||||||
|
|
||||||
// Add paths from create secrets
|
// Add paths from create secrets
|
||||||
Object.values(create || {}).forEach((secData) => {
|
create.forEach((secData) => {
|
||||||
if (secData.secretPath && secData.secretPath !== secretPath) {
|
if (secData.secretPath && secData.secretPath !== secretPath) {
|
||||||
allPaths.add(secData.secretPath);
|
allPaths.add(secData.secretPath);
|
||||||
}
|
}
|
||||||
@@ -577,8 +577,8 @@ export const ActionBar = ({
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
|
|
||||||
if (Object.keys(create || {}).length > 0) {
|
if (create.length > 0) {
|
||||||
Object.entries(create).forEach(([secretKey, secData]) => {
|
create.forEach((secData) => {
|
||||||
// Use the stored secretPath or fall back to the current secretPath
|
// Use the stored secretPath or fall back to the current secretPath
|
||||||
const path = secData.secretPath || secretPath;
|
const path = secData.secretPath || secretPath;
|
||||||
|
|
||||||
@@ -590,7 +590,7 @@ export const ActionBar = ({
|
|||||||
type: SecretType.Shared,
|
type: SecretType.Shared,
|
||||||
secretComment: secData.comments.join("\n"),
|
secretComment: secData.comments.join("\n"),
|
||||||
secretValue: secData.value,
|
secretValue: secData.value,
|
||||||
secretKey
|
secretKey: secData.secretKey
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -606,8 +606,8 @@ export const ActionBar = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(update || {}).length > 0) {
|
if (update.length > 0) {
|
||||||
Object.entries(update).forEach(([secretKey, secData]) => {
|
update.forEach((secData) => {
|
||||||
// Use the stored secretPath or fall back to the current secretPath
|
// Use the stored secretPath or fall back to the current secretPath
|
||||||
const path = secData.secretPath || secretPath;
|
const path = secData.secretPath || secretPath;
|
||||||
|
|
||||||
@@ -619,7 +619,7 @@ export const ActionBar = ({
|
|||||||
type: SecretType.Shared,
|
type: SecretType.Shared,
|
||||||
secretComment: secData.comments.join("\n"),
|
secretComment: secData.comments.join("\n"),
|
||||||
secretValue: secData.value,
|
secretValue: secData.value,
|
||||||
secretKey
|
secretKey: secData.secretKey
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1241,8 +1241,8 @@ export const ActionBar = ({
|
|||||||
<div className="flex flex-col text-gray-300">
|
<div className="flex flex-col text-gray-300">
|
||||||
<div>Your project already contains the following {updateSecretCount} secrets:</div>
|
<div>Your project already contains the following {updateSecretCount} secrets:</div>
|
||||||
<div className="mt-2 text-sm text-gray-400">
|
<div className="mt-2 text-sm text-gray-400">
|
||||||
{Object.keys((popUp?.confirmUpload?.data as TSecOverwriteOpt)?.update || {})
|
{(popUp?.confirmUpload?.data as TSecOverwriteOpt)?.update
|
||||||
?.map((key) => key)
|
?.map((sec) => sec.secretKey)
|
||||||
.join(", ")}
|
.join(", ")}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-6">
|
<div className="mt-6">
|
||||||
|
|||||||
Reference in New Issue
Block a user