Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
refactor(dynamic-secrets): remove legacy provider forms (#7932)
Andrew Huang225a8d331a5b
diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/production-route-cutover.test.ts b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/production-route-cutover.test.tsindex 58b8b1b6ad..9c30d11677 100644--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/production-route-cutover.test.ts+++ b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/production-route-cutover.test.ts@@ -20,10 +20,10 @@ describe("dynamic-secret production route cutover", () => {it("routes create and edit through the shared registry and form", async () => {const [createSource, editSource] = await Promise.all([readSource(- "../../../pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx"+ "../../../pages/secret-manager/OverviewPage/components/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx"),readSource(- "../../../pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx"+ "../../../pages/secret-manager/OverviewPage/components/EditDynamicSecretForm/EditDynamicSecretForm.tsx")]);@@ -42,7 +42,7 @@ describe("dynamic-secret production route cutover", () => {it("keeps provider presentation and lease behavior behind the shared registry", async () => {const [pickerSource, rowSource, provisionSource, leasesSource] = await Promise.all([readSource(- "../../../pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/DynamicSecretProviderSelect.tsx"+ "../../../pages/secret-manager/OverviewPage/components/CreateDynamicSecretForm/DynamicSecretProviderSelect.tsx"),readSource("../../../pages/secret-manager/OverviewPage/components/DynamicSecretTableRow/DynamicSecretTableRow.tsx"diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/cassandra.tsx b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/cassandra.tsxindex 0445c83643..336d6ec559 100644--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/cassandra.tsx+++ b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/cassandra.tsx@@ -2,6 +2,7 @@ import { useState } from "react";import { useFormContext } from "react-hook-form";import { InfoIcon } from "lucide-react";+import { VaultCassandraImportModal } from "@app/components/external-migrations";import { createNotification } from "@app/components/notifications";import { Alert, AlertAction, AlertDescription, Button } from "@app/components/v3";import { ProjectPermissionSub, useProject } from "@app/context";@@ -10,7 +11,6 @@ import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";import { AppConnection } from "@app/hooks/api/appConnections/enums";import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";import type { VaultDatabaseRole } from "@app/hooks/api/migration/types";-import { VaultCassandraImportModal } from "@app/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultCassandraImportModal";import { DynamicSecretProviderFields } from "../DynamicSecretProviderFields";import { DynamicSecretProviderGroup } from "../DynamicSecretProviderGroup";diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/kubernetes.tsx b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/kubernetes.tsxindex 444e019733..7e3deda2b3 100644--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/kubernetes.tsx+++ b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/kubernetes.tsx@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";import { Controller, useFieldArray, useFormContext } from "react-hook-form";import { InfoIcon, PlusIcon, Trash2Icon } from "lucide-react";+import { VaultKubernetesImportModal } from "@app/components/external-migrations";import { createNotification } from "@app/components/notifications";import { OrgPermissionCan } from "@app/components/permissions";import {@@ -33,7 +34,6 @@ import {KubernetesDynamicSecretCredentialType} from "@app/hooks/api/dynamicSecret/types";import type { VaultKubernetesRole } from "@app/hooks/api/migration/types";-import { VaultKubernetesImportModal } from "@app/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultKubernetesImportModal";import { DynamicSecretProviderFields } from "../DynamicSecretProviderFields";import { DynamicSecretProviderGroup } from "../DynamicSecretProviderGroup";diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/ldap.tsx b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/ldap.tsxindex 673f9b5681..536df2af9e 100644--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/ldap.tsx+++ b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/providerDefinitions/ldap.tsx@@ -2,6 +2,7 @@ import { useState } from "react";import { Controller, useFormContext } from "react-hook-form";import { InfoIcon } from "lucide-react";+import { VaultLdapImportModal } from "@app/components/external-migrations";import { createNotification } from "@app/components/notifications";import {Alert,@@ -27,7 +28,6 @@ import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";import { AppConnection } from "@app/hooks/api/appConnections/enums";import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";import type { VaultLdapRole } from "@app/hooks/api/migration/types";-import { VaultLdapImportModal } from "@app/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultLdapImportModal";import { DynamicSecretProviderFields } from "../DynamicSecretProviderFields";import { DynamicSecretProviderGroup } from "../DynamicSecretProviderGroup";diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsxindex e53daad538..e4482fd624 100644--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx@@ -202,7 +202,6 @@ import {import { RequestAccessModal } from "@app/pages/secret-manager/SecretApprovalsPage/components/AccessApprovalRequest/components/RequestAccessModal";import { AddEnvironmentModal } from "@app/pages/secret-manager/SettingsPage/components/EnvironmentSection/AddEnvironmentModal";-import { CreateDynamicSecretForm } from "../SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm";import { CreateSecretImportForm } from "../SecretDashboardPage/components/ActionBar/CreateSecretImportForm";import { DopplerSecretImportModal } from "../SecretDashboardPage/components/ActionBar/DopplerSecretImportModal";import { FolderForm } from "../SecretDashboardPage/components/ActionBar/FolderForm";@@ -215,7 +214,6 @@ import { VaultSecretImportModal } from "../SecretDashboardPage/components/Actionimport { CommitForm } from "../SecretDashboardPage/components/CommitForm";import { CreateDynamicSecretLease } from "../SecretDashboardPage/components/DynamicSecretListView/CreateDynamicSecretLease";import { DynamicSecretLease } from "../SecretDashboardPage/components/DynamicSecretListView/DynamicSecretLease";-import { EditDynamicSecretForm } from "../SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm";import {HIDDEN_SECRET_VALUE,HIDDEN_SECRET_VALUE_API_MASK@@ -228,7 +226,9 @@ import {useBatchModeActions} from "../SecretDashboardPage/SecretMainPage.store";import { AddResourceButtons } from "./components/AddResourceButtons/AddResourceButtons";+import { CreateDynamicSecretForm } from "./components/CreateDynamicSecretForm";import { CreateSecretForm } from "./components/CreateSecretForm";+import { EditDynamicSecretForm } from "./components/EditDynamicSecretForm";import { InviteMembersModal } from "./components/InviteMembersModal";import { ImportSecretsModal, SecretDropzone } from "./components/SecretDropzone";import { SecretV2MigrationSection } from "./components/SecretV2MigrationSection";diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/CreateDynamicSecretForm/CreateDynamicSecretForm.tsxsimilarity index 100%rename from frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsxrename to frontend/src/pages/secret-manager/OverviewPage/components/CreateDynamicSecretForm/CreateDynamicSecretForm.tsxdiff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/DynamicSecretProviderSelect.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/CreateDynamicSecretForm/DynamicSecretProviderSelect.tsxsimilarity index 100%rename from frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/DynamicSecretProviderSelect.tsxrename to frontend/src/pages/secret-manager/OverviewPage/components/CreateDynamicSecretForm/DynamicSecretProviderSelect.tsxdiff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/index.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/CreateDynamicSecretForm/index.tssimilarity index 100%rename from frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/index.tsxrename to frontend/src/pages/secret-manager/OverviewPage/components/CreateDynamicSecretForm/index.tsdiff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/EditDynamicSecretForm/EditDynamicSecretForm.tsxsimilarity index 100%rename from frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsxrename to frontend/src/pages/secret-manager/OverviewPage/components/EditDynamicSecretForm/EditDynamicSecretForm.tsxdiff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/index.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/EditDynamicSecretForm/index.tssimilarity index 100%rename from frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/index.tsxrename to frontend/src/pages/secret-manager/OverviewPage/components/EditDynamicSecretForm/index.tsdiff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsElastiCacheInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsElastiCacheInputForm.tsxdeleted file mode 100644index 84a3ba0cdd..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsElastiCacheInputForm.tsx+++ /dev/null@@ -1,348 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- TextArea-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";--const formSchema = z.object({- provider: z.object({- clusterName: z.string().trim().min(1),- accessKeyId: z.string().trim().min(1),- secretAccessKey: z.string().trim().min(1),-- region: z.string().trim(),- creationStatement: z.string().trim(),- revocationStatement: z.string().trim()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const AwsElastiCacheInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- creationStatement: `{- "UserId": "{{username}}",- "UserName": "{{username}}",- "Engine": "redis",- "Passwords": ["{{password}}"],- "AccessString": "on ~* +@all"-}`,- revocationStatement: `{- "UserId": "{{username}}"-}`- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.AwsElastiCache, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.clusterName"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster name"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="redis-oss-cluster" />- </FormControl>- )}- />- <Controller- control={control}- defaultValue=""- name="provider.region"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Region"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="us-east-1" {...field} type="text" />- </FormControl>- )}- />- </div>- <div className="flex w-full items-center space-x-2">- <Controller- control={control}- name="provider.accessKeyId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Access Key ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.secretAccessKey"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Access Key"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify ElastiCache Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsIamInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsIamInputForm.tsxdeleted file mode 100644index 152a6a3ef7..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsIamInputForm.tsx+++ /dev/null@@ -1,585 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Button,- FilterableSelect,- FormControl,- Input,- Select,- SelectItem,- TextArea-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { useGetServerConfig } from "@app/hooks/api/admin";-import {- DynamicSecretAwsIamAuth,- DynamicSecretAwsIamCredentialType,- DynamicSecretProviders-} from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";--import { MetadataForm } from "../../DynamicSecretListView/MetadataForm";--const formSchema = z.object({- provider: z.discriminatedUnion("method", [- z.object({- method: z.literal(DynamicSecretAwsIamAuth.AccessKey),- credentialType: z- .nativeEnum(DynamicSecretAwsIamCredentialType)- .default(DynamicSecretAwsIamCredentialType.IamUser),- accessKey: z.string().trim().min(1),- secretAccessKey: z.string().trim().min(1),- region: z.string().trim().min(1),- awsPath: z.string().trim().optional(),- permissionBoundaryPolicyArn: z.string().trim().optional(),- policyDocument: z.string().trim().optional(),- userGroups: z.string().trim().optional(),- policyArns: z.string().trim().optional(),- tags: z- .array(- z.object({- key: z.string().trim().min(1).max(128),- value: z.string().trim().min(1).max(256)- })- )- .optional()- }),- z.object({- method: z.literal(DynamicSecretAwsIamAuth.AssumeRole),- credentialType: z- .nativeEnum(DynamicSecretAwsIamCredentialType)- .default(DynamicSecretAwsIamCredentialType.IamUser),- roleArn: z.string().trim().min(1),- region: z.string().trim().min(1),- awsPath: z.string().trim().optional(),- permissionBoundaryPolicyArn: z.string().trim().optional(),- policyDocument: z.string().trim().optional(),- userGroups: z.string().trim().optional(),- policyArns: z.string().trim().optional(),- sessionPolicyArns: z.string().trim().optional(),- sessionPolicyDocument: z.string().trim().optional(),- tags: z- .array(- z.object({- key: z.string().trim().min(1).max(128),- value: z.string().trim().min(1).max(256)- })- )- .optional()- }),- z.object({- method: z.literal(DynamicSecretAwsIamAuth.IRSA),- credentialType: z- .nativeEnum(DynamicSecretAwsIamCredentialType)- .default(DynamicSecretAwsIamCredentialType.IamUser),- region: z.string().trim().min(1),- awsPath: z.string().trim().optional(),- permissionBoundaryPolicyArn: z.string().trim().optional(),- policyDocument: z.string().trim().optional(),- userGroups: z.string().trim().optional(),- policyArns: z.string().trim().optional(),- tags: z- .array(- z.object({- key: z.string().trim().min(1).max(128),- value: z.string().trim().min(1).max(256)- })- )- .optional()- })- ]),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const AwsIamInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const { data: serverConfig } = useGetServerConfig();-- const {- control,- formState: { isSubmitting },- handleSubmit,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}",- provider: {- method: DynamicSecretAwsIamAuth.AssumeRole,- credentialType: DynamicSecretAwsIamCredentialType.IamUser- }- }- });-- const createDynamicSecret = useCreateDynamicSecret();- const method = watch("provider.method");- const credentialType = watch("provider.credentialType");- const isIamUser = credentialType !== DynamicSecretAwsIamCredentialType.TemporaryCredentials;- // session policies only apply to temporary credentials issued via STS AssumeRole- const isSessionPolicySupported = !isIamUser && method === DynamicSecretAwsIamAuth.AssumeRole;-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;-- // react-hook-form keeps values of unmounted fields; clear policies that do not apply to the submitted credential type / method combination- const sanitizedProvider = {- ...provider,- ...(!isIamUser && { policyArns: "", policyDocument: "" }),- ...(!isSessionPolicySupported && { sessionPolicyArns: "", sessionPolicyDocument: "" })- };-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.AwsIam, inputs: sanitizedProvider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-aws-iam" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <Controller- name="provider.method"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Method"- >- <Select- value={value}- onValueChange={(val) => onChange(val)}- className="w-full border border-mineshaft-500"- position="popper"- dropdownContainerClassName="max-w-none"- >- <SelectItem value={DynamicSecretAwsIamAuth.AssumeRole}>- Assume Role (Recommended)- </SelectItem>- <SelectItem value={DynamicSecretAwsIamAuth.AccessKey}>Access Key</SelectItem>- {serverConfig?.kubernetesAutoFetchServiceAccountToken && (- <SelectItem value={DynamicSecretAwsIamAuth.IRSA}>IRSA (EKS)</SelectItem>- )}- </Select>- </FormControl>- )}- />- <Controller- name="provider.credentialType"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Credential Type"- >- <>- <Select- value={value}- onValueChange={(val) => onChange(val)}- className="w-full border border-mineshaft-500"- position="popper"- dropdownContainerClassName="max-w-none"- >- <SelectItem value={DynamicSecretAwsIamCredentialType.IamUser}>- IAM User- </SelectItem>- <SelectItem value={DynamicSecretAwsIamCredentialType.TemporaryCredentials}>- Temporary Credentials- </SelectItem>- </Select>- <div className="mt-1 text-xs text-mineshaft-300">- {value === DynamicSecretAwsIamCredentialType.IamUser- ? "Creates temporary IAM users with access keys"- : "Uses STS to generate temporary credentials from your connection. Duration is controlled by the Default TTL setting above."}- </div>- </>- </FormControl>- )}- />- {method === DynamicSecretAwsIamAuth.AccessKey && (- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.accessKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Access Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.secretAccessKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Secret Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" />- </FormControl>- )}- />- </div>- )}- {method === DynamicSecretAwsIamAuth.AssumeRole && (- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.roleArn"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Assume Role ARN"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- )}- <div className="flex items-center space-x-2">- {credentialType !== DynamicSecretAwsIamCredentialType.TemporaryCredentials && (- <Controller- control={control}- name="provider.awsPath"- defaultValue="/"- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS IAM Path"- className="grow"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- )}- <Controller- control={control}- name="provider.region"- defaultValue="us-east-1"- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Region"- className={- credentialType === DynamicSecretAwsIamCredentialType.TemporaryCredentials- ? "w-full"- : "grow"- }- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- {isIamUser && (- <>- <Controller- control={control}- name="provider.permissionBoundaryPolicyArn"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="IAM User Permission Boundary ARN"- isError={Boolean(error?.message)}- isOptional- errorText={error?.message}- helperText="ARN to be attached to the generated user for AWS Permission Boundary."- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.userGroups"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS IAM Groups"- isError={Boolean(error?.message)}- isOptional- errorText={error?.message}- helperText="Generated users will get attached to given groups."- >- <Input {...field} placeholder="group1,group2" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.policyArns"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Policy ARNs"- isError={Boolean(error?.message)}- isOptional- errorText={error?.message}- helperText="Generated users will get attached to given policy arns. AWS allows at most 10 attached managed policies."- >- <Input- {...field}- placeholder="arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.policyDocument"- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS IAM Policy Document"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Generated users will have the inline policy."- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </>- )}- {isSessionPolicySupported && (- <>- <Controller- control={control}- name="provider.sessionPolicyArns"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Session Policy ARNs"- isError={Boolean(error?.message)}- isOptional- errorText={error?.message}- helperText="Leased credentials are limited to the intersection of the role's permissions and these managed policies. They can only restrict, never add, permissions. Up to 10 ARNs, comma-separated."- >- <Input- {...field}- placeholder="arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.sessionPolicyDocument"- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Session Policy Document"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Inline session policy (JSON) that further restricts the leased temporary credentials. It cannot grant permissions beyond the role's policies. Maximum 2,048 characters."- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </>- )}- {credentialType !== DynamicSecretAwsIamCredentialType.TemporaryCredentials && (- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- )}- {credentialType !== DynamicSecretAwsIamCredentialType.TemporaryCredentials && (- <MetadataForm control={control} name="provider.tags" title="Tags" isValueRequired />- )}- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsMemoryDbInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsMemoryDbInputForm.tsxdeleted file mode 100644index cdcf6719cc..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsMemoryDbInputForm.tsx+++ /dev/null@@ -1,350 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- TextArea-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { AwsMemoryDbAuthType, DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";--const formSchema = z.object({- provider: z.object({- clusterName: z.string().trim().min(1),- region: z.string().trim().min(1),- auth: z.discriminatedUnion("type", [- z.object({- type: z.literal(AwsMemoryDbAuthType.IAM),- accessKeyId: z.string().trim().min(1),- secretAccessKey: z.string().trim().min(1)- })- ]),- creationStatement: z.string().trim(),- revocationStatement: z.string().trim()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const AwsMemoryDbInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- auth: { type: AwsMemoryDbAuthType.IAM, accessKeyId: "", secretAccessKey: "" },- creationStatement: `{- "UserName": "{{username}}",- "AccessString": "on ~* +@all",- "AuthenticationMode": { "Type": "password", "Passwords": ["{{password}}"] }-}`,- revocationStatement: `{- "UserName": "{{username}}"-}`- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.AwsMemoryDb, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.clusterName"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster name"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="my-memorydb-cluster" />- </FormControl>- )}- />- <Controller- control={control}- defaultValue=""- name="provider.region"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Region"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="us-east-1" {...field} type="text" />- </FormControl>- )}- />- </div>- <div className="flex w-full items-center space-x-2">- <Controller- control={control}- name="provider.auth.accessKeyId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Access Key ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.auth.secretAccessKey"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Access Key"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify MemoryDB Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={4}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AzureEntraIdInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AzureEntraIdInputForm.tsxdeleted file mode 100644index 6587b0cfb8..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AzureEntraIdInputForm.tsx+++ /dev/null@@ -1,409 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faCheckCircle, faWarning } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import { AxiosError } from "axios";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { Button, FilterableSelect, FormControl, Input } from "@app/components/v2";-import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuTrigger-} from "@app/components/v2/Dropdown/Dropdown";-import { Tooltip } from "@app/components/v2/Tooltip";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { useGetDynamicSecretProviderData } from "@app/hooks/api/dynamicSecret/queries";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";--// Sanitize a user display name into a valid dynamic secret name suffix:-// lowercase, only alphanumeric characters and dashes.-const sanitizeUserName = (name: string) => name.toLowerCase().replace(/[^a-z0-9-]/g, "-");--const formSchema = z.object({- selectedUsers: z.array(- z.object({- id: z.string().min(1),- name: z.string().min(1),- email: z.string().min(1)- })- ),- provider: z.object({- tenantId: z.string().min(1),- applicationId: z.string().min(1),- clientSecret: z.string().min(1)- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: z- .string()- .min(1)- .refine((val) => val.toLowerCase() === val, "Must be lowercase"),- environment: z.object({ name: z.string(), slug: z.string() })-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const AzureEntraIdInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- watch,- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- environment: isSingleEnvironmentMode ? environments[0] : undefined- }- });- const tenantId = watch("provider.tenantId");- const applicationId = watch("provider.applicationId");- const clientSecret = watch("provider.clientSecret");-- const configurationComplete = !!(tenantId && applicationId && clientSecret);- const {- data,- isLoading,- isError,- error: fetchUsersError,- isFetching- } = useGetDynamicSecretProviderData({- tenantId,- applicationId,- clientSecret,- projectSlug,- enabled: !!configurationComplete- });- const loading = configurationComplete && isFetching;- const errored = configurationComplete && !isFetching && isError;- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- selectedUsers,- provider,- maxTTL,- defaultTTL,- environment- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;- await Promise.all(- selectedUsers.map(async (user: { id: string; name: string; email: string }) => {- await createDynamicSecret.mutateAsync({- provider: {- type: DynamicSecretProviders.AzureEntraId,- inputs: {- userId: user.id,- tenantId: provider.tenantId,- email: user.email,- applicationId: provider.applicationId,- clientSecret: provider.clientSecret- }- },- maxTTL,- name: `${name}-${sanitizeUserName(user.name)}`,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug- });- })- );- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Prefix"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="provider.tenantId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Tenant Id"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- {...field}- placeholder="Tenant Id from Azure Entra ID App installation"- />- </FormControl>- )}- />- </div>- </div>- <div className="flex flex-col">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="provider.applicationId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Application Id"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- {...field}- placeholder="Application ID from Azure Entra ID App installation"- />- </FormControl>- )}- />- </div>- </div>- <div className="flex flex-col">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="provider.clientSecret"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client Secret"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- {...field}- placeholder="Client Secret from Azure Entra ID App installation"- />- </FormControl>- )}- />- </div>- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Select Users- </div>- <div className="mb-4 flex items-center text-sm font-normal text-mineshaft-400">- We create a unique dynamic secret for each user in Entra Id.- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-4">- <Controller- control={control}- name="selectedUsers"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isRequired isError={Boolean(error)} errorText={error?.message}>- <DropdownMenu>- <DropdownMenuTrigger- className="w-72"- disabled={loading || errored || !configurationComplete}- >- <Tooltip- hidden={!loading && !errored && configurationComplete}- content={- <div>- {(() => {- let icon;- if (errored) {- icon = <FontAwesomeIcon icon={faWarning} color="red" />;- } else if (loading || !configurationComplete) {- icon = <FontAwesomeIcon icon={faWarning} color="yellow" />;- } else {- icon = null;- }- return icon;- })()}- <span className="ml-4 cursor-default text-mineshaft-300 hover:text-mineshaft-200">- {(() => {- let message;- if (loading) {- message = "Loading, please wait...";- } else if (errored) {- message =- (- fetchUsersError as AxiosError<{- message?: string;- }>- )?.response?.data?.message || "Check the configuration";- } else if (!configurationComplete) {- message = "Configuration incomplete";- } else {- message = ""; // or you can leave it undefined- }- return message;- })()}- </span>- </div>- }- >- <div>- <Input- isReadOnly- value={value?.length ? `${value.length} selected` : ""}- className={`text-left ${loading || errored || !configurationComplete ? "cursor-not-allowed" : ""}`}- placeholder="Select users"- />- </div>- </Tooltip>- </DropdownMenuTrigger>- <DropdownMenuContent- align="start"- style={{ width: "var(--radix-dropdown-menu-trigger-width)" }}- >- {data &&- data.map((user) => {- const ids = value?.map((selectedUser) => selectedUser.id);- const isChecked = ids?.includes(user.id);- return (- <DropdownMenuItem- onClick={(evt) => {- evt.preventDefault();- onChange(- isChecked- ? value?.filter((el) => el.id !== user.id)- : [...(value || []), user]- );- }}- key={`create-policy-members-${user.id}`}- iconPos="right"- icon={isChecked && <FontAwesomeIcon icon={faCheckCircle} />}- >- {user.name} <br /> {`(${user.email})`}- </DropdownMenuItem>- );- })}- </DropdownMenuContent>- </DropdownMenu>- </FormControl>- )}- />- </div>- </div>- </div>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting} isDisabled={isLoading || isError}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AzureSqlDatabaseInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AzureSqlDatabaseInputForm.tsxdeleted file mode 100644index c79742898d..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AzureSqlDatabaseInputForm.tsx+++ /dev/null@@ -1,745 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- SecretInput,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import {- OrgGatewayPermissionActions,- OrgPermissionSubjects-} from "@app/context/OrgPermissionContext/types";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--import { MetadataForm } from "../../DynamicSecretListView/MetadataForm";--const passwordRequirementsSchema = z- .object({- length: z.number().min(1).max(250),- required: z- .object({- lowercase: z.number().min(0),- uppercase: z.number().min(0),- digits: z.number().min(0),- symbols: z.number().min(0)- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 250;- }, "Sum of required characters cannot exceed 250"),- allowedSymbols: z.string().optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const formSchema = z.object({- provider: z.object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- passwordRequirements: passwordRequirementsSchema.optional(),- masterCreationStatement: z.string().min(1),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- sslEnabled: z.boolean().optional(),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true),- gatewayId: z.string().optional(),- gatewayPoolId: z.string().optional()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- metadata: z- .object({- key: z.string().trim().min(1),- value: z.string().trim().default("")- })- .array()- .optional(),- usernameTemplate: z.string().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--const getDefaultAzureSqlStatements = () => ({- masterCreationStatement: "CREATE LOGIN [{{username}}] WITH PASSWORD = '{{password}}';",- creationStatement:- "CREATE USER [{{username}}] FOR LOGIN [{{username}}];\nGRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::dbo TO [{{username}}];",- renewStatement: "",- revocationStatement: "DROP USER [{{username}}];\nDROP LOGIN [{{username}}];"-});--export const AzureSqlDatabaseInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- port: 1433,- ...getDefaultAzureSqlStatements(),- sslRejectUnauthorized: true,- passwordRequirements: {- length: 48,- required: {- lowercase: 1,- uppercase: 1,- digits: 1,- symbols: 0- },- allowedSymbols: "-_.~!*"- }- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();- const sslEnabled = watch("provider.sslEnabled");- const providerGatewayId = watch("provider.gatewayId");- const providerGatewayPoolId = watch("provider.gatewayPoolId");-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- metadata,- usernameTemplate- }: TForm) => {- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: {- type: DynamicSecretProviders.AzureSqlDatabase,- inputs: { ...provider, masterDatabase: "master" }- },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- metadata,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>-- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <MetadataForm control={control} />- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: providerGatewayId ?? null,- gatewayPoolId: providerGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("provider.gatewayId", newGwId ?? undefined, {- shouldDirty: true- });- setValue("provider.gatewayPoolId", newPoolId ?? undefined, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="server.database.windows.net" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={1433}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- </div>- <div className="grow">- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div className="grow">- <Controller- control={control}- name="provider.database"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="mydatabase" />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-2 mb-2">- <Controller- control={control}- name="provider.sslEnabled"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="azure-sql-ds-ssl-enabled"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- Encrypt Connection (SSL)- </Switch>- </FormControl>- )}- />- </div>- {sslEnabled && (- <>- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the- list of supplied CAs. Disable this option if you are using a- self-signed certificate.- </p>- }- >- <FontAwesomeIcon- icon={faQuestionCircle}- size="sm"- className="ml-1"- />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- </>- )}- <Accordion type="multiple" className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advanced">- <AccordionTrigger>- Creation, Revocation & Renew Statements (optional)- </AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <div className="mb-4 text-sm text-mineshaft-300">- Customize SQL statements for managing Azure SQL Database user lifecycle- </div>- <Controller- control={control}- name="provider.masterCreationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Master Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Statement to create login in master database"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Statement to create user in target database and grant permissions"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Statement to drop user and login"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>Password Configuration (optional)</AccordionTrigger>- <AccordionContent>- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated database password- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="provider.passwordRequirements.length"- defaultValue={48}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={1}- max={250}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("provider.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("provider.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="provider.passwordRequirements.required.lowercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of lowercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.uppercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of uppercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.digits"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of digits"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.symbols"- defaultValue={0}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of symbols"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="provider.passwordRequirements.allowedSymbols"- defaultValue="-_.~!*"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbols to use in password"- isError={Boolean(error)}- errorText={error?.message}- helperText="Default: -_.~!*"- >- <Input {...field} placeholder="-_.~!*" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CassandraInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CassandraInputForm.tsxdeleted file mode 100644index 407eaea048..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CassandraInputForm.tsx+++ /dev/null@@ -1,577 +0,0 @@-import { useState } from "react";-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { VaultCassandraImportModal } from "@app/components/external-migrations";-import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- SecretInput,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { ProjectPermissionSub, useProject } from "@app/context";-import { useCanUseProjectAppConnectionImport } from "@app/hooks";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";-import { AppConnection } from "@app/hooks/api/appConnections/enums";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { VaultDatabaseRole } from "@app/hooks/api/migration/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--import { LoadFromVaultBanner } from "./components/LoadFromVaultBanner";--const formSchema = z.object({- provider: z.object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- keyspace: z.string().optional(),- localDataCenter: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true)- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--const getSqlStatements = () => {- return {- creationStatement:- "CREATE ROLE '{{username}}' WITH PASSWORD = '{{password}}' AND LOGIN=true;\nGRANT ALL PERMISSIONS ON ALL KEYSPACES TO '{{username}}';",- renewStatement: "",- revocationStatement: 'DROP ROLE "{{username}}";'- };-};--export const CassandraInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const [isVaultImportModalOpen, setIsVaultImportModalOpen] = useState(false);-- const { projectId } = useProject();- const canUseAppConnectionImport = useCanUseProjectAppConnectionImport(- ProjectPermissionSub.Secrets- );- const { data: vaultAppConnections = [] } = useListAvailableAppConnections(- AppConnection.HCVault,- projectId,- { enabled: canUseAppConnectionImport }- );-- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: { ...getSqlStatements(), sslRejectUnauthorized: true },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleVaultImport = (role: VaultDatabaseRole) => {- try {- setValue("name", role.name);-- // Parse hosts field or connection_url- const hostsField = role.config.connection_details.hosts || "";- const connectionUrl = role.config.connection_details.connection_url || "";- const connectionString = hostsField || connectionUrl;-- try {- const trimmedUrl = connectionString.trim();- if (trimmedUrl) {- // Try to extract host and port from various formats- const parts = trimmedUrl.split(",");- const hosts: string[] = [];- let port = 9042; // Default Cassandra port-- parts.forEach((part) => {- const hostPort = part.trim().split(":");- hosts.push(hostPort[0]);- if (hostPort[1]) {- port = parseInt(hostPort[1], 10);- }- });-- if (hosts.length > 0) {- setValue("provider.host", hosts.join(","));- }- if (!Number.isNaN(port)) {- setValue("provider.port", port);- }- }- } catch {- createNotification({- type: "info",- text: "Could not parse connection URL. Host and port fields may need to be filled manually."- });- }-- if (role.config.connection_details.username) {- setValue("provider.username", role.config.connection_details.username);- }-- if (role.config.connection_details.tls_ca) {- setValue("provider.ca", role.config.connection_details.tls_ca);- }-- // Convert {{name}} variable to {{username}}- const convertVaultVariables = (statement: string) =>- statement.replace(/\{\{name\}\}/g, "{{username}}");-- // Set statements- if (role.creation_statements && role.creation_statements.length > 0) {- setValue(- "provider.creationStatement",- role.creation_statements.map(convertVaultVariables).join("\n")- );- }-- if (role.revocation_statements && role.revocation_statements.length > 0) {- setValue(- "provider.revocationStatement",- role.revocation_statements.map(convertVaultVariables).join("\n")- );- }-- if (role.renew_statements && role.renew_statements.length > 0) {- setValue(- "provider.renewStatement",- role.renew_statements.map(convertVaultVariables).join("\n")- );- }-- // Set TTLs- if (role.default_ttl) {- const defaultTTL = `${role.default_ttl}s`;- setValue("defaultTTL", defaultTTL);- }-- if (role.max_ttl) {- const maxTTL = `${role.max_ttl}s`;- setValue("maxTTL", maxTTL);- }-- createNotification({- type: "info",- text: "Configuration loaded successfully from HashiCorp Vault"- });- } catch {- createNotification({- type: "error",- text: "Failed to load configuration from HashiCorp Vault"- });- }- };-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Cassandra, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <LoadFromVaultBanner onClick={() => setIsVaultImportModalOpen(true)} />- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-postgres" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="host1,host2" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={9042}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <Controller- control={control}- name="provider.localDataCenter"- defaultValue="datacenter1"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Local Data Center"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.keyspace"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Keyspace"- isError={Boolean(error?.message)}- isOptional- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div>- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA(SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify CQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="variables: keyspace. username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="variables: keyspace, username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="variables: keyspace, username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- <VaultCassandraImportModal- isOpen={isVaultImportModalOpen}- onOpenChange={setIsVaultImportModalOpen}- appConnections={vaultAppConnections}- onImport={handleVaultImport}- />- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ClickHouseInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ClickHouseInputForm.tsxdeleted file mode 100644index 3220eaf676..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ClickHouseInputForm.tsx+++ /dev/null@@ -1,652 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- SecretInput,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import {- OrgGatewayPermissionActions,- OrgPermissionSubjects-} from "@app/context/OrgPermissionContext/types";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--import { MetadataForm } from "../../DynamicSecretListView/MetadataForm";--const passwordRequirementsSchema = z- .object({- length: z.number().min(1).max(250),- required: z- .object({- lowercase: z.number().min(0),- uppercase: z.number().min(0),- digits: z.number().min(0),- symbols: z.number().min(0)- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 250;- }, "Sum of required characters cannot exceed 250"),- allowedSymbols: z.string().optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const formSchema = z.object({- provider: z.object({- host: z.string().min(1),- port: z.coerce.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- passwordRequirements: passwordRequirementsSchema.optional(),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- ca: z.string().optional(),- gatewayId: z.string().optional(),- gatewayPoolId: z.string().optional()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- metadata: z- .object({- key: z.string().trim().min(1),- value: z.string().trim().default("")- })- .array()- .optional(),- usernameTemplate: z.string().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--const DEFAULT_PASSWORD_REQUIREMENTS = {- length: 48,- required: {- lowercase: 1,- uppercase: 1,- digits: 1,- symbols: 1- },- allowedSymbols: "-_.~!*"-};--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const ClickHouseInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- host: "",- port: 8123,- database: "default",- username: "",- password: "",- creationStatement:- "CREATE USER '{{username}}' IDENTIFIED WITH sha256_password BY '{{password}}';\nGRANT SELECT ON {{database}}.* TO '{{username}}';",- revocationStatement: "DROP USER IF EXISTS '{{username}}';",- renewStatement: "",- passwordRequirements: DEFAULT_PASSWORD_REQUIREMENTS- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();- const providerGatewayId = watch("provider.gatewayId");- const providerGatewayPoolId = watch("provider.gatewayPoolId");-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- metadata,- usernameTemplate- }: TForm) => {- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Clickhouse, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- metadata,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>-- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <MetadataForm control={control} />- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: providerGatewayId ?? null,- gatewayPoolId: providerGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("provider.gatewayId", newGwId ?? undefined, {- shouldDirty: true- });- setValue("provider.gatewayPoolId", newPoolId ?? undefined, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="https://your-host.clickhouse.cloud" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={8123}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.database"- defaultValue="default"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database Name"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div>- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL) - optionally needed for self-signed certificates"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Accordion type="multiple" className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advanced">- <AccordionTrigger>- Creation, Revocation & Renew Statements (optional)- </AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <div className="mb-4 text-sm text-mineshaft-300">- Customize ClickHouse statements for managing database user lifecycle- </div>- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>Password Configuration (optional)</AccordionTrigger>- <AccordionContent>- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated database password- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="provider.passwordRequirements.length"- defaultValue={48}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={1}- max={250}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("provider.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("provider.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="provider.passwordRequirements.required.lowercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of lowercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.uppercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of uppercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.digits"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of digits"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.symbols"- defaultValue={0}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of symbols"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="provider.passwordRequirements.allowedSymbols"- defaultValue="-_.~!*"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbols to use in password"- isError={Boolean(error)}- errorText={error?.message}- helperText="Default: -_.~!*"- >- <Input {...field} placeholder="-_.~!*" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CouchbaseInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CouchbaseInputForm.tsxdeleted file mode 100644index 5e6c957522..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CouchbaseInputForm.tsx+++ /dev/null@@ -1,940 +0,0 @@-/* eslint-disable jsx-a11y/label-has-associated-control */-import { Controller, useForm } from "react-hook-form";-import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- IconButton,- Input,- SecretInput,- Switch,- Tooltip-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--// Component for managing scopes and collections within a bucket-const BucketScopesConfiguration = ({- control,- bucketIndex,- bucketsValue,- setValue,- addScope,- removeScope,- addCollection,- removeCollection-}: {- control: any;- bucketIndex: number;- bucketsValue: any;- setValue: any;- addScope: (bucketIndex: number) => void;- removeScope: (bucketIndex: number, scopeIndex: number) => void;- addCollection: (bucketIndex: number, scopeIndex: number) => void;- removeCollection: (bucketIndex: number, scopeIndex: number, collectionIndex: number) => void;-}) => {- const bucket = Array.isArray(bucketsValue) ? bucketsValue[bucketIndex] : null;- const scopeFields = bucket?.scopes || [];-- return (- <div className="space-y-3">- <div className="flex items-center justify-between">- <label className="text-sm font-medium text-mineshaft-300">Scopes</label>- <Button- type="button"- variant="outline_bg"- size="xs"- onClick={() => addScope(bucketIndex)}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add Scope- </Button>- </div>-- {scopeFields.map((_scope: any, scopeIndex: number) => (- <div- key={`scope-${scopeIndex + 1}`}- className="space-y-3 rounded-sm border border-mineshaft-600 bg-mineshaft-700 p-3"- >- <div className="flex items-center justify-between">- <h5 className="text-xs font-medium text-mineshaft-200">Scope {scopeIndex + 1}</h5>- <IconButton- type="button"- variant="plain"- ariaLabel="Remove scope"- size="sm"- onClick={() => removeScope(bucketIndex, scopeIndex)}- >- <FontAwesomeIcon icon={faTrash} className="text-red-400" />- </IconButton>- </div>-- <Controller- control={control}- name={`provider.buckets.${bucketIndex}.scopes.${scopeIndex}.name`}- render={({ field, fieldState: { error } }) => (- <FormControl label="Scope Name" isError={Boolean(error)} errorText={error?.message}>- <Input {...field} placeholder="e.g., inventory, _default" className="text-sm" />- </FormControl>- )}- />-- <div className="space-y-2 pl-4">- <div className="flex items-center justify-between">- <label className="text-xs font-medium text-mineshaft-300">Collections</label>- <Button- type="button"- variant="outline_bg"- size="xs"- onClick={() => addCollection(bucketIndex, scopeIndex)}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add Collection- </Button>- </div>-- {scopeFields[scopeIndex]?.collections?.map(- (collection: string, collectionIndex: number) => (- <div- // eslint-disable-next-line react/no-array-index-key- key={`collection-${bucketIndex}-${scopeIndex}-${collectionIndex}`}- className="flex items-center space-x-2"- >- <FormControl className="flex-1">- <Input- value={collection || ""}- onChange={(e) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]?.scopes?.[scopeIndex]?.collections) {- currentBuckets[bucketIndex].scopes[scopeIndex].collections[- collectionIndex- ] = e.target.value;- setValue("provider.buckets", currentBuckets);- }- }}- placeholder="e.g., airport, airline"- className="text-sm"- />- </FormControl>- <IconButton- type="button"- variant="plain"- ariaLabel="Remove collection"- className="mb-4"- size="sm"- onClick={() => removeCollection(bucketIndex, scopeIndex, collectionIndex)}- >- <FontAwesomeIcon icon={faTrash} className="text-red-400" />- </IconButton>- </div>- )- )}-- {(!scopeFields[scopeIndex]?.collections ||- scopeFields[scopeIndex].collections.length === 0) && (- <div className="text-xs text-mineshaft-400 italic">- No collections specified (access to all collections in scope)- </div>- )}- </div>- </div>- ))}-- {scopeFields.length === 0 && (- <div className="rounded-sm border border-dashed border-mineshaft-600 bg-mineshaft-700 p-4 text-center">- <p className="mb-2 text-xs text-mineshaft-400">- No scopes configured (access to all scopes in bucket)- </p>- <Button- type="button"- variant="outline_bg"- size="xs"- onClick={() => addScope(bucketIndex)}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add Scope- </Button>- </div>- )}- </div>- );-};--const couchbaseRoles = [- { value: "read", label: "Read", description: "Read-only access to bucket data" },- {- value: "write",- label: "Write",- description: "Full write access to bucket data"- }-];--const passwordRequirementsSchema = z- .object({- length: z.number().min(8, "Password must be at least 8 characters").max(128),- required: z- .object({- lowercase: z.number().min(1, "At least 1 lowercase character required"),- uppercase: z.number().min(1, "At least 1 uppercase character required"),- digits: z.number().min(1, "At least 1 digit required"),- symbols: z.number().min(1, "At least 1 special character required")- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 128;- }, "Sum of required characters cannot exceed 128"),- allowedSymbols: z- .string()- .refine((symbols) => {- const forbiddenChars = ["<", ">", ";", ".", "*", "&", "|", "£"];- return !forbiddenChars.some((char) => symbols?.includes(char));- }, "Cannot contain: < > ; . * & | £")- .optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const bucketSchema = z.object({- name: z.string().trim().min(1, "Bucket name is required"),- scopes: z- .array(- z.object({- name: z.string().trim().min(1, "Scope name is required"),- collections: z.array(z.string().trim().min(1)).optional()- })- )- .optional()-});--const formSchema = z.object({- provider: z.object({- url: z.string().url().trim().min(1),- orgId: z.string().trim().min(1),- projectId: z.string().trim().min(1),- clusterId: z.string().trim().min(1),- roles: z.array(z.string()).min(1, "At least one role must be selected"),- buckets: z.union([z.string().trim().min(1), z.array(bucketSchema)]),- useAdvancedBuckets: z.boolean().default(false),- passwordRequirements: passwordRequirementsSchema.optional(),- auth: z.object({- apiKey: z.string().trim().min(1)- })- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const CouchbaseInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- getValues,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- url: "https://cloudapi.cloud.couchbase.com",- roles: ["read"],- buckets: "*",- useAdvancedBuckets: false,- passwordRequirements: {- length: 12,- required: {- lowercase: 1,- uppercase: 1,- digits: 1,- symbols: 1- },- allowedSymbols: "!@#$%^()_+-=[]{}:,?/~`"- },- auth: {- apiKey: ""- }- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const isAdvancedMode = watch("provider.useAdvancedBuckets");- const bucketsValue = watch("provider.buckets");-- const addBucket = () => {- const currentBuckets = Array.isArray(bucketsValue) ? bucketsValue : [];- setValue("provider.buckets", [...currentBuckets, { name: "", scopes: [] }]);- };-- const removeBucket = (index: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? bucketsValue : [];- const newBuckets = currentBuckets.filter((_, i) => i !== index);- setValue("provider.buckets", newBuckets);- };-- const addScope = (bucketIndex: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]) {- const currentScopes = currentBuckets[bucketIndex].scopes || [];- currentBuckets[bucketIndex] = {- ...currentBuckets[bucketIndex],- scopes: [...currentScopes, { name: "", collections: [] }]- };- setValue("provider.buckets", currentBuckets);- }- };-- const removeScope = (bucketIndex: number, scopeIndex: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]?.scopes) {- currentBuckets[bucketIndex].scopes = currentBuckets[bucketIndex].scopes.filter(- (_, i) => i !== scopeIndex- );- setValue("provider.buckets", currentBuckets);- }- };-- const addCollection = (bucketIndex: number, scopeIndex: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]?.scopes?.[scopeIndex]) {- const currentCollections = currentBuckets[bucketIndex].scopes[scopeIndex].collections || [];- currentBuckets[bucketIndex].scopes[scopeIndex].collections = [...currentCollections, ""];- setValue("provider.buckets", currentBuckets);- }- };-- const removeCollection = (bucketIndex: number, scopeIndex: number, collectionIndex: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]?.scopes?.[scopeIndex]?.collections) {- currentBuckets[bucketIndex].scopes[scopeIndex].collections = currentBuckets[- bucketIndex- ].scopes[scopeIndex].collections.filter((_, i) => i !== collectionIndex);- setValue("provider.buckets", currentBuckets);- }- };-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- if (createDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";-- const transformedProvider = {- ...provider,- buckets: provider.useAdvancedBuckets ? provider.buckets : (provider.buckets as string)- };-- const { useAdvancedBuckets, ...finalProvider } = transformedProvider;-- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Couchbase, inputs: finalProvider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.url"- defaultValue="https://cloudapi.cloud.couchbase.com"- render={({ field, fieldState: { error } }) => (- <FormControl- label="URL"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="https://cloudapi.cloud.couchbase.com" {...field} />- </FormControl>- )}- />- </div>- <div className="flex flex-col space-y-4">- <Controller- control={control}- name="provider.orgId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Organization ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.projectId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Project ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.clusterId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <Controller- control={control}- name="provider.roles"- defaultValue={["read"]}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Roles"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Select one or more roles to assign to the user"- >- <FilterableSelect- isMulti- value={couchbaseRoles.filter((role) => value?.includes(role.value))}- onChange={(selectedRoles) => {- if (Array.isArray(selectedRoles)) {- onChange(selectedRoles.map((role: any) => role.value));- } else {- onChange([]);- }- }}- options={couchbaseRoles}- placeholder="Select roles..."- getOptionLabel={(option) => option.label}- getOptionValue={(option) => option.value}- />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.useAdvancedBuckets"- render={({ field: { value, onChange } }) => (- <FormControl- label="Advanced Bucket Configuration"- helperText="Enable to configure specific buckets, scopes and collections. When disabled, '*' grants access to all buckets, scopes, and collections."- >- <Switch- id="advanced-buckets-switch"- isChecked={value}- onCheckedChange={(checked) => {- onChange(checked);- const bucketsController = getValues("provider.buckets");- if (checked && typeof bucketsController === "string") {- setValue("provider.buckets", []);- } else if (!checked && Array.isArray(bucketsController)) {- setValue("provider.buckets", "*");- }- }}- />- </FormControl>- )}- />-- {!watch("provider.useAdvancedBuckets") && (- <Controller- control={control}- name="provider.buckets"- defaultValue="*"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Bucket Access"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Specify bucket names separated by commas (e.g., 'bucket1,bucket2') or use '*' for all buckets, scopes, and collections"- >- <Input- {...field}- value={typeof field.value === "string" ? field.value : "*"}- onChange={(e) => field.onChange(e.target.value)}- placeholder="* (all buckets, scopes & collections) or bucket1,bucket2,bucket3"- />- </FormControl>- )}- />- )}-- {isAdvancedMode && Array.isArray(bucketsValue) && (- <div className="space-y-4">- <div className="flex items-center justify-between">- <div>- <div className="text-sm font-medium text-mineshaft-200">- Advanced Bucket Configuration- </div>- <div className="text-sm text-mineshaft-400">- Configure specific buckets with their scopes and collections. Leave scopes- empty for access to all scopes in a bucket.- </div>- </div>- <Button- type="button"- variant="outline_bg"- size="sm"- onClick={addBucket}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add Bucket- </Button>- </div>-- <div className="space-y-4">- {Array.isArray(bucketsValue) &&- (bucketsValue as any[]).map((_, bucketIndex) => (- <div- key={`bucket-${bucketIndex + 1}`}- className="space-y-4 rounded-sm border border-mineshaft-600 bg-mineshaft-800 p-4"- >- <div className="flex items-center justify-between">- <h4 className="text-sm font-medium text-mineshaft-200">- Bucket {bucketIndex + 1}- </h4>- <IconButton- type="button"- variant="plain"- ariaLabel="Remove bucket"- onClick={() => removeBucket(bucketIndex)}- >- <FontAwesomeIcon icon={faTrash} className="text-red-400" />- </IconButton>- </div>-- <Controller- control={control}- name={`provider.buckets.${bucketIndex}.name`}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Bucket Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="e.g., travel-sample" />- </FormControl>- )}- />-- <BucketScopesConfiguration- control={control}- bucketIndex={bucketIndex}- bucketsValue={bucketsValue}- setValue={setValue}- addScope={addScope}- removeScope={removeScope}- addCollection={addCollection}- removeCollection={removeCollection}- />- </div>- ))}-- {(!Array.isArray(bucketsValue) || bucketsValue.length === 0) && (- <div className="rounded-sm border border-dashed border-mineshaft-600 p-8 text-center">- <p className="mb-2 text-sm text-mineshaft-400">No buckets configured</p>- <Button- type="button"- variant="outline_bg"- size="sm"- onClick={addBucket}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add First Bucket- </Button>- </div>- )}- </div>- </div>- )}- <Controller- name="provider.auth.apiKey"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- className="w-full"- label="API Key"- >- <SecretInput- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- valueAlwaysHidden- value={value}- rows={1}- wrap="hard"- onChange={(e) => onChange(e.target.value)}- />- </FormControl>- )}- />- </div>-- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>- <div className="flex items-center space-x-2">- <span>Password Configuration (optional)</span>- <Tooltip content="Couchbase password requirements: minimum 8 characters, at least 1 uppercase, 1 lowercase, 1 digit, 1 special character. Cannot contain: < > ; . * & | £">- <div className="flex h-4 w-4 cursor-help items-center justify-center rounded-full bg-mineshaft-600 text-xs text-mineshaft-300">- ?- </div>- </Tooltip>- </div>- </AccordionTrigger>- <AccordionContent>- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated Couchbase user password (8-128 characters)- <br />- <span className="text-xs text-mineshaft-400">- Forbidden characters: < > ; . * & | £- </span>- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="provider.passwordRequirements.length"- defaultValue={12}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={8}- max={128}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("provider.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("provider.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="provider.passwordRequirements.required.lowercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Min lowercase letters (required: ≥1)"- >- <Input- type="number"- min={1}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.uppercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Min uppercase letters (required: ≥1)"- >- <Input- type="number"- min={1}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.digits"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Min digits (required: ≥1)"- >- <Input- type="number"- min={1}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.symbols"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Min special characters (required: ≥1)"- >- <Input- type="number"- min={1}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="provider.passwordRequirements.allowedSymbols"- defaultValue="!@#$%^()_+-=[]{}:,?/~`"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Allowed Symbols"- isError={Boolean(error)}- errorText={error?.message}- helperText="Cannot contain: < > ; . * & | £"- >- <Input {...field} placeholder="!@#$%^()_+-=[]{}:,?/~`" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ElasticSearchInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ElasticSearchInputForm.tsxdeleted file mode 100644index 5365b2d6f8..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/ElasticSearchInputForm.tsx+++ /dev/null@@ -1,509 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faPlus, faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Button,- FilterableSelect,- FormControl,- FormLabel,- IconButton,- Input,- SecretInput,- Select,- SelectItem,- Switch,- Tooltip-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const authMethods = [- {- label: "Username/Password",- value: "user"- },- {- label: "API Key",- value: "api-key"- }-] as const;--const formSchema = z.object({- provider: z.object({- host: z.string().trim().min(1),- port: z.coerce.number(),-- // two auth types "user, apikey"- auth: z.discriminatedUnion("type", [- z.object({- type: z.literal("user"),- username: z.string().trim(),- password: z.string().trim()- }),- z.object({- type: z.literal("api-key"),- apiKey: z.string().trim(),- apiKeyId: z.string().trim()- })- ]),-- roles: z.array(z.string().trim().min(1)).min(1, "At least one role is required"),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true)- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const ElasticSearchInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- auth: {- type: "user"- },- roles: ["superuser"],- port: 443,- sslRejectUnauthorized: true- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.ElasticSearch, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- const selectedAuthType = watch("provider.auth.type");- const selectedRoles = watch("provider.roles");-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- placeholder="https://fgy543ws2w35dfh7jdaafa12ha.aws-us-east-1.io"- {...field}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={443}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>-- <div className="flex w-full items-center gap-2">- <Controller- control={control}- name="provider.auth.type"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Authentication Method"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => {- const authFields = [- "provider.auth.username",- "provider.auth.password",- "provider.auth.apiKey",- "provider.auth.apiKeyId"- ] as const;-- authFields.forEach((f) => {- setValue(f, "");- });-- field.onChange(e);- }}- >- {authMethods.map((authType) => (- <SelectItem value={authType.value} key={`auth-method-${authType.value}`}>- {authType.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- <Controller- control={control}- name={- selectedAuthType === "user"- ? "provider.auth.username"- : "provider.auth.apiKeyId"- }- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label={selectedAuthType === "user" ? "Username" : "API Key ID"}- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name={- selectedAuthType === "user" ? "provider.auth.password" : "provider.auth.apiKey"- }- render={({ field, fieldState: { error } }) => (- <FormControl- label={selectedAuthType === "user" ? "Password" : "API Key"}- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>-- <div className="mb-3 flex flex-col">- <FormLabel- className="mb-2"- label="Roles"- tooltipText={- <div className="space-y-4">- <p>Select which role(s) to assign the users provisioned by Infisical.</p>- <p>- There is a wide range of in-built roles in Elastic Search. Some include,- superuser, apm_user, kibana_admin, monitoring_user, and many more. You can{" "}- <a- href="https://www.elastic.co/guide/en/elasticsearch/reference/current/built-in-roles.html"- target="_blank"- rel="noopener noreferrer"- >- <span className="cursor-pointer text-primary-400">- read more about roles here- </span>- </a>- .- </p>- <p>- You can also assign custom roles by providing the name of the custom role in- the input field.- </p>- </div>- }- />- <div className="flex flex-col -space-y-2">- {selectedRoles.map((_, i) => (- <Controller- control={control}- name={`provider.roles.${i}`}- // eslint-disable-next-line react/no-array-index-key- key={`role-${i}`}- render={({ field, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <div className="flex h-9 items-center gap-2">- <Input- placeholder="Insert role name, (superuser, kibana_admin, custom_role)"- className="mb-0 grow"- {...field}- />- <IconButton- isDisabled={selectedRoles.length === 1}- ariaLabel="delete key"- className="h-9"- variant="outline_bg"- onClick={() => {- if (selectedRoles && selectedRoles?.length > 1) {- setValue(- "provider.roles",- selectedRoles.filter((__, idx) => idx !== i)- );- }- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- </FormControl>- )}- />- ))}- </div>- </div>- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- className="mb-3"- variant="outline_bg"- onClick={() => {- setValue("provider.roles", [...selectedRoles, ""]);- }}- >- Add Role- </Button>- </div>- <div>- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GcpIamInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GcpIamInputForm.tsxdeleted file mode 100644index d4bbc86afd..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GcpIamInputForm.tsx+++ /dev/null@@ -1,307 +0,0 @@-import { Controller, useFieldArray, useForm } from "react-hook-form";-import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { Button, FilterableSelect, FormControl, IconButton, Input } from "@app/components/v2";-import { useOrganization } from "@app/context";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";--const validateTTL = (val: string, ctx: z.RefinementCtx) => {- if (!val) return;- const valMs = ms(val);- if (valMs === undefined) {- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid TTL format" });- return;- }- if (valMs < 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1 second" });- if (valMs > 60 * 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 1 hour" });-};--const formSchema = z- .object({- provider: z.object({- serviceAccountEmail: z.string().email().trim().min(1, "Service account email required"),- tokenScopes: z- .array(z.object({ value: z.string().trim().min(1, "Scope is required") }))- .min(1, "At least one scope is required")- }),- defaultTTL: z.string().superRefine(validateTTL),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (val) validateTTL(val, ctx);- }),- name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),- environment: z.object({ name: z.string(), slug: z.string() })- })- .refine((d) => !d.maxTTL || ms(d.maxTTL)! >= ms(d.defaultTTL)!, {- path: ["maxTTL"],- message: "Max TTL must be greater than or equal to Default TTL"- });-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const GcpIamInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const { currentOrg } = useOrganization();- const expectedAccountIdSuffix = currentOrg.id.split("-").slice(0, 2).join("-");-- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- environment: isSingleEnvironmentMode && environments.length > 0 ? environments[0] : undefined,- provider: {- tokenScopes: [- { value: "https://www.googleapis.com/auth/iam" },- { value: "https://www.googleapis.com/auth/cloud-platform" }- ]- }- }- });-- const { fields, append, remove } = useFieldArray({- control,- name: "provider.tokenScopes"- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;- await createDynamicSecret.mutateAsync({- provider: {- type: DynamicSecretProviders.GcpIam,- inputs: {- ...provider,- tokenScopes: [...new Set(provider.tokenScopes.map((scope) => scope.value))]- }- },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="30m"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>-- <div className="flex flex-col">- <Controller- control={control}- name="provider.serviceAccountEmail"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Service Account Email"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- tooltipText={`The service account ID (the part of the email before "@") must end with the first two sections of your organization ID: "${expectedAccountIdSuffix}". Example: my-service-account-${expectedAccountIdSuffix}@my-project.iam.gserviceaccount.com`}- helperText={- <span>- Don't know where to get this value?{" "}- <a- href="https://infisical.com/docs/documentation/platform/dynamic-secrets/gcp-iam#param-service-account-email"- target="_blank"- className="underline"- rel="noreferrer"- >- Read our docs- </a>- </span>- }- >- <Input placeholder="[email protected]" {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.tokenScopes"- render={({ fieldState: { error } }) => (- <FormControl- label="Token Scopes"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <div className="flex flex-col space-y-2">- {fields.map((field, index) => (- <div key={field.id} className="flex items-end space-x-2">- <div className="grow">- <Controller- control={control}- name={`provider.tokenScopes.${index}.value`}- render={({ field: itemField, fieldState: { error: itemError } }) => (- <FormControl- isError={Boolean(itemError?.message)}- errorText={itemError?.message}- className="mb-0 grow"- >- <Input- {...itemField}- placeholder="https://www.googleapis.com/auth/cloud-platform"- />- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="Remove scope"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => remove(index)}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() => append({ value: "" })}- type="button"- >- Add Scope- </Button>- </div>- </div>- </FormControl>- )}- />- </div>-- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>-- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GithubInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GithubInputForm.tsxdeleted file mode 100644index 31256f5a11..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GithubInputForm.tsx+++ /dev/null@@ -1,226 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import { z } from "zod";--import {- Button,- FilterableSelect,- FormControl,- FormLabel,- Input,- SecretInput,- Tooltip-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";--const formSchema = z.object({- provider: z.object({- appId: z.coerce.number().min(1, "Required"),- installationId: z.coerce.number().min(1, "Required"),- privateKey: z- .string()- .trim()- .min(1, "Required")- .refine(- (val) =>- /^-----BEGIN(?:(?: RSA| PGP| ENCRYPTED)? PRIVATE KEY)-----\s*[\s\S]*?-----END(?:(?: RSA| PGP| ENCRYPTED)? PRIVATE KEY)-----$/.test(- val- ),- "Invalid PEM format for private key"- )- }),- name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),- environment: z.object({ name: z.string(), slug: z.string() })-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const GithubInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- environment: isSingleEnvironmentMode && environments.length > 0 ? environments[0] : undefined- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({ name, provider, environment }: TForm) => {- if (createDynamicSecret.isPending) return;- await createDynamicSecret.mutateAsync({- provider: {- type: DynamicSecretProviders.Github,- inputs: {- ...provider- }- },- defaultTTL: "1h", // Github is limited to 1 hour tokens- name,- path: secretPath,- projectSlug,- environmentSlug: environment.slug- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <FormControl- label={- <FormLabel- label="Default TTL"- icon={- <Tooltip content="Github token TTL is fixed to 1 hour">- <FontAwesomeIcon- icon={faQuestionCircle}- size="sm"- className="relative right-1 bottom-px"- />- </Tooltip>- }- />- }- >- <Input disabled value="1h" className="pointer-events-none opacity-50" />- </FormControl>- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>-- <div className="flex flex-col">- <Controller- control={control}- name="provider.appId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="App ID"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input placeholder="0000000" {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.installationId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Installation ID"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input placeholder="00000000" {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.privateKey"- render={({ field, fieldState: { error } }) => (- <FormControl- label="App Private Key PEM"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />- </div>-- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>-- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/IbmApiConnectInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/IbmApiConnectInputForm.tsxdeleted file mode 100644index efd7d81c9d..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/IbmApiConnectInputForm.tsx+++ /dev/null@@ -1,547 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { SingleValue } from "react-select";-import {- faCheckCircle,- faCircleNotch,- faTriangleExclamation-} from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { OrgPermissionCan } from "@app/components/permissions";-import { Button, FilterableSelect, FormControl, Input, SecretInput } from "@app/components/v2";-import { Tooltip } from "@app/components/v2/Tooltip";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import {- OrgGatewayPermissionActions,- OrgPermissionSubjects-} from "@app/context/OrgPermissionContext/types";-import { useCreateDynamicSecret } from "@app/hooks/api";-import {- useGetIbmApiConnectOrgApps,- useGetIbmApiConnectOrgCatalogs,- useGetIbmApiConnectOrgs-} from "@app/hooks/api/dynamicSecret/queries";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";--const validateTTL = (val: string, ctx: z.RefinementCtx) => {- if (!val) return;- const valMs = ms(val);- if (valMs === undefined) {- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid TTL format" });- return;- }- if (valMs < 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1 second" });-};--const formSchema = z- .object({- provider: z.object({- clientId: z.string().trim().min(1, "Client ID is required"),- clientSecret: z.string().trim().min(1, "Client Secret is required"),- instanceUrl: z.string().url("Must be a valid URL").trim().min(1, "Instance URL is required"),- apiKey: z.string().trim().min(1, "API Key is required"),- orgId: z.string().trim().min(1, "Organization is required"),- catalogId: z.string().trim().min(1, "Catalog is required"),- consumerOrgId: z.string().trim().min(1, "Consumer Organization is required"),- appId: z.string().trim().min(1, "Application is required"),- gatewayId: z.string().optional(),- gatewayPoolId: z.string().optional()- }),- defaultTTL: z.string().superRefine(validateTTL),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (val) validateTTL(val, ctx);- }),- name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),- environment: z.object({ name: z.string(), slug: z.string() })- })- .refine((d) => !d.maxTTL || ms(d.maxTTL)! >= ms(d.defaultTTL)!, {- path: ["maxTTL"],- message: "Max TTL must be greater than or equal to Default TTL"- });-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const IbmApiConnectInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- watch,- setValue,- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- environment: isSingleEnvironmentMode && environments.length > 0 ? environments[0] : undefined- }- });-- const instanceUrl = watch("provider.instanceUrl");- const apiKey = watch("provider.apiKey");- const clientId = watch("provider.clientId");- const clientSecret = watch("provider.clientSecret");- const orgId = watch("provider.orgId");- const catalogId = watch("provider.catalogId");-- const credentialsComplete = !!(instanceUrl && apiKey && clientId && clientSecret);- const orgSelected = credentialsComplete && !!orgId;- const catalogSelected = orgSelected && !!catalogId;-- const {- data: orgs,- isFetching: isOrgsFetching,- isError: isOrgsError- } = useGetIbmApiConnectOrgs({- instanceUrl: instanceUrl || "",- apiKey: apiKey || "",- clientId: clientId || "",- clientSecret: clientSecret || "",- projectSlug,- enabled: credentialsComplete- });-- const selectedOrg = orgs?.find((o) => o.id === orgId);-- const {- data: catalogs,- isFetching: isCatalogsFetching,- isError: isCatalogsError- } = useGetIbmApiConnectOrgCatalogs({- instanceUrl: instanceUrl || "",- apiKey: apiKey || "",- clientId: clientId || "",- clientSecret: clientSecret || "",- orgId: selectedOrg?.id || "",- projectSlug,- enabled: orgSelected- });-- const selectedCatalog = catalogs?.find((c) => c.id === catalogId);-- const {- data: apps,- isFetching: isAppsFetching,- isError: isAppsError- } = useGetIbmApiConnectOrgApps({- instanceUrl: instanceUrl || "",- apiKey: apiKey || "",- clientId: clientId || "",- clientSecret: clientSecret || "",- orgId: selectedOrg?.id || "",- catalogId: selectedCatalog?.id || "",- projectSlug,- enabled: catalogSelected- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment- }: TForm) => {- if (createDynamicSecret.isPending) return;- await createDynamicSecret.mutateAsync({- provider: {- type: DynamicSecretProviders.IbmApiConnect,- inputs: {- ...provider- }- },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug- });- onCompleted();- };-- const getOrgTooltipContent = () => {- if (!credentialsComplete) return "Fill in all credentials above first";- if (isOrgsError) return "Failed to load organizations — check your credentials";- return undefined;- };-- const getCatalogTooltipContent = () => {- if (!orgSelected) return "Select an organization first";- if (isCatalogsError) return "Failed to load catalogs";- return undefined;- };-- const getAppTooltipContent = () => {- if (!catalogSelected) return "Select a catalog first";- if (isAppsError) return "Failed to load applications";- return undefined;- };-- const getStatusIndicator = (isComplete: boolean, isFetching: boolean, isError: boolean) => {- if (!isComplete) return null;- if (isFetching)- return <FontAwesomeIcon icon={faCircleNotch} className="animate-spin text-primary" />;- if (isError) return <FontAwesomeIcon icon={faTriangleExclamation} className="text-red-500" />;- return <FontAwesomeIcon icon={faCheckCircle} className="text-green-500" />;- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>-- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: watch("provider.gatewayId") ?? null,- gatewayPoolId: watch("provider.gatewayPoolId") ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("provider.gatewayId", newGwId ?? undefined, {- shouldDirty: true- });- setValue("provider.gatewayPoolId", newPoolId ?? undefined, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>-- <div className="flex flex-col">- <Controller- control={control}- name="provider.instanceUrl"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Instance URL"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input- placeholder="https://platform-api.trial.apiconnect.automation.ibm.com"- {...field}- />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.apiKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="API Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.clientId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client ID"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input placeholder="" {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.clientSecret"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client Secret"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />- </div>-- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- <div className="flex items-center space-x-2">- <span>Organization, Catalog & Application</span>- {getStatusIndicator(credentialsComplete, isOrgsFetching, isOrgsError)}- </div>- </div>-- <Controller- control={control}- name="provider.orgId"- defaultValue=""- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Organization"- isError={Boolean(error)}- errorText={error?.message}- isRequired- >- <Tooltip- content={getOrgTooltipContent()}- isDisabled={credentialsComplete && !isOrgsError}- >- <div>- <FilterableSelect- isDisabled={!credentialsComplete || isOrgsFetching || isOrgsError}- isLoading={isOrgsFetching}- options={orgs ?? []}- value={orgs?.find((o) => o.id === value) ?? null}- onChange={(opt) => {- const option = opt as SingleValue<NonNullable<typeof orgs>[number]>;- onChange(option?.id ?? "");- setValue("provider.catalogId", "");- setValue("provider.consumerOrgId", "");- setValue("provider.appId", "");- }}- placeholder="Select an organization..."- getOptionLabel={(option) => option.title || option.name}- getOptionValue={(option) => option.id}- />- </div>- </Tooltip>- </FormControl>- )}- />-- <Controller- control={control}- name="provider.catalogId"- defaultValue=""- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label={- <div className="flex items-center space-x-2">- <span>Catalog</span>- {getStatusIndicator(orgSelected, isCatalogsFetching, isCatalogsError)}- </div>- }- isError={Boolean(error)}- errorText={error?.message}- isRequired- >- <Tooltip- content={getCatalogTooltipContent()}- isDisabled={orgSelected && !isCatalogsError}- >- <div>- <FilterableSelect- isDisabled={!orgSelected || isCatalogsFetching || isCatalogsError}- isLoading={isCatalogsFetching}- options={catalogs ?? []}- value={catalogs?.find((c) => c.id === value) ?? null}- onChange={(opt) => {- const option = opt as SingleValue<NonNullable<typeof catalogs>[number]>;- onChange(option?.id ?? "");- setValue("provider.consumerOrgId", "");- setValue("provider.appId", "");- }}- placeholder="Select a catalog..."- getOptionLabel={(option) => option.title || option.name}- getOptionValue={(option) => option.id}- />- </div>- </Tooltip>- </FormControl>- )}- />-- <Controller- control={control}- name="provider.appId"- defaultValue=""- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label={- <div className="flex items-center space-x-2">- <span>Application</span>- {getStatusIndicator(catalogSelected, isAppsFetching, isAppsError)}- </div>- }- isError={Boolean(error)}- errorText={error?.message}- isRequired- >- <Tooltip- content={getAppTooltipContent()}- isDisabled={catalogSelected && !isAppsError}- >- <div>- <FilterableSelect- isDisabled={!catalogSelected || isAppsFetching || isAppsError}- isLoading={isAppsFetching}- options={apps ?? []}- value={apps?.find((a) => a.id === value) ?? null}- onChange={(opt) => {- const option = opt as SingleValue<NonNullable<typeof apps>[number]>;- onChange(option?.id ?? "");- setValue("provider.consumerOrgId", option?.consumerOrgId ?? "");- }}- placeholder="Select an application..."- getOptionLabel={(option) => option.title || option.name}- getOptionValue={(option) => option.id}- />- </div>- </Tooltip>- </FormControl>- )}- />-- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>-- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/KubernetesInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/KubernetesInputForm.tsxdeleted file mode 100644index 53f792cfa9..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/KubernetesInputForm.tsx+++ /dev/null@@ -1,775 +0,0 @@-import { useState } from "react";-import { Controller, FieldValues, useFieldArray, useForm } from "react-hook-form";-import { faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { VaultKubernetesImportModal } from "@app/components/external-migrations";-import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Button,- FilterableSelect,- FormControl,- IconButton,- Input,- Select,- SelectItem,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import { ProjectPermissionSub, useProject } from "@app/context";-import { OrgPermissionSubjects } from "@app/context/OrgPermissionContext";-import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";-import { useCanUseProjectAppConnectionImport } from "@app/hooks";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";-import { AppConnection } from "@app/hooks/api/appConnections/enums";-import {- DynamicSecretProviders,- KubernetesDynamicSecretCredentialType-} from "@app/hooks/api/dynamicSecret/types";-import { VaultKubernetesRole } from "@app/hooks/api/migration/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--import { LoadFromVaultBanner } from "./components/LoadFromVaultBanner";--enum RoleType {- ClusterRole = "cluster-role",- Role = "role"-}--export enum AuthMethod {- Api = "api",- Gateway = "gateway"-}--const credentialTypes = [- {- label: "Static",- value: KubernetesDynamicSecretCredentialType.Static- },- {- label: "Dynamic",- value: KubernetesDynamicSecretCredentialType.Dynamic- }-] as const;--const formSchema = z- .object({- provider: z.discriminatedUnion("credentialType", [- z.object({- url: z.string().trim().optional(),- clusterToken: z.string().trim().optional(),- ca: z.string().optional(),- sslEnabled: z.boolean().default(false),- sslRejectUnauthorized: z.boolean().default(true),- credentialType: z.literal(KubernetesDynamicSecretCredentialType.Static),- serviceAccountName: z.string().trim().min(1),- namespace: z- .string()- .trim()- .min(1)- .refine(- (val) => !val.includes(","),- "Namespace must be a single value, not a comma-separated list"- ),- gatewayId: z.string().optional(),- gatewayPoolId: z.string().optional(),- audiences: z.array(z.string().trim().min(1)),- authMethod: z.nativeEnum(AuthMethod).default(AuthMethod.Api)- }),- z.object({- url: z.string().trim().optional(),- clusterToken: z.string().trim().optional(),- ca: z.string().optional(),- sslEnabled: z.boolean().default(false),- sslRejectUnauthorized: z.boolean().default(true),- credentialType: z.literal(KubernetesDynamicSecretCredentialType.Dynamic),- namespace: z- .string()- .trim()- .min(1)- .refine((val) => {- const namespaces = val.split(",").map((ns) => ns.trim());- return namespaces.length > 0 && namespaces.every((ns) => ns.length > 0);- }, "Must be a valid comma-separated list of namespace values"),- gatewayId: z.string().optional(),- gatewayPoolId: z.string().optional(),- audiences: z.array(z.string().trim().min(1)),- roleType: z.nativeEnum(RoleType),- role: z.string().trim().min(1),- authMethod: z.nativeEnum(AuthMethod).default(AuthMethod.Api)- })- ]),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().trim().optional()- })- .superRefine((data, ctx) => {- if (- data.provider.authMethod === AuthMethod.Gateway &&- !data.provider.gatewayId &&- !data.provider.gatewayPoolId- ) {- ctx.addIssue({- path: ["provider.gatewayId"],- code: z.ZodIssueCode.custom,- message: "When auth method is set to Gateway, a gateway or gateway pool must be selected"- });- }- if (data.provider.authMethod === AuthMethod.Api) {- if (!data.provider.clusterToken) {- ctx.addIssue({- path: ["provider.clusterToken"],- code: z.ZodIssueCode.custom,- message: "When auth method is set to Token, a cluster token must be provided"- });- }- if (!data.provider.url) {- ctx.addIssue({- path: ["provider.url"],- code: z.ZodIssueCode.custom,- message: "When auth method is set to Token, a cluster URL must be provided"- });- }- }- });--type TForm = z.infer<typeof formSchema> & FieldValues;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const KubernetesInputForm = ({- onCompleted,- onCancel,- secretPath,- projectSlug,- environments,- isSingleEnvironmentMode-}: Props) => {- const [isVaultImportModalOpen, setIsVaultImportModalOpen] = useState(false);-- const { projectId } = useProject();- const canUseAppConnectionImport = useCanUseProjectAppConnectionImport(- ProjectPermissionSub.Secrets- );- const { data: vaultAppConnections = [] } = useListAvailableAppConnections(- AppConnection.HCVault,- projectId,- { enabled: canUseAppConnectionImport }- );-- const {- control,- formState: { isSubmitting },- handleSubmit,- watch,- setValue- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- url: "",- clusterToken: "",- ca: "",- sslEnabled: false,- sslRejectUnauthorized: true,- serviceAccountName: "",- namespace: "",- credentialType: KubernetesDynamicSecretCredentialType.Static,- gatewayId: undefined,- audiences: [],- authMethod: AuthMethod.Api- } as const,- environment: isSingleEnvironmentMode ? environments[0] : undefined- }- });-- const { fields, append, remove, replace } = useFieldArray({- control,- name: "provider.audiences"- });-- const createDynamicSecret = useCreateDynamicSecret();- const providerGatewayId = watch("provider.gatewayId");- const providerGatewayPoolId = watch("provider.gatewayPoolId");-- const sslEnabled = watch("provider.sslEnabled");- const credentialType = watch("provider.credentialType");- const authMethod = watch("provider.authMethod");-- const handleVaultImport = (role: VaultKubernetesRole) => {- try {- setValue("name", role.name);-- setValue("provider.url", role.config.kubernetes_host);-- // Set CA certificate if available- if (role.config.kubernetes_ca_cert) {- setValue("provider.ca", role.config.kubernetes_ca_cert);- setValue("provider.sslEnabled", true);- }-- // Determine credential type based on role configuration- if (role.service_account_name) {- // Static credential type- setValue("provider.credentialType", KubernetesDynamicSecretCredentialType.Static);- setValue("provider.serviceAccountName", role.service_account_name);-- // Set namespace (single namespace for static)- if (role.allowed_kubernetes_namespaces && role.allowed_kubernetes_namespaces.length > 0) {- setValue("provider.namespace", role.allowed_kubernetes_namespaces[0]);- }- } else if (role.kubernetes_role_name) {- // Dynamic credential type- setValue("provider.credentialType", KubernetesDynamicSecretCredentialType.Dynamic);- setValue("provider.role", role.kubernetes_role_name);-- // Set role type- const roleType =- role.kubernetes_role_type === "ClusterRole" ? RoleType.ClusterRole : RoleType.Role;- setValue("provider.roleType", roleType);-- // Set allowed namespaces (comma-separated for dynamic)- if (role.allowed_kubernetes_namespaces && role.allowed_kubernetes_namespaces.length > 0) {- setValue("provider.namespace", role.allowed_kubernetes_namespaces.join(", "));- }- }-- // Set TTLs if available- if (role.token_default_ttl) {- const defaultTTL = `${role.token_default_ttl}s`;- setValue("defaultTTL", defaultTTL);- }-- if (role.token_max_ttl) {- const maxTTL = `${role.token_max_ttl}s`;- setValue("maxTTL", maxTTL);- }-- // Set audiences if available- if (role.token_default_audiences && role.token_default_audiences.length > 0) {- replace(role.token_default_audiences);- }-- createNotification({- type: "info",- text: "Configuration loaded successfully from HashiCorp Vault"- });- } catch {- createNotification({- type: "error",- text: "Failed to load configuration from HashiCorp Vault"- });- }- };-- const handleCreateDynamicSecret = async (formData: TForm) => {- const { provider, usernameTemplate, ...rest } = formData;- // wait till previous request is finished- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: {- type: DynamicSecretProviders.Kubernetes,- inputs: {- ...provider,- url: provider.url || undefined- }- },- maxTTL: rest.maxTTL,- name: rest.name,- path: secretPath,- defaultTTL: rest.defaultTTL,- projectSlug,- environmentSlug: rest.environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });-- onCompleted();- };-- return (- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <LoadFromVaultBanner onClick={() => setIsVaultImportModalOpen(true)} />-- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1">- <h3 className="font-medium text-mineshaft-200">Configuration</h3>- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <div className="grow">- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: providerGatewayId ?? null,- gatewayPoolId: providerGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("provider.gatewayId", newGwId ?? undefined, {- shouldDirty: true- });- setValue("provider.gatewayPoolId", newPoolId ?? undefined, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <Controller- control={control}- name="provider.authMethod"- defaultValue={AuthMethod.Api}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Auth Method"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- tooltipText="Select the method of authentication. Token (API) uses a direct API token, while Gateway uses the service account of a Gateway deployed in a Kubernetes cluster to generate the service account token."- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => field.onChange(e)}- >- <SelectItem value={AuthMethod.Api}>Token (API)</SelectItem>- <SelectItem value={AuthMethod.Gateway}>Gateway</SelectItem>- </Select>- </FormControl>- )}- />- {authMethod === AuthMethod.Api && (- <>- <Controller- control={control}- name="provider.url"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster URL"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <div className="mb-2 flex items-center">- <span className="mr-3 flex items-center text-sm text-mineshaft-400">- Enable SSL- <Tooltip- className="ml-1 max-w-md"- content={- <span>- If enabled, you can optionally provide a custom CA certificate. Leave- blank to use the system/public CA.- </span>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </span>- <Controller- name="provider.sslEnabled"- control={control}- render={({ field: { value, onChange } }) => (- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-enabled"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- aria-label="Enable SSL"- />- )}- />- </div>- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- label="CA"- isError={Boolean(error?.message)}- errorText={error?.message}- className={sslEnabled ? "" : "opacity-50"}- >- <TextArea- {...field}- placeholder="-----BEGIN CERTIFICATE----- ..."- isDisabled={!sslEnabled}- />- </FormControl>- )}- />- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the- list of supplied CAs. Disable this option if you are using a- self-signed certificate.- </p>- }- >- <FontAwesomeIcon- icon={faQuestionCircle}- size="sm"- className="ml-1"- />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- </>- )}- {authMethod === AuthMethod.Api && (- <Controller- control={control}- name="provider.clusterToken"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster Token"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- )}- <Controller- control={control}- name="provider.credentialType"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Credential Type"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- tooltipText="Choose 'Static' to generate service account tokens for a predefined service account. Choose 'Dynamic' to create a temporary service account, assign it to a defined role/cluster-role, and generate the service account token. Only 'Dynamic' supports role assignment."- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => field.onChange(e)}- >- {credentialTypes.map((ct) => (- <SelectItem value={ct.value} key={`credential-type-${ct.value}`}>- {ct.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- <div className="flex items-center space-x-2">- {credentialType === KubernetesDynamicSecretCredentialType.Static && (- <div className="flex-1">- <Controller- control={control}- name="provider.serviceAccountName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Service Account Name"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="new-password" />- </FormControl>- )}- />- </div>- )}- {credentialType === KubernetesDynamicSecretCredentialType.Dynamic && (- <div className="flex-1">- <Controller- control={control}- name="usernameTemplate"- defaultValue="{{randomUsername}}"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </div>- )}- <div className="flex-1">- <Controller- control={control}- name="provider.namespace"- render={({ field, fieldState: { error } }) => (- <FormControl- label={- credentialType === KubernetesDynamicSecretCredentialType.Static- ? "Namespace"- : "Allowed Namespace(s)"- }- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- {credentialType === KubernetesDynamicSecretCredentialType.Dynamic && (- <div className="flex items-center space-x-2">- <div className="flex-1">- <Controller- control={control}- name="provider.roleType"- defaultValue={RoleType.ClusterRole}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Role Type"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => field.onChange(e)}- >- <SelectItem- value={RoleType.ClusterRole}- key={`role-type-${RoleType.ClusterRole}`}- >- Cluster Role- </SelectItem>- <SelectItem value={RoleType.Role} key={`role-type-${RoleType.Role}`}>- Role- </SelectItem>- </Select>- </FormControl>- )}- />- </div>- <div className="flex-1">- <Controller- control={control}- name="provider.role"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Role"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- )}- <div className="mt-2 w-1/2">- <Controller- control={control}- name="provider.audiences"- render={({ fieldState: { error } }) => (- <FormControl- label="Audiences"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <div className="space-y-2">- {fields.map((field, index) => (- <div key={field.id} className="flex items-center space-x-2">- <Input- {...control.register(`provider.audiences.${index}`)}- placeholder="Enter audience"- className="grow"- />- <IconButton- onClick={() => remove(index)}- variant="outline_bg"- ariaLabel="Remove audience"- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <Button variant="outline_bg" onClick={() => append("")} type="button">- Add Audience- </Button>- </div>- </FormControl>- )}- />- </div>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- <VaultKubernetesImportModal- isOpen={isVaultImportModalOpen}- onOpenChange={setIsVaultImportModalOpen}- appConnections={vaultAppConnections}- onImport={handleVaultImport}- />- </form>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/LdapInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/LdapInputForm.tsxdeleted file mode 100644index 5bac298547..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/LdapInputForm.tsx+++ /dev/null@@ -1,556 +0,0 @@-import { useState } from "react";-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { VaultLdapImportModal } from "@app/components/external-migrations";-import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Button,- FilterableSelect,- FormControl,- Input,- Select,- SelectItem,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { ProjectPermissionSub, useProject } from "@app/context";-import { useCanUseProjectAppConnectionImport } from "@app/hooks";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";-import { AppConnection } from "@app/hooks/api/appConnections/enums";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { VaultLdapRole } from "@app/hooks/api/migration/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--import { LoadFromVaultBanner } from "./components/LoadFromVaultBanner";--enum CredentialType {- Dynamic = "dynamic",- Static = "static"-}--const credentialTypes = [- {- label: "Dynamic",- value: CredentialType.Dynamic- },- {- label: "Static",- value: CredentialType.Static- }-] as const;--const formSchema = z.object({- provider: z.discriminatedUnion("credentialType", [- z.object({- url: z.string().trim().min(1),- binddn: z.string().trim().min(1),- bindpass: z.string().trim().min(1),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true),- credentialType: z.literal(CredentialType.Dynamic),- creationLdif: z.string().min(1),- revocationLdif: z.string().min(1),- rollbackLdif: z.string().optional()- }),- z.object({- url: z.string().trim().min(1),- binddn: z.string().trim().min(1),- bindpass: z.string().trim().min(1),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true),- credentialType: z.literal(CredentialType.Static),- rotationLdif: z.string().min(1)- })- ]),-- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const LdapInputForm = ({- onCompleted,- onCancel,- secretPath,- projectSlug,- environments,- isSingleEnvironmentMode-}: Props) => {- const [isVaultImportModalOpen, setIsVaultImportModalOpen] = useState(false);-- const { projectId } = useProject();- const canUseAppConnectionImport = useCanUseProjectAppConnectionImport(- ProjectPermissionSub.Secrets- );- const { data: vaultAppConnections = [] } = useListAvailableAppConnections(- AppConnection.HCVault,- projectId,- { enabled: canUseAppConnectionImport }- );-- const {- control,- formState: { isSubmitting },- setValue,- watch,- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- url: "",- binddn: "",- bindpass: "",- ca: "",- sslRejectUnauthorized: true,- creationLdif: "",- revocationLdif: "",- rollbackLdif: "",- credentialType: CredentialType.Dynamic- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const selectedCredentialType = watch("provider.credentialType");-- const createDynamicSecret = useCreateDynamicSecret();-- const handleVaultImport = (role: VaultLdapRole) => {- try {- setValue("name", role.name);-- if (role.config.url) {- setValue("provider.url", role.config.url);- }-- if (role.config.binddn) {- setValue("provider.binddn", role.config.binddn);- }-- if (role.config.certificate) {- setValue("provider.ca", role.config.certificate);- }-- // Set credential type to Dynamic if creation_ldif is present- if (role.creation_ldif) {- setValue("provider.credentialType", CredentialType.Dynamic);- setValue("provider.creationLdif", role.creation_ldif);-- if (role.deletion_ldif) {- setValue("provider.revocationLdif", role.deletion_ldif);- }-- if (role.rollback_ldif) {- setValue("provider.rollbackLdif", role.rollback_ldif);- }- }-- // Set TTLs- if (role.default_ttl) {- const defaultTTL = `${role.default_ttl}s`;- setValue("defaultTTL", defaultTTL);- }-- if (role.max_ttl) {- const maxTTL = `${role.max_ttl}s`;- setValue("maxTTL", maxTTL);- }-- // Set username template- if (role.username_template) {- setValue("usernameTemplate", role.username_template);- }-- createNotification({- type: "info",- text: "Configuration loaded successfully from HashiCorp Vault"- });- } catch {- createNotification({- type: "error",- text: "Failed to load configuration from HashiCorp Vault"- });- }- };-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Ldap, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate,- environmentSlug: environment.slug- });- onCompleted();- };-- return (- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <LoadFromVaultBanner onClick={() => setIsVaultImportModalOpen(true)} />- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="provider.url"- render={({ field, fieldState: { error } }) => (- <FormControl- label="URL"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.binddn"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Bind DN"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.bindpass"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Bind Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- label="CA"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea {...field} placeholder="-----BEGIN CERTIFICATE----- ..." />- </FormControl>- )}- />-- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />-- <Controller- control={control}- name="provider.credentialType"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Credential Type"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => {- const ldifFields = [- "provider.creationLdif",- "provider.revocationLdif",- "provider.rollbackLdif",- "provider.rotationLdif"- ] as const;-- ldifFields.forEach((f) => {- setValue(f, "");- });-- field.onChange(e);- }}- >- {credentialTypes.map((credentialType) => (- <SelectItem- value={credentialType.value}- key={`credential-type-${credentialType.value}`}- >- {credentialType.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />-- {selectedCredentialType === CredentialType.Dynamic && (- <>- <Controller- control={control}- name="provider.creationLdif"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation LDIF"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.revocationLdif"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation LDIF"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.rollbackLdif"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Rollback LDIF"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea {...field} />- </FormControl>- )}- />- </>- )}- {selectedCredentialType === CredentialType.Static && (- <Controller- control={control}- name="provider.rotationLdif"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Rotation LDIF"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea {...field} />- </FormControl>- )}- />- )}- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- <VaultLdapImportModal- isOpen={isVaultImportModalOpen}- onOpenChange={setIsVaultImportModalOpen}- appConnections={vaultAppConnections}- onImport={handleVaultImport}- />- </form>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MilvusInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MilvusInputForm.tsxdeleted file mode 100644index fdae21128a..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MilvusInputForm.tsx+++ /dev/null@@ -1,559 +0,0 @@-import { Controller, useFieldArray, useForm } from "react-hook-form";-import { faPlus, faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Button,- FilterableSelect,- FormControl,- FormLabel,- IconButton,- Input,- Select,- SelectItem,- Switch,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import {- OrgGatewayPermissionActions,- OrgPermissionSubjects-} from "@app/context/OrgPermissionContext/types";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders, MILVUS_OBJECT_TYPES } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- provider: z.object({- host: z.string().trim().min(1),- port: z.coerce.number(),- username: z.string().trim().min(1),- password: z.string().trim().min(1),- database: z.string().trim().min(1).default("default"),- privileges: z- .array(- z.object({- objectType: z.string().trim().min(1),- objectName: z.string().trim().min(1).default("*"),- privilege: z.string().trim().min(1),- dbName: z- .string()- .trim()- .optional()- .transform((val) => (val && val.length > 0 ? val : undefined))- })- )- .default([]),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true),- gatewayId: z.string().optional(),- gatewayPoolId: z.string().optional()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const MilvusInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- host: "http://localhost",- port: 19530,- username: "root",- password: "",- database: "default",- privileges: [],- sslRejectUnauthorized: true- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const privilegeFields = useFieldArray({- control,- name: "provider.privileges"- });-- const providerGatewayId = watch("provider.gatewayId");- const providerGatewayPoolId = watch("provider.gatewayPoolId");-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";-- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Milvus, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: providerGatewayId ?? null,- gatewayPoolId: providerGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("provider.gatewayId", newGwId ?? undefined, {- shouldDirty: true- });- setValue("provider.gatewayPoolId", newPoolId ?? undefined, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col">- <div className="flex items-start space-x-2">- <Controller- control={control}- name="provider.host"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Optional URL scheme. Defaults to https when a CA is provided, otherwise http."- >- <Input {...field} placeholder="http://localhost" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- className="w-32"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" placeholder="19530" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.username"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <Controller- control={control}- name="provider.database"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Default Database"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Used as the dbName for granted privileges when not explicitly overridden."- >- <Input {...field} placeholder="default" />- </FormControl>- )}- />- <FormLabel- label="Privileges"- isOptional- className="mb-2"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText={- "Privileges granted to an ephemeral role assigned to the lease user. " +- "Leave empty to create a user with only the built-in public role. " +- "See https://milvus.io/docs/grant_privileges.md for the full list."- }- />- <div className="mb-3 flex flex-col space-y-2">- {privilegeFields.fields.map(({ id: privilegeFieldId }, i) => (- <div key={privilegeFieldId} className="flex items-end space-x-2">- <div className="w-36">- {i === 0 && <span className="text-xs text-mineshaft-400">Object Type</span>}- <Controller- control={control}- name={`provider.privileges.${i}.objectType`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Select- value={field.value}- onValueChange={(value) => field.onChange(value)}- className="w-full"- >- {MILVUS_OBJECT_TYPES.map((option) => (- <SelectItem- value={option.value}- key={`milvus-object-type-${option.value}`}- >- {option.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && <span className="text-xs text-mineshaft-400">Object Name</span>}- <Controller- control={control}- name={`provider.privileges.${i}.objectName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input {...field} placeholder="*" />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && <span className="text-xs text-mineshaft-400">Privilege</span>}- <Controller- control={control}- name={`provider.privileges.${i}.privilege`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input {...field} placeholder="Search" />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && (- <FormLabel- label="DB Name"- isOptional- className="text-xs text-mineshaft-400"- />- )}- <Controller- control={control}- name={`provider.privileges.${i}.dbName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input- value={field.value || ""}- onChange={(e) => field.onChange(e.target.value)}- placeholder="default"- />- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="Remove privilege"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => privilegeFields.remove(i)}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- type="button"- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() =>- privilegeFields.append({- objectType: "Collection",- objectName: "*",- privilege: "",- dbName: undefined- })- }- >- Add Privilege- </Button>- </div>- </div>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Milvus usernames are limited to 32 characters. Longer template output is truncated automatically."- >- <Input- {...field}- value={field.value || ""}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- label="CA Certificate"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="PEM-encoded CA certificate for verifying the Milvus server's TLS certificate."- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.sslRejectUnauthorized"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="milvus-ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MongoAtlasInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MongoAtlasInputForm.tsxdeleted file mode 100644index 317febae82..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MongoAtlasInputForm.tsx+++ /dev/null@@ -1,507 +0,0 @@-import { Controller, useFieldArray, useForm } from "react-hook-form";-import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- FormLabel,- IconButton,- Input,- Select,- SelectItem-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- provider: z.object({- adminPublicKey: z.string().trim().min(1),- adminPrivateKey: z.string().trim().min(1),- groupId: z.string().trim().min(1),- roles: z- .object({- collectionName: z.string().optional(),- databaseName: z.string().min(1),- roleName: z.string().min(1)- })- .array()- .min(1),- scopes: z- .object({- name: z.string().min(1),- type: z.string().min(1)- })- .array()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--const ATLAS_SCOPE_TYPES = [- {- label: "Cluster",- value: "CLUSTER"- },- {- label: "Data Lake",- value: "DATA_LAKE"- },- {- label: "Stream",- value: "STREAM"- }-];--export const MongoAtlasInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- getValues,- setValue,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- roles: [{ databaseName: "", roleName: "" }]- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const roleFields = useFieldArray({- control,- name: "provider.roles"- });-- const scopeFields = useFieldArray({- control,- name: "provider.scopes"- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.MongoAtlas, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.adminPublicKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Admin Public Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.adminPrivateKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Admin Private Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" />- </FormControl>- )}- />- </div>- <Controller- control={control}- name="provider.groupId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Group/Project ID"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Unique 24-hexadecimal digit string that identifies your project"- >- <Input {...field} />- </FormControl>- )}- />- <FormLabel label="Roles" />- <div className="mb-3 flex flex-col space-y-2">- {roleFields.fields.map(({ id: roleFieldId }, i) => (- <div key={roleFieldId} className="flex items-end space-x-2">- <div className="grow">- {i === 0 && <span className="text-xs text-mineshaft-400">Database Name</span>}- <Controller- control={control}- name={`provider.roles.${i}.databaseName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && (- <FormLabel- label="Collection Name"- className="text-xs text-mineshaft-400"- isOptional- />- )}- <Controller- control={control}- name={`provider.roles.${i}.collectionName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && (- <FormLabel- label="Role"- className="text-xs text-mineshaft-400"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText={`Human-readable label that identifies a group of privileges assigned to a database user. This value can either be a built-in role or a custom role.- Built-in: atlasAdmin, backup, clusterMonitor, dbAdmin, dbAdminAnyDatabase, enableSharding, read, readAnyDatabase, readWrite, readWriteAnyDatabase.`}- />- )}- <Controller- control={control}- name={`provider.roles.${i}.roleName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0 grow"- >- <Input {...field} />- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="delete key"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => {- const roles = getValues("provider.roles");- if (roles && roles?.length > 1) {- roleFields.remove(i);- } else {- setValue("provider.roles", [{ databaseName: "", roleName: "" }]);- }- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() => roleFields.append({ databaseName: "", roleName: "" })}- >- Add Role- </Button>- </div>- </div>- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-section">- <AccordionTrigger>Advanced</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <FormLabel- label="Scopes"- isOptional- className="mb-2"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText="List that contains clusters, MongoDB Atlas Data Lakes, and MongoDB Atlas Streams Instances that this database user can access. If omitted, MongoDB Cloud grants the database user access to all the clusters, MongoDB Atlas Data Lakes, and MongoDB Atlas Streams Instances in the project."- />- <div className="mb-2 flex flex-col space-y-2">- {scopeFields.fields.map(({ id: scopeFieldId }, i) => (- <div key={scopeFieldId} className="flex items-end space-x-2">- <div className="grow">- {i === 0 && (- <FormLabel- label="Label"- className="text-xs text-mineshaft-400"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText="Human-readable label that identifies the cluster or MongoDB Atlas Data Lake that this database user can access."- />- )}- <Controller- control={control}- name={`provider.scopes.${i}.name`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0 grow"- >- <Input {...field} placeholder="Cluster or data lake id" />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && <span className="text-xs text-mineshaft-400">Type</span>}- <Controller- control={control}- name={`provider.scopes.${i}.type`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0 grow"- >- <Select- defaultValue={field.value}- {...field}- onValueChange={(e) => field.onChange(e)}- className="w-full"- >- {ATLAS_SCOPE_TYPES.map((el) => (- <SelectItem value={el.value} key={`atlas-scope-${el.value}`}>- {el.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="delete key"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => {- scopeFields.remove(i);- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() =>- scopeFields.append({ name: "", type: ATLAS_SCOPE_TYPES[0].value })- }- >- Add Scope- </Button>- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MongoDBInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MongoDBInputForm.tsxdeleted file mode 100644index 5c6e59eea5..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MongoDBInputForm.tsx+++ /dev/null@@ -1,432 +0,0 @@-import { Controller, useFieldArray, useForm } from "react-hook-form";-import { faPlus, faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Button,- FilterableSelect,- FormControl,- FormLabel,- IconButton,- Input,- SecretInput,- Switch,- Tooltip-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- provider: z.object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number().optional(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true),- roles: z- .object({- roleName: z.string().min(1)- })- .array()- .min(1)- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const MongoDBDatabaseInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- setValue,- getValues,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- roles: [{ roleName: "readWrite" }],- sslRejectUnauthorized: true- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const roleFields = useFieldArray({- control,- name: "provider.roles"- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: {- type: DynamicSecretProviders.MongoDB,- inputs: {- ...provider,- port: provider?.port ? provider.port : undefined,- roles: provider.roles.map((el) => el.roleName)- }- },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={27017}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.database"- defaultValue="default"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database Name"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <FormLabel- label="Roles"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText={`Human-readable label that identifies a group of privileges assigned to a database user. This value can either be a built-in role or a custom role.- Built-in: atlasAdmin, backup, clusterMonitor, dbAdmin, dbAdminAnyDatabase, enableSharding, read, readAnyDatabase, readWrite, readWriteAnyDatabase.`}- />- <div className="mt-1 mb-3 flex flex-col space-y-2">- {roleFields.fields.map(({ id: roleFieldId }, i) => (- <div key={roleFieldId} className="flex items-end space-x-2">- <div className="grow">- <Controller- control={control}- name={`provider.roles.${i}.roleName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0 grow"- >- <Input {...field} />- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="delete key"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => {- const roles = getValues("provider.roles");- if (roles && roles?.length > 1) {- roleFields.remove(i);- } else {- setValue("provider.roles", [{ roleName: "" }]);- }- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() => roleFields.append({ roleName: "" })}- >- Add Role- </Button>- </div>- </div>- <div>- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA(SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/RabbitMqInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/RabbitMqInputForm.tsxdeleted file mode 100644index 042accc403..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/RabbitMqInputForm.tsx+++ /dev/null@@ -1,516 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faPlus, faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Button,- FilterableSelect,- FormControl,- FormLabel,- IconButton,- Input,- SecretInput,- Switch,- Tooltip-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- provider: z.object({- host: z.string().trim().min(1),- port: z.coerce.number(), // important: this is the management plugin port-- username: z.string(),- password: z.string(),-- tags: z.array(z.string().trim()),- virtualHost: z.object({- name: z.string().trim().min(1),- permissions: z.object({- read: z.string().trim().min(1),- write: z.string().trim().min(1),- configure: z.string().trim().min(1)- })- }),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true)- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const RabbitMqInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- port: 15672,- virtualHost: {- name: "/",- permissions: {- read: ".*",- write: ".*",- configure: ".*"- }- },- tags: [],- sslRejectUnauthorized: true- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.RabbitMq, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- const selectedTags = watch("provider.tags");-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="https://your-rabbitmq-host.com" {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={443}- render={({ field, fieldState: { error } }) => (- <FormControl- tooltipText="The port on which the RabbitMQ management plugin is running. Default is 15672."- label="Management Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>-- <div className="flex w-full items-center gap-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>-- <div>- <FormLabel label="Virtual Host" className="mb-2" />- <div className="mt-2 flex items-center justify-evenly gap-2">- <Controller- control={control}- name="provider.virtualHost.name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Name"- tooltipText="The virtual host to which the user will be assigned. Default is /."- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="/virtual-host" {...field} autoComplete="off" />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.virtualHost.permissions.read"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Read Permissions"- tooltipText="A regular expression matching resource names for which the user is granted read permissions."- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder=".*" {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.virtualHost.permissions.write"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Write Permissions"- tooltipText="A regular expression matching resource names for which the user is granted write permissions."- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder=".*" {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.virtualHost.permissions.configure"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Configure Permissions"- tooltipText="A regular expression matching resource names for which the user is granted configure permissions."- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder=".*" {...field} autoComplete="off" />- </FormControl>- )}- />- </div>- </div>-- <div className="flex flex-col">- <FormLabel- isOptional- className="mb-2"- label="Tags"- tooltipText={- <div className="space-y-4">- <p>Select which tag(s) to assign the users provisioned by Infisical.</p>- <p>- There is a wide range of in-built roles in RabbitMQ. Some include,- management, policymaker, monitoring, administrator. <br />- <a- href="https://www.rabbitmq.com/docs/management#permissions"- target="_blank"- rel="noopener noreferrer"- >- <span className="cursor-pointer text-primary-400">- Read more about management tags here- </span>- </a>- .- </p>- <p>- You can also assign custom roles by providing the name of the custom role in- the input field.- </p>- </div>- }- />- <div className="flex flex-col -space-y-2">- {selectedTags.map((_, i) => (- <Controller- control={control}- name={`provider.tags.${i}`}- // eslint-disable-next-line react/no-array-index-key- key={`role-${i}`}- render={({ field, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <div className="flex h-9 items-center gap-2">- <Input- placeholder="Insert tag name, (management, policymaker, etc.)"- className="mb-0 grow"- {...field}- />- <IconButton- isDisabled={selectedTags.length === 1}- ariaLabel="delete key"- className="h-9"- variant="outline_bg"- onClick={() => {- if (selectedTags && selectedTags?.length > 1) {- setValue(- "provider.tags",- selectedTags.filter((__, idx) => idx !== i)- );- }- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- </FormControl>- )}- />- ))}- </div>- </div>- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- className="mb-4"- variant="outline_bg"- onClick={() => {- setValue("provider.tags", [...selectedTags, ""]);- }}- >- Add Tag- </Button>- </div>- <div>- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/RedisInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/RedisInputForm.tsxdeleted file mode 100644index ba840332d6..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/RedisInputForm.tsx+++ /dev/null@@ -1,419 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- SecretInput,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- provider: z.object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- username: z.string().min(1),- password: z.string().min(1).optional(),- creationStatement: z.string().min(1),- renewStatement: z.string().optional(),- revocationStatement: z.string().min(1),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true)- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const RedisInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- username: "default",- port: 6379,- creationStatement: "ACL SETUSER {{username}} on >{{password}} ~* &* +@all",- revocationStatement: "ACL DELUSER {{username}}",- sslRejectUnauthorized: true- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- usernameTemplate,- environment- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Redis, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={5432}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex w-full items-center space-x-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- tooltipText="Required if your Redis instance is password protected."- label="Password"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA(SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify Redis Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapAseInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapAseInputForm.tsxdeleted file mode 100644index 42c06ebeac..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapAseInputForm.tsx+++ /dev/null@@ -1,360 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- TextArea-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- provider: z.object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1)- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const SapAseInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- database: "master",- port: 5000,- creationStatement: `sp_addlogin '{{username}}', '{{password}}';-sp_adduser '{{username}}', '{{username}}', null;-sp_role 'grant', 'mon_role', '{{username}}';`,- revocationStatement: `sp_dropuser '{{username}}';-sp_droplogin '{{username}}';`- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.SapAse, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="92.41.22.72" {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={5000}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.database"- defaultValue="master"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="text" />- </FormControl>- )}- />- </div>- <div className="flex w-full items-center space-x-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-full"- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-full"- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify SQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username and password are dynamically provisioned. The sp_addlogin statement is automatically called against the master database. All other statements are called against the database you specify."- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned. The sp_droplogin statement is automatically called against the master database. All other statements are called against the database you specify."- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapHanaInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapHanaInputForm.tsxdeleted file mode 100644index a76e656925..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapHanaInputForm.tsx+++ /dev/null@@ -1,417 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- SecretInput,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- provider: z.object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- username: z.string().min(1),- password: z.string().min(1),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true)- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const SapHanaInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- creationStatement: `CREATE USER {{username}} PASSWORD {{password}} NO FORCE_FIRST_PASSWORD_CHANGE VALID UNTIL '{{expiration}}';-GRANT "MONITORING" TO {{username}};`,- revocationStatement: `REVOKE "MONITORING" FROM {{username}};-DROP USER {{username}};`,- renewStatement: "ALTER USER {{username}} VALID UNTIL '{{expiration}}';",- sslRejectUnauthorized: true- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- usernameTemplate,- maxTTL,- provider,- defaultTTL,- environment- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.SapHana, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate,- environmentSlug: environment.slug- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={443}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA(SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify SQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SnowflakeInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SnowflakeInputForm.tsxdeleted file mode 100644index 7b154881da..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SnowflakeInputForm.tsx+++ /dev/null@@ -1,363 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- TextArea-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- provider: z.object({- accountId: z.string().trim().min(1),- orgId: z.string().trim().min(1),- username: z.string().trim().min(1),- password: z.string().trim().min(1),- creationStatement: z.string().trim().min(1),- revocationStatement: z.string().trim().min(1),- renewStatement: z.string().trim().optional()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const SnowflakeInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- creationStatement:- "CREATE USER {{username}} PASSWORD = '{{password}}' DEFAULT_ROLE = public DEFAULT_SECONDARY_ROLES = ('ALL') MUST_CHANGE_PASSWORD = FALSE DAYS_TO_EXPIRY = {{expiration}};",- revocationStatement: "DROP USER {{username}};",- renewStatement: "ALTER USER {{username}} SET DAYS_TO_EXPIRY = {{expiration}};"- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Snowflake, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.accountId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Account Identifier"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.orgId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Organization Identifier"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Programmatic Access Token"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- tooltipText="The Programmatic Access Token (PAT) used to authenticate with Snowflake. A user password is still accepted, but Snowflake is phasing out password authentication."- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify SQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsxdeleted file mode 100644index 97bf5f7747..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx+++ /dev/null@@ -1,960 +0,0 @@-import { useState } from "react";-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { VaultSqlDatabaseImportModal } from "@app/components/external-migrations";-import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { OrgPermissionCan } from "@app/components/permissions";-import { ValidationRuleOverrideNotice } from "@app/components/secret-validation/ValidationRuleOverrideNotice";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- SecretInput,- Select,- SelectItem,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import { ProjectPermissionSub, useProject } from "@app/context";-import {- OrgGatewayPermissionActions,- OrgPermissionSubjects-} from "@app/context/OrgPermissionContext/types";-import { useCanUseProjectAppConnectionImport } from "@app/hooks";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";-import { AppConnection } from "@app/hooks/api/appConnections/enums";-import { DynamicSecretProviders, SqlProviders } from "@app/hooks/api/dynamicSecret/types";-import { VaultDatabaseRole } from "@app/hooks/api/migration/types";-import {- DynamicSecretRuleProvider,- SecretValidationRuleType-} from "@app/hooks/api/secretValidationRules";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--import { MetadataForm } from "../../DynamicSecretListView/MetadataForm";-import { LoadFromVaultBanner } from "./components/LoadFromVaultBanner";--const passwordRequirementsSchema = z- .object({- length: z.number().min(1).max(250),- required: z- .object({- lowercase: z.number().min(0),- uppercase: z.number().min(0),- digits: z.number().min(0),- symbols: z.number().min(0)- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 250;- }, "Sum of required characters cannot exceed 250"),- allowedSymbols: z.string().optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const formSchema = z.object({- provider: z.object({- client: z.nativeEnum(SqlProviders),- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- passwordRequirements: passwordRequirementsSchema.optional(),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- sslEnabled: z.boolean().optional(),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().default(true),- gatewayId: z.string().optional(),- gatewayPoolId: z.string().optional()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() }),- metadata: z- .object({- key: z.string().trim().min(1),- value: z.string().trim().default("")- })- .array()- .optional(),- usernameTemplate: z.string().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--const getSqlStatements = (provider: SqlProviders) => {- if (provider === SqlProviders.MySql) {- return {- creationStatement:- "CREATE USER \"{{username}}\"@'%' IDENTIFIED BY '{{password}}';\nGRANT ALL ON \"{{database}}\".* TO \"{{username}}\"@'%';",- renewStatement: "",- revocationStatement:- 'REVOKE ALL PRIVILEGES ON "{{database}}".* FROM "{{username}}"@\'%\';\nDROP USER "{{username}}"@\'%\';'- };- }-- if (provider === SqlProviders.Oracle) {- return {- creationStatement:- 'CREATE USER "{{username}}" IDENTIFIED BY "{{password}}";\nGRANT CONNECT TO "{{username}}";\nGRANT CREATE SESSION TO "{{username}}";',- renewStatement: "",- revocationStatement:- 'REVOKE CONNECT FROM "{{username}}";\nREVOKE CREATE SESSION FROM "{{username}}";\nDROP USER "{{username}}";'- };- }- if (provider === SqlProviders.MsSQL) {- return {- creationStatement:- "CREATE LOGIN [{{username}}] WITH PASSWORD = '{{password}}';\nCREATE USER [{{username}}] FOR LOGIN [{{username}}];\nGRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::dbo TO [{{username}}];",- renewStatement: "",- revocationStatement: "DROP USER [{{username}}];\nDROP LOGIN [{{username}}];"- };- }-- return {- creationStatement:- "CREATE USER \"{{username}}\" WITH ENCRYPTED PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';\nGRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO \"{{username}}\";",- renewStatement: "ALTER ROLE \"{{username}}\" VALID UNTIL '{{expiration}}';",- revocationStatement:- 'REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM "{{username}}";\nDROP ROLE "{{username}}";'- };-};--const getDefaultPort = (provider: SqlProviders) => {- switch (provider) {- case SqlProviders.MySql:- return 3306;- case SqlProviders.Oracle:- return 1521;- case SqlProviders.MsSQL:- return 1433;- default:- return 5432;- }-};--export const SqlDatabaseInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const [isVaultImportModalOpen, setIsVaultImportModalOpen] = useState(false);-- const { projectId } = useProject();- const canUseAppConnectionImport = useCanUseProjectAppConnectionImport(- ProjectPermissionSub.Secrets- );- const { data: vaultAppConnections = [] } = useListAvailableAppConnections(- AppConnection.HCVault,- projectId,- { enabled: canUseAppConnectionImport }- );-- const {- control,- setValue,- formState: { isSubmitting },- handleSubmit,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- ...getSqlStatements(SqlProviders.Postgres),- sslRejectUnauthorized: true,- passwordRequirements: {- length: 48,- required: {- lowercase: 1,- uppercase: 1,- digits: 1,- symbols: 0- },- allowedSymbols: "-_.~!*"- }- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();- const selectedClient = watch("provider.client");- const providerGatewayId = watch("provider.gatewayId");- const providerGatewayPoolId = watch("provider.gatewayPoolId");-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- metadata,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.SqlDatabase, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- metadata,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- const handleDatabaseChange = (type: SqlProviders) => {- const sqlStatment = getSqlStatements(type);- setValue("provider.creationStatement", sqlStatment.creationStatement);- setValue("provider.renewStatement", sqlStatment.renewStatement);- setValue("provider.revocationStatement", sqlStatment.revocationStatement);- setValue("provider.port", getDefaultPort(type));-- // Update password requirements based on provider- const length = type === SqlProviders.Oracle ? 30 : 48;- setValue("provider.passwordRequirements.length", length);- };-- const handleVaultImport = (role: VaultDatabaseRole) => {- try {- setValue("name", role.name);-- // Determine the SQL provider from the plugin name- const pluginName = role.config.plugin_name?.toLowerCase() || "";- let sqlProvider = SqlProviders.Postgres;- if (pluginName.includes("mysql")) {- sqlProvider = SqlProviders.MySql;- } else if (pluginName.includes("oracle")) {- sqlProvider = SqlProviders.Oracle;- } else if (pluginName.includes("mssql")) {- sqlProvider = SqlProviders.MsSQL;- }- setValue("provider.client", sqlProvider);-- // Parse connection URL to extract host, port, database- const connectionUrl = role.config.connection_details.connection_url || "";- try {- const trimmedUrl = connectionUrl.trim();- if (!trimmedUrl) throw new Error("Empty URL");-- const defaultPort = getDefaultPort(sqlProvider);-- const setConnectionDetails = (host: string, port: number | undefined, database: string) => {- if (host) setValue("provider.host", host);- const parsedPort = port ?? defaultPort;- setValue("provider.port", Number.isNaN(parsedPort) ? defaultPort : parsedPort);- if (database) setValue("provider.database", database);- };-- const parseStandardUrl = (url: URL, dbFromParams?: string) => {- if (url.username) {- setValue("provider.username", url.username);- }- const port = url.port ? parseInt(url.port, 10) : undefined;- const database = dbFromParams || url.pathname.replace(/^\//, "");- setConnectionDetails(url.hostname, port, database);- };-- if (sqlProvider === SqlProviders.MySql) {- // MySQL format: user:pass@tcp(host:port)/database or standard URL- const tcpMatch = trimmedUrl.match(/@tcp\(([^:]+):?(\d+)?\)\/([^?#]+)/);- if (tcpMatch) {- const port = tcpMatch[2] ? parseInt(tcpMatch[2], 10) : undefined;- setConnectionDetails(tcpMatch[1], port, tcpMatch[3]);- } else if (trimmedUrl.includes("://")) {- parseStandardUrl(new URL(trimmedUrl));- }- } else if (sqlProvider === SqlProviders.Oracle) {- // Oracle format: user/pass@host:port/service_name or user/pass@//host:port/service_name- const oracleMatch = trimmedUrl.match(/@(?:\/\/)?([^:/]+):?(\d+)?\/(.+)/);- if (oracleMatch) {- const port = oracleMatch[2] ? parseInt(oracleMatch[2], 10) : undefined;- setConnectionDetails(oracleMatch[1], port, oracleMatch[3]);- }- } else if (sqlProvider === SqlProviders.MsSQL) {- // MSSQL format: sqlserver://user:pass@host:port?database=name- const url = new URL(trimmedUrl);- const dbParam =- url.searchParams.get("database") || url.searchParams.get("databaseName") || "";- parseStandardUrl(url, dbParam);- } else {- // PostgreSQL format: postgresql://user:pass@host:port/database- parseStandardUrl(new URL(trimmedUrl));- }- } catch {- createNotification({- type: "info",- text: "Could not parse connection URL. Host, port, and database fields may need to be filled manually."- });- }-- if (role.config.connection_details.username) {- setValue("provider.username", role.config.connection_details.username);- }-- if (role.config.connection_details.tls_ca) {- setValue("provider.ca", role.config.connection_details.tls_ca);- }-- // Convert {{name}} variable to {{username}}- const convertVaultVariables = (statement: string) =>- statement.replace(/\{\{name\}\}/g, "{{username}}");-- // Set statements- if (role.creation_statements && role.creation_statements.length > 0) {- setValue(- "provider.creationStatement",- role.creation_statements.map(convertVaultVariables).join("\n")- );- }-- if (role.revocation_statements && role.revocation_statements.length > 0) {- setValue(- "provider.revocationStatement",- role.revocation_statements.map(convertVaultVariables).join("\n")- );- }-- if (role.renew_statements && role.renew_statements.length > 0) {- setValue(- "provider.renewStatement",- role.renew_statements.map(convertVaultVariables).join("\n")- );- }-- // Set TTLs- if (role.default_ttl) {- const defaultTTL = `${role.default_ttl}s`;- setValue("defaultTTL", defaultTTL);- }-- if (role.max_ttl) {- const maxTTL = `${role.max_ttl}s`;- setValue("maxTTL", maxTTL);- }-- createNotification({- type: "info",- text: "Configuration loaded successfully from HashiCorp Vault"- });- } catch {- createNotification({- type: "error",- text: "Failed to load configuration from HashiCorp Vault"- });- }- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <LoadFromVaultBanner onClick={() => setIsVaultImportModalOpen(true)} />- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>-- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <MetadataForm control={control} />- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: providerGatewayId ?? null,- gatewayPoolId: providerGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("provider.gatewayId", newGwId ?? undefined, {- shouldDirty: true- });- setValue("provider.gatewayPoolId", newPoolId ?? undefined, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col">- <div className="pb-0.5 pl-1 text-sm text-mineshaft-400">Service</div>- <Controller- control={control}- name="provider.client"- defaultValue={SqlProviders.Postgres}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Select- value={value}- onValueChange={(val) => {- onChange(val);- handleDatabaseChange(val as SqlProviders);- }}- className="w-full border border-mineshaft-500"- >- <SelectItem value={SqlProviders.Postgres}>PostgreSQL</SelectItem>- <SelectItem value={SqlProviders.MySql}>MySQL</SelectItem>- <SelectItem value={SqlProviders.Oracle}>Oracle</SelectItem>- <SelectItem value={SqlProviders.MsSQL}>MS SQL</SelectItem>- </Select>- </FormControl>- )}- />- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={5432}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.database"- defaultValue="default"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database Name"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div>- {selectedClient === SqlProviders.MsSQL && (- <div className="mt-2 mb-2">- <Controller- control={control}- name="provider.sslEnabled"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="sql-ds-ssl-enabled"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- Encrypt Connection (SSL)- </Switch>- </FormControl>- )}- />- </div>- )}- <Controller- control={control}- name="provider.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="provider.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Accordion type="multiple" className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advanced">- <AccordionTrigger>- Creation, Revocation & Renew Statements (optional)- </AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <div className="mb-4 text-sm text-mineshaft-300">- Customize SQL statements for managing database user lifecycle- </div>- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>Password Configuration (optional)</AccordionTrigger>- <AccordionContent>- <ValidationRuleOverrideNotice- type={SecretValidationRuleType.DynamicSecrets}- provider={DynamicSecretRuleProvider.SqlDatabase}- environmentSlug={watch("environment")?.slug}- secretPath={secretPath}- />- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated database password- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="provider.passwordRequirements.length"- defaultValue={48}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={1}- max={250}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("provider.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("provider.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="provider.passwordRequirements.required.lowercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of lowercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.uppercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of uppercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.digits"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of digits"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.symbols"- defaultValue={0}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of symbols"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="provider.passwordRequirements.allowedSymbols"- defaultValue="-_.~!*"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbols to use in password"- isError={Boolean(error)}- errorText={error?.message}- helperText="Default: -_.~!*"- >- <Input {...field} placeholder="-_.~!*" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- <VaultSqlDatabaseImportModal- isOpen={isVaultImportModalOpen}- onOpenChange={setIsVaultImportModalOpen}- appConnections={vaultAppConnections}- onImport={handleVaultImport}- />- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SshInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SshInputForm.tsxdeleted file mode 100644index 3be4878c46..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SshInputForm.tsx+++ /dev/null@@ -1,437 +0,0 @@-import { useState } from "react";-import { Controller, useForm } from "react-hook-form";-import { faCopy } from "@fortawesome/free-regular-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import { EyeIcon, EyeOffIcon } from "lucide-react";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Button,- FilterableSelect,- FormControl,- IconButton,- Input,- Modal,- ModalContent,- Select,- SelectItem,- Tag-} from "@app/components/v2";-import { useCreateDynamicSecret, useGetSshCaPublicKey } from "@app/hooks/api";-import { SshCertKeyAlgorithm, sshCertKeyAlgorithms } from "@app/hooks/api/dynamicSecret/constants";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { getAuthToken } from "@app/hooks/api/reactQuery";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--const sshCertKeyAlgorithmsArray = sshCertKeyAlgorithms.map((a) => a.value);--const formSchema = z- .object({- provider: z.object({- principals: z.array(z.string().trim().min(1)).min(1, "At least one principal is required"),- keyAlgorithm: z.enum(sshCertKeyAlgorithmsArray as [string, ...string[]])- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- name: slugSchema({ field: "Name" }),- environment: z.object({ name: z.string(), slug: z.string() })- })- .refine((d) => !d.maxTTL || ms(d.maxTTL)! >= ms(d.defaultTTL)!, {- path: ["maxTTL"],- message: "Max TTL must be greater than or equal to Default TTL"- });-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const SshInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- principals: [],- keyAlgorithm: SshCertKeyAlgorithm.ED25519- },- defaultTTL: "1h",- maxTTL: "24h",- environment: isSingleEnvironmentMode && environments.length > 0 ? environments[0] : undefined- }- });-- const [showSetupModal, setShowSetupModal] = useState(false);- const [createdDynamicSecretId, setCreatedDynamicSecretId] = useState<string | null>(null);- const [principalInput, setPrincipalInput] = useState("");- const [isPublicKeyVisible, setIsPublicKeyVisible] = useState(false);-- const { data: caPublicKey } = useGetSshCaPublicKey({- dynamicSecretId: createdDynamicSecretId || "",- enabled: showSetupModal && !!createdDynamicSecretId- });-- const createDynamicSecret = useCreateDynamicSecret();-- const principals = watch("provider.principals");-- const handleCreateDynamicSecret = async ({- name,- provider,- defaultTTL,- maxTTL,- environment- }: TForm) => {- if (createDynamicSecret.isPending) return;- const result = await createDynamicSecret.mutateAsync({- provider: {- type: DynamicSecretProviders.Ssh,- inputs: {- principals: provider.principals,- keyAlgorithm: provider.keyAlgorithm- }- },- defaultTTL,- maxTTL: maxTTL || undefined,- name,- path: secretPath,- projectSlug,- environmentSlug: environment.slug- });-- const dynamicSecret = result as { id: string };- setCreatedDynamicSecretId(dynamicSecret.id);- setShowSetupModal(true);- };-- const handleAddPrincipal = () => {- const trimmed = principalInput.trim();- if (trimmed && !principals.includes(trimmed)) {- setValue("provider.principals", [...principals, trimmed], { shouldValidate: true });- }- setPrincipalInput("");- };-- const handleRemovePrincipal = (idx: number) => {- setValue(- "provider.principals",- principals.filter((_, i) => i !== idx),- { shouldValidate: true }- );- };-- const { protocol, hostname, port } = window.location;- const portSuffix = port && port !== "80" ? `:${port}` : "";- const siteURL = `${protocol}//${hostname}${portSuffix}`;-- const setupCommand = createdDynamicSecretId- ? `curl -H "Authorization: Bearer ${getAuthToken()}" "${siteURL}/api/v1/dynamic-secrets/ssh-ca-setup/${createdDynamicSecretId}" | sudo bash`- : "";-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-border pb-2 pl-1 font-medium text-label">- Configuration- </div>-- <div className="flex flex-col">- <Controller- control={control}- name="provider.principals"- render={({ fieldState: { error } }) => (- <FormControl- label="Allowed Principals"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="The usernames this dynamic secret can issue certificates for (e.g., deploy, ubuntu, root)"- isRequired- >- <div className="flex flex-col gap-2">- <div className="flex items-center gap-2">- <Input- value={principalInput}- onChange={(e) => setPrincipalInput(e.target.value)}- placeholder="Enter principal name..."- onKeyDown={(e) => {- if (e.key === "Enter") {- e.preventDefault();- handleAddPrincipal();- }- }}- />- <Button- type="button"- variant="outline_bg"- size="sm"- onClick={handleAddPrincipal}- isDisabled={!principalInput.trim()}- >- Add- </Button>- </div>- {principals.length > 0 && (- <div className="flex flex-wrap gap-1">- {principals.map((principal, idx) => (- <Tag- className="bg-neutral/15 text-neutral"- key={principal}- onClose={() => handleRemovePrincipal(idx)}- >- {principal}- </Tag>- ))}- </div>- )}- </div>- </FormControl>- )}- />-- <Controller- control={control}- name="provider.keyAlgorithm"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Key Algorithm"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Algorithm for ephemeral key pairs generated per lease"- >- <Select value={value} onValueChange={onChange} className="w-full">- {sshCertKeyAlgorithms.map((alg) => (- <SelectItem key={alg.value} value={alg.value}>- {alg.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- </div>-- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>-- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>-- <Modal- isOpen={showSetupModal}- onOpenChange={(open) => {- if (!open) {- setShowSetupModal(false);- onCompleted();- }- }}- >- <ModalContent- className="max-w-2xl"- title="Certificate Authentication Setup"- subTitle="Configure the target host to trust certificates issued by this dynamic secret."- >- <div className="flex flex-col">- <span className="text-sm text-muted">Run this command on the target host:</span>- <div className="mt-2 flex items-center gap-1">- <Input value={setupCommand} isDisabled />- <IconButton- ariaLabel="copy"- variant="plain"- colorSchema="secondary"- size="sm"- onClick={() => {- navigator.clipboard.writeText(setupCommand);- createNotification({- text: "Command copied to clipboard",- type: "info"- });- }}- className="size-8 shrink-0"- >- <FontAwesomeIcon icon={faCopy} className="text-label" />- </IconButton>- </div>- <div className="mt-4 flex flex-col gap-1 text-sm text-muted">- <span>This command will:</span>- <span>- Install the CA certificate on the target host</span>- <span>- Configure SSH to trust certificate-based authentication</span>- <span>- Restart the SSH service</span>- </div>- <span className="mt-4 text-sm text-muted">- Or, copy the CA public key to install it manually:- </span>- <div className="mt-2 flex items-center gap-1">- <Input- type={isPublicKeyVisible ? "text" : "password"}- value={caPublicKey || ""}- isDisabled- />- <IconButton- ariaLabel="toggle visibility"- variant="plain"- colorSchema="secondary"- size="sm"- onClick={() => setIsPublicKeyVisible((v) => !v)}- className="size-8 shrink-0"- >- {isPublicKeyVisible ? (- <EyeOffIcon className="size-4 text-label" />- ) : (- <EyeIcon className="size-4 text-label" />- )}- </IconButton>- <IconButton- ariaLabel="copy"- variant="plain"- colorSchema="secondary"- size="sm"- onClick={() => {- if (caPublicKey) {- navigator.clipboard.writeText(caPublicKey);- createNotification({- text: "CA public key copied to clipboard",- type: "info"- });- }- }}- className="size-8 shrink-0"- >- <FontAwesomeIcon icon={faCopy} className="text-label" />- </IconButton>- </div>- </div>- <div className="mt-6 flex justify-end">- <Button- colorSchema="secondary"- onClick={() => {- setShowSetupModal(false);- onCompleted();- }}- >- Close- </Button>- </div>- </ModalContent>- </Modal>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsxdeleted file mode 100644index 54a0bb8a21..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx+++ /dev/null@@ -1,620 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import {- Button,- FilterableSelect,- FormControl,- Input,- SecretInput,- Select,- SelectItem,- Switch-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import {- DynamicSecretProviders,- TailscaleAuthMethod,- TailscaleKeyAuthType,- TDynamicSecretProvider-} from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--type TailscaleInputs = Extract<- TDynamicSecretProvider,- { type: DynamicSecretProviders.Tailscale }->["inputs"];--const validateTTL = (val: string, ctx: z.RefinementCtx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be greater than 1 minute" });- if (valMs > ms("90d"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 90 days" });-};--const tailscaleAuthSchema = z.discriminatedUnion("method", [- z.object({- method: z.literal(TailscaleAuthMethod.ApiKey),- apiKey: z.string().trim().min(1, "API key is required")- }),- z.object({- method: z.literal(TailscaleAuthMethod.OAuth),- clientId: z.string().trim().min(1, "Client ID is required"),- clientSecret: z.string().trim().min(1, "Client secret is required")- })-]);--const formSchema = z- .object({- provider: z.discriminatedUnion("authType", [- z.object({- authType: z.literal(TailscaleKeyAuthType.AuthKeys),- auth: tailscaleAuthSchema,- tailnet: z.string().trim().min(1, "Tailnet is required"),- description: z.string().trim().max(50).optional(),- tags: z.string().trim().optional(),- reusable: z.boolean().default(false),- preauthorized: z.boolean().default(false)- }),- z.object({- authType: z.literal(TailscaleKeyAuthType.OAuthKeys),- auth: tailscaleAuthSchema,- tailnet: z.string().trim().min(1, "Tailnet is required"),- description: z.string().trim().max(50).optional(),- tags: z.string().trim().optional(),- scopes: z.string().trim().min(1, "At least one scope is required")- }),- z.object({- authType: z.literal(TailscaleKeyAuthType.FederatedKeys),- auth: tailscaleAuthSchema,- tailnet: z.string().trim().min(1, "Tailnet is required"),- description: z.string().trim().max(50).optional(),- tags: z.string().trim().optional(),- scopes: z.string().trim().min(1, "At least one scope is required"),- issuer: z- .string()- .trim()- .min(1, "Issuer is required")- .url("Issuer must be a valid https URL"),- subject: z.string().trim().min(1, "Subject is required"),- audience: z.string().trim().optional()- })- ]),- defaultTTL: z.string().superRefine(validateTTL),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- validateTTL(val, ctx);- }),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() })- })- .superRefine((val, ctx) => {- // Tailscale requires tags on tailnet-owned auth keys (created via OAuth).- if (- val.provider.authType === TailscaleKeyAuthType.AuthKeys &&- val.provider.auth.method === TailscaleAuthMethod.OAuth &&- !val.provider.tags?.trim()- ) {- ctx.addIssue({- code: z.ZodIssueCode.custom,- path: ["provider", "tags"],- message: "Tags are required when creating auth keys with OAuth authentication"- });- }- });-type TForm = z.infer<typeof formSchema>;--const splitCsv = (val?: string) =>- val- ? val- .split(",")- .map((entry) => entry.trim())- .filter(Boolean)- : [];--const assertNever = (value: never): never => {- throw new Error(`Unhandled Tailscale auth type: ${String(value)}`);-};--const buildAuth = (auth: TForm["provider"]["auth"]): TailscaleInputs["auth"] =>- auth.method === TailscaleAuthMethod.ApiKey- ? { method: TailscaleAuthMethod.ApiKey, apiKey: auth.apiKey }- : {- method: TailscaleAuthMethod.OAuth,- clientId: auth.clientId,- clientSecret: auth.clientSecret- };--const buildInputs = (- provider: TForm["provider"],- auth: TailscaleInputs["auth"]-): TailscaleInputs => {- const base = {- auth,- tailnet: provider.tailnet,- description: provider.description || undefined,- tags: splitCsv(provider.tags)- };-- switch (provider.authType) {- case TailscaleKeyAuthType.AuthKeys:- return {- ...base,- authType: provider.authType,- reusable: provider.reusable,- preauthorized: provider.preauthorized- };- case TailscaleKeyAuthType.OAuthKeys:- return {- ...base,- authType: provider.authType,- scopes: splitCsv(provider.scopes)- };- case TailscaleKeyAuthType.FederatedKeys:- return {- ...base,- authType: provider.authType,- scopes: splitCsv(provider.scopes),- issuer: provider.issuer,- subject: provider.subject,- audience: provider.audience || undefined- };- default:- return assertNever(provider);- }-};--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const TailscaleInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- environment: isSingleEnvironmentMode && environments.length > 0 ? environments[0] : undefined,- provider: {- authType: TailscaleKeyAuthType.AuthKeys,- auth: { method: TailscaleAuthMethod.ApiKey },- tailnet: "-",- reusable: false,- preauthorized: false- }- }- });-- const createDynamicSecret = useCreateDynamicSecret();- const authType = watch("provider.authType");- const authMethod = watch("provider.auth.method");- const tagsRequired =- authType === TailscaleKeyAuthType.OAuthKeys || authType === TailscaleKeyAuthType.FederatedKeys;-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment- }: TForm) => {- if (createDynamicSecret.isPending) return;-- const auth = buildAuth(provider.auth);- const inputs = buildInputs(provider, auth);-- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Tailscale, inputs },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <Controller- name="provider.auth.method"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Authentication Method"- >- <Select- value={value}- onValueChange={onChange}- className="w-full border border-mineshaft-500"- position="popper"- dropdownContainerClassName="max-w-none"- >- <SelectItem value={TailscaleAuthMethod.ApiKey}>API Key</SelectItem>- <SelectItem value={TailscaleAuthMethod.OAuth}>OAuth</SelectItem>- </Select>- </FormControl>- )}- />-- {authMethod === TailscaleAuthMethod.ApiKey && (- <Controller- control={control}- name="provider.auth.apiKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="API Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="Tailscale API access token with permission to create and revoke keys."- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />- )}-- {authMethod === TailscaleAuthMethod.OAuth && (- <>- <Controller- control={control}- name="provider.auth.clientId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client ID"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input {...field} placeholder="kXKWj5bUY611CNTRL" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.auth.clientSecret"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client Secret"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="OAuth client secret with permission to create and revoke keys."- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />- </>- )}-- <Controller- name="provider.authType"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Key Type"- >- <Select- value={value}- onValueChange={onChange}- className="w-full border border-mineshaft-500"- position="popper"- dropdownContainerClassName="max-w-none"- >- <SelectItem value={TailscaleKeyAuthType.AuthKeys}>Auth Key</SelectItem>- <SelectItem value={TailscaleKeyAuthType.OAuthKeys}>OAuth Client</SelectItem>- <SelectItem value={TailscaleKeyAuthType.FederatedKeys}>- Federated Identity- </SelectItem>- </Select>- </FormControl>- )}- />-- <Controller- control={control}- name="provider.tailnet"- defaultValue="-"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Tailnet"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="Use '-' for the token owner's default tailnet, or provide a tailnet name (e.g. example.com)."- >- <Input {...field} placeholder="-" />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.description"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Description"- className="grow"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="Created by Infisical" />- </FormControl>- )}- />-- <Controller- control={control}- name="provider.tags"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Tags"- className="grow"- isOptional={!tagsRequired}- isRequired={tagsRequired}- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Comma-separated ACL tags (e.g. tag:ci, tag:prod). Required when creating auth keys with OAuth authentication."- >- <Input {...field} placeholder="tag:ci, tag:prod" />- </FormControl>- )}- />-- {(authType === TailscaleKeyAuthType.OAuthKeys ||- authType === TailscaleKeyAuthType.FederatedKeys) && (- <Controller- control={control}- name="provider.scopes"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Scopes"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="Comma-separated OAuth scopes (e.g. devices:core, users:read)."- >- <Input {...field} placeholder="devices:core, users:read" />- </FormControl>- )}- />- )}-- {authType === TailscaleKeyAuthType.FederatedKeys && (- <>- <Controller- control={control}- name="provider.issuer"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Issuer"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="HTTPS URL of the OIDC issuer trusted for token exchange."- >- <Input- {...field}- placeholder="https://token.actions.githubusercontent.com"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.subject"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Subject"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="Pattern matched against the sub claim of the OIDC token (supports wildcards)."- >- <Input {...field} placeholder="repo:my-org/my-repo:*" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.audience"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Audience"- className="grow"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Leave blank to let Tailscale auto-generate one."- >- <Input {...field} />- </FormControl>- )}- />- </>- )}-- {authType === TailscaleKeyAuthType.AuthKeys && (- <div className="flex flex-col gap-3 pt-1 pb-2">- <Controller- control={control}- name="provider.reusable"- render={({ field: { value, onChange } }) => (- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="tailscale-reusable"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">Reusable</p>- </Switch>- )}- />- <Controller- control={control}- name="provider.preauthorized"- render={({ field: { value, onChange } }) => (- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="tailscale-preauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">Pre-authorized</p>- </Switch>- )}- />- </div>- )}-- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>-- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TotpInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TotpInputForm.tsxdeleted file mode 100644index f86ac4017c..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TotpInputForm.tsx+++ /dev/null@@ -1,320 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import { z } from "zod";--import {- Button,- FilterableSelect,- FormControl,- Input,- Select,- SelectItem-} from "@app/components/v2";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";-import { slugSchema } from "@app/lib/schemas";--enum ConfigType {- URL = "url",- MANUAL = "manual"-}--enum TotpAlgorithm {- SHA1 = "sha1",- SHA256 = "sha256",- SHA512 = "sha512"-}--const formSchema = z.object({- provider: z.discriminatedUnion("configType", [- z.object({- configType: z.literal(ConfigType.URL),- url: z- .string()- .url()- .trim()- .min(1)- .refine((val) => {- const urlObj = new URL(val);- const secret = urlObj.searchParams.get("secret");-- return Boolean(secret);- }, "OTP URL must contain secret field")- }),- z.object({- configType: z.literal(ConfigType.MANUAL),- secret: z- .string()- .trim()- .min(1)- .transform((val) => val.replace(/\s+/g, "")),- period: z.number().optional(),- algorithm: z.nativeEnum(TotpAlgorithm).optional(),- digits: z.number().optional()- })- ]),- name: slugSchema(),- environment: z.object({ name: z.string(), slug: z.string() })-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const TotpInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- watch,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- configType: ConfigType.URL- },- environment: isSingleEnvironmentMode ? environments[0] : undefined- }- });-- const selectedConfigType = watch("provider.configType");-- const createDynamicSecret = useCreateDynamicSecret();-- const handleCreateDynamicSecret = async ({ name, provider, environment }: TForm) => {- // wait till previous request is finished- if (createDynamicSecret.isPending) return;- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Totp, inputs: provider },- maxTTL: "24h",- name,- path: secretPath,- defaultTTL: "1m",- projectSlug,- environmentSlug: environment.slug- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <Controller- control={control}- name="provider.configType"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Configuration Type"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(val) => {- field.onChange(val);- }}- dropdownContainerClassName="max-w-full"- >- <SelectItem value={ConfigType.URL} key="config-type-url">- URL- </SelectItem>- <SelectItem value={ConfigType.MANUAL} key="config-type-manual">- Manual- </SelectItem>- </Select>- </FormControl>- )}- />- {selectedConfigType === ConfigType.URL && (- <Controller- control={control}- name="provider.url"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="OTP URL"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="otpauth://" />- </FormControl>- )}- />- )}- {selectedConfigType === ConfigType.MANUAL && (- <>- <Controller- control={control}- name="provider.secret"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <div className="flex flex-row gap-2">- <Controller- control={control}- name="provider.period"- defaultValue={30}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Period"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- type="number"- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.digits"- defaultValue={6}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digits"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- type="number"- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.algorithm"- defaultValue={TotpAlgorithm.SHA1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Algorithm"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- dropdownContainerClassName="max-w-full"- onValueChange={(val) => {- field.onChange(val);- }}- >- <SelectItem value={TotpAlgorithm.SHA1} key="algorithm-sha-1">- SHA1- </SelectItem>- <SelectItem value={TotpAlgorithm.SHA256} key="algorithm-sha-256">- SHA256- </SelectItem>- <SelectItem value={TotpAlgorithm.SHA512} key="algorithm-sha-512">- SHA512- </SelectItem>- </Select>- </FormControl>- )}- />- </div>- <p className="mb-8 text-sm font-normal text-gray-400">- The period, digits, and algorithm values can remain at their defaults unless- your TOTP provider specifies otherwise.- </p>- </>- )}- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultCassandraImportModal.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultCassandraImportModal.tsxdeleted file mode 100644index fb34e3752e..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultCassandraImportModal.tsx+++ /dev/null@@ -1,242 +0,0 @@-import { useEffect, useState } from "react";-import { InfoIcon } from "lucide-react";--import {- defaultVaultConnectionId,- VaultConnectionAndNamespaceFields-} from "@app/components/external-migrations";-import { createNotification } from "@app/components/notifications";-import {- Button,- FilterableSelect,- FormControl,- Modal,- ModalClose,- ModalContent-} from "@app/components/v2";-import { Alert, AlertDescription } from "@app/components/v3";-import { TAvailableAppConnection } from "@app/hooks/api/appConnections/types";-import { useGetVaultDatabaseRoles, useGetVaultMounts } from "@app/hooks/api/migration/queries";-import { VaultDatabaseRole } from "@app/hooks/api/migration/types";--type Props = {- isOpen: boolean;- onOpenChange: (isOpen: boolean) => void;- appConnections: TAvailableAppConnection[];- onImport: (role: VaultDatabaseRole) => void;-};--type ContentProps = {- onClose: () => void;- appConnections: TAvailableAppConnection[];- onImport: (role: VaultDatabaseRole) => void;-};--const Content = ({ onClose, appConnections, onImport }: ContentProps) => {- const hasAppConnections = appConnections.length > 0;- const [selectedConnectionId, setSelectedConnectionId] = useState<string | null>(- defaultVaultConnectionId(appConnections)- );- const [selectedNamespace, setSelectedNamespace] = useState<string | null>(null);- const [selectedMountPath, setSelectedMountPath] = useState<string | null>(null);- const [selectedRole, setSelectedRole] = useState<VaultDatabaseRole | null>(null);- const [shouldFetchRoles, setShouldFetchRoles] = useState(false);- const [shouldFetchMounts, setShouldFetchMounts] = useState(false);-- const activeConnectionId = hasAppConnections ? (selectedConnectionId ?? undefined) : undefined;-- const { data: roles, isLoading: isLoadingRoles } = useGetVaultDatabaseRoles(- shouldFetchRoles,- selectedNamespace ?? undefined,- selectedMountPath ?? undefined,- activeConnectionId- );- const { data: mounts, isLoading: isLoadingMounts } = useGetVaultMounts(- shouldFetchMounts,- selectedNamespace ?? undefined,- activeConnectionId- );-- const databaseMounts = mounts?.filter((mount) => mount.type === "database");-- const cassandraRoles = roles?.filter((role) =>- role.config.plugin_name?.toLowerCase().includes("cassandra")- );-- const handleConnectionChange = (id: string) => {- setSelectedConnectionId(id);- setSelectedNamespace(null);- setSelectedMountPath(null);- setSelectedRole(null);- setShouldFetchMounts(false);- setShouldFetchRoles(false);- };-- const handleNamespaceChange = (ns: string) => {- setSelectedNamespace(ns);- setSelectedMountPath(null);- setSelectedRole(null);- };-- useEffect(() => {- if (selectedNamespace) {- setShouldFetchMounts(true);- }- }, [selectedNamespace]);-- useEffect(() => {- if (selectedNamespace && selectedMountPath) {- setShouldFetchRoles(true);- } else {- setShouldFetchRoles(false);- }- }, [selectedNamespace, selectedMountPath]);-- const handleImport = () => {- if (!selectedRole) {- createNotification({- type: "error",- text: "Please select a Vault Cassandra role to load"- });- return;- }-- if (!selectedNamespace) {- createNotification({ type: "error", text: "Please select a namespace" });- return;- }-- if (hasAppConnections && !selectedConnectionId) {- createNotification({ type: "error", text: "Please select an app connection" });- return;- }-- if (!mounts || mounts.length === 0) {- createNotification({- type: "error",- text: "No Vault mounts found. Please ensure you have database secrets engine configured."- });- return;- }-- onImport(selectedRole);- onClose();- };-- return (- <>- <Alert variant="info" className="mb-4">- <InfoIcon />- <AlertDescription>- Select a Cassandra database role from Vault to pre-fill the form with its configuration- including connection details, creation/revocation statements, TTL settings, etc.- </AlertDescription>- </Alert>-- <VaultConnectionAndNamespaceFields- appConnections={appConnections}- connectionId={selectedConnectionId}- onConnectionIdChange={handleConnectionChange}- namespace={selectedNamespace}- onNamespaceChange={handleNamespaceChange}- namespaceTooltip="Select the Vault namespace containing the database secrets engine."- namespaceHelpText="Select the Vault namespace to fetch available database secrets engines"- />-- <FormControl- label="Database Secrets Engine"- className="mb-4"- tooltipText="Select the database secrets engine mount to fetch available Cassandra roles."- >- <>- <FilterableSelect- value={databaseMounts?.find((mount) => mount.path === selectedMountPath)}- onChange={(value) => {- if (value && !Array.isArray(value)) {- const mount = value as { path: string; type: string; version: string | null };- setSelectedMountPath(mount.path.replace(/\/$/, ""));- setSelectedRole(null);- }- }}- options={databaseMounts || []}- getOptionValue={(option) => option.path}- getOptionLabel={(option) => option.path.replace(/\/$/, "")}- isDisabled={isLoadingMounts || !databaseMounts?.length}- placeholder="Select database secrets engine..."- className="w-full"- />- <p className="mt-1 text-xs text-mineshaft-400">- Choose a database secrets engine mount to list available Cassandra roles- </p>- </>- </FormControl>-- <FormControl label="Cassandra Role" className="mb-6">- <>- <FilterableSelect- value={selectedRole}- onChange={(value) => {- if (value && !Array.isArray(value)) {- setSelectedRole(value as VaultDatabaseRole);- } else {- setSelectedRole(null);- }- }}- options={cassandraRoles || []}- getOptionValue={(option) => option.name}- getOptionLabel={(option) => option.name}- isDisabled={isLoadingRoles || !cassandraRoles?.length || !selectedMountPath}- placeholder={(() => {- if (!selectedMountPath) return "Select a mount path first...";- if (cassandraRoles?.length === 0) return "No Cassandra roles found...";- return "Select a role to load...";- })()}- isClearable- className="w-full"- />- <p className="mt-1 text-xs text-mineshaft-400">- Choose a Cassandra role from the selected mount to load its configuration- </p>- </>- </FormControl>-- <div className="mt-8 flex space-x-4">- <Button- onClick={handleImport}- isDisabled={!selectedRole || isLoadingMounts || isLoadingRoles}- >- Load Configuration- </Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>- </>- );-};--export const VaultCassandraImportModal = ({- isOpen,- onOpenChange,- appConnections,- onImport-}: Props) => {- return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent- bodyClassName="overflow-visible"- title="Load from HashiCorp Vault"- subTitle="Select a Cassandra database role to load its configuration."- className="max-w-2xl"- >- <Content- onClose={() => onOpenChange(false)}- appConnections={appConnections}- onImport={onImport}- />- </ModalContent>- </Modal>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultKubernetesImportModal.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultKubernetesImportModal.tsxdeleted file mode 100644index 7193d00cae..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultKubernetesImportModal.tsx+++ /dev/null@@ -1,236 +0,0 @@-import { useEffect, useState } from "react";-import { InfoIcon } from "lucide-react";--import {- defaultVaultConnectionId,- VaultConnectionAndNamespaceFields-} from "@app/components/external-migrations";-import { createNotification } from "@app/components/notifications";-import {- Button,- FilterableSelect,- FormControl,- Modal,- ModalClose,- ModalContent-} from "@app/components/v2";-import { Alert, AlertDescription } from "@app/components/v3";-import { TAvailableAppConnection } from "@app/hooks/api/appConnections/types";-import { useGetVaultKubernetesRoles, useGetVaultMounts } from "@app/hooks/api/migration/queries";-import { VaultKubernetesRole } from "@app/hooks/api/migration/types";--type Props = {- isOpen: boolean;- onOpenChange: (isOpen: boolean) => void;- appConnections: TAvailableAppConnection[];- onImport: (role: VaultKubernetesRole) => void;-};--type ContentProps = {- onClose: () => void;- appConnections: TAvailableAppConnection[];- onImport: (role: VaultKubernetesRole) => void;-};--const Content = ({ onClose, appConnections, onImport }: ContentProps) => {- const hasAppConnections = appConnections.length > 0;- const [selectedConnectionId, setSelectedConnectionId] = useState<string | null>(- defaultVaultConnectionId(appConnections)- );- const [selectedNamespace, setSelectedNamespace] = useState<string | null>(null);- const [selectedMountPath, setSelectedMountPath] = useState<string | null>(null);- const [selectedRole, setSelectedRole] = useState<VaultKubernetesRole | null>(null);- const [shouldFetchRoles, setShouldFetchRoles] = useState(false);- const [shouldFetchMounts, setShouldFetchMounts] = useState(false);-- const activeConnectionId = hasAppConnections ? (selectedConnectionId ?? undefined) : undefined;-- const { data: roles, isLoading: isLoadingRoles } = useGetVaultKubernetesRoles(- shouldFetchRoles,- selectedNamespace ?? undefined,- selectedMountPath ?? undefined,- activeConnectionId- );- const { data: mounts, isLoading: isLoadingMounts } = useGetVaultMounts(- shouldFetchMounts,- selectedNamespace ?? undefined,- activeConnectionId- );-- const kubernetesMounts = mounts?.filter((mount) => mount.type === "kubernetes");-- const handleConnectionChange = (id: string) => {- setSelectedConnectionId(id);- setSelectedNamespace(null);- setSelectedMountPath(null);- setSelectedRole(null);- setShouldFetchMounts(false);- setShouldFetchRoles(false);- };-- const handleNamespaceChange = (ns: string) => {- setSelectedNamespace(ns);- setSelectedMountPath(null);- setSelectedRole(null);- };-- useEffect(() => {- if (selectedNamespace) {- setShouldFetchMounts(true);- }- }, [selectedNamespace]);-- useEffect(() => {- if (selectedNamespace && selectedMountPath) {- setShouldFetchRoles(true);- } else {- setShouldFetchRoles(false);- }- }, [selectedNamespace, selectedMountPath]);-- const handleImport = () => {- if (!selectedRole) {- createNotification({- type: "error",- text: "Please select a Vault Kubernetes role to load"- });- return;- }-- if (!selectedNamespace) {- createNotification({ type: "error", text: "Please select a namespace" });- return;- }-- if (hasAppConnections && !selectedConnectionId) {- createNotification({ type: "error", text: "Please select an app connection" });- return;- }-- if (!mounts || mounts.length === 0) {- createNotification({- type: "error",- text: "No Vault mounts found. Please ensure you have Kubernetes secrets engine configured."- });- return;- }-- onImport(selectedRole);- onClose();- };-- return (- <>- <Alert variant="info" className="mb-4">- <InfoIcon />- <AlertDescription>- Select a Kubernetes secrets engine role from Vault to pre-fill the form with its- configuration including cluster URL, CA certificate, TTL settings, etc.- </AlertDescription>- </Alert>-- <VaultConnectionAndNamespaceFields- appConnections={appConnections}- connectionId={selectedConnectionId}- onConnectionIdChange={handleConnectionChange}- namespace={selectedNamespace}- onNamespaceChange={handleNamespaceChange}- namespaceTooltip="Select the Vault namespace containing the Kubernetes secrets engine."- namespaceHelpText="Select the Vault namespace to fetch available Kubernetes secrets engines"- />-- <FormControl- label="Kubernetes Secrets Engine"- className="mb-4"- tooltipText="Select the Kubernetes secrets engine mount to fetch available roles."- >- <>- <FilterableSelect- value={kubernetesMounts?.find((mount) => mount.path === selectedMountPath)}- onChange={(value) => {- if (value && !Array.isArray(value)) {- const mount = value as { path: string; type: string; version: string | null };- setSelectedMountPath(mount.path.replace(/\/$/, ""));- setSelectedRole(null);- }- }}- options={kubernetesMounts || []}- getOptionValue={(option) => option.path}- getOptionLabel={(option) => option.path.replace(/\/$/, "")}- isDisabled={isLoadingMounts || !kubernetesMounts?.length}- placeholder="Select Kubernetes secrets engine..."- className="w-full"- />- <p className="mt-1 text-xs text-mineshaft-400">- Choose a Kubernetes secrets engine mount to list available roles- </p>- </>- </FormControl>-- <FormControl label="Kubernetes Role" className="mb-6">- <>- <FilterableSelect- value={selectedRole}- onChange={(value) => {- if (value && !Array.isArray(value)) {- setSelectedRole(value as VaultKubernetesRole);- } else {- setSelectedRole(null);- }- }}- options={roles || []}- getOptionValue={(option) => option.name}- getOptionLabel={(option) => option.name}- isDisabled={isLoadingRoles || !roles?.length || !selectedMountPath}- placeholder={- !selectedMountPath ? "Select a mount path first..." : "Select a role to load..."- }- isClearable- className="w-full"- />- <p className="mt-1 text-xs text-mineshaft-400">- Choose a Kubernetes role from the selected mount to load its configuration- </p>- </>- </FormControl>-- <div className="mt-8 flex space-x-4">- <Button- onClick={handleImport}- isDisabled={!selectedRole || isLoadingMounts || isLoadingRoles}- >- Load Configuration- </Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>- </>- );-};--export const VaultKubernetesImportModal = ({- isOpen,- onOpenChange,- appConnections,- onImport-}: Props) => {- return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent- bodyClassName="overflow-visible"- title="Load from HashiCorp Vault"- subTitle="Select a Kubernetes secrets engine role to load its configuration."- className="max-w-2xl"- >- <Content- onClose={() => onOpenChange(false)}- appConnections={appConnections}- onImport={onImport}- />- </ModalContent>- </Modal>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultLdapImportModal.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultLdapImportModal.tsxdeleted file mode 100644index 9ccff3875c..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultLdapImportModal.tsx+++ /dev/null@@ -1,231 +0,0 @@-import { useEffect, useState } from "react";-import { InfoIcon } from "lucide-react";--import {- defaultVaultConnectionId,- VaultConnectionAndNamespaceFields-} from "@app/components/external-migrations";-import { createNotification } from "@app/components/notifications";-import {- Button,- FilterableSelect,- FormControl,- Modal,- ModalClose,- ModalContent-} from "@app/components/v2";-import { Alert, AlertDescription } from "@app/components/v3";-import { TAvailableAppConnection } from "@app/hooks/api/appConnections/types";-import { useGetVaultLdapRoles, useGetVaultMounts } from "@app/hooks/api/migration/queries";-import { VaultLdapRole } from "@app/hooks/api/migration/types";--type Props = {- isOpen: boolean;- onOpenChange: (isOpen: boolean) => void;- appConnections: TAvailableAppConnection[];- onImport: (role: VaultLdapRole) => void;-};--type ContentProps = {- onClose: () => void;- appConnections: TAvailableAppConnection[];- onImport: (role: VaultLdapRole) => void;-};--const Content = ({ onClose, appConnections, onImport }: ContentProps) => {- const hasAppConnections = appConnections.length > 0;- const [selectedConnectionId, setSelectedConnectionId] = useState<string | null>(- defaultVaultConnectionId(appConnections)- );- const [selectedNamespace, setSelectedNamespace] = useState<string | null>(null);- const [selectedMountPath, setSelectedMountPath] = useState<string | null>(null);- const [selectedRole, setSelectedRole] = useState<VaultLdapRole | null>(null);- const [shouldFetchRoles, setShouldFetchRoles] = useState(false);- const [shouldFetchMounts, setShouldFetchMounts] = useState(false);-- const activeConnectionId = hasAppConnections ? (selectedConnectionId ?? undefined) : undefined;-- const { data: roles, isLoading: isLoadingRoles } = useGetVaultLdapRoles(- shouldFetchRoles,- selectedNamespace ?? undefined,- selectedMountPath ?? undefined,- activeConnectionId- );- const { data: mounts, isLoading: isLoadingMounts } = useGetVaultMounts(- shouldFetchMounts,- selectedNamespace ?? undefined,- activeConnectionId- );-- const ldapMounts = mounts?.filter((mount) => mount.type === "ldap");-- const handleConnectionChange = (id: string) => {- setSelectedConnectionId(id);- setSelectedNamespace(null);- setSelectedMountPath(null);- setSelectedRole(null);- setShouldFetchMounts(false);- setShouldFetchRoles(false);- };-- const handleNamespaceChange = (ns: string) => {- setSelectedNamespace(ns);- setSelectedMountPath(null);- setSelectedRole(null);- };-- useEffect(() => {- if (selectedNamespace) {- setShouldFetchMounts(true);- }- }, [selectedNamespace]);-- useEffect(() => {- if (selectedNamespace && selectedMountPath) {- setShouldFetchRoles(true);- } else {- setShouldFetchRoles(false);- }- }, [selectedNamespace, selectedMountPath]);-- const handleImport = () => {- if (!selectedRole) {- createNotification({- type: "error",- text: "Please select a Vault LDAP role to load"- });- return;- }-- if (!selectedNamespace) {- createNotification({ type: "error", text: "Please select a namespace" });- return;- }-- if (hasAppConnections && !selectedConnectionId) {- createNotification({ type: "error", text: "Please select an app connection" });- return;- }-- if (!mounts || mounts.length === 0) {- createNotification({- type: "error",- text: "No Vault mounts found. Please ensure you have LDAP secrets engine configured."- });- return;- }-- onImport(selectedRole);- onClose();- };-- return (- <>- <Alert variant="info" className="mb-4">- <InfoIcon />- <AlertDescription>- Select an LDAP secrets engine role from Vault to pre-fill the form with its configuration- including connection details, LDIF statements, TTL settings, etc.- </AlertDescription>- </Alert>-- <VaultConnectionAndNamespaceFields- appConnections={appConnections}- connectionId={selectedConnectionId}- onConnectionIdChange={handleConnectionChange}- namespace={selectedNamespace}- onNamespaceChange={handleNamespaceChange}- namespaceTooltip="Select the Vault namespace containing the LDAP secrets engine."- namespaceHelpText="Select the Vault namespace to fetch available LDAP secrets engines"- />-- <FormControl- label="LDAP Secrets Engine"- className="mb-4"- tooltipText="Select the LDAP secrets engine mount to fetch available roles."- >- <>- <FilterableSelect- value={ldapMounts?.find((mount) => mount.path === selectedMountPath)}- onChange={(value) => {- if (value && !Array.isArray(value)) {- const mount = value as { path: string; type: string; version: string | null };- setSelectedMountPath(mount.path.replace(/\/$/, ""));- setSelectedRole(null);- }- }}- options={ldapMounts || []}- getOptionValue={(option) => option.path}- getOptionLabel={(option) => option.path.replace(/\/$/, "")}- isDisabled={isLoadingMounts || !ldapMounts?.length}- placeholder="Select LDAP secrets engine..."- className="w-full"- />- <p className="mt-1 text-xs text-mineshaft-400">- Choose an LDAP secrets engine mount to list available roles- </p>- </>- </FormControl>-- <FormControl label="LDAP Role" className="mb-6">- <>- <FilterableSelect- value={selectedRole}- onChange={(value) => {- if (value && !Array.isArray(value)) {- setSelectedRole(value as VaultLdapRole);- } else {- setSelectedRole(null);- }- }}- options={roles || []}- getOptionValue={(option) => option.name}- getOptionLabel={(option) => option.name}- isDisabled={isLoadingRoles || !roles?.length || !selectedMountPath}- placeholder={- !selectedMountPath ? "Select a mount path first..." : "Select a role to load..."- }- isClearable- className="w-full"- />- <p className="mt-1 text-xs text-mineshaft-400">- Choose an LDAP role from the selected mount to load its configuration- </p>- </>- </FormControl>-- <div className="mt-8 flex space-x-4">- <Button- onClick={handleImport}- isDisabled={!selectedRole || isLoadingMounts || isLoadingRoles}- >- Load Configuration- </Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>- </>- );-};--export const VaultLdapImportModal = ({ isOpen, onOpenChange, appConnections, onImport }: Props) => {- return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent- bodyClassName="overflow-visible"- title="Load from HashiCorp Vault"- subTitle="Select an LDAP secrets engine role to load its configuration."- className="max-w-2xl"- >- <Content- onClose={() => onOpenChange(false)}- appConnections={appConnections}- onImport={onImport}- />- </ModalContent>- </Modal>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultSqlDatabaseImportModal.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultSqlDatabaseImportModal.tsxdeleted file mode 100644index d6bcb3d9e1..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VaultSqlDatabaseImportModal.tsx+++ /dev/null@@ -1,237 +0,0 @@-import { useEffect, useState } from "react";-import { InfoIcon } from "lucide-react";--import {- defaultVaultConnectionId,- VaultConnectionAndNamespaceFields-} from "@app/components/external-migrations";-import { createNotification } from "@app/components/notifications";-import {- Button,- FilterableSelect,- FormControl,- Modal,- ModalClose,- ModalContent-} from "@app/components/v2";-import { Alert, AlertDescription } from "@app/components/v3";-import { TAvailableAppConnection } from "@app/hooks/api/appConnections/types";-import { useGetVaultDatabaseRoles, useGetVaultMounts } from "@app/hooks/api/migration/queries";-import { VaultDatabaseRole } from "@app/hooks/api/migration/types";--type Props = {- isOpen: boolean;- onOpenChange: (isOpen: boolean) => void;- appConnections: TAvailableAppConnection[];- onImport: (role: VaultDatabaseRole) => void;-};--type ContentProps = {- onClose: () => void;- appConnections: TAvailableAppConnection[];- onImport: (role: VaultDatabaseRole) => void;-};--const Content = ({ onClose, appConnections, onImport }: ContentProps) => {- const hasAppConnections = appConnections.length > 0;- const [selectedConnectionId, setSelectedConnectionId] = useState<string | null>(- defaultVaultConnectionId(appConnections)- );- const [selectedNamespace, setSelectedNamespace] = useState<string | null>(null);- const [selectedMountPath, setSelectedMountPath] = useState<string | null>(null);- const [selectedRole, setSelectedRole] = useState<VaultDatabaseRole | null>(null);- const [shouldFetchRoles, setShouldFetchRoles] = useState(false);- const [shouldFetchMounts, setShouldFetchMounts] = useState(false);-- const activeConnectionId = hasAppConnections ? (selectedConnectionId ?? undefined) : undefined;-- const { data: roles, isLoading: isLoadingRoles } = useGetVaultDatabaseRoles(- shouldFetchRoles,- selectedNamespace ?? undefined,- selectedMountPath ?? undefined,- activeConnectionId- );- const { data: mounts, isLoading: isLoadingMounts } = useGetVaultMounts(- shouldFetchMounts,- selectedNamespace ?? undefined,- activeConnectionId- );-- const databaseMounts = mounts?.filter((mount) => mount.type === "database");-- const handleConnectionChange = (id: string) => {- setSelectedConnectionId(id);- setSelectedNamespace(null);- setSelectedMountPath(null);- setSelectedRole(null);- setShouldFetchMounts(false);- setShouldFetchRoles(false);- };-- const handleNamespaceChange = (ns: string) => {- setSelectedNamespace(ns);- setSelectedMountPath(null);- setSelectedRole(null);- };-- useEffect(() => {- if (selectedNamespace) {- setShouldFetchMounts(true);- }- }, [selectedNamespace]);-- useEffect(() => {- if (selectedNamespace && selectedMountPath) {- setShouldFetchRoles(true);- } else {- setShouldFetchRoles(false);- }- }, [selectedNamespace, selectedMountPath]);-- const handleImport = () => {- if (!selectedRole) {- createNotification({- type: "error",- text: "Please select a Vault database role to load"- });- return;- }-- if (!selectedNamespace) {- createNotification({ type: "error", text: "Please select a namespace" });- return;- }-- if (hasAppConnections && !selectedConnectionId) {- createNotification({ type: "error", text: "Please select an app connection" });- return;- }-- if (!mounts || mounts.length === 0) {- createNotification({- type: "error",- text: "No Vault mounts found. Please ensure you have database secrets engine configured."- });- return;- }-- onImport(selectedRole);- onClose();- };-- return (- <>- <Alert variant="info" className="mb-4">- <InfoIcon />- <AlertDescription>- Select a database secrets engine role from Vault to pre-fill the form with its- configuration including connection details, creation/revocation statements, TTL settings,- etc.- </AlertDescription>- </Alert>-- <VaultConnectionAndNamespaceFields- appConnections={appConnections}- connectionId={selectedConnectionId}- onConnectionIdChange={handleConnectionChange}- namespace={selectedNamespace}- onNamespaceChange={handleNamespaceChange}- namespaceTooltip="Select the Vault namespace containing the database secrets engine."- namespaceHelpText="Select the Vault namespace to fetch available database secrets engines"- />-- <FormControl- label="Database Secrets Engine"- className="mb-4"- tooltipText="Select the database secrets engine mount to fetch available roles."- >- <>- <FilterableSelect- value={databaseMounts?.find((mount) => mount.path === selectedMountPath)}- onChange={(value) => {- if (value && !Array.isArray(value)) {- const mount = value as { path: string; type: string; version: string | null };- setSelectedMountPath(mount.path.replace(/\/$/, "")); // Remove trailing slash- setSelectedRole(null);- }- }}- options={databaseMounts || []}- getOptionValue={(option) => option.path}- getOptionLabel={(option) => option.path.replace(/\/$/, "")}- isDisabled={isLoadingMounts || !databaseMounts?.length}- placeholder="Select database secrets engine..."- className="w-full"- />- <p className="mt-1 text-xs text-mineshaft-400">- Choose a database secrets engine mount to list available roles- </p>- </>- </FormControl>-- <FormControl label="Database Role" className="mb-6">- <>- <FilterableSelect- value={selectedRole}- onChange={(value) => {- if (value && !Array.isArray(value)) {- setSelectedRole(value as VaultDatabaseRole);- } else {- setSelectedRole(null);- }- }}- options={roles || []}- getOptionValue={(option) => option.name}- getOptionLabel={(option) => option.name}- isDisabled={isLoadingRoles || !roles?.length || !selectedMountPath}- placeholder={- !selectedMountPath ? "Select a mount path first..." : "Select a role to load..."- }- isClearable- className="w-full"- />- <p className="mt-1 text-xs text-mineshaft-400">- Choose a database dynamic role from the selected mount to load its configuration- </p>- </>- </FormControl>-- <div className="mt-8 flex space-x-4">- <Button- onClick={handleImport}- isDisabled={!selectedRole || isLoadingMounts || isLoadingRoles}- >- Load Configuration- </Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>- </>- );-};--export const VaultSqlDatabaseImportModal = ({- isOpen,- onOpenChange,- appConnections,- onImport-}: Props) => {- return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent- bodyClassName="overflow-visible"- title="Load from HashiCorp Vault"- subTitle="Select a database secrets engine role to load its configuration."- className="max-w-2xl"- >- <Content- onClose={() => onOpenChange(false)}- appConnections={appConnections}- onImport={onImport}- />- </ModalContent>- </Modal>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VerticaInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VerticaInputForm.tsxdeleted file mode 100644index 441a28d7fa..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/VerticaInputForm.tsx+++ /dev/null@@ -1,585 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- Input,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import {- OrgGatewayPermissionActions,- OrgPermissionSubjects-} from "@app/context/OrgPermissionContext/types";-import { useCreateDynamicSecret } from "@app/hooks/api";-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";-import { ProjectEnv } from "@app/hooks/api/types";--const passwordRequirementsSchema = z- .object({- length: z.number().min(8).max(250),- required: z- .object({- lowercase: z.number().min(0),- uppercase: z.number().min(0),- digits: z.number().min(0),- symbols: z.number().min(0)- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 250;- }, "Sum of required characters cannot exceed 250"),- allowedSymbols: z.string().optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const formSchema = z.object({- provider: z.object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- passwordRequirements: passwordRequirementsSchema.optional(),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- gatewayId: z.string().optional(),- gatewayPoolId: z.string().optional()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),- environment: z.object({ name: z.string(), slug: z.string() }),- usernameTemplate: z.string().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onCompleted: () => void;- onCancel: () => void;- secretPath: string;- projectSlug: string;- environments: ProjectEnv[];- isSingleEnvironmentMode?: boolean;-};--export const VerticaInputForm = ({- onCompleted,- onCancel,- environments,- secretPath,- projectSlug,- isSingleEnvironmentMode-}: Props) => {- const {- control,- watch,- setValue,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- provider: {- database: "",- port: 5433,- passwordRequirements: {- length: 48,- required: {- lowercase: 1,- uppercase: 1,- digits: 1,- symbols: 0- },- allowedSymbols: "-_.~!*"- },- creationStatement: `CREATE USER {{username}} IDENTIFIED BY '{{password}}';-GRANT CREATE ON SCHEMA public TO {{username}};`,- revocationStatement: "DROP USER {{username}} CASCADE;"- },- environment: isSingleEnvironmentMode ? environments[0] : undefined,- usernameTemplate: "{{randomUsername}}"- }- });-- const createDynamicSecret = useCreateDynamicSecret();- const providerGatewayId = watch("provider.gatewayId");- const providerGatewayPoolId = watch("provider.gatewayPoolId");-- const handleCreateDynamicSecret = async ({- name,- maxTTL,- provider,- defaultTTL,- environment,- usernameTemplate- }: TForm) => {- if (createDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await createDynamicSecret.mutateAsync({- provider: { type: DynamicSecretProviders.Vertica, inputs: provider },- maxTTL,- name,- path: secretPath,- defaultTTL,- projectSlug,- environmentSlug: environment.slug,- usernameTemplate:- !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate- });- onCompleted();- };-- return (- <div>- <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: providerGatewayId ?? null,- gatewayPoolId: providerGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("provider.gatewayId", newGwId ?? undefined, {- shouldDirty: true- });- setValue("provider.gatewayPoolId", newPoolId ?? undefined, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="provider.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="Vertica Host" {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="provider.port"- defaultValue={5433}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.database"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="text" />- </FormControl>- )}- />- </div>- <div className="flex w-full items-center space-x-2">- <Controller- control={control}- name="provider.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-full"- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="provider.password"- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-full"- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Accordion type="multiple" className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify SQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>Password Configuration (optional)</AccordionTrigger>- <AccordionContent>- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated database password- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="provider.passwordRequirements.length"- defaultValue={48}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={1}- max={250}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("provider.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("provider.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="provider.passwordRequirements.required.lowercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of lowercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.uppercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of uppercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.digits"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of digits"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="provider.passwordRequirements.required.symbols"- defaultValue={0}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of symbols"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="provider.passwordRequirements.allowedSymbols"- defaultValue="-_.~!*"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbols to use in password"- isError={Boolean(error)}- errorText={error?.message}- helperText="Default: -_.~!*"- >- <Input {...field} placeholder="-_.~!*" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- {!isSingleEnvironmentMode && (- <Controller- control={control}- name="environment"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Environment"- isError={Boolean(error)}- errorText={error?.message}- >- <FilterableSelect- options={environments}- value={value}- onChange={onChange}- placeholder="Select the environment to create secret in..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- menuPlacement="top"- />- </FormControl>- )}- />- )}- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onCancel}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/components/LoadFromVaultBanner.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/components/LoadFromVaultBanner.tsxdeleted file mode 100644index 37358d8c5d..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/components/LoadFromVaultBanner.tsx+++ /dev/null@@ -1,49 +0,0 @@-import { InfoIcon } from "lucide-react";--import { Alert, AlertAction, AlertDescription, Button } from "@app/components/v3";-import { ProjectPermissionSub, useProject } from "@app/context";-import { useCanUseProjectAppConnectionImport } from "@app/hooks";-import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";-import { AppConnection } from "@app/hooks/api/appConnections/enums";--type Props = {- onClick: () => void;-};--export const LoadFromVaultBanner = ({ onClick }: Props) => {- const { projectId } = useProject();- const canUseAppConnectionImport = useCanUseProjectAppConnectionImport(- ProjectPermissionSub.Secrets- );- const { data: vaultAppConnections = [] } = useListAvailableAppConnections(- AppConnection.HCVault,- projectId,- { enabled: canUseAppConnectionImport }- );- const hasVaultConnection = vaultAppConnections.length > 0;-- if (hasVaultConnection && canUseAppConnectionImport) {- return (- <Alert variant="info" className="mb-4">- <InfoIcon />- <AlertDescription>- <span>Load values from HashiCorp Vault</span>- <AlertAction>- <Button- variant="info"- size="xs"- type="button"- onClick={onClick}- isDisabled={!canUseAppConnectionImport}- >- <img src="/images/integrations/Vault.png" alt="" className="size-4" />- Load from Vault- </Button>- </AlertAction>- </AlertDescription>- </Alert>- );- }-- return <span />;-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsElastiCacheProviderForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsElastiCacheProviderForm.tsxdeleted file mode 100644index 413eaebfe5..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsElastiCacheProviderForm.tsx+++ /dev/null@@ -1,317 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- TextArea-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z- .object({- clusterName: z.string().trim().min(1),- accessKeyId: z.string().trim().min(1),- secretAccessKey: z.string().trim().min(1),-- region: z.string().trim(),- creationStatement: z.string().trim(),- revocationStatement: z.string().trim()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretAwsElastiCacheProviderForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.clusterName"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster name"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="redis-oss-cluster" />- </FormControl>- )}- />- <Controller- control={control}- defaultValue=""- name="inputs.region"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Region"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="us-east-1" {...field} type="text" />- </FormControl>- )}- />- </div>- <div className="flex w-full items-center space-x-2">- <Controller- control={control}- name="inputs.accessKeyId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Access Key ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.secretAccessKey"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Access Key"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify ElastiCache Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsIamForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsIamForm.tsxdeleted file mode 100644index 912cfd1e2b..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsIamForm.tsx+++ /dev/null@@ -1,531 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { Button, FormControl, Input, Select, SelectItem, TextArea } from "@app/components/v2";-import { useGetServerConfig, useUpdateDynamicSecret } from "@app/hooks/api";-import {- DynamicSecretAwsIamAuth,- DynamicSecretAwsIamCredentialType,- TDynamicSecret-} from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--import { MetadataForm } from "../MetadataForm";--const formSchema = z.object({- inputs: z.discriminatedUnion("method", [- z.object({- method: z.literal(DynamicSecretAwsIamAuth.AccessKey),- credentialType: z- .nativeEnum(DynamicSecretAwsIamCredentialType)- .default(DynamicSecretAwsIamCredentialType.IamUser),- accessKey: z.string().trim().min(1),- secretAccessKey: z.string().trim().min(1),- region: z.string().trim().min(1),- awsPath: z.string().trim().optional(),- permissionBoundaryPolicyArn: z.string().trim().optional(),- policyDocument: z.string().trim().optional(),- userGroups: z.string().trim().optional(),- policyArns: z.string().trim().optional(),- tags: z- .array(z.object({ key: z.string().trim().min(1), value: z.string().trim().min(1) }))- .optional()- }),- z.object({- method: z.literal(DynamicSecretAwsIamAuth.AssumeRole),- credentialType: z- .nativeEnum(DynamicSecretAwsIamCredentialType)- .default(DynamicSecretAwsIamCredentialType.IamUser),- roleArn: z.string().trim().min(1),- region: z.string().trim().min(1),- awsPath: z.string().trim().optional(),- permissionBoundaryPolicyArn: z.string().trim().optional(),- policyDocument: z.string().trim().optional(),- userGroups: z.string().trim().optional(),- policyArns: z.string().trim().optional(),- sessionPolicyArns: z.string().trim().optional(),- sessionPolicyDocument: z.string().trim().optional(),- tags: z- .array(z.object({ key: z.string().trim().min(1), value: z.string().trim().min(1) }))- .optional()- }),- z.object({- method: z.literal(DynamicSecretAwsIamAuth.IRSA),- credentialType: z- .nativeEnum(DynamicSecretAwsIamCredentialType)- .default(DynamicSecretAwsIamCredentialType.IamUser),- region: z.string().trim().min(1),- awsPath: z.string().trim().optional(),- permissionBoundaryPolicyArn: z.string().trim().optional(),- policyDocument: z.string().trim().optional(),- userGroups: z.string().trim().optional(),- policyArns: z.string().trim().optional(),- tags: z- .array(z.object({ key: z.string().trim().min(1), value: z.string().trim().min(1) }))- .optional()- })- ]),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretAwsIamForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const { data: serverConfig } = useGetServerConfig();-- const {- control,- watch,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });- const method = watch("inputs.method");- const credentialType = watch("inputs.credentialType");- const isIamUser = credentialType !== DynamicSecretAwsIamCredentialType.TemporaryCredentials;- // session policies only apply to temporary credentials issued via STS AssumeRole- const isSessionPolicySupported = !isIamUser && method === DynamicSecretAwsIamAuth.AssumeRole;-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;-- // clear policies that do not apply to the submitted credential type / method combination; explicit "" is required- // because the update endpoint shallow-merges inputs, so omitted keys would keep their stored values- const sanitizedInputs = {- ...inputs,- ...(!isIamUser && { policyArns: "", policyDocument: "" }),- ...(!isSessionPolicySupported && { sessionPolicyArns: "", sessionPolicyDocument: "" })- };-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs: sanitizedInputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mb-4 border-b border-b-mineshaft-600 pb-2">Configuration</div>- <div className="flex flex-col">- <Controller- name="inputs.method"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Method"- >- <Select- value={value}- onValueChange={(val) => onChange(val)}- className="w-full border border-mineshaft-500"- position="popper"- dropdownContainerClassName="max-w-none"- >- <SelectItem value={DynamicSecretAwsIamAuth.AssumeRole}>- Assume Role (Recommended)- </SelectItem>- <SelectItem value={DynamicSecretAwsIamAuth.AccessKey}>Access Key</SelectItem>- {serverConfig?.kubernetesAutoFetchServiceAccountToken && (- <SelectItem value={DynamicSecretAwsIamAuth.IRSA}>IRSA (EKS)</SelectItem>- )}- </Select>- </FormControl>- )}- />- <Controller- name="inputs.credentialType"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Credential Type"- >- <>- <Select- value={value}- onValueChange={(val) => onChange(val)}- className="w-full border border-mineshaft-500"- position="popper"- dropdownContainerClassName="max-w-none"- >- <SelectItem value={DynamicSecretAwsIamCredentialType.IamUser}>- IAM User- </SelectItem>- <SelectItem value={DynamicSecretAwsIamCredentialType.TemporaryCredentials}>- Temporary Credentials- </SelectItem>- </Select>- <div className="mt-1 text-xs text-mineshaft-300">- {value === DynamicSecretAwsIamCredentialType.IamUser- ? "Creates temporary IAM users with access keys"- : "Uses STS to generate temporary credentials from your connection. Duration is controlled by the Default TTL setting above."}- </div>- </>- </FormControl>- )}- />- {method === DynamicSecretAwsIamAuth.AccessKey && (- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.accessKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Access Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.secretAccessKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Secret Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" />- </FormControl>- )}- />- </div>- )}- {method === DynamicSecretAwsIamAuth.AssumeRole && (- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.roleArn"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Assume Role ARN"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- )}- <div className="flex items-center space-x-2">- {credentialType !== DynamicSecretAwsIamCredentialType.TemporaryCredentials && (- <Controller- control={control}- name="inputs.awsPath"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS IAM Path"- className="grow"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- )}- <Controller- control={control}- name="inputs.region"- defaultValue="us-east-1"- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Region"- className={- credentialType === DynamicSecretAwsIamCredentialType.TemporaryCredentials- ? "w-full"- : "grow"- }- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- {isIamUser && (- <>- <Controller- control={control}- name="inputs.userGroups"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS IAM Groups"- isError={Boolean(error?.message)}- isOptional- errorText={error?.message}- helperText="Generated users will get attached to given groups."- >- <Input {...field} placeholder="group1,group2" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.permissionBoundaryPolicyArn"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="IAM User Permission Boundary ARN"- isError={Boolean(error?.message)}- isOptional- errorText={error?.message}- helperText="ARN to be attached to the generated user for AWS Permission Boundary."- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.policyArns"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Policy ARNs"- isError={Boolean(error?.message)}- isOptional- errorText={error?.message}- helperText="Generated users will get attached to given policy arns. AWS allows at most 10 attached managed policies."- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.policyDocument"- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS IAM Policy Document"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Generated users will have the inline policy."- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </>- )}- {isSessionPolicySupported && (- <>- <Controller- control={control}- name="inputs.sessionPolicyArns"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Session Policy ARNs"- isError={Boolean(error?.message)}- isOptional- errorText={error?.message}- helperText="Leased credentials are limited to the intersection of the role's permissions and these managed policies. They can only restrict, never add, permissions. Up to 10 ARNs, comma-separated."- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.sessionPolicyDocument"- render={({ field, fieldState: { error } }) => (- <FormControl- label="AWS Session Policy Document"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Inline session policy (JSON) that further restricts the leased temporary credentials. It cannot grant permissions beyond the role's policies. Maximum 2,048 characters."- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </>- )}- {credentialType !== DynamicSecretAwsIamCredentialType.TemporaryCredentials && (- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- )}- {credentialType !== DynamicSecretAwsIamCredentialType.TemporaryCredentials && (- <MetadataForm control={control} name="inputs.tags" title="Tags" isValueRequired />- )}- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsMemoryDbProviderForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsMemoryDbProviderForm.tsxdeleted file mode 100644index 39d2cc85fa..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsMemoryDbProviderForm.tsx+++ /dev/null@@ -1,320 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- TextArea-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { AwsMemoryDbAuthType, TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z- .object({- clusterName: z.string().trim().min(1),- region: z.string().trim().min(1),- auth: z.discriminatedUnion("type", [- z.object({- type: z.literal(AwsMemoryDbAuthType.IAM),- accessKeyId: z.string().trim().min(1),- secretAccessKey: z.string().trim().min(1)- })- ]),- creationStatement: z.string().trim(),- revocationStatement: z.string().trim()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretAwsMemoryDbProviderForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- if (updateDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.clusterName"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster name"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="my-memorydb-cluster" />- </FormControl>- )}- />- <Controller- control={control}- defaultValue=""- name="inputs.region"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Region"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="us-east-1" {...field} type="text" />- </FormControl>- )}- />- </div>- <div className="flex w-full items-center space-x-2">- <Controller- control={control}- name="inputs.auth.accessKeyId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Access Key ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.auth.secretAccessKey"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Access Key"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify MemoryDB Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={4}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAzureEntraIdForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAzureEntraIdForm.tsxdeleted file mode 100644index 2799a95ed2..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAzureEntraIdForm.tsx+++ /dev/null@@ -1,255 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { Button, FormControl, Input, SecretInput } from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z.object({- email: z.string(),- userId: z.string(),- tenantId: z.string(),- applicationId: z.string(),- clientSecret: z.string()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- newName: slugSchema().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretAzureEntraIdForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({ maxTTL, defaultTTL, newName, inputs }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- newName: newName === dynamicSecret.name ? undefined : newName,- inputs- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- </div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="inputs.email"- render={({ field, fieldState: { error } }) => (- <FormControl label="Email" isError={Boolean(error)} errorText={error?.message}>- <SecretInput- value={field.value}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- <div className="grow">- <Controller- control={control}- defaultValue=""- name="inputs.userId"- render={({ field, fieldState: { error } }) => (- <FormControl label="User ID" isError={Boolean(error)} errorText={error?.message}>- <SecretInput- isReadOnly- value={field.value}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- </div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="inputs.tenantId"- render={({ field, fieldState: { error } }) => (- <FormControl label="Tenant ID" isError={Boolean(error)} errorText={error?.message}>- <SecretInput- isReadOnly- value={field.value}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- <div className="grow">- <Controller- control={control}- defaultValue=""- name="inputs.applicationId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Application ID"- isError={Boolean(error)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- </div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="inputs.clientSecret"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client Secret"- isError={Boolean(error)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAzureSqlDatabaseForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAzureSqlDatabaseForm.tsxdeleted file mode 100644index 4505ca8a4b..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAzureSqlDatabaseForm.tsx+++ /dev/null@@ -1,703 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- SecretInput,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import { OrgPermissionSubjects } from "@app/context";-import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--import { MetadataForm } from "../MetadataForm";--const passwordRequirementsSchema = z- .object({- length: z.number().min(1).max(250),- required: z- .object({- lowercase: z.number().min(0),- uppercase: z.number().min(0),- digits: z.number().min(0),- symbols: z.number().min(0)- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 250;- }, "Sum of required characters cannot exceed 250"),- allowedSymbols: z.string().optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const formSchema = z.object({- inputs: z- .object({- host: z.string().toLowerCase().min(1),- port: z.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- passwordRequirements: passwordRequirementsSchema.optional(),- masterCreationStatement: z.string().min(1),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- ca: z.string().optional(),- sslEnabled: z.boolean().optional(),- sslRejectUnauthorized: z.boolean().optional(),- gatewayId: z.string().optional().nullable(),- gatewayPoolId: z.string().optional().nullable()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- newName: slugSchema().optional(),- metadata: z- .object({- key: z.string().trim().min(1),- value: z.string().trim().default("")- })- .array()- .optional(),- usernameTemplate: z.string().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- projectSlug: string;- environment: string;-};--export const EditDynamicSecretAzureSqlDatabaseForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const getDefaultPasswordRequirements = () => ({- length: 48,- required: {- lowercase: 1,- uppercase: 1,- digits: 1,- symbols: 0- },- allowedSymbols: "-_.~!*"- });-- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL || "",- newName: dynamicSecret.name,- metadata: dynamicSecret.metadata?.map((item) => ({ key: item.key, value: item.value })) || [],- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"]),- passwordRequirements:- (dynamicSecret.inputs as TForm["inputs"])?.passwordRequirements ||- getDefaultPasswordRequirements()- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();- const sslEnabled = watch("inputs.sslEnabled");- const inputsGatewayId = watch("inputs.gatewayId");- const inputsGatewayPoolId = watch("inputs.gatewayPoolId");-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- metadata,- usernameTemplate- }: TForm) => {- if (updateDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- projectSlug,- environmentSlug: environment,- path: secretPath,- name: dynamicSecret.name,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs: inputs ? { ...inputs, masterDatabase: "master" } : undefined,- newName: newName === dynamicSecret.name ? undefined : newName,- metadata,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>-- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <MetadataForm control={control} />- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: inputsGatewayId ?? null,- gatewayPoolId: inputsGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("inputs.gatewayId", newGwId ?? null, {- shouldDirty: true- });- setValue("inputs.gatewayPoolId", newPoolId ?? null, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="server.database.windows.net" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="inputs.username"- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- </div>- <div className="grow">- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div className="grow">- <Controller- control={control}- name="inputs.database"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="mydatabase" />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-2 mb-2">- <Controller- control={control}- name="inputs.sslEnabled"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="azure-sql-edit-ssl-enabled"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- Encrypt Connection (SSL)- </Switch>- </FormControl>- )}- />- </div>- {sslEnabled && (- <>- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the- list of supplied CAs. Disable this option if you are using a- self-signed certificate.- </p>- }- >- <FontAwesomeIcon- icon={faQuestionCircle}- size="sm"- className="ml-1"- />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- </>- )}- <Accordion type="multiple" className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advanced">- <AccordionTrigger>- Creation, Revocation & Renew Statements (optional)- </AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <div className="mb-4 text-sm text-mineshaft-300">- Customize SQL statements for managing Azure SQL Database user lifecycle- </div>- <Controller- control={control}- name="inputs.masterCreationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Master Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Statement to create login in master database"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Statement to create user in target database and grant permissions"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Statement to drop user and login"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>Password Configuration (optional)</AccordionTrigger>- <AccordionContent>- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated database password- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="inputs.passwordRequirements.length"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={1}- max={250}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("inputs.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("inputs.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="inputs.passwordRequirements.required.lowercase"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of lowercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.uppercase"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of uppercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.digits"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of digits"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.symbols"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of symbols"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="inputs.passwordRequirements.allowedSymbols"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbols to use in password"- isError={Boolean(error)}- errorText={error?.message}- helperText="Default: -_.~!*"- >- <Input {...field} placeholder="-_.~!*" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save Changes- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretCassandraForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretCassandraForm.tsxdeleted file mode 100644index df9bc4b8d2..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretCassandraForm.tsx+++ /dev/null@@ -1,427 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- SecretInput,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z- .object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- keyspace: z.string().optional(),- localDataCenter: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretCassandraForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- },- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}"- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mb-4 border-b border-b-mineshaft-600 pb-2">Configuration</div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- defaultValue={9042}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- type="number"- onChange={(el) => field.onChange(parseInt(el.target.value, 10))}- />- </FormControl>- )}- />- </div>- <Controller- control={control}- name="inputs.localDataCenter"- defaultValue="datacenter1"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Local Data Center"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.keyspace"- defaultValue="default"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Keyspace"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div>- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA(SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Accordion type="multiple" className="w-full bg-mineshaft-700">- <AccordionItem value="modify-sql-statement">- <AccordionTrigger>Modify CQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.creationStatement"- defaultValue={- "CREATE ROLE '{{username}}' WITH PASSWORD '{{password}}' AND LOGIN=true;\nGRANT ALL PERMISSIONS ON ALL KEYSPACES TO '{{username}}';"- }- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="variables: keyspace. username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- defaultValue='DROP ROLE "{{username}}";'- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="variables: keyspace, username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.renewStatement"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="variables: keyspace, username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretClickHouseForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretClickHouseForm.tsxdeleted file mode 100644index 0eec6e8afa..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretClickHouseForm.tsx+++ /dev/null@@ -1,624 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- SecretInput,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import { OrgPermissionSubjects } from "@app/context";-import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--import { MetadataForm } from "../MetadataForm";--const passwordRequirementsSchema = z- .object({- length: z.number().min(1).max(250),- required: z- .object({- lowercase: z.number().min(0),- uppercase: z.number().min(0),- digits: z.number().min(0),- symbols: z.number().min(0)- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 250;- }, "Sum of required characters cannot exceed 250"),- allowedSymbols: z.string().optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const formSchema = z.object({- inputs: z- .object({- host: z.string().min(1),- port: z.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- passwordRequirements: passwordRequirementsSchema.optional(),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- ca: z.string().optional(),- gatewayId: z.string().optional().nullable(),- gatewayPoolId: z.string().optional().nullable()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- metadata: z- .object({- key: z.string().trim().min(1),- value: z.string().trim().default("")- })- .array()- .optional(),- usernameTemplate: z.string().trim().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--const DEFAULT_PASSWORD_REQUIREMENTS = {- length: 48,- required: {- lowercase: 1,- uppercase: 1,- digits: 1,- symbols: 1- },- allowedSymbols: "-_.~!*"-};--export const EditDynamicSecretClickHouseForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- watch,- setValue,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- metadata: dynamicSecret.metadata,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"]),- passwordRequirements:- (dynamicSecret.inputs as TForm["inputs"])?.passwordRequirements ||- DEFAULT_PASSWORD_REQUIREMENTS- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();- const selectedGatewayId = watch("inputs.gatewayId");- const selectedGatewayPoolId = watch("inputs.gatewayPoolId");-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- metadata,- usernameTemplate- }: TForm) => {- if (updateDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs: {- ...inputs,- gatewayId: inputs.gatewayId ?? null,- gatewayPoolId: inputs.gatewayPoolId ?? null- },- newName: newName === dynamicSecret.name ? undefined : newName,- metadata,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <MetadataForm control={control} />- <div>- <div className="mb-4 border-b border-b-mineshaft-600 pb-2">Configuration</div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: selectedGatewayId ?? null,- gatewayPoolId: selectedGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("inputs.gatewayId", newGwId ?? null, { shouldDirty: true });- setValue("inputs.gatewayPoolId", newPoolId ?? null, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="https://your-host.clickhouse.cloud" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- defaultValue={8123}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- type="number"- onChange={(el) => field.onChange(parseInt(el.target.value, 10))}- />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.database"- defaultValue="default"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database Name"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div>- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL) - optionally needed for self-signed certificates"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advanced">- <AccordionTrigger>- Creation, Revocation & Renew Statements (optional)- </AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <div className="mb-4 text-sm text-mineshaft-300">- Customize ClickHouse statements for managing database user lifecycle- </div>- <Controller- control={control}- name="inputs.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>Password Configuration (optional)</AccordionTrigger>- <AccordionContent>- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated database password- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="inputs.passwordRequirements.length"- defaultValue={48}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={1}- max={250}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("inputs.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("inputs.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="inputs.passwordRequirements.required.lowercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of lowercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.uppercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of uppercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.digits"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of digits"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.symbols"- defaultValue={0}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of symbols"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="inputs.passwordRequirements.allowedSymbols"- defaultValue="-_.~!*"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbols to use in password"- isError={Boolean(error)}- errorText={error?.message}- helperText="Default: -_.~!*"- >- <Input {...field} placeholder="-_.~!*" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretCouchbaseForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretCouchbaseForm.tsxdeleted file mode 100644index de38358f33..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretCouchbaseForm.tsx+++ /dev/null@@ -1,922 +0,0 @@-/* eslint-disable jsx-a11y/label-has-associated-control */-import { Controller, useForm } from "react-hook-form";-import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FilterableSelect,- FormControl,- IconButton,- Input,- SecretInput,- Switch,- Tooltip-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--import { MetadataForm } from "../MetadataForm";--const BucketScopesConfiguration = ({- control,- bucketIndex,- bucketsValue,- setValue,- addScope,- removeScope,- addCollection,- removeCollection-}: {- control: any;- bucketIndex: number;- bucketsValue: any;- setValue: any;- addScope: (bucketIndex: number) => void;- removeScope: (bucketIndex: number, scopeIndex: number) => void;- addCollection: (bucketIndex: number, scopeIndex: number) => void;- removeCollection: (bucketIndex: number, scopeIndex: number, collectionIndex: number) => void;-}) => {- const bucket = Array.isArray(bucketsValue) ? bucketsValue[bucketIndex] : null;- const scopeFields = bucket?.scopes || [];-- return (- <div className="space-y-3">- <div className="flex items-center justify-between">- <label className="text-sm font-medium text-mineshaft-300">Scopes</label>- <Button- type="button"- variant="outline_bg"- size="xs"- onClick={() => addScope(bucketIndex)}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add Scope- </Button>- </div>-- {scopeFields.map((_scope: any, scopeIndex: number) => (- <div- key={`scope-${scopeIndex + 1}`}- className="space-y-3 rounded-sm border border-mineshaft-600 bg-mineshaft-700 p-3"- >- <div className="flex items-center justify-between">- <h5 className="text-xs font-medium text-mineshaft-200">Scope {scopeIndex + 1}</h5>- <IconButton- type="button"- variant="plain"- ariaLabel="Remove scope"- size="sm"- onClick={() => removeScope(bucketIndex, scopeIndex)}- >- <FontAwesomeIcon icon={faTrash} className="text-red-400" />- </IconButton>- </div>-- <Controller- control={control}- name={`inputs.buckets.${bucketIndex}.scopes.${scopeIndex}.name`}- render={({ field, fieldState: { error } }) => (- <FormControl label="Scope Name" isError={Boolean(error)} errorText={error?.message}>- <Input {...field} placeholder="e.g., inventory, _default" className="text-sm" />- </FormControl>- )}- />-- <div className="space-y-2 pl-4">- <div className="flex items-center justify-between">- <label className="text-xs font-medium text-mineshaft-300">Collections</label>- <Button- type="button"- variant="outline_bg"- size="xs"- onClick={() => addCollection(bucketIndex, scopeIndex)}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add Collection- </Button>- </div>-- {scopeFields[scopeIndex]?.collections?.map(- (collection: string, collectionIndex: number) => (- <div- // eslint-disable-next-line react/no-array-index-key- key={`collection-${bucketIndex}-${scopeIndex}-${collectionIndex}`}- className="flex items-center space-x-2"- >- <FormControl className="flex-1">- <Input- value={collection || ""}- onChange={(e) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]?.scopes?.[scopeIndex]?.collections) {- currentBuckets[bucketIndex].scopes[scopeIndex].collections[- collectionIndex- ] = e.target.value;- setValue("inputs.buckets", currentBuckets);- }- }}- placeholder="e.g., airport, airline"- className="text-sm"- />- </FormControl>- <IconButton- type="button"- variant="plain"- ariaLabel="Remove collection"- size="sm"- onClick={() => removeCollection(bucketIndex, scopeIndex, collectionIndex)}- >- <FontAwesomeIcon icon={faTrash} className="mb-4 text-red-400" />- </IconButton>- </div>- )- )}-- {(!scopeFields[scopeIndex]?.collections ||- scopeFields[scopeIndex].collections.length === 0) && (- <div className="text-xs text-mineshaft-400 italic">- No collections specified (access to all collections in scope)- </div>- )}- </div>- </div>- ))}-- {scopeFields.length === 0 && (- <div className="rounded-sm border border-dashed border-mineshaft-600 bg-mineshaft-700 p-4 text-center">- <p className="mb-2 text-xs text-mineshaft-400">- No scopes configured (access to all scopes in bucket)- </p>- <Button- type="button"- variant="outline_bg"- size="xs"- onClick={() => addScope(bucketIndex)}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add Scope- </Button>- </div>- )}- </div>- );-};--const couchbaseRoles = [- { value: "read", label: "Read", description: "Read-only access to bucket data" },- {- value: "write",- label: "Write",- description: "Full write access to bucket data"- }-];--const passwordRequirementsSchema = z- .object({- length: z.number().min(8, "Password must be at least 8 characters").max(128),- required: z- .object({- lowercase: z.number().min(1, "At least 1 lowercase character required"),- uppercase: z.number().min(1, "At least 1 uppercase character required"),- digits: z.number().min(1, "At least 1 digit required"),- symbols: z.number().min(1, "At least 1 special character required")- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 128;- }, "Sum of required characters cannot exceed 128"),- allowedSymbols: z- .string()- .refine((symbols) => {- const forbiddenChars = ["<", ">", ";", ".", "*", "&", "|", "�"];- return !forbiddenChars.some((char) => symbols?.includes(char));- }, "Cannot contain: < > ; . * &")- .optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const bucketSchema = z.object({- name: z.string().trim().min(1, "Bucket name is required"),- scopes: z- .array(- z.object({- name: z.string().trim().min(1, "Scope name is required"),- collections: z.array(z.string().trim().min(1)).optional()- })- )- .optional()-});--const formSchema = z.object({- inputs: z- .object({- url: z.string().url().min(1),- orgId: z.string().min(1),- projectId: z.string().min(1),- clusterId: z.string().min(1),- roles: z.array(z.string()).min(1),- buckets: z.union([z.string().trim().min(1), z.array(bucketSchema)]),- useAdvancedBuckets: z.boolean().default(false),- passwordRequirements: passwordRequirementsSchema.optional(),- auth: z.object({- apiKey: z.string().min(1)- })- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- metadata: z- .object({- key: z.string().trim().min(1),- value: z.string().trim().default("")- })- .array()- .optional(),- usernameTemplate: z.string().trim().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- projectSlug: string;- environment: string;-};--export const EditDynamicSecretCouchbaseForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL || undefined,- newName: dynamicSecret.name,- metadata: dynamicSecret.metadata,- usernameTemplate: dynamicSecret.usernameTemplate,- inputs: {- ...(dynamicSecret.inputs as any),- useAdvancedBuckets: Array.isArray((dynamicSecret.inputs as any)?.buckets)- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const isAdvancedMode = watch("inputs.useAdvancedBuckets");- const bucketsValue = watch("inputs.buckets");-- const addBucket = () => {- const currentBuckets = Array.isArray(bucketsValue) ? bucketsValue : [];- setValue("inputs.buckets", [...currentBuckets, { name: "", scopes: [] }]);- };-- const removeBucket = (index: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? bucketsValue : [];- const newBuckets = currentBuckets.filter((_, i) => i !== index);- setValue("inputs.buckets", newBuckets);- };-- const addScope = (bucketIndex: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]) {- const currentScopes = currentBuckets[bucketIndex].scopes || [];- currentBuckets[bucketIndex] = {- ...currentBuckets[bucketIndex],- scopes: [...currentScopes, { name: "", collections: [] }]- };- setValue("inputs.buckets", currentBuckets);- }- };-- const removeScope = (bucketIndex: number, scopeIndex: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]?.scopes) {- currentBuckets[bucketIndex].scopes = currentBuckets[bucketIndex].scopes.filter(- (_, i) => i !== scopeIndex- );- setValue("inputs.buckets", currentBuckets);- }- };-- const addCollection = (bucketIndex: number, scopeIndex: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]?.scopes?.[scopeIndex]) {- const currentCollections = currentBuckets[bucketIndex].scopes[scopeIndex].collections || [];- currentBuckets[bucketIndex].scopes[scopeIndex].collections = [...currentCollections, ""];- setValue("inputs.buckets", currentBuckets);- }- };-- const removeCollection = (bucketIndex: number, scopeIndex: number, collectionIndex: number) => {- const currentBuckets = Array.isArray(bucketsValue) ? [...bucketsValue] : [];- if (currentBuckets[bucketIndex]?.scopes?.[scopeIndex]?.collections) {- currentBuckets[bucketIndex].scopes[scopeIndex].collections = currentBuckets[- bucketIndex- ].scopes[scopeIndex].collections.filter((_, i) => i !== collectionIndex);- setValue("inputs.buckets", currentBuckets);- }- };-- const handleUpdateDynamicSecret = async ({- inputs,- newName,- defaultTTL,- maxTTL,- metadata,- usernameTemplate- }: TForm) => {- if (updateDynamicSecret.isPending) return;-- const transformedInputs = inputs- ? {- ...inputs,- buckets: inputs.useAdvancedBuckets ? inputs.buckets : (inputs.buckets as string)- }- : inputs;-- const finalInputs = transformedInputs- ? (() => {- const { useAdvancedBuckets, ...rest } = transformedInputs;- return rest;- })()- : transformedInputs;-- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- defaultTTL,- maxTTL: maxTTL || undefined,- newName: newName === dynamicSecret.name ? undefined : newName,- metadata,- usernameTemplate:- !usernameTemplate || usernameTemplate === "{{randomUsername}}"- ? undefined- : usernameTemplate,- inputs: finalInputs- }- });-- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });-- onClose();- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <MetadataForm control={control} />- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col space-y-4">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.url"- defaultValue="https://cloudapi.cloud.couchbase.com"- render={({ field, fieldState: { error } }) => (- <FormControl- label="URL"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="https://cloudapi.cloud.couchbase.com" {...field} />- </FormControl>- )}- />- </div>- <Controller- control={control}- name="inputs.orgId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Organization ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.projectId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Project ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.clusterId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster ID"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <Controller- control={control}- name="inputs.roles"- defaultValue={["read"]}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Roles"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Select one or more roles to assign to the user"- >- <FilterableSelect- isMulti- value={couchbaseRoles.filter((role) => value?.includes(role.value))}- onChange={(selectedRoles) => {- if (Array.isArray(selectedRoles)) {- onChange(selectedRoles.map((role: any) => role.value));- } else {- onChange([]);- }- }}- options={couchbaseRoles}- placeholder="Select roles..."- getOptionLabel={(option) => option.label}- getOptionValue={(option) => option.value}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.useAdvancedBuckets"- render={({ field: { value, onChange } }) => (- <FormControl- label="Advanced Bucket Configuration"- helperText="Enable to configure specific buckets, scopes and collections. When disabled, '*' grants access to all buckets, scopes, and collections."- >- <Switch- id="advanced-buckets-switch"- isChecked={value}- onCheckedChange={(checked) => {- onChange(checked);- const bucketsController = watch("inputs.buckets");- if (checked && typeof bucketsController === "string") {- setValue("inputs.buckets", []);- } else if (!checked && Array.isArray(bucketsController)) {- setValue("inputs.buckets", "*");- }- }}- />- </FormControl>- )}- />-- {!watch("inputs.useAdvancedBuckets") && (- <Controller- control={control}- name="inputs.buckets"- defaultValue="*"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Bucket Access"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Specify bucket names separated by commas (e.g., 'bucket1,bucket2') or use '*' for all buckets, scopes, and collections"- >- <Input- {...field}- value={typeof field.value === "string" ? field.value : "*"}- onChange={(e) => field.onChange(e.target.value)}- placeholder="* (all buckets, scopes & collections) or bucket1,bucket2,bucket3"- />- </FormControl>- )}- />- )}-- {isAdvancedMode && Array.isArray(bucketsValue) && (- <div className="space-y-4">- <div className="flex items-center justify-between">- <div>- <div className="text-sm font-medium text-mineshaft-200">- Advanced Bucket Configuration- </div>- <div className="text-sm text-mineshaft-400">- Configure specific buckets with their scopes and collections. Leave scopes- empty for access to all scopes in a bucket.- </div>- </div>- <Button- type="button"- variant="outline_bg"- size="sm"- onClick={addBucket}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add Bucket- </Button>- </div>-- <div className="space-y-4">- {Array.isArray(bucketsValue) &&- (bucketsValue as any[]).map((_, bucketIndex) => (- <div- key={`bucket-${bucketIndex + 1}`}- className="space-y-4 rounded-sm border border-mineshaft-600 bg-mineshaft-800 p-4"- >- <div className="flex items-center justify-between">- <h4 className="text-sm font-medium text-mineshaft-200">- Bucket {bucketIndex + 1}- </h4>- <IconButton- type="button"- variant="plain"- ariaLabel="Remove bucket"- onClick={() => removeBucket(bucketIndex)}- >- <FontAwesomeIcon icon={faTrash} className="text-red-400" />- </IconButton>- </div>-- <Controller- control={control}- name={`inputs.buckets.${bucketIndex}.name`}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Bucket Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="e.g., travel-sample" />- </FormControl>- )}- />-- <BucketScopesConfiguration- control={control}- bucketIndex={bucketIndex}- bucketsValue={bucketsValue}- setValue={setValue}- addScope={addScope}- removeScope={removeScope}- addCollection={addCollection}- removeCollection={removeCollection}- />- </div>- ))}-- {(!Array.isArray(bucketsValue) || bucketsValue.length === 0) && (- <div className="rounded-sm border border-dashed border-mineshaft-600 p-8 text-center">- <p className="mb-2 text-sm text-mineshaft-400">No buckets configured</p>- <Button- type="button"- variant="outline_bg"- size="sm"- onClick={addBucket}- leftIcon={<FontAwesomeIcon icon={faPlus} />}- >- Add First Bucket- </Button>- </div>- )}- </div>- </div>- )}- <Controller- name="inputs.auth.apiKey"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- className="w-full"- label="API Key"- >- <SecretInput- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- value={value}- valueAlwaysHidden- rows={1}- wrap="hard"- onChange={(e) => onChange(e.target.value)}- />- </FormControl>- )}- />- <Controller- control={control}- name="usernameTemplate"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || ""}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>- <div className="flex items-center space-x-2">- <span>Password Configuration (optional)</span>- <Tooltip content="Couchbase password requirements: minimum 8 characters, at least 1 uppercase, 1 lowercase, 1 digit, 1 special character. Cannot contain: < > ; . * & | �">- <div className="flex h-4 w-4 cursor-help items-center justify-center rounded-full bg-mineshaft-600 text-xs text-mineshaft-300">- ?- </div>- </Tooltip>- </div>- </AccordionTrigger>- <AccordionContent>- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated Couchbase user password (8-128 characters)- <br />- <span className="text-xs text-mineshaft-400">- Forbidden characters: < > ; . * & | �- </span>- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="inputs.passwordRequirements.length"- defaultValue={12}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={8}- max={128}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("inputs.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("inputs.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="inputs.passwordRequirements.required.lowercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Min lowercase letters (required: e1)"- >- <Input- type="number"- min={1}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.uppercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Min uppercase letters (required: e1)"- >- <Input- type="number"- min={1}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.digits"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Min digits (required: e1)"- >- <Input- type="number"- min={1}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.symbols"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Min special characters (required: e1)"- >- <Input- type="number"- min={1}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="inputs.passwordRequirements.allowedSymbols"- defaultValue="!@#$%^()_+-=[]{}:,?/~`"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Allowed Symbols"- isError={Boolean(error)}- errorText={error?.message}- helperText="Cannot contain: < > ; . * & | �"- >- <Input {...field} placeholder="!@#$%^()_+-=[]{}:,?/~`" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretElasticSearchForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretElasticSearchForm.tsxdeleted file mode 100644index a6d8b35a7f..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretElasticSearchForm.tsx+++ /dev/null@@ -1,477 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faPlus, faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Button,- FormControl,- FormLabel,- IconButton,- Input,- SecretInput,- Select,- SelectItem,- Switch,- Tooltip-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const authMethods = [- {- label: "Username/Password",- value: "user"- },- {- label: "API Key",- value: "api-key"- }-] as const;--const formSchema = z.object({- inputs: z.object({- host: z.string().trim().min(1),- port: z.coerce.number(),-- // two auth types "user, apikey"- auth: z.discriminatedUnion("type", [- z.object({- type: z.literal("user"),- username: z.string().trim(),- password: z.string().trim()- }),- z.object({- type: z.literal("api-key"),- apiKey: z.string().trim(),- apiKeyId: z.string().trim()- })- ]),-- roles: z.array(z.string().trim().min(1)).min(1, "At least one role is required"),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretElasticSearchForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- const selectedAuthType = watch("inputs.auth.type");- const selectedRoles = watch("inputs.roles");-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- defaultValue={443}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>-- <div className="flex w-full items-center gap-2">- <Controller- control={control}- name="inputs.auth.type"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Authentication Method"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => {- const authFields = [- "inputs.auth.username",- "inputs.auth.password",- "inputs.auth.apiKey",- "inputs.auth.apiKeyId"- ] as const;-- authFields.forEach((f) => {- setValue(f, "");- });-- field.onChange(e);- }}- >- {authMethods.map((authType) => (- <SelectItem value={authType.value} key={`auth-method-${authType.value}`}>- {authType.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- <Controller- control={control}- name={- selectedAuthType === "user" ? "inputs.auth.username" : "inputs.auth.apiKeyId"- }- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label={selectedAuthType === "user" ? "Username" : "API Key ID"}- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name={selectedAuthType === "user" ? "inputs.auth.password" : "inputs.auth.apiKey"}- render={({ field, fieldState: { error } }) => (- <FormControl- label={selectedAuthType === "user" ? "Password" : "API Key"}- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>-- <div className="relative mb-3 flex flex-col">- <FormLabel- label="Roles"- tooltipText={- <div className="space-y-4">- <p>Select which role(s) to assign the users provisioned by Infisical.</p>- <p>- There is a wide range of in-built roles in Elastic Search. Some include,- superuser, apm_user, kibana_admin, monitoring_user, and many more. You can{" "}- <a- href="https://www.elastic.co/guide/en/elasticsearch/reference/current/built-in-roles.html"- target="_blank"- rel="noopener noreferrer"- >- <span className="cursor-pointer text-primary-400">- read more about roles here- </span>- </a>- .- </p>- <p>- You can also assign custom roles by providing the name of the custom role in- the input field.- </p>- </div>- }- />- {selectedRoles.map((_, i) => (- <Controller- control={control}- name={`inputs.roles.${i}`}- // eslint-disable-next-line react/no-array-index-key- key={`role-${i}`}- render={({ field, fieldState: { error } }) => (- <div className="flex items-center gap-2">- <div className="grow">- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Input- placeholder="Insert role name, (superuser, kibana_admin, custom_role)"- className="mb-0 grow"- {...field}- />- </FormControl>- </div>-- <IconButton- isDisabled={selectedRoles.length === 1}- ariaLabel="delete key"- className="bottom-2 h-9"- variant="outline_bg"- onClick={() => {- if (selectedRoles && selectedRoles?.length > 1) {- setValue(- "inputs.roles",- selectedRoles.filter((__, idx) => idx !== i)- );- }- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- )}- />- ))}-- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- className="bottom-2"- variant="outline_bg"- onClick={() => {- setValue("inputs.roles", [...selectedRoles, ""]);- }}- >- Add Role- </Button>- </div>- </div>- <div>- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGcpIamForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGcpIamForm.tsxdeleted file mode 100644index 58e0947fc0..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGcpIamForm.tsx+++ /dev/null@@ -1,263 +0,0 @@-import { Controller, useFieldArray, useForm } from "react-hook-form";-import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { Button, FormControl, IconButton, Input } from "@app/components/v2";-import { useOrganization } from "@app/context";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";--const validateTTL = (val: string, ctx: z.RefinementCtx) => {- if (!val) return;- const valMs = ms(val);- if (valMs === undefined) {- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid TTL format" });- return;- }- if (valMs < 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1 second" });- if (valMs > 60 * 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 1 hour" });-};--const formSchema = z- .object({- inputs: z.object({- serviceAccountEmail: z.string().email().trim().min(1, "Service account email required"),- tokenScopes: z- .array(z.object({ value: z.string().trim().min(1, "Scope is required") }))- .min(1, "At least one scope is required")- }),- defaultTTL: z.string().superRefine(validateTTL),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (val) validateTTL(val, ctx);- }),- newName: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase")- })- .refine((d) => !d.maxTTL || ms(d.maxTTL)! >= ms(d.defaultTTL)!, {- path: ["maxTTL"],- message: "Max TTL must be greater than or equal to Default TTL"- });-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};-export const EditDynamicSecretGcpIamForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const { currentOrg } = useOrganization();- const expectedAccountIdSuffix = currentOrg.id.split("-").slice(0, 2).join("-");-- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- inputs: {- serviceAccountEmail: (dynamicSecret.inputs as { serviceAccountEmail: string })- .serviceAccountEmail,- tokenScopes: (- (dynamicSecret.inputs as { tokenScopes?: string[] }).tokenScopes ?? [- "https://www.googleapis.com/auth/iam",- "https://www.googleapis.com/auth/cloud-platform"- ]- ).map((value) => ({ value }))- }- }- });-- const { fields, append, remove } = useFieldArray({- control,- name: "inputs.tokenScopes"- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newName }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs: {- ...inputs,- tokenScopes: [...new Set(inputs.tokenScopes.map((scope) => scope.value))]- },- newName: newName === dynamicSecret.name ? undefined : newName- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>-- <Controller- control={control}- name="inputs.serviceAccountEmail"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Service Account Email"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- tooltipText={`The service account ID (the part of the email before "@") must end with the first two sections of your organization ID: "${expectedAccountIdSuffix}". Example: my-service-account-${expectedAccountIdSuffix}@my-project.iam.gserviceaccount.com`}- >- <Input {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.tokenScopes"- render={({ fieldState: { error } }) => (- <FormControl- label="Token Scopes"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <div className="flex flex-col space-y-2">- {fields.map((field, index) => (- <div key={field.id} className="flex items-end space-x-2">- <div className="grow">- <Controller- control={control}- name={`inputs.tokenScopes.${index}.value`}- render={({ field: itemField, fieldState: { error: itemError } }) => (- <FormControl- isError={Boolean(itemError?.message)}- errorText={itemError?.message}- className="mb-0 grow"- >- <Input- {...itemField}- placeholder="https://www.googleapis.com/auth/cloud-platform"- />- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="Remove scope"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => remove(index)}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() => append({ value: "" })}- type="button"- >- Add Scope- </Button>- </div>- </div>- </FormControl>- )}- />- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGithubForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGithubForm.tsxdeleted file mode 100644index b5539d85dc..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGithubForm.tsx+++ /dev/null@@ -1,192 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import { z } from "zod";--import { createNotification } from "@app/components/notifications";-import { Button, FormControl, FormLabel, Input, SecretInput, Tooltip } from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";--const formSchema = z.object({- inputs: z.object({- appId: z.coerce.number().min(1, "Required"),- installationId: z.coerce.number().min(1, "Required"),- privateKey: z- .string()- .trim()- .min(1, "Required")- .refine(- (val) =>- /^-----BEGIN(?:(?: RSA| PGP| ENCRYPTED)? PRIVATE KEY)-----\s*[\s\S]*?-----END(?:(?: RSA| PGP| ENCRYPTED)? PRIVATE KEY)-----$/.test(- val- ),- "Invalid PEM format for private key"- )- }),- newName: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase")-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};-export const EditDynamicSecretGithubForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- newName: dynamicSecret.name,- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({ inputs, newName }: TForm) => {- if (updateDynamicSecret.isPending) return;- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- inputs,- newName: newName === dynamicSecret.name ? undefined : newName- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <FormControl- label={- <FormLabel- label="Default TTL"- icon={- <Tooltip content="Github token TTL is fixed to 1 hour">- <FontAwesomeIcon- icon={faQuestionCircle}- size="sm"- className="relative right-1 bottom-px"- />- </Tooltip>- }- />- }- >- <Input disabled value="1h" className="pointer-events-none opacity-50" />- </FormControl>- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>-- <div className="flex flex-col">- <Controller- control={control}- name="inputs.appId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="App ID"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input placeholder="0000000" {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.installationId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Installation ID"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input placeholder="00000000" {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.privateKey"- render={({ field, fieldState: { error } }) => (- <FormControl- label="App Private Key PEM"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretIbmApiConnectForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretIbmApiConnectForm.tsxdeleted file mode 100644index a7bd20c666..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretIbmApiConnectForm.tsx+++ /dev/null@@ -1,510 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { SingleValue } from "react-select";-import {- faCheckCircle,- faCircleNotch,- faTriangleExclamation-} from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { OrgPermissionCan } from "@app/components/permissions";-import { Button, FilterableSelect, FormControl, Input, SecretInput } from "@app/components/v2";-import { Tooltip } from "@app/components/v2/Tooltip";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import {- OrgGatewayPermissionActions,- OrgPermissionSubjects-} from "@app/context/OrgPermissionContext/types";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import {- useGetIbmApiConnectOrgApps,- useGetIbmApiConnectOrgCatalogs,- useGetIbmApiConnectOrgs-} from "@app/hooks/api/dynamicSecret/queries";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";--const validateTTL = (val: string, ctx: z.RefinementCtx) => {- if (!val) return;- const valMs = ms(val);- if (valMs === undefined) {- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid TTL format" });- return;- }- if (valMs < 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1 second" });-};--const formSchema = z- .object({- inputs: z.object({- clientId: z.string().trim().min(1, "Client ID is required"),- clientSecret: z.string().trim().min(1, "Client Secret is required"),- instanceUrl: z.string().url("Must be a valid URL").trim().min(1, "Instance URL is required"),- apiKey: z.string().trim().min(1, "API Key is required"),- orgId: z.string().trim().min(1, "Organization is required"),- catalogId: z.string().trim().min(1, "Catalog is required"),- consumerOrgId: z.string().trim().min(1, "Consumer Organization is required"),- appId: z.string().trim().min(1, "Application is required"),- gatewayId: z.string().optional().nullable(),- gatewayPoolId: z.string().optional().nullable()- }),- defaultTTL: z.string().superRefine(validateTTL),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (val) validateTTL(val, ctx);- }),- newName: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase")- })- .refine((d) => !d.maxTTL || ms(d.maxTTL)! >= ms(d.defaultTTL)!, {- path: ["maxTTL"],- message: "Max TTL must be greater than or equal to Default TTL"- });-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretIbmApiConnectForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- watch,- setValue,- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const instanceUrl = watch("inputs.instanceUrl");- const apiKey = watch("inputs.apiKey");- const clientId = watch("inputs.clientId");- const clientSecret = watch("inputs.clientSecret");- const orgId = watch("inputs.orgId");- const catalogId = watch("inputs.catalogId");-- const credentialsComplete = !!(instanceUrl && apiKey && clientId && clientSecret);- const orgSelected = credentialsComplete && !!orgId;- const catalogSelected = orgSelected && !!catalogId;-- const {- data: orgs,- isFetching: isOrgsFetching,- isError: isOrgsError- } = useGetIbmApiConnectOrgs({- instanceUrl: instanceUrl || "",- apiKey: apiKey || "",- clientId: clientId || "",- clientSecret: clientSecret || "",- projectSlug,- enabled: credentialsComplete- });-- const selectedOrg = orgs?.find((o) => o.id === orgId);-- const {- data: catalogs,- isFetching: isCatalogsFetching,- isError: isCatalogsError- } = useGetIbmApiConnectOrgCatalogs({- instanceUrl: instanceUrl || "",- apiKey: apiKey || "",- clientId: clientId || "",- clientSecret: clientSecret || "",- orgId: selectedOrg?.id || "",- projectSlug,- enabled: orgSelected- });-- const selectedCatalog = catalogs?.find((c) => c.id === catalogId);-- const {- data: apps,- isFetching: isAppsFetching,- isError: isAppsError- } = useGetIbmApiConnectOrgApps({- instanceUrl: instanceUrl || "",- apiKey: apiKey || "",- clientId: clientId || "",- clientSecret: clientSecret || "",- orgId: selectedOrg?.id || "",- catalogId: selectedCatalog?.id || "",- projectSlug,- enabled: catalogSelected- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newName }: TForm) => {- if (updateDynamicSecret.isPending) return;- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- const getOrgTooltipContent = () => {- if (!credentialsComplete) return "Fill in all credentials above first";- if (isOrgsError) return "Failed to load organizations — check your credentials";- return undefined;- };-- const getCatalogTooltipContent = () => {- if (!orgSelected) return "Select an organization first";- if (isCatalogsError) return "Failed to load catalogs";- return undefined;- };-- const getAppTooltipContent = () => {- if (!catalogSelected) return "Select a catalog first";- if (isAppsError) return "Failed to load applications";- return undefined;- };-- const getStatusIndicator = (isComplete: boolean, isFetching: boolean, isError: boolean) => {- if (!isComplete) return null;- if (isFetching)- return <FontAwesomeIcon icon={faCircleNotch} className="animate-spin text-primary" />;- if (isError) return <FontAwesomeIcon icon={faTriangleExclamation} className="text-red-500" />;- return <FontAwesomeIcon icon={faCheckCircle} className="text-green-500" />;- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>-- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: watch("inputs.gatewayId") ?? null,- gatewayPoolId: watch("inputs.gatewayPoolId") ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("inputs.gatewayId", newGwId ?? undefined, {- shouldDirty: true- });- setValue("inputs.gatewayPoolId", newPoolId ?? undefined, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>-- <div className="flex flex-col">- <Controller- control={control}- name="inputs.instanceUrl"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Instance URL"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input- placeholder="https://platform-api.trial.apiconnect.automation.ibm.com"- {...field}- />- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.apiKey"- render={({ field, fieldState: { error } }) => (- <FormControl- label="API Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.clientId"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client ID"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input {...field} />- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.clientSecret"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client Secret"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />- </div>-- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- <div className="flex items-center space-x-2">- <span>Organization, Catalog & Application</span>- {getStatusIndicator(credentialsComplete, isOrgsFetching, isOrgsError)}- </div>- </div>-- <Controller- control={control}- name="inputs.orgId"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Organization"- isError={Boolean(error)}- errorText={error?.message}- isRequired- >- <Tooltip- content={getOrgTooltipContent()}- isDisabled={credentialsComplete && !isOrgsError}- >- <div>- <FilterableSelect- isDisabled={!credentialsComplete || isOrgsFetching || isOrgsError}- isLoading={isOrgsFetching}- options={orgs ?? []}- value={orgs?.find((o) => o.id === value) ?? null}- onChange={(opt) => {- const option = opt as SingleValue<NonNullable<typeof orgs>[number]>;- onChange(option?.id ?? "");- setValue("inputs.catalogId", "");- setValue("inputs.consumerOrgId", "");- setValue("inputs.appId", "");- }}- placeholder="Select an organization..."- getOptionLabel={(option) => option.title || option.name}- getOptionValue={(option) => option.id}- />- </div>- </Tooltip>- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.catalogId"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label={- <div className="flex items-center space-x-2">- <span>Catalog</span>- {getStatusIndicator(orgSelected, isCatalogsFetching, isCatalogsError)}- </div>- }- isError={Boolean(error)}- errorText={error?.message}- isRequired- >- <Tooltip- content={getCatalogTooltipContent()}- isDisabled={orgSelected && !isCatalogsError}- >- <div>- <FilterableSelect- isDisabled={!orgSelected || isCatalogsFetching || isCatalogsError}- isLoading={isCatalogsFetching}- options={catalogs ?? []}- value={catalogs?.find((c) => c.id === value) ?? null}- onChange={(opt) => {- const option = opt as SingleValue<NonNullable<typeof catalogs>[number]>;- onChange(option?.id ?? "");- setValue("inputs.consumerOrgId", "");- setValue("inputs.appId", "");- }}- placeholder="Select a catalog..."- getOptionLabel={(option) => option.title || option.name}- getOptionValue={(option) => option.id}- />- </div>- </Tooltip>- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.appId"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label={- <div className="flex items-center space-x-2">- <span>Application</span>- {getStatusIndicator(catalogSelected, isAppsFetching, isAppsError)}- </div>- }- isError={Boolean(error)}- errorText={error?.message}- isRequired- >- <Tooltip- content={getAppTooltipContent()}- isDisabled={catalogSelected && !isAppsError}- >- <div>- <FilterableSelect- isDisabled={!catalogSelected || isAppsFetching || isAppsError}- isLoading={isAppsFetching}- options={apps ?? []}- value={apps?.find((a) => a.id === value) ?? null}- onChange={(opt) => {- const option = opt as SingleValue<NonNullable<typeof apps>[number]>;- onChange(option?.id ?? "");- setValue("inputs.consumerOrgId", option?.consumerOrgId ?? "");- }}- placeholder="Select an application..."- getOptionLabel={(option) => option.title || option.name}- getOptionValue={(option) => option.id}- />- </div>- </Tooltip>- </FormControl>- )}- />- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretKubernetesForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretKubernetesForm.tsxdeleted file mode 100644index 1139122542..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretKubernetesForm.tsx+++ /dev/null@@ -1,651 +0,0 @@-import { Controller, FieldValues, useFieldArray, useForm } from "react-hook-form";-import { faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Button,- FormControl,- IconButton,- Input,- Select,- SelectItem,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import { OrgPermissionSubjects } from "@app/context/OrgPermissionContext";-import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import {- KubernetesDynamicSecretCredentialType,- TDynamicSecret-} from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--enum RoleType {- ClusterRole = "cluster-role",- Role = "role"-}--enum AuthMethod {- Api = "api",- Gateway = "gateway"-}--const credentialTypes = [- {- label: "Static",- value: KubernetesDynamicSecretCredentialType.Static- },- {- label: "Dynamic",- value: KubernetesDynamicSecretCredentialType.Dynamic- }-] as const;--const formSchema = z- .object({- inputs: z.discriminatedUnion("credentialType", [- z.object({- url: z.string().trim().optional(),- clusterToken: z.string().trim().optional(),- ca: z.string().optional(),- sslEnabled: z.boolean().default(false),- sslRejectUnauthorized: z.boolean().optional(),- credentialType: z.literal(KubernetesDynamicSecretCredentialType.Static),- serviceAccountName: z.string().trim().min(1),- namespace: z- .string()- .trim()- .min(1)- .refine(- (val) => !val.includes(","),- "Namespace must be a single value, not a comma-separated list"- ),- gatewayId: z.string().optional().nullable(),- gatewayPoolId: z.string().optional().nullable(),- audiences: z.array(z.string().trim().min(1)),- authMethod: z.nativeEnum(AuthMethod).default(AuthMethod.Api)- }),- z.object({- url: z.string().trim().optional(),- clusterToken: z.string().trim().optional(),- ca: z.string().optional(),- sslEnabled: z.boolean().default(false),- sslRejectUnauthorized: z.boolean().optional(),- credentialType: z.literal(KubernetesDynamicSecretCredentialType.Dynamic),- namespace: z- .string()- .trim()- .min(1)- .refine((val) => {- const namespaces = val.split(",").map((ns) => ns.trim());- return namespaces.length > 0 && namespaces.every((ns) => ns.length > 0);- }, "Must be a valid comma-separated list of namespace values"),- gatewayId: z.string().optional().nullable(),- gatewayPoolId: z.string().optional().nullable(),- audiences: z.array(z.string().trim().min(1)),- roleType: z.nativeEnum(RoleType),- role: z.string().trim().min(1),- authMethod: z.nativeEnum(AuthMethod).default(AuthMethod.Api)- })- ]),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().optional()- })- .superRefine((data, ctx) => {- if (- data.inputs.authMethod === AuthMethod.Gateway &&- !data.inputs.gatewayId &&- !data.inputs.gatewayPoolId- ) {- ctx.addIssue({- path: ["inputs.gatewayId"],- code: z.ZodIssueCode.custom,- message: "When auth method is set to Gateway, a gateway or gateway pool must be selected"- });- }- if (data.inputs.authMethod === AuthMethod.Api) {- if (!data.inputs.clusterToken) {- ctx.addIssue({- path: ["inputs.clusterToken"],- code: z.ZodIssueCode.custom,- message: "When auth method is set to Token, a cluster token must be provided"- });- }- if (!data.inputs.url) {- ctx.addIssue({- path: ["inputs.url"],- code: z.ZodIssueCode.custom,- message: "When auth method is set to Token, a cluster URL must be provided"- });- }- }- });--type TForm = z.infer<typeof formSchema> & FieldValues;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- projectSlug: string;- environment: string;-};--export const EditDynamicSecretKubernetesForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- newName: dynamicSecret.name,- defaultTTL: dynamicSecret.defaultTTL,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- maxTTL: dynamicSecret.maxTTL,- inputs: dynamicSecret.inputs as TForm["inputs"]- }- });-- const { fields, append, remove } = useFieldArray({- control,- name: "inputs.audiences"- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const sslEnabled = watch("inputs.sslEnabled");- const credentialType = watch("inputs.credentialType");- const authMethod = watch("inputs.authMethod");- const inputsGatewayId = watch("inputs.gatewayId");- const inputsGatewayPoolId = watch("inputs.gatewayPoolId");-- const handleUpdateDynamicSecret = async (formData: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = formData.usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- inputs: {- ...formData.inputs,- url: formData.inputs.url || undefined- },- newName: formData.newName === dynamicSecret.name ? undefined : formData.newName,- defaultTTL: formData.defaultTTL,- maxTTL: formData.maxTTL,- usernameTemplate:- !formData.usernameTemplate || isDefaultUsernameTemplate ? null : formData.usernameTemplate- }- });-- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <div className="grow">- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: inputsGatewayId ?? null,- gatewayPoolId: inputsGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("inputs.gatewayId", newGwId ?? null, {- shouldDirty: true- });- setValue("inputs.gatewayPoolId", newPoolId ?? null, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <Controller- control={control}- name="inputs.authMethod"- defaultValue={AuthMethod.Api}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Auth Method"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- tooltipText="Select the method of authentication. Token (API) uses a direct API token, while Gateway uses the service account of a Gateway deployed in a Kubernetes cluster to generate the service account token."- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => field.onChange(e)}- >- <SelectItem value={AuthMethod.Api}>Token (API)</SelectItem>- <SelectItem value={AuthMethod.Gateway}>Gateway</SelectItem>- </Select>- </FormControl>- )}- />- {authMethod === AuthMethod.Api && (- <>- <Controller- control={control}- name="inputs.url"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster URL"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />-- <div className="mb-2 flex items-center">- <span className="mr-3 flex items-center text-sm text-mineshaft-400">- Enable SSL- <Tooltip- className="ml-1 max-w-md"- content={- <span>- If enabled, you can optionally provide a custom CA certificate.- Leave blank to use the system/public CA.- </span>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </span>- <Controller- name="inputs.sslEnabled"- control={control}- render={({ field: { value, onChange } }) => (- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-enabled"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- aria-label="Enable SSL"- />- )}- />- </div>-- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- label="CA"- isError={Boolean(error?.message)}- errorText={error?.message}- className={sslEnabled ? "" : "opacity-50"}- >- <TextArea- {...field}- placeholder="-----BEGIN CERTIFICATE----- ..."- isDisabled={!sslEnabled}- />- </FormControl>- )}- />- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against- the list of supplied CAs. Disable this option if you are using- a self-signed certificate.- </p>- }- >- <FontAwesomeIcon- icon={faQuestionCircle}- size="sm"- className="ml-1"- />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- </>- )}- {authMethod === AuthMethod.Api && (- <Controller- control={control}- name="inputs.clusterToken"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Cluster Token"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- )}- <Controller- control={control}- name="inputs.credentialType"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Credential Type"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- tooltipText="Choose 'Static' to generate service account tokens for a predefined service account. Choose 'Dynamic' to create a temporary service account, assign it to a defined role/cluster-role, and generate the service account token. Only 'Dynamic' supports role assignment."- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => field.onChange(e)}- >- {credentialTypes.map((ct) => (- <SelectItem value={ct.value} key={`credential-type-${ct.value}`}>- {ct.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- <div className="flex items-center space-x-2">- {credentialType === KubernetesDynamicSecretCredentialType.Static && (- <div className="flex-1">- <Controller- control={control}- name="inputs.serviceAccountName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Service Account Name"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="new-password" />- </FormControl>- )}- />- </div>- )}- {credentialType === KubernetesDynamicSecretCredentialType.Dynamic && (- <div className="flex-1">- <Controller- control={control}- name="usernameTemplate"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </div>- )}- <div className="flex-1">- <Controller- control={control}- name="inputs.namespace"- render={({ field, fieldState: { error } }) => (- <FormControl- label={- credentialType === KubernetesDynamicSecretCredentialType.Static- ? "Namespace"- : "Allowed Namespace(s)"- }- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- {credentialType === KubernetesDynamicSecretCredentialType.Dynamic && (- <div className="flex items-center space-x-2">- <div className="flex-1">- <Controller- control={control}- name="inputs.roleType"- defaultValue={RoleType.ClusterRole}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Role Type"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => field.onChange(e)}- >- <SelectItem- value={RoleType.ClusterRole}- key={`role-type-${RoleType.ClusterRole}`}- >- Cluster Role- </SelectItem>- <SelectItem- value={RoleType.Role}- key={`role-type-${RoleType.Role}`}- >- Role- </SelectItem>- </Select>- </FormControl>- )}- />- </div>- <div className="flex-1">- <Controller- control={control}- name="inputs.role"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Role"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- )}- </div>- </div>- <div className="mt-2 w-1/2">- <Controller- control={control}- name="inputs.audiences"- render={({ fieldState: { error } }) => (- <FormControl- label="Audiences"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <div className="space-y-2">- {fields.map((field, index) => (- <div key={field.id} className="flex items-center space-x-2">- <Input- {...control.register(`inputs.audiences.${index}`)}- placeholder="Enter audience"- className="grow"- />- <IconButton- onClick={() => remove(index)}- variant="outline_bg"- ariaLabel="Remove audience"- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <Button variant="outline_bg" onClick={() => append("")} type="button">- Add Audience- </Button>- </div>- </FormControl>- )}- />- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretLdapForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretLdapForm.tsxdeleted file mode 100644index 361c6db918..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretLdapForm.tsx+++ /dev/null@@ -1,406 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Button,- FormControl,- Input,- Select,- SelectItem,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--enum CredentialType {- Dynamic = "dynamic",- Static = "static"-}--const credentialTypes = [- {- label: "Dynamic",- value: CredentialType.Dynamic- },- {- label: "Static",- value: CredentialType.Static- }-] as const;--const formSchema = z.object({- inputs: z.discriminatedUnion("credentialType", [- z.object({- url: z.string().trim().min(1),- binddn: z.string().trim().min(1),- bindpass: z.string().trim().min(1),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional(),- credentialType: z.literal(CredentialType.Dynamic),- creationLdif: z.string().min(1),- revocationLdif: z.string().min(1),- rollbackLdif: z.string().optional()- }),- z.object({- url: z.string().trim().min(1),- binddn: z.string().trim().min(1),- bindpass: z.string().trim().min(1),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional(),- credentialType: z.literal(CredentialType.Static),- rotationLdif: z.string().min(1)- })- ]),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretLdapForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- watch,- setValue- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();- const selectedCredentialType = watch("inputs.credentialType");-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div className="mt-4">- <Controller- control={control}- name="inputs.url"- render={({ field, fieldState: { error } }) => (- <FormControl label="URL" isError={Boolean(error)} errorText={error?.message}>- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.binddn"- render={({ field, fieldState: { error } }) => (- <FormControl label="Bind DN" isError={Boolean(error)} errorText={error?.message}>- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.bindpass"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Bind Password"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} type="password" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl label="CA" isError={Boolean(error)} errorText={error?.message}>- <TextArea {...field} />- </FormControl>- )}- />- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list of- supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Controller- control={control}- name="inputs.credentialType"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Credential Type"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(e) => {- const ldifFields = [- "inputs.creationLdif",- "inputs.revocationLdif",- "inputs.rollbackLdif",- "inputs.rotationLdif"- ] as const;-- ldifFields.forEach((f) => {- setValue(f, "");- });-- field.onChange(e);- }}- >- {credentialTypes.map((credentialType) => (- <SelectItem- value={credentialType.value}- key={`credential-type-${credentialType.value}`}- >- {credentialType.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- {selectedCredentialType === CredentialType.Dynamic && (- <>- <Controller- control={control}- name="inputs.creationLdif"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation LDIF"- isError={Boolean(error)}- errorText={error?.message}- >- <TextArea {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationLdif"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation LDIF"- isError={Boolean(error)}- errorText={error?.message}- >- <TextArea {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.rollbackLdif"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Rollback LDIF"- isError={Boolean(error)}- errorText={error?.message}- >- <TextArea {...field} />- </FormControl>- )}- />- </>- )}- {selectedCredentialType === CredentialType.Static && (- <Controller- control={control}- name="inputs.rotationLdif"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Rotation LDIF"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea {...field} />- </FormControl>- )}- />- )}- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMilvusForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMilvusForm.tsxdeleted file mode 100644index 54fa592394..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMilvusForm.tsx+++ /dev/null@@ -1,564 +0,0 @@-import { Controller, useFieldArray, useForm } from "react-hook-form";-import { faPlus, faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Button,- FormControl,- FormLabel,- IconButton,- Input,- Select,- SelectItem,- Switch,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import {- OrgGatewayPermissionActions,- OrgPermissionSubjects-} from "@app/context/OrgPermissionContext/types";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import {- DynamicSecretProviders,- MILVUS_OBJECT_TYPES,- TDynamicSecret,- TDynamicSecretProvider-} from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--import { MetadataForm } from "../MetadataForm";--type MilvusInputs = Extract<- TDynamicSecretProvider,- { type: DynamicSecretProviders.Milvus }->["inputs"];--const formSchema = z.object({- inputs: z- .object({- host: z.string().trim().min(1),- port: z.coerce.number(),- username: z.string().trim().min(1),- password: z.string().trim().min(1),- database: z.string().trim().min(1).default("default"),- privileges: z- .array(- z.object({- objectType: z.string().trim().min(1),- objectName: z.string().trim().min(1).default("*"),- privilege: z.string().trim().min(1),- dbName: z- .string()- .trim()- .optional()- .transform((val) => (val && val.length > 0 ? val : undefined))- })- )- .default([]),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional(),- gatewayId: z.string().optional().nullable(),- gatewayPoolId: z.string().optional().nullable()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- metadata: z- .object({- key: z.string().trim().min(1),- value: z.string().trim().default("")- })- .array()- .optional(),- usernameTemplate: z.string().trim().nullable().optional()-});--type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- projectSlug: string;- environment: string;-};--export const EditDynamicSecretMilvusForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- defaultValues: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL || undefined,- newName: dynamicSecret.name,- metadata: dynamicSecret.metadata,- usernameTemplate: dynamicSecret.usernameTemplate,- inputs: {- ...(dynamicSecret.inputs as MilvusInputs),- privileges: (dynamicSecret.inputs as MilvusInputs)?.privileges ?? []- }- }- });-- const privilegeFields = useFieldArray({- control,- name: "inputs.privileges"- });-- const selectedGatewayId = watch("inputs.gatewayId");- const selectedGatewayPoolId = watch("inputs.gatewayPoolId");-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- newName,- defaultTTL,- maxTTL,- metadata,- usernameTemplate- }: TForm) => {- if (updateDynamicSecret.isPending) return;-- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- defaultTTL,- maxTTL: maxTTL || undefined,- newName: newName === dynamicSecret.name ? undefined : newName,- metadata,- usernameTemplate:- !usernameTemplate || usernameTemplate === "{{randomUsername}}"- ? undefined- : usernameTemplate,- inputs: {- ...inputs,- gatewayId: inputs.gatewayId ?? null,- gatewayPoolId: inputs.gatewayPoolId ?? null- }- }- });-- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });-- onClose();- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <MetadataForm control={control} />- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: selectedGatewayId ?? null,- gatewayPoolId: selectedGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("inputs.gatewayId", newGwId ?? null, {- shouldDirty: true- });- setValue("inputs.gatewayPoolId", newPoolId ?? null, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col space-y-4">- <div className="flex items-start space-x-2">- <Controller- control={control}- name="inputs.host"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Optional URL scheme. Defaults to https when a CA is provided, otherwise http."- >- <Input {...field} placeholder="http://localhost" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- className="w-32"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" placeholder="19530" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.username"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <Controller- control={control}- name="inputs.database"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Default Database"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Used as the dbName for granted privileges when not explicitly overridden."- >- <Input {...field} placeholder="default" />- </FormControl>- )}- />- <FormLabel- label="Privileges"- isOptional- className="mb-2"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText={- "Privileges granted to an ephemeral role assigned to the lease user. " +- "Leave empty to create a user with only the built-in public role."- }- />- <div className="mb-3 flex flex-col space-y-2">- {privilegeFields.fields.map(({ id: privilegeFieldId }, i) => (- <div key={privilegeFieldId} className="flex items-end space-x-2">- <div className="w-36">- {i === 0 && <span className="text-xs text-mineshaft-400">Object Type</span>}- <Controller- control={control}- name={`inputs.privileges.${i}.objectType`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Select- value={field.value}- onValueChange={(value) => field.onChange(value)}- className="w-full"- >- {MILVUS_OBJECT_TYPES.map((option) => (- <SelectItem- value={option.value}- key={`milvus-edit-object-type-${option.value}`}- >- {option.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && <span className="text-xs text-mineshaft-400">Object Name</span>}- <Controller- control={control}- name={`inputs.privileges.${i}.objectName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input {...field} placeholder="*" />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && <span className="text-xs text-mineshaft-400">Privilege</span>}- <Controller- control={control}- name={`inputs.privileges.${i}.privilege`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input {...field} placeholder="Search" />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && (- <FormLabel- label="DB Name"- isOptional- className="text-xs text-mineshaft-400"- />- )}- <Controller- control={control}- name={`inputs.privileges.${i}.dbName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input- value={field.value || ""}- onChange={(e) => field.onChange(e.target.value)}- placeholder="default"- />- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="Remove privilege"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => privilegeFields.remove(i)}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- type="button"- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() =>- privilegeFields.append({- objectType: "Collection",- objectName: "*",- privilege: "",- dbName: undefined- })- }- >- Add Privilege- </Button>- </div>- </div>- <Controller- control={control}- name="usernameTemplate"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Milvus usernames are limited to 32 characters. Longer template output is truncated automatically."- >- <Input- {...field}- value={field.value || ""}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- placeholder="{{randomUsername}}"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- label="CA Certificate"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="PEM-encoded CA certificate for verifying the Milvus server's TLS certificate."- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.sslRejectUnauthorized"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="milvus-edit-ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value ?? true}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMongoAtlasForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMongoAtlasForm.tsxdeleted file mode 100644index 905e006608..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMongoAtlasForm.tsx+++ /dev/null@@ -1,484 +0,0 @@-import { Controller, useFieldArray, useForm } from "react-hook-form";-import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- FormLabel,- IconButton,- Input,- Select,- SelectItem-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z- .object({- adminPublicKey: z.string().trim().min(1),- adminPrivateKey: z.string().trim().min(1),- groupId: z.string().trim().min(1),- roles: z- .object({- collectionName: z.string().optional(),- databaseName: z.string().min(1),- roleName: z.string().min(1)- })- .array()- .min(1),- scopes: z- .object({- name: z.string().min(1),- type: z.string().min(1)- })- .array()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--const ATLAS_SCOPE_TYPES = [- {- label: "Cluster",- value: "CLUSTER"- },- {- label: "Data Lake",- value: "DATA_LAKE"- },- {- label: "Stream",- value: "STREAM"- }-];--export const EditDynamicSecretMongoAtlasForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- getValues,- setValue,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const roleFields = useFieldArray({- control,- name: "inputs.roles"- });-- const scopeFields = useFieldArray({- control,- name: "inputs.scopes"- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.adminPublicKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Admin Public Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.adminPrivateKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Admin Private Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" />- </FormControl>- )}- />- </div>- <Controller- control={control}- name="inputs.groupId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Group/Project ID"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Unique 24-hexadecimal digit string that identifies your project"- >- <Input {...field} />- </FormControl>- )}- />- <FormLabel label="Roles" />- <div className="mb-3 flex flex-col space-y-2">- {roleFields.fields.map(({ id: roleFieldId }, i) => (- <div key={roleFieldId} className="flex items-end space-x-2">- <div className="grow">- {i === 0 && <span className="text-xs text-mineshaft-400">Database Name</span>}- <Controller- control={control}- name={`inputs.roles.${i}.databaseName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && (- <FormLabel- label="Collection Name"- className="text-xs text-mineshaft-400"- isOptional- />- )}- <Controller- control={control}- name={`inputs.roles.${i}.collectionName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0"- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && (- <FormLabel- label="Role"- className="text-xs text-mineshaft-400"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText={`Human-readable label that identifies a group of privileges assigned to a database user. This value can either be a built-in role or a custom role.- Built-in: atlasAdmin, backup, clusterMonitor, dbAdmin, dbAdminAnyDatabase, enableSharding, read, readAnyDatabase, readWrite, readWriteAnyDatabase.`}- />- )}- <Controller- control={control}- name={`inputs.roles.${i}.roleName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0 grow"- >- <Input {...field} />- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="delete key"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => {- const roles = getValues("inputs.roles");- if (roles && roles?.length > 1) {- roleFields.remove(i);- } else {- setValue("inputs.roles", [{ databaseName: "", roleName: "" }]);- }- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() => roleFields.append({ databaseName: "", roleName: "" })}- >- Add Role- </Button>- </div>- </div>- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-section">- <AccordionTrigger>Advanced</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <FormLabel- label="Scopes"- isOptional- className="mb-2"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText="List that contains clusters, MongoDB Atlas Data Lakes, and MongoDB Atlas Streams Instances that this database user can access. If omitted, MongoDB Cloud grants the database user access to all the clusters, MongoDB Atlas Data Lakes, and MongoDB Atlas Streams Instances in the project."- />- <div className="mb-2 flex flex-col space-y-2">- {scopeFields.fields.map(({ id: scopeFieldId }, i) => (- <div key={scopeFieldId} className="flex items-end space-x-2">- <div className="grow">- {i === 0 && (- <FormLabel- label="Label"- className="text-xs text-mineshaft-400"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText="Human-readable label that identifies the cluster or MongoDB Atlas Data Lake that this database user can access."- />- )}- <Controller- control={control}- name={`inputs.scopes.${i}.name`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0 grow"- >- <Input {...field} placeholder="Cluster or data lake id" />- </FormControl>- )}- />- </div>- <div className="grow">- {i === 0 && <span className="text-xs text-mineshaft-400">Type</span>}- <Controller- control={control}- name={`inputs.scopes.${i}.type`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0 grow"- >- <Select- defaultValue={field.value}- {...field}- onValueChange={(e) => field.onChange(e)}- className="w-full"- >- {ATLAS_SCOPE_TYPES.map((el) => (- <SelectItem value={el.value} key={`atlas-scope-${el.value}`}>- {el.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="delete key"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => {- scopeFields.remove(i);- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() =>- scopeFields.append({ name: "", type: ATLAS_SCOPE_TYPES[0].value })- }- >- Add Scope- </Button>- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMongoDBForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMongoDBForm.tsxdeleted file mode 100644index 5d18ac7a8b..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMongoDBForm.tsx+++ /dev/null@@ -1,410 +0,0 @@-import { Controller, useFieldArray, useForm } from "react-hook-form";-import { faPlus, faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Button,- FormControl,- FormLabel,- IconButton,- Input,- SecretInput,- Switch,- Tooltip-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z- .object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number().optional(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional(),- roles: z- .object({- roleName: z.string().min(1)- })- .array()- .min(1)- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretMongoDBForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- getValues,- setValue,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"]),- roles: (dynamicSecret.inputs as { roles: string[] }).roles?.map((roleName) => ({- roleName- }))- }- }- });-- const roleFields = useFieldArray({- control,- name: "inputs.roles"- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs: {- ...inputs,- port: inputs?.port ? inputs.port : undefined,- roles: inputs?.roles?.map((el) => el.roleName)- },- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate,- newName: newName === dynamicSecret.name ? undefined : newName- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- defaultValue={27017}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.database"- defaultValue="default"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database Name"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <FormLabel- label="Roles"- tooltipClassName="max-w-md whitespace-pre-line"- tooltipText={`Human-readable label that identifies a group of privileges assigned to a database user. This value can either be a built-in role or a custom role.- Built-in: atlasAdmin, backup, clusterMonitor, dbAdmin, dbAdminAnyDatabase, enableSharding, read, readAnyDatabase, readWrite, readWriteAnyDatabase.`}- />- <div className="mt-1 mb-3 flex flex-col space-y-2">- {roleFields.fields.map(({ id: roleFieldId }, i) => (- <div key={roleFieldId} className="flex items-end space-x-2">- <div className="grow">- <Controller- control={control}- name={`inputs.roles.${i}.roleName`}- render={({ field, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- className="mb-0 grow"- >- <Input {...field} />- </FormControl>- )}- />- </div>- <IconButton- ariaLabel="delete key"- className="bottom-0.5 h-9"- variant="outline_bg"- onClick={() => {- const roles = getValues("inputs.roles");- if (roles && roles?.length > 1) {- roleFields.remove(i);- } else {- setValue("inputs.roles", [{ roleName: "" }]);- }- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- ))}- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- variant="outline_bg"- onClick={() => roleFields.append({ roleName: "" })}- >- Add Role- </Button>- </div>- </div>- <div>- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA(SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list of- supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <div>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretRabbitMqForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretRabbitMqForm.tsxdeleted file mode 100644index 8bc6ba9256..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretRabbitMqForm.tsx+++ /dev/null@@ -1,486 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faPlus, faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Button,- FormControl,- FormLabel,- IconButton,- Input,- SecretInput,- Switch,- Tooltip-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z.object({- host: z.string().trim().min(1),- port: z.coerce.number(), // important: this is the management plugin port-- username: z.string(),- password: z.string(),-- tags: z.array(z.string().trim()),- virtualHost: z.object({- name: z.string().trim().min(1),- permissions: z.object({- read: z.string().trim().min(1),- write: z.string().trim().min(1),- configure: z.string().trim().min(1)- })- }),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional()- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};-export const EditDynamicSecretRabbitMqForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- const selectedTags = watch("inputs.tags");-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="https://your-rabbitmq-host.com" {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- defaultValue={443}- render={({ field, fieldState: { error } }) => (- <FormControl- tooltipText="The port on which the RabbitMQ management plugin is running. Default is 15672."- label="Management Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>-- <div className="flex w-full items-center gap-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>-- <div>- <FormLabel label="Virtual Host" className="mb-2" />- <div className="mt-2 flex items-center justify-evenly gap-2">- <Controller- control={control}- name="inputs.virtualHost.name"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Name"- tooltipText="The virtual host to which the user will be assigned. Default is /."- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder="/virtual-host" {...field} autoComplete="off" />- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.virtualHost.permissions.read"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Read Permissions"- tooltipText="A regular expression matching resource names for which the user is granted read permissions."- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder=".*" {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.virtualHost.permissions.write"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Write Permissions"- tooltipText="A regular expression matching resource names for which the user is granted write permissions."- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder=".*" {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.virtualHost.permissions.configure"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Configure Permissions"- tooltipText="A regular expression matching resource names for which the user is granted configure permissions."- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input placeholder=".*" {...field} autoComplete="off" />- </FormControl>- )}- />- </div>- </div>-- <div className="flex flex-col">- <FormLabel- isOptional- className="mb-2"- label="Tags"- tooltipText={- <div className="space-y-4">- <p>Select which tag(s) to assign the users provisioned by Infisical.</p>- <p>- There is a wide range of in-built roles in RabbitMQ. Some include,- management, policymaker, monitoring, administrator. <br />- <a- href="https://www.rabbitmq.com/docs/management#permissions"- target="_blank"- rel="noopener noreferrer"- >- <span className="cursor-pointer text-primary-400">- Read more about management tags here- </span>- </a>- .- </p>- <p>- You can also assign custom roles by providing the name of the custom role in- the input field.- </p>- </div>- }- />- <div className="flex flex-col -space-y-2">- {selectedTags.map((_, i) => (- <Controller- control={control}- name={`inputs.tags.${i}`}- // eslint-disable-next-line react/no-array-index-key- key={`role-${i}`}- render={({ field, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <div className="flex h-9 items-center gap-2">- <Input- placeholder="Insert tag name, (management, policymaker, etc.)"- className="mb-0 grow"- {...field}- />- <IconButton- isDisabled={selectedTags.length === 1}- ariaLabel="delete key"- className="h-9"- variant="outline_bg"- onClick={() => {- if (selectedTags && selectedTags?.length > 1) {- setValue(- "inputs.tags",- selectedTags.filter((__, idx) => idx !== i)- );- }- }}- >- <FontAwesomeIcon icon={faTrash} />- </IconButton>- </div>- </FormControl>- )}- />- ))}- </div>- </div>- <div>- <Button- leftIcon={<FontAwesomeIcon icon={faPlus} />}- size="xs"- className="mb-4"- variant="outline_bg"- onClick={() => {- setValue("inputs.tags", [...selectedTags, ""]);- }}- >- Add Tag- </Button>- </div>- <div>- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- </div>- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <div>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretRedisProviderForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretRedisProviderForm.tsxdeleted file mode 100644index aa678ac196..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretRedisProviderForm.tsx+++ /dev/null@@ -1,391 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- SecretInput,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z- .object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- username: z.string().min(1),- password: z.string().min(1).optional(),-- creationStatement: z.string().min(1),- renewStatement: z.string().optional(),- revocationStatement: z.string().min(1),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretRedisProviderForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate,- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <Controller- control={control}- name="inputs.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- defaultValue={6379}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex space-x-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username"- className="w-full"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-full"- tooltipText="Required if your Redis server is password protected."- label="Username"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA(SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list of- supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify Redis Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSapAseForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSapAseForm.tsxdeleted file mode 100644index 2f55cca2be..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSapAseForm.tsx+++ /dev/null@@ -1,352 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- SecretInput,- TextArea-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z- .object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- ca: z.string().optional()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- usernameTemplate: z.string().trim().nullable().optional(),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- newName: slugSchema().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- projectSlug: string;- environment: string;-};--export const EditDynamicSecretSapAseForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.database"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="text" />- </FormControl>- )}- />- </div>- <div className="flex w-full items-center space-x-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-full"- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-full"- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA(SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify SQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username and password are dynamically provisioned. The sp_addlogin statement is automatically called against the master database. All other statements are called against the database you specify."- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned. The sp_droplogin statement is automatically called against the master database. All other statements are called against the database you specify."- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSapHanaForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSapHanaForm.tsxdeleted file mode 100644index ab70d1ef55..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSapHanaForm.tsx+++ /dev/null@@ -1,394 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- SecretInput,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z- .object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- username: z.string().min(1),- password: z.string().min(1),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- projectSlug: string;- environment: string;-};--export const EditDynamicSecretSapHanaForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- defaultValue={443}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA(SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify SQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSnowflakeForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSnowflakeForm.tsxdeleted file mode 100644index fde7f1193a..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSnowflakeForm.tsx+++ /dev/null@@ -1,340 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- TextArea-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--const formSchema = z.object({- inputs: z- .object({- accountId: z.string().min(1),- orgId: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- creationStatement: z.string().trim().min(1),- revocationStatement: z.string().trim().min(1),- renewStatement: z.string().trim().optional()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- newName: slugSchema().optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- projectSlug: string;- environment: string;-};--export const EditDynamicSecretSnowflakeForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"])- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs,- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.accountId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Account Identifer"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.orgId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Organizaton Identifier"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Programmatic Access Token"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- tooltipText="The Programmatic Access Token (PAT) used to authenticate with Snowflake. A user password is still accepted, but Snowflake is phasing out password authentication."- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>-- <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify SQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.renewStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsxdeleted file mode 100644index 28ce7a9f0a..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx+++ /dev/null@@ -1,715 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- SecretInput,- Select,- SelectItem,- Switch,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import { OrgPermissionSubjects } from "@app/context";-import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { SqlProviders, TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--import { MetadataForm } from "../MetadataForm";--const passwordRequirementsSchema = z- .object({- length: z.number().min(1).max(250),- required: z- .object({- lowercase: z.number().min(0),- uppercase: z.number().min(0),- digits: z.number().min(0),- symbols: z.number().min(0)- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 250; // Sanity check for individual validation- }, "Sum of required characters cannot exceed 250"),- allowedSymbols: z.string().optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const formSchema = z.object({- inputs: z- .object({- client: z.nativeEnum(SqlProviders),- host: z.string().toLowerCase().min(1),- port: z.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- passwordRequirements: passwordRequirementsSchema.optional(),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- renewStatement: z.string().optional(),- sslEnabled: z.boolean().optional(),- ca: z.string().optional(),- sslRejectUnauthorized: z.boolean().optional(),- gatewayId: z.string().optional().nullable(),- gatewayPoolId: z.string().optional().nullable()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema().optional(),- metadata: z- .object({- key: z.string().trim().min(1),- value: z.string().trim().default("")- })- .array()- .optional(),- usernameTemplate: z.string().trim().nullable().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretSqlProviderForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const getDefaultPasswordRequirements = (provider: SqlProviders) => ({- length: provider === SqlProviders.Oracle ? 30 : 48,- required: {- lowercase: 1,- uppercase: 1,- digits: 1,- symbols: 0- },- allowedSymbols: "-_.~!*"- });-- const {- control,- watch,- setValue,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- metadata: dynamicSecret.metadata,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"]),- passwordRequirements:- (dynamicSecret.inputs as TForm["inputs"])?.passwordRequirements ||- getDefaultPasswordRequirements(- (dynamicSecret.inputs as TForm["inputs"])?.client || SqlProviders.Postgres- )- }- }- });-- const selectedClient = watch("inputs.client");-- const updateDynamicSecret = useUpdateDynamicSecret();- const selectedGatewayId = watch("inputs.gatewayId");- const selectedGatewayPoolId = watch("inputs.gatewayPoolId");-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- metadata,- usernameTemplate- }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs: {- ...inputs,- gatewayId: inputs.gatewayId ?? null,- gatewayPoolId: inputs.gatewayPoolId ?? null- },- newName: newName === dynamicSecret.name ? undefined : newName,- metadata,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="DYN-1" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <MetadataForm control={control} />- <div>- <div className="mb-4 border-b border-b-mineshaft-600 pb-2">Configuration</div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: selectedGatewayId ?? null,- gatewayPoolId: selectedGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("inputs.gatewayId", newGwId ?? null, { shouldDirty: true });- setValue("inputs.gatewayPoolId", newPoolId ?? null, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col">- <Controller- control={control}- name="inputs.client"- defaultValue={SqlProviders.Postgres}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Select- isDisabled- value={value}- onValueChange={(val) => onChange(val)}- className="w-full border border-mineshaft-500"- >- <SelectItem value={SqlProviders.Postgres}>PostgreSQL</SelectItem>- <SelectItem value={SqlProviders.MySql}>MySQL</SelectItem>- <SelectItem value={SqlProviders.Oracle}>Oracle</SelectItem>- <SelectItem value={SqlProviders.MsSQL}>MS SQL</SelectItem>- </Select>- </FormControl>- )}- />- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- defaultValue={5432}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- type="number"- onChange={(el) => field.onChange(parseInt(el.target.value, 10))}- />- </FormControl>- )}- />- </div>- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.database"- defaultValue="default"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database Name"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div>- {selectedClient === SqlProviders.MsSQL && (- <div className="mt-2 mb-2">- <Controller- control={control}- name="inputs.sslEnabled"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="sql-ds-ssl-enabled"- thumbClassName="bg-mineshaft-800"- isChecked={Boolean(value)}- onCheckedChange={onChange}- >- Encrypt Connection (SSL)- </Switch>- </FormControl>- )}- />- </div>- )}- <Controller- control={control}- name="inputs.ca"- render={({ field, fieldState: { error } }) => (- <FormControl- isOptional- label="CA (SSL)"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <SecretInput- {...field}- containerClassName="text-bunker-300 hover:border-primary-400/50 border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5"- />- </FormControl>- )}- />- <Controller- name="inputs.sslRejectUnauthorized"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="ssl-reject-unauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">- SSL Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, the server certificate will be verified against the list- of supplied CAs. Disable this option if you are using a self-signed- certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advanced">- <AccordionTrigger>- Creation, Revocation & Renew Statements (optional)- </AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <div className="mb-4 text-sm text-mineshaft-300">- Customize SQL statements for managing database user lifecycle- </div>- <Controller- control={control}- name="inputs.creationStatement"- defaultValue={- "CREATE USER \"{{username}}\" WITH SUPERUSER ENCRYPTED PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';\nGRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO \"{{username}}\";"- }- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username, password and expiration are dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- defaultValue={- 'REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM "{{username}}";\nDROP OWNED BY "{{username}}"; DROP ROLE "{{username}}";'- }- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="username is dynamically provisioned"- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.renewStatement"- defaultValue={"ALTER ROLE \"{{username}}\" VALID UNTIL '{{expiration}}';"}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Renew Statement"- helperText="username and expiration are dynamically provisioned"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>Password Configuration (optional)</AccordionTrigger>- <AccordionContent>- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated database password- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="inputs.passwordRequirements.length"- defaultValue={48}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={1}- max={250}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("inputs.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("inputs.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="inputs.passwordRequirements.required.lowercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of lowercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.uppercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of uppercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.digits"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of digits"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.symbols"- defaultValue={0}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of symbols"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="inputs.passwordRequirements.allowedSymbols"- defaultValue="-_.~!*"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbols to use in password"- isError={Boolean(error)}- errorText={error?.message}- helperText="Default: -_.~!*"- >- <Input {...field} placeholder="-_.~!*" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSshForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSshForm.tsxdeleted file mode 100644index 9c90ad162e..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSshForm.tsx+++ /dev/null@@ -1,421 +0,0 @@-import { useState } from "react";-import { Controller, useForm } from "react-hook-form";-import { faCopy } from "@fortawesome/free-regular-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { zodResolver } from "@hookform/resolvers/zod";-import { ChevronDownIcon, EyeIcon, EyeOffIcon, ShieldIcon } from "lucide-react";-import ms from "ms";-import { twMerge } from "tailwind-merge";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Button,- FormControl,- IconButton,- Input,- Select,- SelectItem,- Tag-} from "@app/components/v2";-import { useGetSshCaPublicKey, useUpdateDynamicSecret } from "@app/hooks/api";-import { SshCertKeyAlgorithm, sshCertKeyAlgorithms } from "@app/hooks/api/dynamicSecret/constants";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { getAuthToken } from "@app/hooks/api/reactQuery";-import { slugSchema } from "@app/lib/schemas";--const sshCertKeyAlgorithmsArray = sshCertKeyAlgorithms.map((a) => a.value);--const formSchema = z- .object({- inputs: z.object({- principals: z.array(z.string().trim().min(1)).min(1, "At least one principal is required"),- keyAlgorithm: z.enum(sshCertKeyAlgorithmsArray as [string, ...string[]])- }),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- })- .nullable(),- newName: slugSchema({ field: "Name" }).optional()- })- .refine((d) => !d.maxTTL || ms(d.maxTTL)! >= ms(d.defaultTTL)!, {- path: ["maxTTL"],- message: "Max TTL must be greater than or equal to Default TTL"- });-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretSshForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const sshInputs = dynamicSecret.inputs as {- caPublicKey?: string;- principals: string[];- keyAlgorithm: string;- };-- const {- control,- formState: { isSubmitting },- handleSubmit,- setValue,- watch- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- newName: dynamicSecret.name,- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- inputs: {- principals: sshInputs.principals || [],- keyAlgorithm: sshInputs.keyAlgorithm || SshCertKeyAlgorithm.ED25519- }- }- });-- const [principalInput, setPrincipalInput] = useState("");- const [cmdOpen, setCmdOpen] = useState(false);- const [isPublicKeyVisible, setIsPublicKeyVisible] = useState(false);-- const { data: caPublicKey } = useGetSshCaPublicKey({- dynamicSecretId: dynamicSecret.id,- enabled: cmdOpen- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const principals = watch("inputs.principals");-- const handleUpdateDynamicSecret = async ({ inputs, newName, defaultTTL, maxTTL }: TForm) => {- if (updateDynamicSecret.isPending) return;- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- inputs: {- principals: inputs.principals,- keyAlgorithm: inputs.keyAlgorithm- },- newName: newName === dynamicSecret.name ? undefined : newName,- defaultTTL,- maxTTL: maxTTL || undefined- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- const handleAddPrincipal = () => {- const trimmed = principalInput.trim();- if (trimmed && !principals.includes(trimmed)) {- setValue("inputs.principals", [...principals, trimmed], { shouldValidate: true });- }- setPrincipalInput("");- };-- const handleRemovePrincipal = (idx: number) => {- setValue(- "inputs.principals",- principals.filter((_, i) => i !== idx),- { shouldValidate: true }- );- };-- const { protocol, hostname, port } = window.location;- const portSuffix = port && port !== "80" ? `:${port}` : "";- const siteURL = `${protocol}//${hostname}${portSuffix}`;-- const setupSshCaCommand = `curl -H "Authorization: Bearer ${getAuthToken()}" "${siteURL}/api/v1/dynamic-secrets/ssh-ca-setup/${dynamicSecret.id}" | sudo bash`;-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-border pb-2 pl-1 font-medium text-label">- Configuration- </div>-- <div className="flex flex-col">- <Controller- control={control}- name="inputs.principals"- render={({ fieldState: { error } }) => (- <FormControl- label="Allowed Principals"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="The usernames this dynamic secret can issue certificates for"- isRequired- >- <div className="flex flex-col gap-2">- <div className="flex items-center gap-2">- <Input- value={principalInput}- onChange={(e) => setPrincipalInput(e.target.value)}- placeholder="Enter principal name..."- onKeyDown={(e) => {- if (e.key === "Enter") {- e.preventDefault();- handleAddPrincipal();- }- }}- />- <Button- type="button"- variant="outline_bg"- size="sm"- onClick={handleAddPrincipal}- isDisabled={!principalInput.trim()}- >- Add- </Button>- </div>- {principals.length > 0 && (- <div className="flex flex-wrap gap-1">- {principals.map((principal, idx) => (- <Tag- className="bg-neutral/15 text-neutral"- key={principal}- onClose={() => handleRemovePrincipal(idx)}- >- {principal}- </Tag>- ))}- </div>- )}- </div>- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.keyAlgorithm"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- label="Key Algorithm"- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Algorithm for ephemeral key pairs generated per lease"- >- <Select value={value} onValueChange={onChange} className="w-full">- {sshCertKeyAlgorithms.map((alg) => (- <SelectItem key={alg.value} value={alg.value}>- {alg.label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- </div>-- <button- type="button"- onClick={() => {- if (cmdOpen) setIsPublicKeyVisible(false);- setCmdOpen(!cmdOpen);- }}- className="flex w-full cursor-pointer flex-col rounded-md border border-border bg-container p-3 text-sm hover:bg-container-hover"- >- <div className="flex gap-2.5">- <ShieldIcon className="mt-0.5 size-6 shrink-0 text-info" />- <div className="flex w-full flex-col">- <div className="flex justify-between gap-2 pr-1">- <div className="flex flex-col text-left">- <span className="text-base">Certificate-Based Authentication</span>- <span className="text-sm text-muted">- Run this command on target hosts to trust certificates from this dynamic- secret- </span>- </div>- <ChevronDownIcon- className={twMerge(- "shrink-0 text-muted transition-transform duration-200 ease-in-out",- cmdOpen && "rotate-180"- )}- />- </div>- <div- className={twMerge(- "grid transition-all duration-200 ease-in-out",- cmdOpen ? "mt-2 grid-rows-[1fr]" : "mt-0 grid-rows-[0fr]"- )}- >- <div className="overflow-hidden">- <div className="flex flex-col text-left">- <span className="mt-2 text-sm text-muted">- Run this command on the target host:- </span>- <div className="mt-1 flex items-center gap-1">- <Input value={setupSshCaCommand} isDisabled />- <IconButton- ariaLabel="copy"- variant="plain"- colorSchema="secondary"- size="sm"- onClick={(e) => {- e.stopPropagation();- navigator.clipboard.writeText(setupSshCaCommand);- createNotification({- text: "Command copied to clipboard",- type: "info"- });- }}- className="size-8 shrink-0"- >- <FontAwesomeIcon icon={faCopy} className="text-label" />- </IconButton>- </div>- <div className="mt-4 flex flex-col gap-1 text-xs text-muted">- <span>This command will:</span>- <span>- Install the CA certificate on the target host</span>- <span>- Configure SSH to trust certificate-based authentication</span>- <span>- Restart the SSH service</span>- </div>- <span className="mt-4 text-sm text-muted">- Or, copy the CA public key to install it manually:- </span>- <div className="mt-1 flex items-center gap-1">- <Input- type={isPublicKeyVisible ? "text" : "password"}- value={caPublicKey || ""}- isDisabled- />- <IconButton- ariaLabel="toggle visibility"- variant="plain"- colorSchema="secondary"- size="sm"- onClick={(e) => {- e.stopPropagation();- setIsPublicKeyVisible((v) => !v);- }}- className="size-8 shrink-0"- >- {isPublicKeyVisible ? (- <EyeOffIcon className="size-4 text-label" />- ) : (- <EyeIcon className="size-4 text-label" />- )}- </IconButton>- <IconButton- ariaLabel="copy"- variant="plain"- colorSchema="secondary"- size="sm"- onClick={(e) => {- e.stopPropagation();- if (caPublicKey) {- navigator.clipboard.writeText(caPublicKey);- createNotification({- text: "CA public key copied to clipboard",- type: "info"- });- }- }}- className="size-8 shrink-0"- >- <FontAwesomeIcon icon={faCopy} className="text-label" />- </IconButton>- </div>- </div>- </div>- </div>- </div>- </div>- </button>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsxdeleted file mode 100644index 2012cde054..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx+++ /dev/null@@ -1,613 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import {- Button,- FormControl,- Input,- SecretInput,- Select,- SelectItem,- Switch-} from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import {- DynamicSecretProviders,- TailscaleAuthMethod,- TailscaleKeyAuthType,- TDynamicSecret,- TDynamicSecretProvider-} from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--type TailscaleInputs = Extract<- TDynamicSecretProvider,- { type: DynamicSecretProviders.Tailscale }->["inputs"];--const validateTTL = (val: string, ctx: z.RefinementCtx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be greater than 1 minute" });- if (valMs > ms("90d"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 90 days" });-};--const tailscaleAuthSchema = z.discriminatedUnion("method", [- z.object({- method: z.literal(TailscaleAuthMethod.ApiKey),- apiKey: z.string().trim().min(1, "API key is required")- }),- z.object({- method: z.literal(TailscaleAuthMethod.OAuth),- clientId: z.string().trim().min(1, "Client ID is required"),- clientSecret: z.string().trim().min(1, "Client secret is required")- })-]);--const formSchema = z- .object({- inputs: z.discriminatedUnion("authType", [- z.object({- authType: z.literal(TailscaleKeyAuthType.AuthKeys),- auth: tailscaleAuthSchema,- tailnet: z.string().trim().min(1, "Tailnet is required"),- description: z.string().trim().max(50).optional(),- tags: z.string().trim().optional(),- reusable: z.boolean().default(false),- preauthorized: z.boolean().default(false)- }),- z.object({- authType: z.literal(TailscaleKeyAuthType.OAuthKeys),- auth: tailscaleAuthSchema,- tailnet: z.string().trim().min(1, "Tailnet is required"),- description: z.string().trim().max(50).optional(),- tags: z.string().trim().optional(),- scopes: z.string().trim().min(1, "At least one scope is required")- }),- z.object({- authType: z.literal(TailscaleKeyAuthType.FederatedKeys),- auth: tailscaleAuthSchema,- tailnet: z.string().trim().min(1, "Tailnet is required"),- description: z.string().trim().max(50).optional(),- tags: z.string().trim().optional(),- scopes: z.string().trim().min(1, "At least one scope is required"),- issuer: z- .string()- .trim()- .min(1, "Issuer is required")- .url("Issuer must be a valid https URL"),- subject: z.string().trim().min(1, "Subject is required"),- audience: z.string().trim().optional()- })- ]),- defaultTTL: z.string().superRefine(validateTTL),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- validateTTL(val, ctx);- })- .nullable(),- newName: slugSchema().optional()- })- .superRefine((val, ctx) => {- // Tailscale requires tags on tailnet-owned auth keys (created via OAuth).- if (- val.inputs.authType === TailscaleKeyAuthType.AuthKeys &&- val.inputs.auth.method === TailscaleAuthMethod.OAuth &&- !val.inputs.tags?.trim()- ) {- ctx.addIssue({- code: z.ZodIssueCode.custom,- path: ["inputs", "tags"],- message: "Tags are required when creating auth keys with OAuth authentication"- });- }- });-type TForm = z.infer<typeof formSchema>;--const splitCsv = (val?: string) =>- val- ? val- .split(",")- .map((entry) => entry.trim())- .filter(Boolean)- : [];--const buildAuth = (auth: TForm["inputs"]["auth"]): TailscaleInputs["auth"] =>- auth.method === TailscaleAuthMethod.ApiKey- ? { method: TailscaleAuthMethod.ApiKey, apiKey: auth.apiKey }- : {- method: TailscaleAuthMethod.OAuth,- clientId: auth.clientId,- clientSecret: auth.clientSecret- };--const assertNever = (value: never): never => {- throw new Error(`Unhandled Tailscale auth type: ${String(value)}`);-};--const buildInputs = (inputs: TForm["inputs"], auth: TailscaleInputs["auth"]): TailscaleInputs => {- const base = {- auth,- tailnet: inputs.tailnet,- description: inputs.description || undefined,- tags: splitCsv(inputs.tags)- };-- switch (inputs.authType) {- case TailscaleKeyAuthType.AuthKeys:- return {- ...base,- authType: inputs.authType,- reusable: inputs.reusable,- preauthorized: inputs.preauthorized- };- case TailscaleKeyAuthType.OAuthKeys:- return {- ...base,- authType: inputs.authType,- scopes: splitCsv(inputs.scopes)- };- case TailscaleKeyAuthType.FederatedKeys:- return {- ...base,- authType: inputs.authType,- scopes: splitCsv(inputs.scopes),- issuer: inputs.issuer,- subject: inputs.subject,- audience: inputs.audience || undefined- };- default:- return assertNever(inputs);- }-};--const hydrateInputs = (rawInputs: TailscaleInputs): TForm["inputs"] => {- if (rawInputs.authType === TailscaleKeyAuthType.AuthKeys) {- return {- authType: TailscaleKeyAuthType.AuthKeys,- auth: rawInputs.auth,- tailnet: rawInputs.tailnet,- description: rawInputs.description,- tags: (rawInputs.tags ?? []).join(", "),- reusable: rawInputs.reusable,- preauthorized: rawInputs.preauthorized- };- }- if (rawInputs.authType === TailscaleKeyAuthType.OAuthKeys) {- return {- authType: TailscaleKeyAuthType.OAuthKeys,- auth: rawInputs.auth,- tailnet: rawInputs.tailnet,- description: rawInputs.description,- tags: (rawInputs.tags ?? []).join(", "),- scopes: (rawInputs.scopes ?? []).join(", ")- };- }- return {- authType: TailscaleKeyAuthType.FederatedKeys,- auth: rawInputs.auth,- tailnet: rawInputs.tailnet,- description: rawInputs.description,- tags: (rawInputs.tags ?? []).join(", "),- scopes: (rawInputs.scopes ?? []).join(", "),- issuer: rawInputs.issuer,- subject: rawInputs.subject,- audience: rawInputs.audience- };-};--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- environment: string;- projectSlug: string;-};--export const EditDynamicSecretTailscaleForm = ({- onClose,- dynamicSecret,- secretPath,- environment,- projectSlug-}: Props) => {- const {- control,- watch,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- inputs: hydrateInputs(dynamicSecret.inputs as TailscaleInputs)- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();- const authType = watch("inputs.authType");- const authMethod = watch("inputs.auth.method");- const tagsRequired =- authType === TailscaleKeyAuthType.OAuthKeys || authType === TailscaleKeyAuthType.FederatedKeys;-- const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newName }: TForm) => {- if (updateDynamicSecret.isPending) return;-- const auth = buildAuth(inputs.auth);- const builtInputs = buildInputs(inputs, auth);-- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs: builtInputs,- newName: newName === dynamicSecret.name ? undefined : newName- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} value={field.value || ""} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mb-4 border-b border-b-mineshaft-600 pb-2">Configuration</div>- <div className="flex flex-col">- <Controller- name="inputs.auth.method"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Authentication Method"- >- <Select- value={value}- onValueChange={onChange}- className="w-full border border-mineshaft-500"- position="popper"- dropdownContainerClassName="max-w-none"- >- <SelectItem value={TailscaleAuthMethod.ApiKey}>API Key</SelectItem>- <SelectItem value={TailscaleAuthMethod.OAuth}>OAuth</SelectItem>- </Select>- </FormControl>- )}- />-- {authMethod === TailscaleAuthMethod.ApiKey && (- <Controller- control={control}- name="inputs.auth.apiKey"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="API Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="Tailscale API access token with permission to create and revoke keys."- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />- )}-- {authMethod === TailscaleAuthMethod.OAuth && (- <>- <Controller- control={control}- name="inputs.auth.clientId"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client ID"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- >- <Input {...field} placeholder="kXKWj5bUY611CNTRL" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.auth.clientSecret"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Client Secret"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="OAuth client secret with permission to create and revoke keys."- >- <SecretInput- {...field}- containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"- />- </FormControl>- )}- />- </>- )}-- <Controller- name="inputs.authType"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Key Type"- >- <Select- value={value}- onValueChange={onChange}- className="w-full border border-mineshaft-500"- position="popper"- dropdownContainerClassName="max-w-none"- >- <SelectItem value={TailscaleKeyAuthType.AuthKeys}>Auth Key</SelectItem>- <SelectItem value={TailscaleKeyAuthType.OAuthKeys}>OAuth Client</SelectItem>- <SelectItem value={TailscaleKeyAuthType.FederatedKeys}>- Federated Identity- </SelectItem>- </Select>- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.tailnet"- defaultValue="-"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Tailnet"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="Use '-' for the token owner's default tailnet, or provide a tailnet name (e.g. example.com)."- >- <Input {...field} placeholder="-" />- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.description"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Description"- className="grow"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} placeholder="Created by Infisical" />- </FormControl>- )}- />-- <Controller- control={control}- name="inputs.tags"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Tags"- className="grow"- isOptional={!tagsRequired}- isRequired={tagsRequired}- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Comma-separated ACL tags (e.g. tag:ci, tag:prod). Required when creating auth keys with OAuth authentication."- >- <Input {...field} placeholder="tag:ci, tag:prod" />- </FormControl>- )}- />-- {(authType === TailscaleKeyAuthType.OAuthKeys ||- authType === TailscaleKeyAuthType.FederatedKeys) && (- <Controller- control={control}- name="inputs.scopes"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Scopes"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="Comma-separated OAuth scopes (e.g. devices:core, users:read)."- >- <Input {...field} placeholder="devices:core, users:read" />- </FormControl>- )}- />- )}-- {authType === TailscaleKeyAuthType.FederatedKeys && (- <>- <Controller- control={control}- name="inputs.issuer"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Issuer"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="HTTPS URL of the OIDC issuer trusted for token exchange."- >- <Input {...field} placeholder="https://token.actions.githubusercontent.com" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.subject"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Subject"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- isRequired- helperText="Pattern matched against the sub claim of the OIDC token (supports wildcards)."- >- <Input {...field} placeholder="repo:my-org/my-repo:*" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.audience"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Audience"- className="grow"- isOptional- isError={Boolean(error?.message)}- errorText={error?.message}- helperText="Leave blank to let Tailscale auto-generate one."- >- <Input {...field} />- </FormControl>- )}- />- </>- )}-- {authType === TailscaleKeyAuthType.AuthKeys && (- <div className="flex flex-col gap-3 pt-1 pb-2">- <Controller- control={control}- name="inputs.reusable"- render={({ field: { value, onChange } }) => (- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="tailscale-edit-reusable"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">Reusable</p>- </Switch>- )}- />-- <Controller- control={control}- name="inputs.preauthorized"- render={({ field: { value, onChange } }) => (- <Switch- className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"- id="tailscale-edit-preauthorized"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- <p className="w-full">Pre-authorized</p>- </Switch>- )}- />- </div>- )}- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Save- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTotpForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTotpForm.tsxdeleted file mode 100644index 15dead8d03..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTotpForm.tsx+++ /dev/null@@ -1,290 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import { z } from "zod";--import { createNotification } from "@app/components/notifications";-import { Button, FormControl, Input, Select, SelectItem } from "@app/components/v2";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";-import { slugSchema } from "@app/lib/schemas";--enum ConfigType {- URL = "url",- MANUAL = "manual"-}--enum TotpAlgorithm {- SHA1 = "sha1",- SHA256 = "sha256",- SHA512 = "sha512"-}--const formSchema = z.object({- inputs: z- .discriminatedUnion("configType", [- z.object({- configType: z.literal(ConfigType.URL),- url: z- .string()- .url()- .trim()- .min(1)- .refine((val) => {- const urlObj = new URL(val);- const secret = urlObj.searchParams.get("secret");-- return Boolean(secret);- }, "OTP URL must contain secret field")- }),- z.object({- configType: z.literal(ConfigType.MANUAL),- secret: z- .string()- .trim()- .min(1)- .transform((val) => val.replace(/\s+/g, "")),- period: z.number().optional(),- algorithm: z.nativeEnum(TotpAlgorithm).optional(),- digits: z.number().optional()- })- ])- .optional(),- newName: slugSchema().optional()-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- projectSlug: string;- environment: string;-};--export const EditDynamicSecretTotpForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const {- control,- formState: { isSubmitting },- watch,- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- newName: dynamicSecret.name,- inputs: dynamicSecret.inputs as TForm["inputs"]- }- });-- const selectedConfigType = watch("inputs.configType");- const updateDynamicSecret = useUpdateDynamicSecret();-- const handleUpdateDynamicSecret = async ({ inputs, newName }: TForm) => {- // wait till previous request is finished- if (updateDynamicSecret.isPending) return;- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- inputs,- newName: newName === dynamicSecret.name ? undefined : newName- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div className="flex flex-col">- <Controller- control={control}- name="inputs.configType"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Configuration Type"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- onValueChange={(val) => {- field.onChange(val);- }}- dropdownContainerClassName="max-w-full"- >- <SelectItem value={ConfigType.URL} key="config-type-url">- URL- </SelectItem>- <SelectItem value={ConfigType.MANUAL} key="config-type-manual">- Manual- </SelectItem>- </Select>- </FormControl>- )}- />- {selectedConfigType === ConfigType.URL && (- <Controller- control={control}- name="inputs.url"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="OTP URL"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- )}- {selectedConfigType === ConfigType.MANUAL && (- <>- <Controller- control={control}- name="inputs.secret"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Key"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <div className="flex flex-row gap-2">- <Controller- control={control}- name="inputs.period"- defaultValue={30}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Period"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- type="number"- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.digits"- defaultValue={6}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digits"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- type="number"- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.algorithm"- defaultValue={TotpAlgorithm.SHA1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Algorithm"- isError={Boolean(error?.message)}- errorText={error?.message}- className="w-full"- >- <Select- defaultValue={field.value}- {...field}- className="w-full"- dropdownContainerClassName="max-w-full"- onValueChange={(val) => {- field.onChange(val);- }}- >- <SelectItem value={TotpAlgorithm.SHA1} key="algorithm-sha-1">- SHA1- </SelectItem>- <SelectItem value={TotpAlgorithm.SHA256} key="algorithm-sha-256">- SHA256- </SelectItem>- <SelectItem value={TotpAlgorithm.SHA512} key="algorithm-sha-512">- SHA512- </SelectItem>- </Select>- </FormControl>- )}- />- </div>- <p className="mb-8 text-sm font-normal text-gray-400">- The period, digits, and algorithm values can remain at their defaults unless- your TOTP provider specifies otherwise.- </p>- </>- )}- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretVertica.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretVertica.tsxdeleted file mode 100644index 702d2906b9..0000000000--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretVertica.tsx+++ /dev/null@@ -1,567 +0,0 @@-import { Controller, useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import ms from "ms";-import { z } from "zod";--import { TtlFormLabel } from "@app/components/features";-import { createNotification } from "@app/components/notifications";-import { OrgPermissionCan } from "@app/components/permissions";-import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,- Button,- FormControl,- Input,- TextArea,- Tooltip-} from "@app/components/v2";-import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";-import { OrgPermissionSubjects } from "@app/context";-import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";-import { useUpdateDynamicSecret } from "@app/hooks/api";-import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";--const passwordRequirementsSchema = z- .object({- length: z.number().min(1).max(250),- required: z- .object({- lowercase: z.number().min(0),- uppercase: z.number().min(0),- digits: z.number().min(0),- symbols: z.number().min(0)- })- .refine((data) => {- const total = Object.values(data).reduce((sum, count) => sum + count, 0);- return total <= 250;- }, "Sum of required characters cannot exceed 250"),- allowedSymbols: z.string().optional()- })- .refine((data) => {- const total = Object.values(data.required).reduce((sum, count) => sum + count, 0);- return total <= data.length;- }, "Sum of required characters cannot exceed the total length");--const formSchema = z.object({- inputs: z- .object({- host: z.string().toLowerCase().min(1),- port: z.coerce.number(),- database: z.string().min(1),- username: z.string().min(1),- password: z.string().min(1),- passwordRequirements: passwordRequirementsSchema.optional(),- creationStatement: z.string().min(1),- revocationStatement: z.string().min(1),- gatewayId: z.string().optional().nullable(),- gatewayPoolId: z.string().optional().nullable()- })- .partial(),- defaultTTL: z.string().superRefine((val, ctx) => {- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- usernameTemplate: z.string().trim().nullable().optional(),- maxTTL: z- .string()- .optional()- .superRefine((val, ctx) => {- if (!val) return;- const valMs = ms(val);- if (valMs < 60 * 1000)- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });- if (valMs > ms("10y"))- ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });- }),- newName: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase")-});-type TForm = z.infer<typeof formSchema>;--type Props = {- onClose: () => void;- dynamicSecret: TDynamicSecret & { inputs: unknown };- secretPath: string;- projectSlug: string;- environment: string;-};--export const EditDynamicSecretVerticaForm = ({- onClose,- dynamicSecret,- environment,- secretPath,- projectSlug-}: Props) => {- const getDefaultPasswordRequirements = () => ({- length: 48,- required: {- lowercase: 1,- uppercase: 1,- digits: 1,- symbols: 0- },- allowedSymbols: "-_.~!*"- });-- const {- control,- watch,- setValue,- formState: { isSubmitting },- handleSubmit- } = useForm<TForm>({- resolver: zodResolver(formSchema),- values: {- defaultTTL: dynamicSecret.defaultTTL,- maxTTL: dynamicSecret.maxTTL,- newName: dynamicSecret.name,- usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",- inputs: {- ...(dynamicSecret.inputs as TForm["inputs"]),- passwordRequirements:- (dynamicSecret.inputs as TForm["inputs"])?.passwordRequirements ||- getDefaultPasswordRequirements()- }- }- });-- const updateDynamicSecret = useUpdateDynamicSecret();-- const selectedGatewayId = watch("inputs.gatewayId");- const selectedGatewayPoolId = watch("inputs.gatewayPoolId");-- const handleUpdateDynamicSecret = async ({- inputs,- maxTTL,- defaultTTL,- newName,- usernameTemplate- }: TForm) => {- if (updateDynamicSecret.isPending) return;-- const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";-- await updateDynamicSecret.mutateAsync({- name: dynamicSecret.name,- path: secretPath,- projectSlug,- environmentSlug: environment,- data: {- maxTTL: maxTTL || undefined,- defaultTTL,- inputs: {- ...inputs,- gatewayId: inputs.gatewayId ?? null,- gatewayPoolId: inputs.gatewayPoolId ?? null- },- newName: newName === dynamicSecret.name ? undefined : newName,- usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate- }- });- onClose();- createNotification({- type: "success",- text: "Successfully updated dynamic secret"- });- };-- return (- <div>- <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">- <div>- <div className="flex items-center space-x-2">- <div className="grow">- <Controller- control={control}- defaultValue=""- name="newName"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Secret Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="dynamic-secret" />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="defaultTTL"- defaultValue="1h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Default TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- <div className="w-32">- <Controller- control={control}- name="maxTTL"- defaultValue="24h"- render={({ field, fieldState: { error } }) => (- <FormControl- label={<TtlFormLabel label="Max TTL" />}- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- </div>- </div>- <div>- <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">- Configuration- </div>- <div>- <OrgPermissionCan- I={OrgGatewayPermissionActions.AttachGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed) => (- <FormControl label="Gateway">- <Tooltip- isDisabled={isAllowed}- content="Restricted access. You don't have permission to attach gateways to resources."- >- <div>- <GatewayPicker- isDisabled={!isAllowed}- value={{- gatewayId: selectedGatewayId ?? null,- gatewayPoolId: selectedGatewayPoolId ?? null- }}- onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {- setValue("inputs.gatewayId", newGwId ?? null, { shouldDirty: true });- setValue("inputs.gatewayPoolId", newPoolId ?? null, {- shouldDirty: true- });- }}- />- </div>- </Tooltip>- </FormControl>- )}- </OrgPermissionCan>- </div>- <div className="flex flex-col">- <div className="flex items-center space-x-2">- <Controller- control={control}- name="inputs.host"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Host"- className="grow"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.port"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Port"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="number" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.database"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Database"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="text" />- </FormControl>- )}- />- </div>- <div className="flex w-full items-center space-x-2">- <Controller- control={control}- name="inputs.username"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-full"- label="User"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.password"- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-full"- label="Password"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input {...field} type="password" autoComplete="new-password" />- </FormControl>- )}- />- </div>- <div>- <Accordion type="multiple" className="mb-2 w-full bg-mineshaft-700">- <AccordionItem value="advance-statements">- <AccordionTrigger>Modify SQL Statements</AccordionTrigger>- <AccordionContent>- <Controller- control={control}- name="usernameTemplate"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Username Template"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <Input- {...field}- value={field.value || undefined}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.creationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Creation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.revocationStatement"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Revocation Statement"- isError={Boolean(error?.message)}- errorText={error?.message}- >- <TextArea- {...field}- reSize="none"- rows={3}- className="border-mineshaft-600 bg-mineshaft-900 text-sm"- />- </FormControl>- )}- />- </AccordionContent>- </AccordionItem>- </Accordion>- <Accordion type="multiple" className="mt-4 mb-2 w-full bg-mineshaft-700">- <AccordionItem value="password-config">- <AccordionTrigger>Password Configuration (optional)</AccordionTrigger>- <AccordionContent>- <div className="mb-4 text-sm text-mineshaft-300">- Set constraints on the generated database password- </div>- <div className="space-y-4">- <div>- <Controller- control={control}- name="inputs.passwordRequirements.length"- defaultValue={48}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Password Length"- isError={Boolean(error)}- errorText={error?.message}- >- <Input- type="number"- min={1}- max={250}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Minimum Required Character Counts</h4>- <div className="text-sm text-gray-500">- {(() => {- const total = Object.values(- watch("inputs.passwordRequirements.required") || {}- ).reduce((sum, count) => sum + Number(count || 0), 0);- const length = watch("inputs.passwordRequirements.length") || 0;- const isError = total > length;- return (- <span className={isError ? "text-red-500" : ""}>- Total required characters: {total}{" "}- {isError ? `(exceeds length of ${length})` : ""}- </span>- );- })()}- </div>- <div className="grid grid-cols-2 gap-4">- <Controller- control={control}- name="inputs.passwordRequirements.required.lowercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Lowercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of lowercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.uppercase"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Uppercase Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of uppercase letters"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.digits"- defaultValue={1}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Digit Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of digits"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- <Controller- control={control}- name="inputs.passwordRequirements.required.symbols"- defaultValue={0}- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbol Count"- isError={Boolean(error)}- errorText={error?.message}- helperText="Minimum number of symbols"- >- <Input- type="number"- min={0}- {...field}- onChange={(e) => field.onChange(Number(e.target.value))}- />- </FormControl>- )}- />- </div>- </div>-- <div className="space-y-2">- <h4 className="text-sm font-medium">Allowed Symbols</h4>- <Controller- control={control}- name="inputs.passwordRequirements.allowedSymbols"- defaultValue="-_.~!*"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Symbols to use in password"- isError={Boolean(error)}- errorText={error?.message}- helperText="Default: -_.~!*"- >- <Input {...field} placeholder="-_.~!*" />- </FormControl>- )}- />- </div>- </div>- </AccordionContent>- </AccordionItem>- </Accordion>- </div>- </div>- </div>- </div>- <div className="mt-4 flex items-center space-x-4">- <Button type="submit" isLoading={isSubmitting}>- Submit- </Button>- <Button variant="outline_bg" onClick={onClose}>- Cancel- </Button>- </div>- </form>- </div>- );-};