From 4f11abd772d42e664d1d9508892988dea5539c2f Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Fri, 22 Nov 2024 15:06:38 +0100 Subject: [PATCH] wip v1 secrets --- .../src/features/secrets/GeneralSecretNew.tsx | 14 +++- .../secretsV2/DataConnectorSecretItem.tsx | 2 +- .../features/secretsV2/GeneralSecretItem.tsx | 2 +- .../features/secretsV2/SecretItemActions.tsx | 79 +++++++++++++++---- 4 files changed, 80 insertions(+), 17 deletions(-) diff --git a/client/src/features/secrets/GeneralSecretNew.tsx b/client/src/features/secrets/GeneralSecretNew.tsx index d3a4bccec..719290811 100644 --- a/client/src/features/secrets/GeneralSecretNew.tsx +++ b/client/src/features/secrets/GeneralSecretNew.tsx @@ -104,7 +104,19 @@ export default function GeneralSecretNew() { onSubmit={handleSubmit(onSubmit)} > - + + secrets.data?.map((s) => s.default_filename).includes(filename) + ? "This filename is already used by another secret" + : undefined, + }, + }} + /> diff --git a/client/src/features/secretsV2/DataConnectorSecretItem.tsx b/client/src/features/secretsV2/DataConnectorSecretItem.tsx index 92f5001a9..9e2d4853e 100644 --- a/client/src/features/secretsV2/DataConnectorSecretItem.tsx +++ b/client/src/features/secretsV2/DataConnectorSecretItem.tsx @@ -59,7 +59,7 @@ export default function DataConnectorSecretItem({ - + ); diff --git a/client/src/features/secretsV2/GeneralSecretItem.tsx b/client/src/features/secretsV2/GeneralSecretItem.tsx index 5d9e56b1f..159a7aff4 100644 --- a/client/src/features/secretsV2/GeneralSecretItem.tsx +++ b/client/src/features/secretsV2/GeneralSecretItem.tsx @@ -71,7 +71,7 @@ export default function GeneralSecretItem({ secret }: GeneralSecretItemProps) { {usedInContent} - + ); diff --git a/client/src/features/secretsV2/SecretItemActions.tsx b/client/src/features/secretsV2/SecretItemActions.tsx index 29a7606f7..f26b4c696 100644 --- a/client/src/features/secretsV2/SecretItemActions.tsx +++ b/client/src/features/secretsV2/SecretItemActions.tsx @@ -31,7 +31,10 @@ import { ModalHeader, } from "reactstrap"; -import { ButtonWithMenuV2 } from "../../components/buttons/Button"; +import { + ButtonWithMenu, + ButtonWithMenuV2, +} from "../../components/buttons/Button"; import { RtkOrNotebooksError } from "../../components/errors/RtkErrorAlert"; import { Loader } from "../../components/Loader"; import useLegacySelector from "../../utils/customHooks/useLegacySelector.hook"; @@ -42,12 +45,17 @@ import { } from "../usersV2/api/users.api"; import SecretValueField from "./fields/SecretValueField"; import NameField from "./fields/NameField"; +import FilenameField from "./fields/FilenameField"; interface SecretItemActionsProps { + isV2?: boolean; secret: SecretWithId; } -export default function SecretItemActions({ secret }: SecretItemActionsProps) { +export default function SecretItemActions({ + isV2, + secret, +}: SecretItemActionsProps) { const userLogged = useLegacySelector( (state) => state.stateModel.user.logged ); @@ -71,13 +79,20 @@ export default function SecretItemActions({ secret }: SecretItemActionsProps) { return null; } + const ButtonWithMenuTag = isV2 ? ButtonWithMenuV2 : ButtonWithMenu; + const buttonColor = isV2 ? "outline-primary" : "rk-green"; + return ( <> - + @@ -92,15 +107,17 @@ export default function SecretItemActions({ secret }: SecretItemActionsProps) { Delete - + @@ -115,12 +132,14 @@ export default function SecretItemActions({ secret }: SecretItemActionsProps) { interface ReplaceSecretValueModalProps { isOpen: boolean; + isV2?: boolean; secret: SecretWithId; toggle: () => void; } function ReplaceSecretValueModal({ isOpen, + isV2, secret, toggle, }: ReplaceSecretValueModalProps) { @@ -176,7 +195,11 @@ function ReplaceSecretValueModal({ return ( -
+ Replace secret value

@@ -192,12 +215,15 @@ function ReplaceSecretValueModal({ -