Fix: UI secret import indicator

This commit is contained in:
Daniel Hougaard
2024-03-20 21:09:54 +01:00
parent 6363e7d30a
commit 36adf6863b
2 changed files with 6 additions and 4 deletions
@@ -264,12 +264,13 @@ export const useGetImportedSecretsAllEnvs = ({
}); });
const isImportedSecretPresentInEnv = useCallback( const isImportedSecretPresentInEnv = useCallback(
(secPath: string, envSlug: string) => { (secPath: string, envSlug: string, secretName: string) => {
const selectedEnvIndex = environments.indexOf(envSlug); const selectedEnvIndex = environments.indexOf(envSlug);
if (selectedEnvIndex !== -1) { if (selectedEnvIndex !== -1) {
const isPresent = secretImports?.[selectedEnvIndex]?.data?.find( const isPresent = secretImports?.[selectedEnvIndex]?.data?.find(
({ secretPath }) => secretPath === secPath ({ secretPath, ...rest }) =>
secretPath === secPath && rest.secrets.some((s) => s.key === secretName)
); );
return Boolean(isPresent); return Boolean(isPresent);
@@ -27,7 +27,7 @@ type Props = {
onSecretCreate: (env: string, key: string, value: string) => Promise<void>; onSecretCreate: (env: string, key: string, value: string) => Promise<void>;
onSecretUpdate: (env: string, key: string, value: string, secretId?: string) => Promise<void>; onSecretUpdate: (env: string, key: string, value: string, secretId?: string) => Promise<void>;
onSecretDelete: (env: string, key: string, secretId?: string) => Promise<void>; onSecretDelete: (env: string, key: string, secretId?: string) => Promise<void>;
isImportedSecretPresentInEnv: (name: string, env: string) => boolean; isImportedSecretPresentInEnv: (name: string, env: string, secretName: string) => boolean;
}; };
export const SecretOverviewTableRow = ({ export const SecretOverviewTableRow = ({
@@ -65,7 +65,8 @@ export const SecretOverviewTableRow = ({
{environments.map(({ slug }, i) => { {environments.map(({ slug }, i) => {
const secret = getSecretByKey(slug, secretKey); const secret = getSecretByKey(slug, secretKey);
const isSecretImported = isImportedSecretPresentInEnv(secretPath, slug); const isSecretImported = isImportedSecretPresentInEnv(secretPath, slug, secretKey);
const isSecretPresent = Boolean(secret); const isSecretPresent = Boolean(secret);
const isSecretEmpty = secret?.value === ""; const isSecretEmpty = secret?.value === "";
return ( return (