Fix secret imports fetch secret value, and reserved folders not being computed correctly

This commit is contained in:
Carlos Monastyrski
2025-10-15 14:53:02 -03:00
parent 1169940cf1
commit 0d0f67dd35
@@ -73,13 +73,13 @@ export const computeImportedSecretRows = (
isEmpty?: boolean; isEmpty?: boolean;
}[] = []; }[] = [];
importedSec.secrets.forEach(({ key, value, env, path, isEmpty }) => { importedSec.secrets.forEach(({ key, value, isEmpty }) => {
if (!importedEntry[key]) { if (!importedEntry[key]) {
importedSecretEntries.push({ importedSecretEntries.push({
key, key,
value, value,
environment: env, environment: importedSec.environmentInfo.slug,
secretPath: path, secretPath: importedSec.secretPath,
overridden: overridenSec?.[key], overridden: overridenSec?.[key],
isEmpty isEmpty
}); });
@@ -125,6 +125,12 @@ export const SecretImportListView = ({
const [items, setItems] = useState(secretImports ?? []); const [items, setItems] = useState(secretImports ?? []);
const getImportReplicatedFolder = (importPath: string) => {
const cleanImportPath = importPath.replace("/__reserve_replication_", "");
const replicatedFolder = items?.find(({ id }) => id === cleanImportPath);
return replicatedFolder;
};
useEffect(() => { useEffect(() => {
if (!isFetching) { if (!isFetching) {
setItems(secretImports ?? []); setItems(secretImports ?? []);
@@ -204,6 +210,7 @@ export const SecretImportListView = ({
<SortableContext items={items} strategy={verticalListSortingStrategy}> <SortableContext items={items} strategy={verticalListSortingStrategy}>
{items?.map((item) => { {items?.map((item) => {
// TODO(akhilmhdh): change this and pass this whole object instead of one by one // TODO(akhilmhdh): change this and pass this whole object instead of one by one
const replicatedFolder = item.isReserved ? getImportReplicatedFolder(item.importPath) : undefined;
return ( return (
<SecretImportItem <SecretImportItem
searchTerm={searchTerm} searchTerm={searchTerm}
@@ -212,8 +219,8 @@ export const SecretImportListView = ({
onExpandReplicateSecrets={handleOpenReplicationSecrets} onExpandReplicateSecrets={handleOpenReplicationSecrets}
secretImport={item} secretImport={item}
importedSecrets={computeImportedSecretRows( importedSecrets={computeImportedSecretRows(
item.importEnv.slug, replicatedFolder?.importEnv.slug ?? item.importEnv.slug,
item.importPath, replicatedFolder?.importPath ?? item.importPath,
importedSecrets importedSecrets
// secrets scott - now that secrets are paginated we are not showing if they are overridden (yet?) // secrets scott - now that secrets are paginated we are not showing if they are overridden (yet?)
)} )}