diff --git a/client/src/features/secrets/GeneralSecretNew.tsx b/client/src/features/secrets/GeneralSecretNew.tsx index d3a4bccecf..719290811a 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 92f5001a9d..9e2d4853e5 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 5d9e56b1f3..159a7aff4e 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 29a7606f70..f26b4c6965 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 ( <> - + Replace @@ -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({ - + Close @@ -220,11 +246,17 @@ interface ReplaceSecretValueForm { interface EditSecretModalProps { isOpen: boolean; + isV2?: boolean; secret: SecretWithId; toggle: () => void; } -function EditSecretModal({ isOpen, secret, toggle }: EditSecretModalProps) { +function EditSecretModal({ + isOpen, + isV2, + secret, + toggle, +}: EditSecretModalProps) { const { id: secretId } = secret; const [patchUserSecret, result] = usePatchUserSecretMutation(); @@ -237,6 +269,7 @@ function EditSecretModal({ isOpen, secret, toggle }: EditSecretModalProps) { } = useForm({ defaultValues: { name: secret.name, + filename: secret.default_filename, }, }); @@ -246,10 +279,11 @@ function EditSecretModal({ isOpen, secret, toggle }: EditSecretModalProps) { secretId, secretPatch: { name: data.name, + ...(!isV2 ? { default_filename: data.filename } : {}), }, }); }, - [patchUserSecret, secretId] + [isV2, patchUserSecret, secretId] ); const onSubmit = useMemo( () => handleSubmit(submitHandler), @@ -259,6 +293,7 @@ function EditSecretModal({ isOpen, secret, toggle }: EditSecretModalProps) { useEffect(() => { reset({ name: secret.name, + filename: secret.default_filename, }); }, [reset, secret]); @@ -277,7 +312,11 @@ function EditSecretModal({ isOpen, secret, toggle }: EditSecretModalProps) { return ( - + Edit secret {result.error && ( @@ -285,14 +324,25 @@ function EditSecretModal({ isOpen, secret, toggle }: EditSecretModalProps) { )} + {!isV2 && ( + + )} - + Close @@ -311,6 +361,7 @@ function EditSecretModal({ isOpen, secret, toggle }: EditSecretModalProps) { interface EditSecretForm { name: string; + filename: string; } interface DeleteSecretModalProps {
@@ -192,12 +215,15 @@ function ReplaceSecretValueModal({