Feat: Show overwritten value in secret overview and allow for edits

This commit is contained in:
Daniel Hougaard
2024-06-21 15:23:09 +02:00
parent dc0fe6920c
commit c43a18904d
@@ -10,24 +10,33 @@ import { IconButton, Tooltip } from "@app/components/v2";
import { InfisicalSecretInput } from "@app/components/v2/InfisicalSecretInput"; import { InfisicalSecretInput } from "@app/components/v2/InfisicalSecretInput";
import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
import { useToggle } from "@app/hooks"; import { useToggle } from "@app/hooks";
import { SecretType } from "@app/hooks/api/types";
type Props = { type Props = {
defaultValue?: string | null; defaultValue?: string | null;
secretName: string; secretName: string;
secretId?: string; secretId?: string;
isOverride?: boolean;
isCreatable?: boolean; isCreatable?: boolean;
isVisible?: boolean; isVisible?: boolean;
isImportedSecret: boolean; isImportedSecret: boolean;
environment: string; environment: string;
secretPath: string; secretPath: string;
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,
type?: SecretType,
secretId?: string
) => Promise<void>;
onSecretDelete: (env: string, key: string, secretId?: string) => Promise<void>; onSecretDelete: (env: string, key: string, secretId?: string) => Promise<void>;
}; };
export const SecretEditRow = ({ export const SecretEditRow = ({
defaultValue, defaultValue,
isCreatable, isCreatable,
isOverride,
isImportedSecret, isImportedSecret,
onSecretUpdate, onSecretUpdate,
secretName, secretName,
@@ -73,7 +82,13 @@ export const SecretEditRow = ({
if (isCreatable) { if (isCreatable) {
await onSecretCreate(environment, secretName, value); await onSecretCreate(environment, secretName, value);
} else { } else {
await onSecretUpdate(environment, secretName, value, secretId); await onSecretUpdate(
environment,
secretName,
value,
isOverride ? SecretType.Personal : SecretType.Shared,
secretId
);
} }
} }
reset({ value }); reset({ value });