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
sheet for resources and accounts
x03220569e11e800e80
diff --git a/backend/src/ee/services/pam-resource/pam-resource-fns.ts b/backend/src/ee/services/pam-resource/pam-resource-fns.tsindex 3171f2348c..3522419335 100644--- a/backend/src/ee/services/pam-resource/pam-resource-fns.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-fns.ts@@ -11,6 +11,7 @@ import { TPamResource, TPamResourceConnectionDetails, TPamResourceInternalMetadaimport { getPostgresResourceListItem } from "./postgres/postgres-resource-fns";import { getRedisResourceListItem } from "./redis/redis-resource-fns";import { getWindowsResourceListItem } from "./windows-server/windows-server-resource-fns";+import { getSshResourceListItem } from "./ssh/ssh-resource-fns";export const listResourceOptions = () => {return [@@ -19,6 +20,7 @@ export const listResourceOptions = () => {getAwsIamResourceListItem(),getKubernetesResourceListItem(),getRedisResourceListItem(),+ getSshResourceListItem(),getWindowsResourceListItem(),getActiveDirectoryResourceListItem()].sort((a, b) => a.name.localeCompare(b.name));diff --git a/backend/src/ee/services/pam-resource/ssh/ssh-resource-fns.ts b/backend/src/ee/services/pam-resource/ssh/ssh-resource-fns.tsnew file mode 100644index 0000000000..761ec078a9--- /dev/null+++ b/backend/src/ee/services/pam-resource/ssh/ssh-resource-fns.ts@@ -0,0 +1,8 @@+import { SSHResourceListItemSchema } from "./ssh-resource-schemas";++export const getSshResourceListItem = () => {+ return {+ name: SSHResourceListItemSchema.shape.name.value,+ resource: SSHResourceListItemSchema.shape.resource.value+ };+};diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/ActiveDirectoryAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/ActiveDirectoryAccountForm.tsxindex 7f19f6cebf..9d88c426c9 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/ActiveDirectoryAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/ActiveDirectoryAccountForm.tsx@@ -3,7 +3,8 @@ import { Controller, FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, FormControl, Input, ModalClose, Select, SelectItem } from "@app/components/v2";+import { FormControl, Input, Select, SelectItem } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { PamResourceType, TActiveDirectoryAccount } from "@app/hooks/api/pam";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";import { ActiveDirectoryAccountType } from "@app/hooks/api/pam/types/active-directory-resource";@@ -17,6 +18,7 @@ type Props = {resourceId?: string;resourceType?: PamResourceType;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const formSchema = genericAccountFieldsSchema.extend({@@ -32,7 +34,7 @@ const formSchema = genericAccountFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const ActiveDirectoryAccountForm = ({ account, onSubmit }: Props) => {+export const ActiveDirectoryAccountForm = ({ account, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(account);const [showPassword, setShowPassword] = useState(false);@@ -68,98 +70,96 @@ export const ActiveDirectoryAccountForm = ({ account, onSubmit }: Props) => {return (<FormProvider {...form}>- <form onSubmit={handleSubmit(onSubmit)}>- <GenericAccountFields />- <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3">- <Controller- name="internalMetadata.accountType"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- className="mb-3"- isError={Boolean(error?.message)}- errorText={error?.message}- label="Account Type"- >- <Select- value={value}- onValueChange={onChange}- className="w-full border border-mineshaft-500"+ <form className="flex flex-1 flex-col overflow-hidden" onSubmit={handleSubmit(onSubmit)}>+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericAccountFields />+ <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3">+ <Controller+ name="internalMetadata.accountType"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ className="mb-3"+ isError={Boolean(error?.message)}+ errorText={error?.message}+ label="Account Type">- <SelectItem value={ActiveDirectoryAccountType.User}>User Account</SelectItem>- <SelectItem value={ActiveDirectoryAccountType.Service}>- Service Account- </SelectItem>- </Select>- </FormControl>- )}- />+ <Select+ value={value}+ onValueChange={onChange}+ className="w-full border border-mineshaft-500"+ >+ <SelectItem value={ActiveDirectoryAccountType.User}>User Account</SelectItem>+ <SelectItem value={ActiveDirectoryAccountType.Service}>+ Service Account+ </SelectItem>+ </Select>+ </FormControl>+ )}+ />- <Controller- name="credentials.username"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="mb-3"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Username"- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />+ <Controller+ name="credentials.username"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="mb-3"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Username"+ >+ <Input {...field} autoComplete="off" />+ </FormControl>+ )}+ />- <Controller- name="credentials.password"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="mb-0"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Password"- >- <Input- {...field}- type={showPassword ? "text" : "password"}- autoComplete="new-password"- onFocus={() => {- if (isUpdate && field.value === UNCHANGED_PASSWORD_SENTINEL) {- field.onChange("");- }- setShowPassword(true);- }}- onBlur={() => {- if (isUpdate && field.value === "") {- field.onChange(UNCHANGED_PASSWORD_SENTINEL);- }- setShowPassword(false);- }}- />- </FormControl>- )}- />+ <Controller+ name="credentials.password"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="mb-0"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Password"+ >+ <Input+ {...field}+ type={showPassword ? "text" : "password"}+ autoComplete="new-password"+ onFocus={() => {+ if (isUpdate && field.value === UNCHANGED_PASSWORD_SENTINEL) {+ field.onChange("");+ }+ setShowPassword(true);+ }}+ onBlur={() => {+ if (isUpdate && field.value === "") {+ field.onChange(UNCHANGED_PASSWORD_SENTINEL);+ }+ setShowPassword(false);+ }}+ />+ </FormControl>+ )}+ />+ </div>+ <RequireMfaField />+ <MetadataFields /></div>- <RequireMfaField />- <MetadataFields />- <div className="mt-6 flex items-center">+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Account" : "Create Account"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={() => closeSheet()} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsxindex 59db4b95ea..18fb05ae40 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx@@ -11,12 +11,11 @@ import {AccordionContent,AccordionItem,AccordionTrigger,- Button,FormControl,- Input,- ModalClose+ Input} from "@app/components/v2";import { CopyButton } from "@app/components/v2/CopyButton";+import { Button, SheetFooter } from "@app/components/v3";import { useProject } from "@app/context";import {PamResourceType,@@ -45,6 +44,7 @@ type Props = {resourceId?: string;resourceType?: PamResourceType;onSubmit: (formData: SubmitData) => Promise<void>;+ closeSheet: () => void;};const arnRoleRegex = /^arn:aws:iam::\d{12}:role\/[\w+=,.@/-]+$/;@@ -88,7 +88,13 @@ const formSchema = genericAccountFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const AwsIamAccountForm = ({ account, resourceId, resourceType, onSubmit }: Props) => {+export const AwsIamAccountForm = ({+ account,+ resourceId,+ resourceType,+ onSubmit,+ closeSheet+}: Props) => {const isUpdate = Boolean(account);const { projectId } = useProject();@@ -173,108 +179,109 @@ export const AwsIamAccountForm = ({ account, resourceId, resourceType, onSubmitreturn (<FormProvider {...form}>- <form onSubmit={handleSubmit(handleFormSubmit)}>- <GenericAccountFields />+ <form+ className="flex flex-1 flex-col overflow-hidden"+ onSubmit={handleSubmit(handleFormSubmit)}+ >+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericAccountFields />- <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3">- <h4 className="mb-3 text-sm font-medium text-mineshaft-200">AWS IAM Configuration</h4>+ <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3">+ <h4 className="mb-3 text-sm font-medium text-mineshaft-200">AWS IAM Configuration</h4>- <Controller- name="credentials.targetRoleArn"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="mb-3"- helperText="The ARN of the IAM role that users will assume to access the AWS Console"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Target Role ARN"- >- <Input- {...field}- placeholder="arn:aws:iam::123456789012:role/infisical-pam-MyTargetRole"- autoComplete="off"- />- </FormControl>- )}- />+ <Controller+ name="credentials.targetRoleArn"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="mb-3"+ helperText="The ARN of the IAM role that users will assume to access the AWS Console"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Target Role ARN"+ >+ <Input+ {...field}+ placeholder="arn:aws:iam::123456789012:role/infisical-pam-MyTargetRole"+ autoComplete="off"+ />+ </FormControl>+ )}+ />- <Controller- name="credentials.defaultSessionDuration"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="mb-0"- helperText="Min 15m, max 1h due to AWS role chaining limit."- errorText={error?.message}- isError={Boolean(error?.message)}- label={<TtlFormLabel label="Default Session Duration" />}- >- <Input {...field} placeholder="1h" />- </FormControl>- )}- />- </div>+ <Controller+ name="credentials.defaultSessionDuration"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="mb-0"+ helperText="Min 15m, max 1h due to AWS role chaining limit."+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label={<TtlFormLabel label="Default Session Duration" />}+ >+ <Input {...field} placeholder="1h" />+ </FormControl>+ )}+ />+ </div>- <Accordion- type="single"- collapsible- className="mb-4 w-full rounded-r border-l-2 border-l-primary bg-mineshaft-300/5"- >- <AccordionItem value="target-role-setup" className="border-b-0">- <AccordionTrigger className="px-4 py-2.5 hover:no-underline [&[data-state=open]]:pb-1">- <div className="flex items-center text-sm transition-colors duration-150 hover:text-primary">- <FontAwesomeIcon icon={faInfoCircle} size="sm" className="mr-1.5 text-primary" />- Target Role Setup- </div>- </AccordionTrigger>- <AccordionContent className="px-4 pb-2.5">- <p className="mb-3 text-sm text-mineshaft-300">- The target role must have a trust policy that allows the Resource Role (created in- the "Resources" tab) to assume it. Ensure the target role's trust- policy includes the Resource Role as a trusted principal.- </p>+ <Accordion+ type="single"+ collapsible+ className="mb-4 w-full rounded-r border-l-2 border-l-primary bg-mineshaft-300/5"+ >+ <AccordionItem value="target-role-setup" className="border-b-0">+ <AccordionTrigger className="px-4 py-2.5 hover:no-underline [&[data-state=open]]:pb-1">+ <div className="flex items-center text-sm transition-colors duration-150 hover:text-primary">+ <FontAwesomeIcon icon={faInfoCircle} size="sm" className="mr-1.5 text-primary" />+ Target Role Setup+ </div>+ </AccordionTrigger>+ <AccordionContent className="px-4 pb-2.5">+ <p className="mb-3 text-sm text-mineshaft-300">+ The target role must have a trust policy that allows the Resource Role (created in+ the "Resources" tab) to assume it. Ensure the target role's trust+ policy includes the Resource Role as a trusted principal.+ </p>- <p className="mb-2 text-sm font-medium text-mineshaft-200">- Target role trust policy:- </p>- <div className="relative mb-3">- <div className="absolute top-1 right-3">- <CopyButton value={targetRoleTrustPolicy} size="sm" variant="plain" />+ <p className="mb-2 text-sm font-medium text-mineshaft-200">+ Target role trust policy:+ </p>+ <div className="relative mb-3">+ <div className="absolute top-1 right-3">+ <CopyButton value={targetRoleTrustPolicy} size="sm" variant="plain" />+ </div>+ <pre className="max-h-45 overflow-y-auto rounded-sm border border-mineshaft-600 bg-mineshaft-800 p-2 pr-8 text-xs whitespace-pre-wrap text-mineshaft-300">+ {targetRoleTrustPolicy}+ </pre></div>- <pre className="max-h-45 overflow-y-auto rounded-sm border border-mineshaft-600 bg-mineshaft-800 p-2 pr-8 text-xs whitespace-pre-wrap text-mineshaft-300">- {targetRoleTrustPolicy}- </pre>- </div>- <p className="text-xs text-mineshaft-400">- <strong>Note:</strong> The Principal role ARN shown above is from the Resource- selected for this account. The External ID{" "}- <code className="rounded bg-mineshaft-700 px-1 font-bold">{projectId}</code> is your- current project ID. If you configured granular permissions in your Resource- Role's policy, ensure this target role's ARN is included.- </p>- </AccordionContent>- </AccordionItem>- </Accordion>+ <p className="text-xs text-mineshaft-400">+ <strong>Note:</strong> The Principal role ARN shown above is from the Resource+ selected for this account. The External ID{" "}+ <code className="rounded bg-mineshaft-700 px-1 font-bold">{projectId}</code> is+ your current project ID. If you configured granular permissions in your Resource+ Role's policy, ensure this target role's ARN is included.+ </p>+ </AccordionContent>+ </AccordionItem>+ </Accordion>- <MetadataFields />- <div className="mt-6 flex items-center">+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Account" : "Create Account"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={() => closeSheet()} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/GenericAccountFields.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/GenericAccountFields.tsxindex 47875745f1..012acfebf5 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/GenericAccountFields.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/GenericAccountFields.tsx@@ -1,7 +1,14 @@import { Controller, useFormContext } from "react-hook-form";import { z } from "zod";-import { FormControl, Input, TextArea } from "@app/components/v2";+import {+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ TextArea,+ UnstableInput+} from "@app/components/v3";import { slugSchema } from "@app/lib/schemas";export const genericAccountFieldsSchema = z.object({@@ -23,34 +30,41 @@ export const GenericAccountFields = () => {}>();return (- <>+ <div className="flex flex-col gap-3"><Controller- name="name"control={control}+ name="name"render={({ field, fieldState: { error } }) => (- <FormControl- helperText="Name must be slug-friendly"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Name"- >- <Input autoFocus placeholder="my-account" {...field} />- </FormControl>+ <Field>+ <FieldLabel>Name</FieldLabel>+ <FieldContent>+ <div className="relative">+ <UnstableInput+ {...field}+ autoFocus+ isError={Boolean(error)}+ placeholder="my-discovery-source"+ />+ </div>+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/>+<Controllername="description"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Description"- >- <TextArea {...field} />- </FormControl>+ <Field>+ <FieldLabel>Description</FieldLabel>+ <FieldContent>+ <TextArea {...field} className="max-h-32" />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/>- </>+ </div>);};diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/KubernetesAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/KubernetesAccountForm.tsxindex 9f776ce686..88cbc6da1e 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/KubernetesAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/KubernetesAccountForm.tsx@@ -2,7 +2,8 @@ import { Controller, FormProvider, useForm, useFormContext } from "react-hook-foimport { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, FormControl, ModalClose, TextArea } from "@app/components/v2";+import { FormControl, TextArea } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { KubernetesAuthMethod, PamResourceType, TKubernetesAccount } from "@app/hooks/api/pam";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";@@ -14,6 +15,7 @@ type Props = {resourceId?: string;resourceType?: PamResourceType;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const KubernetesServiceAccountTokenCredentialsSchema = z.object({@@ -60,7 +62,7 @@ const KubernetesAccountFields = ({ isUpdate }: { isUpdate: boolean }) => {);};-export const KubernetesAccountForm = ({ account, onSubmit }: Props) => {+export const KubernetesAccountForm = ({ account, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(account);const form = useForm<FormData>({@@ -91,30 +93,29 @@ export const KubernetesAccountForm = ({ account, onSubmit }: Props) => {return (<FormProvider {...form}><form+ className="flex flex-1 flex-col overflow-hidden"onSubmit={(e) => {handleSubmit(onSubmit)(e);}}>- <GenericAccountFields />- <KubernetesAccountFields isUpdate={isUpdate} />- <MetadataFields />- <div className="mt-6 flex items-center">+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericAccountFields />+ <KubernetesAccountFields isUpdate={isUpdate} />+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Account" : "Create Account"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={() => closeSheet()} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MetadataFields.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MetadataFields.tsxindex e998f4fd04..ede16a6a73 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MetadataFields.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MetadataFields.tsx@@ -4,5 +4,5 @@ import { MetadataForm } from "@app/pages/secret-manager/SecretDashboardPage/compexport const MetadataFields = () => {const { control } = useFormContext();- return <MetadataForm control={control} />;+ return <MetadataForm control={control} title={undefined} />;};diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MySQLAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MySQLAccountForm.tsxindex 9d232d2d53..8030e2d4eb 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MySQLAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/MySQLAccountForm.tsx@@ -2,7 +2,7 @@ import { FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, ModalClose } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { PamResourceType, TMySQLAccount } from "@app/hooks/api/pam";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";@@ -17,6 +17,7 @@ type Props = {resourceId?: string;resourceType?: PamResourceType;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const formSchema = genericAccountFieldsSchema.extend({@@ -26,7 +27,7 @@ const formSchema = genericAccountFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const MySQLAccountForm = ({ account, onSubmit }: Props) => {+export const MySQLAccountForm = ({ account, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(account);const form = useForm<FormData>({@@ -49,28 +50,26 @@ export const MySQLAccountForm = ({ account, onSubmit }: Props) => {return (<FormProvider {...form}>- <form onSubmit={handleSubmit(onSubmit)}>- <GenericAccountFields />- <SqlAccountFields isUpdate={isUpdate} />- <RequireMfaField />- <MetadataFields />- <div className="mt-6 flex items-center">+ <form className="flex flex-1 flex-col overflow-hidden" onSubmit={handleSubmit(onSubmit)}>+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericAccountFields />+ <SqlAccountFields isUpdate={isUpdate} />+ <RequireMfaField />+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Account" : "Create Account"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={() => closeSheet()} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsxindex 492ad259bf..e73de3a232 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx@@ -7,7 +7,6 @@ import {} from "@app/hooks/api/pam";import { DiscriminativePick } from "@app/types";-import { PamAccountHeader } from "../PamAccountHeader";import { ActiveDirectoryAccountForm } from "./ActiveDirectoryAccountForm";import { AwsIamAccountForm } from "./AwsIamAccountForm";import { KubernetesAccountForm } from "./KubernetesAccountForm";@@ -18,7 +17,7 @@ import { SshAccountForm } from "./SshAccountForm";import { WindowsAccountForm } from "./WindowsAccountForm";type FormProps = {- onComplete: (account: TPamAccount) => void;+ closeSheet: (account?: TPamAccount) => void;};type CreateFormProps = FormProps & {@@ -33,7 +32,7 @@ type UpdateFormProps = FormProps & {};const CreateForm = ({- onComplete,+ closeSheet,projectId,resourceId,resourceType,@@ -51,6 +50,7 @@ const CreateForm = ({}) => {const { internalMetadata, ...rest } = formData;+ console.log(rest);const account = await createPamAccount.mutateAsync({...rest,folderId,@@ -63,7 +63,7 @@ const CreateForm = ({text: "Successfully created account",type: "success"});- onComplete(account);+ closeSheet(account);};switch (resourceType) {@@ -71,30 +71,43 @@ const CreateForm = ({return (<PostgresAccountFormonSubmit={onSubmit}+ closeSheet={closeSheet}resourceId={resourceId}resourceType={resourceType}/>);case PamResourceType.MySQL:return (- <MySQLAccountForm onSubmit={onSubmit} resourceId={resourceId} resourceType={resourceType} />+ <MySQLAccountForm+ onSubmit={onSubmit}+ closeSheet={closeSheet}+ resourceId={resourceId}+ resourceType={resourceType}+ />);case PamResourceType.Redis:return (<RedisAccountFormonSubmit={onSubmit as Parameters<typeof RedisAccountForm>[0]["onSubmit"]}+ closeSheet={closeSheet}resourceId={resourceId}resourceType={resourceType}/>);case PamResourceType.SSH:return (- <SshAccountForm onSubmit={onSubmit} resourceId={resourceId} resourceType={resourceType} />+ <SshAccountForm+ onSubmit={onSubmit}+ closeSheet={closeSheet}+ resourceId={resourceId}+ resourceType={resourceType}+ />);case PamResourceType.Kubernetes:return (<KubernetesAccountFormonSubmit={onSubmit}+ closeSheet={closeSheet}resourceId={resourceId}resourceType={resourceType}/>@@ -103,6 +116,7 @@ const CreateForm = ({return (<AwsIamAccountFormonSubmit={onSubmit}+ closeSheet={closeSheet}resourceId={resourceId}resourceType={resourceType}/>@@ -111,6 +125,7 @@ const CreateForm = ({return (<WindowsAccountFormonSubmit={onSubmit}+ closeSheet={closeSheet}resourceId={resourceId}resourceType={resourceType}/>@@ -119,6 +134,7 @@ const CreateForm = ({return (<ActiveDirectoryAccountFormonSubmit={onSubmit}+ closeSheet={closeSheet}resourceId={resourceId}resourceType={resourceType}/>@@ -128,7 +144,7 @@ const CreateForm = ({}};-const UpdateForm = ({ account, onComplete }: UpdateFormProps) => {+const UpdateForm = ({ account, closeSheet }: UpdateFormProps) => {const updatePamAccount = useUpdatePamAccount();const onSubmit = async (@@ -141,6 +157,7 @@ const UpdateForm = ({ account, onComplete }: UpdateFormProps) => {}) => {const { internalMetadata, ...rest } = formData;+ console.log(rest);const updatedAccount = await updatePamAccount.mutateAsync({accountId: account.id,resourceType: account.resource.resourceType,@@ -151,67 +168,82 @@ const UpdateForm = ({ account, onComplete }: UpdateFormProps) => {text: "Successfully updated account",type: "success"});- onComplete(updatedAccount);+ closeSheet(updatedAccount);};switch (account.resource.resourceType) {case PamResourceType.Postgres:- return <PostgresAccountForm account={account as any} onSubmit={onSubmit} />;+ return (+ <PostgresAccountForm account={account as any} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.MySQL:- return <MySQLAccountForm account={account as any} onSubmit={onSubmit} />;+ return (+ <MySQLAccountForm account={account as any} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.Redis:return (<RedisAccountFormaccount={account as any}onSubmit={onSubmit as Parameters<typeof RedisAccountForm>[0]["onSubmit"]}+ closeSheet={closeSheet}/>);case PamResourceType.SSH:- return <SshAccountForm account={account as any} onSubmit={onSubmit} />;+ return (+ <SshAccountForm account={account as any} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.Kubernetes:- return <KubernetesAccountForm account={account as any} onSubmit={onSubmit} />;+ return (+ <KubernetesAccountForm+ account={account as any}+ onSubmit={onSubmit}+ closeSheet={closeSheet}+ />+ );case PamResourceType.AwsIam:- return <AwsIamAccountForm account={account as any} onSubmit={onSubmit} />;+ return (+ <AwsIamAccountForm account={account as any} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.Windows:- return <WindowsAccountForm account={account as any} onSubmit={onSubmit} />;+ return (+ <WindowsAccountForm account={account as any} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.ActiveDirectory:- return <ActiveDirectoryAccountForm account={account as any} onSubmit={onSubmit} />;+ return (+ <ActiveDirectoryAccountForm+ account={account as any}+ onSubmit={onSubmit}+ closeSheet={closeSheet}+ />+ );default:throw new Error(`Unhandled resource: ${account.resource.resourceType}`);}};type Props = {- onBack?: () => void;projectId: string;} & FormProps &(| {account: TPamAccount;resourceId?: undefined;- resourceName?: undefined;resourceType?: undefined;folderId?: undefined;}| {account?: undefined;resourceId: string;- resourceName: string;resourceType: PamResourceType;folderId?: string;});-export const PamAccountForm = ({ onBack, projectId, ...props }: Props) => {- const { account, resourceName, resourceType } = props;+export const PamAccountForm = ({ projectId, ...props }: Props) => {+ const { account } = props;return (- <div>- <PamAccountHeader- resourceName={account ? account.resource.name : resourceName}- resourceType={account ? account.resource.resourceType : resourceType}- onBack={onBack}- />+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden">{account ? (<UpdateForm {...props} account={account} />) : (diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsxindex 4337628cd3..e7a8133c45 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx@@ -2,7 +2,7 @@ import { FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, ModalClose } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { PamResourceType, TPostgresAccount } from "@app/hooks/api/pam";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";@@ -17,6 +17,7 @@ type Props = {resourceId?: string;resourceType?: PamResourceType;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const formSchema = genericAccountFieldsSchema.extend({@@ -26,7 +27,7 @@ const formSchema = genericAccountFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const PostgresAccountForm = ({ account, onSubmit }: Props) => {+export const PostgresAccountForm = ({ account, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(account);const form = useForm<FormData>({@@ -49,32 +50,26 @@ export const PostgresAccountForm = ({ account, onSubmit }: Props) => {return (<FormProvider {...form}>- <form- onSubmit={(e) => {- handleSubmit(onSubmit)(e);- }}- >- <GenericAccountFields />- <SqlAccountFields isUpdate={isUpdate} />- <RequireMfaField />- <MetadataFields />- <div className="mt-6 flex items-center">+ <form className="flex flex-1 flex-col overflow-hidden" onSubmit={handleSubmit(onSubmit)}>+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericAccountFields />+ <SqlAccountFields isUpdate={isUpdate} />+ <RequireMfaField />+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">- {isUpdate ? "Update Account" : "Create Account"}+ {isUpdate ? "Update Account" : "Add Account"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={() => closeSheet()} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/RedisAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/RedisAccountForm.tsxindex 6d59bcf6e2..aec2e68d29 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/RedisAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/RedisAccountForm.tsx@@ -3,7 +3,8 @@ import { Controller, FormProvider, useForm, useWatch } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, FormControl, Input, ModalClose, Switch } from "@app/components/v2";+import { FormControl, Input, Switch } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { PamResourceType, TRedisAccount } from "@app/hooks/api/pam";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";@@ -59,9 +60,10 @@ type Props = {resourceId?: string;resourceType?: PamResourceType;onSubmit: (formData: SubmitData) => Promise<void>;+ closeSheet: () => void;};-export const RedisAccountForm = ({ account, onSubmit }: Props) => {+export const RedisAccountForm = ({ account, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(account);const form = useForm<FormData>({@@ -125,103 +127,102 @@ export const RedisAccountForm = ({ account, onSubmit }: Props) => {return (<FormProvider {...form}><form+ className="flex flex-1 flex-col overflow-hidden"onSubmit={(e) => {handleSubmit(handleFormSubmit)(e);}}>- <GenericAccountFields />- <Controller- name="credentialsEnabled"- control={control}- render={({ field: { value, onChange } }) => (- <div className="mt-4 mb-4">- <Switch- id="credentials-enabled"- isChecked={value}- onCheckedChange={(checked) => {- onChange(checked);- if (checked) {- setValue("credentials.username", "", { shouldDirty: true });- setValue("credentials.password", "", { shouldDirty: true });- } else {- setValue("credentials.username", undefined, { shouldDirty: true });- setValue("credentials.password", undefined, { shouldDirty: true });- clearErrors("credentials");- }- form.trigger("credentials");- }}- >- Use Credentials- </Switch>+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericAccountFields />+ <Controller+ name="credentialsEnabled"+ control={control}+ render={({ field: { value, onChange } }) => (+ <div className="mt-4 mb-4">+ <Switch+ id="credentials-enabled"+ isChecked={value}+ onCheckedChange={(checked) => {+ onChange(checked);+ if (checked) {+ setValue("credentials.username", "", { shouldDirty: true });+ setValue("credentials.password", "", { shouldDirty: true });+ } else {+ setValue("credentials.username", undefined, { shouldDirty: true });+ setValue("credentials.password", undefined, { shouldDirty: true });+ clearErrors("credentials");+ }+ form.trigger("credentials");+ }}+ >+ Use Credentials+ </Switch>+ </div>+ )}+ />+ {credentialsEnabled && (+ <div className="mt-4 flex gap-2">+ <Controller+ name="credentials.username"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="flex-1"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Username"+ >+ <Input {...field} autoComplete="off" />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.password"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="flex-1"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Password"+ >+ <Input+ {...field}+ type={showPassword ? "text" : "password"}+ autoComplete="new-password"+ onFocus={() => {+ if (isUpdate && field.value === UNCHANGED_PASSWORD_SENTINEL) {+ field.onChange("");+ }+ setShowPassword(true);+ }}+ onBlur={() => {+ if (isUpdate && field.value === "") {+ field.onChange(UNCHANGED_PASSWORD_SENTINEL);+ }+ setShowPassword(false);+ }}+ />+ </FormControl>+ )}+ /></div>)}- />- {credentialsEnabled && (- <div className="mt-4 flex gap-2">- <Controller- name="credentials.username"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Username"- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />- <Controller- name="credentials.password"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Password"- >- <Input- {...field}- type={showPassword ? "text" : "password"}- autoComplete="new-password"- onFocus={() => {- if (isUpdate && field.value === UNCHANGED_PASSWORD_SENTINEL) {- field.onChange("");- }- setShowPassword(true);- }}- onBlur={() => {- if (isUpdate && field.value === "") {- field.onChange(UNCHANGED_PASSWORD_SENTINEL);- }- setShowPassword(false);- }}- />- </FormControl>- )}- />- </div>- )}- <MetadataFields />- <div className="mt-6 flex items-center">+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Account" : "Create Account"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={() => closeSheet()} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/RequireMfaField.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/RequireMfaField.tsxindex 1bd21d2e1c..18ecb1b6e8 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/RequireMfaField.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/RequireMfaField.tsx@@ -1,6 +1,6 @@import { Controller, useFormContext } from "react-hook-form";-import { FormControl, Switch } from "@app/components/v2";+import { Field, FieldError, FieldLabel, Switch } from "@app/components/v3";export const RequireMfaField = () => {const { control } = useFormContext<{@@ -8,24 +8,21 @@ export const RequireMfaField = () => {}>();return (- <div className="flex h-9 w-fit items-center gap-3">- <Controller- control={control}- name="requireMfa"- defaultValue={false}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error)} errorText={error?.message} className="mb-0">- <Switch- className="ml-0 bg-mineshaft-400/80 shadow-inner data-[state=checked]:bg-green/80"- id="require-mfa"- thumbClassName="bg-mineshaft-800"- onCheckedChange={onChange}- isChecked={value ?? false}- />- </FormControl>- )}- />- <span className="text-sm">Require MFA for Access</span>- </div>+ <Controller+ control={control}+ name="requireMfa"+ defaultValue={false}+ render={({ field, fieldState: { error } }) => (+ <Field orientation="horizontal">+ <FieldLabel>Require MFA for Access</FieldLabel>+ <Switch+ variant="project"+ checked={field.value || false}+ onCheckedChange={field.onChange}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />);};diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/SshAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/SshAccountForm.tsxindex 3206c145bf..5c1ca707d9 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/SshAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/SshAccountForm.tsx@@ -3,15 +3,8 @@ import { Controller, FormProvider, useForm, useFormContext, useWatch } from "reaimport { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import {- Button,- FormControl,- Input,- ModalClose,- Select,- SelectItem,- TextArea-} from "@app/components/v2";+import { FormControl, Input, Select, SelectItem, TextArea } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { PamResourceType, TSSHAccount } from "@app/hooks/api/pam";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";import { SSHAuthMethod } from "@app/hooks/api/pam/types/ssh-resource";@@ -26,6 +19,7 @@ type Props = {resourceId?: string;resourceType?: PamResourceType;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const SSHPasswordCredentialsSchema = z.object({@@ -191,7 +185,7 @@ const SshAccountFields = ({ isUpdate, resourceId }: { isUpdate: boolean; resourc);};-export const SshAccountForm = ({ account, resourceId, onSubmit }: Props) => {+export const SshAccountForm = ({ account, resourceId, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(account);const effectiveResourceId = resourceId || account?.resource.id || "";@@ -242,31 +236,30 @@ export const SshAccountForm = ({ account, resourceId, onSubmit }: Props) => {return (<FormProvider {...form}><form+ className="flex flex-1 flex-col overflow-hidden"onSubmit={(e) => {handleSubmit(onSubmit)(e);}}>- <GenericAccountFields />- <SshAccountFields isUpdate={isUpdate} resourceId={effectiveResourceId} />- <RequireMfaField />- <MetadataFields />- <div className="mt-6 flex items-center">+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericAccountFields />+ <SshAccountFields isUpdate={isUpdate} resourceId={effectiveResourceId} />+ <RequireMfaField />+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Account" : "Create Account"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={() => closeSheet()} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/WindowsAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/WindowsAccountForm.tsxindex 43ceabc21d..d223bbe9eb 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/WindowsAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/WindowsAccountForm.tsx@@ -3,7 +3,8 @@ import { Controller, FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, FormControl, Input, ModalClose, Select, SelectItem } from "@app/components/v2";+import { FormControl, Input, Select, SelectItem } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { PamResourceType, TWindowsAccount } from "@app/hooks/api/pam";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";import { WindowsAccountType } from "@app/hooks/api/pam/types/windows-server-resource";@@ -17,6 +18,7 @@ type Props = {resourceId?: string;resourceType?: PamResourceType;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const formSchema = genericAccountFieldsSchema.extend({@@ -32,7 +34,7 @@ const formSchema = genericAccountFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const WindowsAccountForm = ({ account, onSubmit }: Props) => {+export const WindowsAccountForm = ({ account, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(account);const [showPassword, setShowPassword] = useState(false);@@ -68,96 +70,94 @@ export const WindowsAccountForm = ({ account, onSubmit }: Props) => {return (<FormProvider {...form}>- <form onSubmit={handleSubmit(onSubmit)}>- <GenericAccountFields />- <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3">- <Controller- name="internalMetadata.accountType"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- className="mb-3"- isError={Boolean(error?.message)}- errorText={error?.message}- label="Account Type"- >- <Select- value={value}- onValueChange={onChange}- className="w-full border border-mineshaft-500"+ <form className="flex flex-1 flex-col overflow-hidden" onSubmit={handleSubmit(onSubmit)}>+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericAccountFields />+ <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3">+ <Controller+ name="internalMetadata.accountType"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ className="mb-3"+ isError={Boolean(error?.message)}+ errorText={error?.message}+ label="Account Type">- <SelectItem value={WindowsAccountType.User}>User Account</SelectItem>- <SelectItem value={WindowsAccountType.Service}>Service Account</SelectItem>- </Select>- </FormControl>- )}- />+ <Select+ value={value}+ onValueChange={onChange}+ className="w-full border border-mineshaft-500"+ >+ <SelectItem value={WindowsAccountType.User}>User Account</SelectItem>+ <SelectItem value={WindowsAccountType.Service}>Service Account</SelectItem>+ </Select>+ </FormControl>+ )}+ />- <Controller- name="credentials.username"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="mb-3"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Username"- >- <Input {...field} autoComplete="off" />- </FormControl>- )}- />+ <Controller+ name="credentials.username"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="mb-3"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Username"+ >+ <Input {...field} autoComplete="off" />+ </FormControl>+ )}+ />- <Controller- name="credentials.password"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="mb-0"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Password"- >- <Input- {...field}- type={showPassword ? "text" : "password"}- autoComplete="new-password"- onFocus={() => {- if (isUpdate && field.value === UNCHANGED_PASSWORD_SENTINEL) {- field.onChange("");- }- setShowPassword(true);- }}- onBlur={() => {- if (isUpdate && field.value === "") {- field.onChange(UNCHANGED_PASSWORD_SENTINEL);- }- setShowPassword(false);- }}- />- </FormControl>- )}- />+ <Controller+ name="credentials.password"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="mb-0"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Password"+ >+ <Input+ {...field}+ type={showPassword ? "text" : "password"}+ autoComplete="new-password"+ onFocus={() => {+ if (isUpdate && field.value === UNCHANGED_PASSWORD_SENTINEL) {+ field.onChange("");+ }+ setShowPassword(true);+ }}+ onBlur={() => {+ if (isUpdate && field.value === "") {+ field.onChange(UNCHANGED_PASSWORD_SENTINEL);+ }+ setShowPassword(false);+ }}+ />+ </FormControl>+ )}+ />+ </div>+ <RequireMfaField />+ <MetadataFields /></div>- <RequireMfaField />- <MetadataFields />- <div className="mt-6 flex items-center">+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Account" : "Create Account"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={() => closeSheet()} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/shared/SqlAccountFields.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/shared/SqlAccountFields.tsxindex 8d507c01ac..c9dc042b48 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/shared/SqlAccountFields.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/shared/SqlAccountFields.tsx@@ -1,7 +1,7 @@import { useEffect, useState } from "react";import { Controller, useFormContext, useWatch } from "react-hook-form";-import { FormControl, Input } from "@app/components/v2";+import { Field, FieldContent, FieldError, FieldLabel, UnstableInput } from "@app/components/v3";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";export const SqlAccountFields = ({ isUpdate }: { isUpdate: boolean }) => {@@ -16,49 +16,55 @@ export const SqlAccountFields = ({ isUpdate }: { isUpdate: boolean }) => {}, [password]);return (- <div className="flex gap-2">+ <div className="grid grid-cols-2 gap-2"><Controllername="credentials.username"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Username"- >- <Input {...field} autoComplete="off" />- </FormControl>+ <Field>+ <FieldLabel>Username</FieldLabel>+ <FieldContent>+ <UnstableInput+ {...field}+ isError={Boolean(error)}+ autoComplete="off"+ placeholder="user"+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/>+<Controllername="credentials.password"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Password"- >- <Input- {...field}- type={showPassword ? "text" : "password"}- autoComplete="new-password"- onFocus={() => {- if (isUpdate && field.value === UNCHANGED_PASSWORD_SENTINEL) {- field.onChange("");- }- setShowPassword(true);- }}- onBlur={() => {- if (isUpdate && field.value === "") {- field.onChange(UNCHANGED_PASSWORD_SENTINEL);- }- setShowPassword(false);- }}- />- </FormControl>+ <Field>+ <FieldLabel>Password</FieldLabel>+ <FieldContent>+ <UnstableInput+ {...field}+ placeholder="••••••"+ isError={Boolean(error)}+ autoComplete="new-password"+ type={showPassword ? "text" : "password"}+ onFocus={() => {+ if (isUpdate && field.value === UNCHANGED_PASSWORD_SENTINEL) {+ field.onChange("");+ }+ setShowPassword(true);+ }}+ onBlur={() => {+ if (isUpdate && field.value === "") {+ field.onChange(UNCHANGED_PASSWORD_SENTINEL);+ }+ setShowPassword(false);+ }}+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/></div>diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountHeader.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountHeader.tsxdeleted file mode 100644index 72120af8ec..0000000000--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountHeader.tsx+++ /dev/null@@ -1,47 +0,0 @@-import { DocumentationLinkBadge } from "@app/components/v3";-import { PAM_RESOURCE_TYPE_MAP, PamResourceType } from "@app/hooks/api/pam";--const PAM_ACCOUNT_DOCS_MAP: Partial<Record<PamResourceType, string>> = {- [PamResourceType.AwsIam]: "aws-iam#create-pam-accounts"-};--type Props = {- resourceName: string;- resourceType: PamResourceType;- onBack?: () => void;-};--export const PamAccountHeader = ({ resourceName, resourceType, onBack }: Props) => {- const details = PAM_RESOURCE_TYPE_MAP[resourceType];- const docsPath = PAM_ACCOUNT_DOCS_MAP[resourceType];-- return (- <div className="mb-4 flex w-full items-start gap-2 border-b border-mineshaft-500 pb-4">- <img- alt={`${details.name} logo`}- src={`/images/integrations/${details.image}`}- className="h-12 w-12 rounded-md bg-bunker-500 p-2"- />- <div>- <div className="flex items-center gap-x-2 text-mineshaft-300">- {resourceName}- {docsPath && (- <DocumentationLinkBadge- href={`https://infisical.com/docs/documentation/platform/pam/resources/${docsPath}`}- />- )}- </div>- <p className="text-sm leading-4 text-mineshaft-400">{details.name} resource</p>- </div>- {onBack && (- <button- type="button"- className="mt-1 ml-auto text-xs text-mineshaft-400 underline underline-offset-2 hover:text-mineshaft-300"- onClick={onBack}- >- Select another resource- </button>- )}- </div>- );-};diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAddAccountModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAddAccountModal.tsxindex 5dd2cb6ac3..2bc05eebc4 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAddAccountModal.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAddAccountModal.tsx@@ -1,10 +1,7 @@-import { useState } from "react";--import { Modal, ModalContent } from "@app/components/v2";+import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@app/components/v3";import { PamResourceType, TPamAccount } from "@app/hooks/api/pam";import { PamAccountForm } from "./PamAccountForm/PamAccountForm";-import { ResourceSelect } from "./ResourceSelect";type Props = {isOpen: boolean;@@ -12,7 +9,7 @@ type Props = {projectId: string;onComplete?: (account: TPamAccount) => void;currentFolderId: string | null;- defaultResource?: {+ resource: {id: string;name: string;resourceType: PamResourceType;@@ -25,52 +22,28 @@ export const PamAddAccountModal = ({projectId,onComplete,currentFolderId,- defaultResource+ resource}: Props) => {- const [selectedResource, setSelectedResource] = useState<{- id: string;- name: string;- resourceType: PamResourceType;- } | null>(defaultResource ?? null);-- const handleOpenChange = (open: boolean) => {- if (!open) {- // Reset state when modal closes- setSelectedResource(defaultResource ?? null);- }- onOpenChange(open);- };-return (- <Modal isOpen={isOpen} onOpenChange={handleOpenChange}>- <ModalContent- className="max-w-2xl"- title="Add Account"- subTitle={- selectedResource- ? "Add account under a select resource."- : "Select a resource to add an account under."- }- bodyClassName={selectedResource ? undefined : "overflow-visible"}- >- {selectedResource ? (+ <Sheet open={isOpen} onOpenChange={onOpenChange} modal={false}>+ <SheetContent className="flex h-full max-h-full flex-col gap-y-0 sm:max-w-lg">+ <SheetHeader className="border-b">+ <SheetTitle>Create Account</SheetTitle>+ <SheetDescription>Input account connection credentials</SheetDescription>+ </SheetHeader>+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden"><PamAccountForm- onComplete={(account) => {- if (onComplete) onComplete(account);+ closeSheet={(account) => {+ if (account && onComplete) onComplete(account);onOpenChange(false);- setSelectedResource(null);}}- onBack={defaultResource ? undefined : () => setSelectedResource(null)}- resourceId={selectedResource.id}- resourceName={selectedResource.name}- resourceType={selectedResource.resourceType}+ resourceId={resource.id}+ resourceType={resource.resourceType}projectId={projectId}folderId={currentFolderId ?? undefined}/>- ) : (- <ResourceSelect projectId={projectId} onSubmit={(e) => setSelectedResource(e.resource)} />- )}- </ModalContent>- </Modal>+ </div>+ </SheetContent>+ </Sheet>);};diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamUpdateAccountModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamUpdateAccountModal.tsxindex c2004d5750..25a87f99d8 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamUpdateAccountModal.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamUpdateAccountModal.tsx@@ -1,4 +1,4 @@-import { Modal, ModalContent } from "@app/components/v2";+import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@app/components/v3";import { TPamAccount } from "@app/hooks/api/pam";import { PamAccountForm } from "./PamAccountForm/PamAccountForm";@@ -13,14 +13,18 @@ export const PamUpdateAccountModal = ({ isOpen, onOpenChange, account }: Props)if (!account) return null;return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent className="max-w-2xl" title="Edit Account" subTitle="Update account details.">+ <Sheet open={isOpen} onOpenChange={onOpenChange} modal={false}>+ <SheetContent className="flex h-full max-h-full flex-col gap-y-0 sm:max-w-lg">+ <SheetHeader className="border-b">+ <SheetTitle>Edit Account</SheetTitle>+ <SheetDescription>Update account details.</SheetDescription>+ </SheetHeader><PamAccountForm- onComplete={() => onOpenChange(false)}+ closeSheet={() => onOpenChange(false)}account={account}projectId={account.projectId}/>- </ModalContent>- </Modal>+ </SheetContent>+ </Sheet>);};diff --git a/frontend/src/pages/pam/PamAccountsPage/components/ResourceSelect.tsx b/frontend/src/pages/pam/PamAccountsPage/components/ResourceSelect.tsxdeleted file mode 100644index d9667ddbf4..0000000000--- a/frontend/src/pages/pam/PamAccountsPage/components/ResourceSelect.tsx+++ /dev/null@@ -1,131 +0,0 @@-import { useState } from "react";-import { Controller, FormProvider, useForm } from "react-hook-form";-import { SingleValue } from "react-select";-import { zodResolver } from "@hookform/resolvers/zod";-import { z } from "zod";--import { Button, FilterableSelect, FormControl, ModalClose } from "@app/components/v2";-import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission } from "@app/context";-import { useDebounce, usePopUp } from "@app/hooks";-import { PamResourceType, useListPamResources } from "@app/hooks/api/pam";--import { PamAddResourceModal } from "../../PamResourcesPage/components/PamAddResourceModal";-import { PamResourceOption } from "./PamResourceOption";--type Props = {- onSubmit: (data: FormData) => void;- projectId: string;-};--const formSchema = z.object({- resource: z.object({- id: z.string(),- name: z.string(),- resourceType: z.nativeEnum(PamResourceType)- })-});--type FormData = z.infer<typeof formSchema>;--export const ResourceSelect = ({ onSubmit, projectId }: Props) => {- const { permission } = useProjectPermission();-- const [search, setSearch] = useState("");- const [debouncedSearch] = useDebounce(search, 350);-- const { isPending, data } = useListPamResources({- projectId,- limit: 100,- search: debouncedSearch- });-- const resources = data?.resources || [];-- const { popUp, handlePopUpToggle, handlePopUpOpen } = usePopUp(["addResource"] as const);-- const form = useForm<FormData>({- resolver: zodResolver(formSchema)- });-- const { handleSubmit, control, setValue } = form;-- const canCreateResource = permission.can(- ProjectPermissionActions.Create,- ProjectPermissionSub.PamResources- );-- return (- <>- <FormProvider {...form}>- <form- onSubmit={(e) => {- handleSubmit(onSubmit)(e);- }}- >- <Controller- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error)} errorText={error?.message} label="Resource">- <FilterableSelect- value={value}- inputValue={search}- onInputChange={(val, actionMeta) => {- if (actionMeta.action === "input-change") {- setSearch(val);- }- }}- onChange={(newValue) => {- if ((newValue as SingleValue<{ id: string }>)?.id === "_create") {- handlePopUpOpen("addResource");- onChange(null);- return;- }-- // Clear search when a value is selected so the selected label is shown- setSearch("");- onChange(newValue);- }}- isLoading={isPending}- options={[- ...(canCreateResource- ? [- {- id: "_create",- name: "Create Resource",- // This is just to make typescript happy. Does not actually do anything- resourceType: PamResourceType.Postgres- }- ]- : []),- ...(resources ?? [])- ]}- placeholder="Select resource..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.id}- components={{ Option: PamResourceOption }}- />- </FormControl>- )}- control={control}- name="resource"- />- <div className="mt-6 flex items-center">- <Button className="mr-4" size="sm" type="submit" colorSchema="secondary">- Continue- </Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>- </form>- </FormProvider>- <PamAddResourceModal- isOpen={popUp.addResource.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("addResource", isOpen)}- projectId={projectId}- onComplete={(resource) => setValue("resource", resource)}- />- </>- );-};diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/PamDiscoverySourceHeader.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/PamDiscoverySourceHeader.tsxindex ba745bce85..f861615f4f 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/PamDiscoverySourceHeader.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/PamDiscoverySourceHeader.tsx@@ -12,24 +12,22 @@ export const PamDiscoverySourceHeader = ({ discoveryType, onBack }: Props) => {const details = PAM_DISCOVERY_TYPE_MAP[discoveryType];return (- <div className="flex pb-0">- <div className="flex w-full items-center gap-2.5 border-b border-border p-3">- <img- alt={`${details.name} logo`}- src={`/images/integrations/${details.image}`}- className="size-9"- />- <div className="flex w-full flex-col gap-1">- <Label>{details.name}</Label>- <p className="text-xs text-muted">Discovery Source</p>- </div>- {onBack && (- <Button size="xs" variant="neutral" onClick={onBack}>- <PencilIcon />- Change- </Button>- )}+ <div className="flex w-full items-center gap-2.5 border-b border-border p-3">+ <img+ alt={`${details.name} logo`}+ src={`/images/integrations/${details.image}`}+ className="size-9"+ />+ <div className="flex w-full flex-col gap-1">+ <Label>{details.name}</Label>+ <p className="text-xs text-muted">Discovery Source</p></div>+ {onBack && (+ <Button size="xs" variant="neutral" onClick={onBack}>+ <PencilIcon />+ Change+ </Button>+ )}</div>);};diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/PamUpdateDiscoverySourceModal.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/PamUpdateDiscoverySourceModal.tsxindex 746113b3c3..d3281f8bc1 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/PamUpdateDiscoverySourceModal.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/PamUpdateDiscoverySourceModal.tsx@@ -1,10 +1,4 @@-import {- Sheet,- SheetContent,- SheetDescription,- SheetHeader,- SheetTitle-} from "@app/components/v3";+import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@app/components/v3";import { PAM_DISCOVERY_TYPE_MAP, TPamDiscoverySource } from "@app/hooks/api/pamDiscovery";import { PamDiscoverySourceForm } from "./PamDiscoverySourceForm/PamDiscoverySourceForm";@@ -25,7 +19,7 @@ export const PamUpdateDiscoverySourceModal = ({ isOpen, onOpenChange, source }:<SheetTitle>Edit Discovery Source</SheetTitle><SheetDescription>Update details for this {PAM_DISCOVERY_TYPE_MAP[source.discoveryType].name} discovery- source.+ source</SheetDescription></SheetHeader><PamDiscoverySourceFormdiff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsxindex e1cedfc3de..10e3a53198 100644--- a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx@@ -581,7 +581,7 @@ export const PamResourceAccountsSection = ({ resource }: Props) => {onOpenChange={(isOpen) => handlePopUpToggle("addAccount", isOpen)}projectId={projectId!}currentFolderId={null}- defaultResource={resource}+ resource={resource}/><PamAccessAccountModaldiff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamAddResourceModal.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamAddResourceModal.tsxindex 498ed9b045..3fc65cdf71 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamAddResourceModal.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamAddResourceModal.tsx@@ -1,6 +1,6 @@-import { useState } from "react";+import { Dispatch, SetStateAction, useState } from "react";-import { Modal, ModalContent } from "@app/components/v2";+import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@app/components/v3";import { PamResourceType, TPamResource } from "@app/hooks/api/pam";import { SshCaSetupModal } from "../../components/SshCaSetupModal";@@ -15,17 +15,22 @@ type Props = {};type ContentProps = {- onComplete: (resource: TPamResource) => void;+ closeSheet: (resource?: TPamResource) => void;projectId: string;+ selectedResourceType: PamResourceType | null;+ setSelectedResourceType: Dispatch<SetStateAction<PamResourceType | null>>;};-const Content = ({ onComplete, projectId }: ContentProps) => {- const [selectedResourceType, setSelectedResourceType] = useState<PamResourceType | null>(null);-+const Content = ({+ closeSheet,+ projectId,+ selectedResourceType,+ setSelectedResourceType+}: ContentProps) => {if (selectedResourceType) {return (<PamResourceForm- onComplete={onComplete}+ closeSheet={closeSheet}onBack={() => setSelectedResourceType(null)}resourceType={selectedResourceType}projectId={projectId}@@ -37,6 +42,7 @@ const Content = ({ onComplete, projectId }: ContentProps) => {};export const PamAddResourceModal = ({ isOpen, onOpenChange, projectId, onComplete }: Props) => {+ const [selectedResourceType, setSelectedResourceType] = useState<PamResourceType | null>(null);const [caSetupModalResourceId, setCaSetupModalResourceId] = useState<string | null>(null);const handleCaSetupModalClose = () => {@@ -45,26 +51,39 @@ export const PamAddResourceModal = ({ isOpen, onOpenChange, projectId, onCompletreturn (<>- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent- className="max-w-2xl"- title="Add Resource"- subTitle="Select a resource to add."- >+ <Sheet+ open={isOpen}+ onOpenChange={(e) => {+ onOpenChange(e);+ setSelectedResourceType(null);+ }}+ modal={false}+ >+ <SheetContent className="flex h-full max-h-full flex-col gap-y-0 sm:max-w-lg">+ <SheetHeader className="border-b">+ <SheetTitle>Create Resource</SheetTitle>+ <SheetDescription>+ {selectedResourceType+ ? "Input resource connection details"+ : "Select a resource type"}+ </SheetDescription>+ </SheetHeader><ContentprojectId={projectId}- onComplete={(resource) => {- if (onComplete) onComplete(resource);+ closeSheet={(resource) => {+ if (resource && onComplete) onComplete(resource);onOpenChange(false);+ setSelectedResourceType(null);- // Show CA setup modal for SSH resources- if (resource.resourceType === PamResourceType.SSH) {+ if (resource?.resourceType === PamResourceType.SSH) {setCaSetupModalResourceId(resource.id);}}}+ selectedResourceType={selectedResourceType}+ setSelectedResourceType={setSelectedResourceType}/>- </ModalContent>- </Modal>+ </SheetContent>+ </Sheet>{caSetupModalResourceId && (<SshCaSetupModalisOpen={Boolean(caSetupModalResourceId)}diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/ActiveDirectoryResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/ActiveDirectoryResourceForm.tsxindex fa9e560777..6a79f21fe8 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/ActiveDirectoryResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/ActiveDirectoryResourceForm.tsx@@ -2,7 +2,15 @@ import { Controller, FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, FormControl, Input, ModalClose } from "@app/components/v2";+import {+ Button,+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ SheetFooter,+ UnstableInput+} from "@app/components/v3";import { PamResourceType, TActiveDirectoryResource } from "@app/hooks/api/pam";import { GenericResourceFields, genericResourceFieldsSchema } from "./GenericResourceFields";@@ -11,6 +19,7 @@ import { MetadataFields } from "./MetadataFields";type Props = {resource?: TActiveDirectoryResource;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const formSchema = genericResourceFieldsSchema.extend({@@ -24,19 +33,25 @@ const formSchema = genericResourceFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const ActiveDirectoryResourceForm = ({ resource, onSubmit }: Props) => {+export const ActiveDirectoryResourceForm = ({ resource, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(resource);const form = useForm<FormData>({resolver: zodResolver(formSchema),- defaultValues: resource ?? {- resourceType: PamResourceType.ActiveDirectory,- connectionDetails: {- domain: "",- dcAddress: "",- port: 389- }- }+ defaultValues: resource+ ? {+ ...resource,+ gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined+ }+ : {+ resourceType: PamResourceType.ActiveDirectory,+ gateway: undefined,+ connectionDetails: {+ domain: "",+ dcAddress: "",+ port: 389+ }+ }});const {@@ -47,21 +62,27 @@ export const ActiveDirectoryResourceForm = ({ resource, onSubmit }: Props) => {return (<FormProvider {...form}>- <form onSubmit={handleSubmit(onSubmit)}>- <GenericResourceFields />- <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3 pb-0">+ <form+ onSubmit={handleSubmit((data) => onSubmit(data as FormData))}+ className="flex flex-1 flex-col overflow-hidden"+ >+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericResourceFields /><Controllername="connectionDetails.domain"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- className="mb-3"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Domain"- >- <Input placeholder="corp.example.com" {...field} />- </FormControl>+ <Field>+ <FieldLabel>Domain</FieldLabel>+ <FieldContent>+ <UnstableInput+ {...field}+ isError={Boolean(error)}+ placeholder="corp.example.com"+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/><div className="flex items-start gap-2">@@ -69,50 +90,48 @@ export const ActiveDirectoryResourceForm = ({ resource, onSubmit }: Props) => {name="connectionDetails.dcAddress"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="DC Address"- >- <Input placeholder="10.0.1.10 or dc.corp.example.com" {...field} />- </FormControl>+ <Field className="flex-1">+ <FieldLabel>DC Address</FieldLabel>+ <FieldContent>+ <UnstableInput+ {...field}+ isError={Boolean(error)}+ placeholder="10.0.1.10 or dc.corp.example.com"+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/><Controllername="connectionDetails.port"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- className="w-28"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Port"- >- <Input type="number" {...field} />- </FormControl>+ <Field className="w-28">+ <FieldLabel>Port</FieldLabel>+ <FieldContent>+ <UnstableInput type="number" {...field} isError={Boolean(error)} />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/></div>+ <MetadataFields /></div>- <MetadataFields />- <div className="mt-6 flex items-center">+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Details" : "Create Resource"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={closeSheet} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/AwsIamResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/AwsIamResourceForm.tsxindex 6c0680b3c6..b0c3b26891 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/AwsIamResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/AwsIamResourceForm.tsx@@ -4,17 +4,17 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";+import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@app/components/v2";+import { CopyButton } from "@app/components/v2/CopyButton";import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,Button,- FormControl,- Input,- ModalClose-} from "@app/components/v2";-import { CopyButton } from "@app/components/v2/CopyButton";+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ SheetFooter,+ UnstableInput+} from "@app/components/v3";import { useProject } from "@app/context";import { PamResourceType, TAwsIamResource } from "@app/hooks/api/pam";import { slugSchema } from "@app/lib/schemas";@@ -24,6 +24,7 @@ import { MetadataFields } from "./MetadataFields";type Props = {resource?: TAwsIamResource;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const arnRoleRegex = /^arn:aws:iam::\d{12}:role\/[\w+=,.@/-]+$/;@@ -57,7 +58,7 @@ type FormData = z.infer<typeof formSchema>;const INFISICAL_AWS_ACCOUNT_US = "381492033652";const INFISICAL_AWS_ACCOUNT_EU = "345594589636";-export const AwsIamResourceForm = ({ resource, onSubmit }: Props) => {+export const AwsIamResourceForm = ({ resource, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(resource);const { projectId } = useProject();@@ -104,131 +105,138 @@ export const AwsIamResourceForm = ({ resource, onSubmit }: Props) => {return (<FormProvider {...form}>- <form onSubmit={handleSubmit(onSubmit)}>- <Controller- name="name"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- helperText="Name must be slug-friendly"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Name"- >- <Input autoFocus placeholder="my-aws-console" {...field} />- </FormControl>- )}- />-- <Controller- name="connectionDetails.roleArn"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- helperText="The ARN of the Infisical Resource Role that can assume target roles"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Resource Role ARN"- >- <Input- placeholder="arn:aws:iam::123456789012:role/InfisicalResourceRole"- {...field}- />- </FormControl>- )}- />-- <Accordion- type="single"- collapsible- className="mt-4 w-full rounded-r border-l-2 border-l-primary bg-mineshaft-300/5"- >- <AccordionItem value="aws-iam-role-setup" className="border-b-0">- <AccordionTrigger className="px-4 py-2.5 hover:no-underline [&[data-state=open]]:pb-1">- <div className="flex items-center text-sm transition-colors duration-150 hover:text-primary">- <FontAwesomeIcon icon={faInfoCircle} size="sm" className="mr-1.5 text-primary" />- AWS IAM Role Setup- </div>- </AccordionTrigger>- <AccordionContent className="px-4 pb-2.5">- <p className="mb-3 text-sm text-mineshaft-300">- Before creating this resource, you need to set up an IAM role in your AWS account- that Infisical can assume. Follow these steps:- </p>-- <p className="mb-2 text-sm font-medium text-mineshaft-200">- Step 1: Create a permissions policy for assuming target roles- </p>- <p className="mb-3 text-sm text-mineshaft-300">- This policy allows the Resource Role to assume target roles. For simplicity, use a- wildcard to allow assuming any role in your account. For more granular control,- replace <code className="rounded bg-mineshaft-700 px-1 text-xs">*</code> with a- specific pattern like{" "}- <code className="rounded bg-mineshaft-700 px-1 text-xs">/pam-*</code> or{" "}- <code className="rounded bg-mineshaft-700 px-1 text-xs">/infisical-*</code>.- </p>- <div className="relative mb-4">- <div className="absolute top-1 right-1">- <CopyButton value={permissionsPolicy} size="sm" variant="plain" />+ <form onSubmit={handleSubmit(onSubmit)} className="flex flex-1 flex-col overflow-hidden">+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <Controller+ name="name"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>Name</FieldLabel>+ <FieldContent>+ <UnstableInput+ autoFocus+ placeholder="my-aws-console"+ {...field}+ isError={Boolean(error)}+ />+ <FieldError errors={[error]} />+ <p className="mt-1 text-xs text-mineshaft-400">Name must be slug-friendly</p>+ </FieldContent>+ </Field>+ )}+ />++ <Controller+ name="connectionDetails.roleArn"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>Resource Role ARN</FieldLabel>+ <FieldContent>+ <UnstableInput+ placeholder="arn:aws:iam::123456789012:role/InfisicalResourceRole"+ {...field}+ isError={Boolean(error)}+ />+ <FieldError errors={[error]} />+ <p className="mt-1 text-xs text-mineshaft-400">+ The ARN of the Infisical Resource Role that can assume target roles+ </p>+ </FieldContent>+ </Field>+ )}+ />++ <Accordion+ type="single"+ collapsible+ className="mt-4 w-full rounded-r border-l-2 border-l-primary bg-mineshaft-300/5"+ >+ <AccordionItem value="aws-iam-role-setup" className="border-b-0">+ <AccordionTrigger className="px-4 py-2.5 hover:no-underline [&[data-state=open]]:pb-1">+ <div className="flex items-center text-sm transition-colors duration-150 hover:text-primary">+ <FontAwesomeIcon icon={faInfoCircle} size="sm" className="mr-1.5 text-primary" />+ AWS IAM Role Setup</div>- <pre className="max-h-45 overflow-y-auto rounded-sm border border-mineshaft-600 bg-mineshaft-800 p-2 pr-8 text-xs whitespace-pre-wrap text-mineshaft-300">- {permissionsPolicy}- </pre>- </div>-- <p className="mb-2 text-sm font-medium text-mineshaft-200">- Step 2: Create the Resource Role with a trust policy- </p>- <p className="mb-3 text-sm text-mineshaft-300">- Create an IAM role (e.g.,{" "}- <code className="rounded bg-mineshaft-700 px-1 text-xs">InfisicalResourceRole</code>- ) with the permissions policy above and the following trust policy:- </p>- <div className="relative mb-4">- <div className="absolute top-1 right-3">- <CopyButton value={trustPolicy} size="sm" variant="plain" />+ </AccordionTrigger>+ <AccordionContent className="px-4 pb-2.5">+ <p className="mb-3 text-sm text-mineshaft-300">+ Before creating this resource, you need to set up an IAM role in your AWS account+ that Infisical can assume. Follow these steps:+ </p>++ <p className="mb-2 text-sm font-medium text-mineshaft-200">+ Step 1: Create a permissions policy for assuming target roles+ </p>+ <p className="mb-3 text-sm text-mineshaft-300">+ This policy allows the Resource Role to assume target roles. For simplicity, use a+ wildcard to allow assuming any role in your account. For more granular control,+ replace <code className="rounded bg-mineshaft-700 px-1 text-xs">*</code> with a+ specific pattern like{" "}+ <code className="rounded bg-mineshaft-700 px-1 text-xs">/pam-*</code> or{" "}+ <code className="rounded bg-mineshaft-700 px-1 text-xs">/infisical-*</code>.+ </p>+ <div className="relative mb-4">+ <div className="absolute top-1 right-1">+ <CopyButton value={permissionsPolicy} size="sm" variant="plain" />+ </div>+ <pre className="max-h-45 overflow-y-auto rounded-sm border border-mineshaft-600 bg-mineshaft-800 p-2 pr-8 text-xs whitespace-pre-wrap text-mineshaft-300">+ {permissionsPolicy}+ </pre>+ </div>++ <p className="mb-2 text-sm font-medium text-mineshaft-200">+ Step 2: Create the Resource Role with a trust policy+ </p>+ <p className="mb-3 text-sm text-mineshaft-300">+ Create an IAM role (e.g.,{" "}+ <code className="rounded bg-mineshaft-700 px-1 text-xs">+ InfisicalResourceRole+ </code>+ ) with the permissions policy above and the following trust policy:+ </p>+ <div className="relative mb-4">+ <div className="absolute top-1 right-3">+ <CopyButton value={trustPolicy} size="sm" variant="plain" />+ </div>+ <pre className="max-h-40 overflow-y-auto rounded-sm border border-mineshaft-600 bg-mineshaft-800 p-2 pr-8 text-xs whitespace-pre-wrap text-mineshaft-300">+ {trustPolicy}+ </pre></div>- <pre className="max-h-40 overflow-y-auto rounded-sm border border-mineshaft-600 bg-mineshaft-800 p-2 pr-8 text-xs whitespace-pre-wrap text-mineshaft-300">- {trustPolicy}- </pre>- </div>- <p className="text-xs text-mineshaft-400">- <strong>Note:</strong> Use{" "}- <code className="rounded bg-mineshaft-700 px-1 font-bold">- {INFISICAL_AWS_ACCOUNT_US}- </code>{" "}- for US region or{" "}- <code className="rounded bg-mineshaft-700 px-1 font-bold">- {INFISICAL_AWS_ACCOUNT_EU}- </code>{" "}- for EU region. For dedicated instances, contact Infisical support. For self-hosted- instances, use your Infisical deployment's AWS account ID. The External ID{" "}- <code className="rounded bg-mineshaft-700 px-1 font-bold">{projectId}</code> is your- current project ID.- </p>- </AccordionContent>- </AccordionItem>- </Accordion>-- <MetadataFields />-- <div className="mt-6 flex items-center">+ <p className="text-xs text-mineshaft-400">+ <strong>Note:</strong> Use{" "}+ <code className="rounded bg-mineshaft-700 px-1 font-bold">+ {INFISICAL_AWS_ACCOUNT_US}+ </code>{" "}+ for US region or{" "}+ <code className="rounded bg-mineshaft-700 px-1 font-bold">+ {INFISICAL_AWS_ACCOUNT_EU}+ </code>{" "}+ for EU region. For dedicated instances, contact Infisical support. For self-hosted+ instances, use your Infisical deployment's AWS account ID. The External ID{" "}+ <code className="rounded bg-mineshaft-700 px-1 font-bold">{projectId}</code> is+ your current project ID.+ </p>+ </AccordionContent>+ </AccordionItem>+ </Accordion>++ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Details" : "Create Resource"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={closeSheet} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/GenericResourceFields.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/GenericResourceFields.tsxindex 82caf12316..dcef99f51a 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/GenericResourceFields.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/GenericResourceFields.tsx@@ -2,13 +2,27 @@ import { Controller, useFormContext } from "react-hook-form";import { useQuery } from "@tanstack/react-query";import { z } from "zod";-import { FormControl, Input, Select, SelectItem } from "@app/components/v2";+import {+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ FilterableSelect,+ UnstableInput+} from "@app/components/v3";import { gatewaysQueryKeys } from "@app/hooks/api";import { slugSchema } from "@app/lib/schemas";+export const gatewayOptionSchema = z.object({+ id: z.string().min(1, "Gateway is required"),+ name: z.string()+});+export const genericResourceFieldsSchema = z.object({name: slugSchema({ min: 1, max: 64, field: "Name" }),- gatewayId: z.string().min(1),+ gateway: gatewayOptionSchema.nullable().refine((val) => val !== null, {+ message: "Gateway is required"+ }),metadata: z.object({key: z.string().trim().min(1),@@ -18,53 +32,65 @@ export const genericResourceFieldsSchema = z.object({.optional()});+type GenericFormValues = {+ name: string;+ gateway: { id: string; name: string } | null;+};+export const GenericResourceFields = () => {const { data: gateways, isPending: isGatewaysLoading } = useQuery(gatewaysQueryKeys.list());- const { control } = useFormContext<{- name: string;- gatewayId: string;- }>();+ const { control } = useFormContext<GenericFormValues>();return (- <>+ <div className="flex flex-col gap-3"><Controller- name="name"control={control}+ name="name"render={({ field, fieldState: { error } }) => (- <FormControl- helperText="Name must be slug-friendly"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Name"- >- <Input autoFocus placeholder="my-resource" {...field} />- </FormControl>+ <Field>+ <FieldLabel>Name</FieldLabel>+ <FieldContent>+ <UnstableInput+ {...field}+ autoFocus+ isError={Boolean(error)}+ placeholder="my-resource"+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/>+<Controllercontrol={control}- name="gatewayId"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error?.message)} errorText={error?.message} label="Gateway">- <Select- value={value || (null as unknown as string)}- onValueChange={onChange}- className="w-full border border-mineshaft-500"- dropdownContainerClassName="max-w-none"- isLoading={isGatewaysLoading}- placeholder="Select a Gateway..."- position="popper"- >- {(gateways || []).map((el) => (- <SelectItem value={el.id} key={el.id}>- {el.name}- </SelectItem>- ))}- </Select>- </FormControl>- )}+ name="gateway"+ render={({ field: { value, onChange, onBlur }, fieldState: { error } }) => {+ const selectedOption =+ value && gateways ? (gateways.find((g) => g.id === value.id) ?? value) : value;++ return (+ <Field>+ <FieldLabel>Gateway</FieldLabel>+ <FieldContent>+ <FilterableSelect+ value={selectedOption}+ onChange={onChange}+ onBlur={onBlur}+ options={gateways}+ isError={Boolean(error)}+ isLoading={isGatewaysLoading}+ placeholder="Select a Gateway..."+ getOptionLabel={(option) => option.name}+ getOptionValue={(option) => option.id}+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ );+ }}/>- </>+ </div>);};diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/KubernetesResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/KubernetesResourceForm.tsxindex 95cf6d2a09..9c5ae72c56 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/KubernetesResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/KubernetesResourceForm.tsx@@ -2,7 +2,7 @@ import { FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, ModalClose } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { KubernetesAuthMethod, PamResourceType, TKubernetesResource } from "@app/hooks/api/pam";import { KubernetesResourceFields } from "./shared/KubernetesResourceFields";@@ -12,6 +12,7 @@ import { MetadataFields } from "./MetadataFields";type Props = {resource?: TKubernetesResource;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const KubernetesConnectionDetailsSchema = z.object({@@ -33,19 +34,22 @@ const formSchema = genericResourceFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const KubernetesResourceForm = ({ resource, onSubmit }: Props) => {+export const KubernetesResourceForm = ({ resource, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(resource);const form = useForm<FormData>({resolver: zodResolver(formSchema),- defaultValues: resource ?? {- resourceType: PamResourceType.Kubernetes,- connectionDetails: {- url: "",- sslRejectUnauthorized: true,- sslCertificate: undefined- }- }+ defaultValues: resource+ ? { ...resource, gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined }+ : {+ resourceType: PamResourceType.Kubernetes,+ gateway: undefined,+ connectionDetails: {+ url: "",+ sslRejectUnauthorized: true,+ sslCertificate: undefined+ }+ }});const {@@ -55,27 +59,25 @@ export const KubernetesResourceForm = ({ resource, onSubmit }: Props) => {return (<FormProvider {...form}>- <form onSubmit={handleSubmit(onSubmit)}>- <GenericResourceFields />- <KubernetesResourceFields />- <MetadataFields />- <div className="mt-6 flex items-center">+ <form onSubmit={handleSubmit((data) => onSubmit(data as FormData))} className="flex flex-1 flex-col overflow-hidden">+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericResourceFields />+ <KubernetesResourceFields />+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Details" : "Create Resource"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={closeSheet} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/MySQLResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/MySQLResourceForm.tsxindex 3409cd8fa5..57951df92c 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/MySQLResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/MySQLResourceForm.tsx@@ -1,9 +1,8 @@-import { useState } from "react";import { FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, ModalClose } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { PamResourceType, TMySQLResource } from "@app/hooks/api/pam";import { BaseSqlResourceSchema } from "./shared/sql-resource-schemas";@@ -14,6 +13,7 @@ import { MetadataFields } from "./MetadataFields";type Props = {resource?: TMySQLResource;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const formSchema = genericResourceFieldsSchema.extend({@@ -25,23 +25,28 @@ const formSchema = genericResourceFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const MySQLResourceForm = ({ resource, onSubmit }: Props) => {+export const MySQLResourceForm = ({ resource, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(resource);- const [selectedTabIndex, setSelectedTabIndex] = useState(0);const form = useForm<FormData>({resolver: zodResolver(formSchema),- defaultValues: resource ?? {- resourceType: PamResourceType.MySQL,- connectionDetails: {- host: "",- port: 3306,- database: "",- sslEnabled: true,- sslRejectUnauthorized: true,- sslCertificate: undefined- }- }+ defaultValues: resource+ ? {+ ...resource,+ gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined+ }+ : {+ resourceType: PamResourceType.MySQL,+ gateway: undefined,+ connectionDetails: {+ host: "",+ port: 3306,+ database: "",+ sslEnabled: true,+ sslRejectUnauthorized: true,+ sslCertificate: undefined+ }+ }});const {@@ -52,34 +57,27 @@ export const MySQLResourceForm = ({ resource, onSubmit }: Props) => {return (<FormProvider {...form}><form- onSubmit={(e) => {- setSelectedTabIndex(0);- handleSubmit(onSubmit)(e);- }}+ onSubmit={handleSubmit((data) => onSubmit(data as FormData))}+ className="flex flex-1 flex-col overflow-hidden">- <GenericResourceFields />- <SqlResourceFields- selectedTabIndex={selectedTabIndex}- setSelectedTabIndex={setSelectedTabIndex}- />- <MetadataFields />- <div className="mt-6 flex items-center">+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericResourceFields />+ <SqlResourceFields />+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Details" : "Create Resource"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={closeSheet} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsxindex fc035c6c1b..53c9ef0ad5 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx@@ -19,7 +19,7 @@ import { SSHResourceForm } from "./SSHResourceForm";import { WindowsResourceForm } from "./WindowsResourceForm";type FormProps = {- onComplete: (resource: TPamResource) => void;+ closeSheet: (resource?: TPamResource) => void;} & ({ resource: TPamResource } | { resourceType: PamResourceType });type CreateFormProps = FormProps & {@@ -31,50 +31,56 @@ type UpdateFormProps = FormProps & {resource: TPamResource;};-const CreateForm = ({ resourceType, onComplete, projectId }: CreateFormProps) => {+const CreateForm = ({ resourceType, closeSheet, projectId }: CreateFormProps) => {const createPamResource = useCreatePamResource();const { name: resourceName } = PAM_RESOURCE_TYPE_MAP[resourceType];const onSubmit = async (formData: DiscriminativePick<TPamResource,- "name" | "resourceType" | "connectionDetails" | "gatewayId" | "adServerResourceId"- > & { metadata?: { key: string; value: string }[] }+ "name" | "resourceType" | "connectionDetails" | "adServerResourceId"+ > & {+ gateway?: { id: string; name: string } | null;+ gatewayId?: string;+ metadata?: { key: string; value: string }[];+ }) => {+ const { gateway, ...rest } = formData;const resource = await createPamResource.mutateAsync({- ...formData,+ ...rest,+ gatewayId: gateway?.id ?? rest.gatewayId,projectId});createNotification({text: `Successfully created ${resourceName} resource`,type: "success"});- onComplete(resource);+ closeSheet(resource);};switch (resourceType) {case PamResourceType.Postgres:- return <PostgresResourceForm onSubmit={onSubmit} />;+ return <PostgresResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.MySQL:- return <MySQLResourceForm onSubmit={onSubmit} />;+ return <MySQLResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.Redis:- return <RedisResourceForm onSubmit={onSubmit} />;+ return <RedisResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.SSH:- return <SSHResourceForm onSubmit={onSubmit} />;+ return <SSHResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.Kubernetes:- return <KubernetesResourceForm onSubmit={onSubmit} />;+ return <KubernetesResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.AwsIam:- return <AwsIamResourceForm onSubmit={onSubmit} />;+ return <AwsIamResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.Windows:- return <WindowsResourceForm onSubmit={onSubmit} />;+ return <WindowsResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.ActiveDirectory:- return <ActiveDirectoryResourceForm onSubmit={onSubmit} />;+ return <ActiveDirectoryResourceForm onSubmit={onSubmit} closeSheet={closeSheet} />;default:throw new Error(`Unhandled resource: ${resourceType}`);}};-const UpdateForm = ({ resource, onComplete }: UpdateFormProps) => {+const UpdateForm = ({ resource, closeSheet }: UpdateFormProps) => {const updatePamResource = useUpdatePamResource();const { name: resourceName } = PAM_RESOURCE_TYPE_MAP[resource.resourceType];@@ -82,42 +88,60 @@ const UpdateForm = ({ resource, onComplete }: UpdateFormProps) => {formData: DiscriminativePick<TPamResource,"name" | "resourceType" | "connectionDetails" | "adServerResourceId"- > & { metadata?: { key: string; value: string }[] }+ > & {+ gateway?: { id: string; name: string } | null;+ gatewayId?: string;+ metadata?: { key: string; value: string }[];+ }) => {+ const { gateway, ...rest } = formData;const updatedResource = await updatePamResource.mutateAsync({resourceId: resource.id,- ...formData+ ...rest,+ gatewayId: gateway?.id ?? rest.gatewayId});createNotification({text: `Successfully updated ${resourceName} resource`,type: "success"});- onComplete(updatedResource);+ closeSheet(updatedResource);};switch (resource.resourceType) {case PamResourceType.Postgres:- return <PostgresResourceForm resource={resource} onSubmit={onSubmit} />;+ return (+ <PostgresResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.MySQL:- return <MySQLResourceForm resource={resource} onSubmit={onSubmit} />;+ return <MySQLResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.Redis:- return <RedisResourceForm resource={resource} onSubmit={onSubmit} />;+ return <RedisResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.SSH:- return <SSHResourceForm resource={resource} onSubmit={onSubmit} />;+ return <SSHResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.Kubernetes:- return <KubernetesResourceForm resource={resource} onSubmit={onSubmit} />;+ return (+ <KubernetesResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.AwsIam:- return <AwsIamResourceForm resource={resource} onSubmit={onSubmit} />;+ return <AwsIamResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />;case PamResourceType.Windows:- return <WindowsResourceForm resource={resource} onSubmit={onSubmit} />;+ return (+ <WindowsResourceForm resource={resource} onSubmit={onSubmit} closeSheet={closeSheet} />+ );case PamResourceType.ActiveDirectory:- return <ActiveDirectoryResourceForm resource={resource} onSubmit={onSubmit} />;+ return (+ <ActiveDirectoryResourceForm+ resource={resource}+ onSubmit={onSubmit}+ closeSheet={closeSheet}+ />+ );default:throw new Error(`Unhandled resource: ${(resource as any).resourceType}`);}};-type Props = { onBack?: () => void; projectId: string } & Pick<FormProps, "onComplete"> &+type Props = { onBack?: () => void; projectId: string } & Pick<FormProps, "closeSheet"> &(| { resourceType: PamResourceType; resource?: undefined }| { resourceType?: undefined; resource: TPamResource }@@ -126,7 +150,7 @@ export const PamResourceForm = ({ onBack, projectId, ...props }: Props) => {const { resource, resourceType } = props;return (- <div>+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden"><PamResourceHeader resourceType={resourceType || resource.resourceType} onBack={onBack} />{resource ? (<UpdateForm {...props} resource={resource} />diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PostgresResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PostgresResourceForm.tsxindex 424f8d9558..56b65eaaf4 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PostgresResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PostgresResourceForm.tsx@@ -1,9 +1,8 @@-import { useState } from "react";import { FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, ModalClose } from "@app/components/v2";+import { Button, SheetFooter } from "@app/components/v3";import { PamResourceType, TPostgresResource } from "@app/hooks/api/pam";import { BaseSqlResourceSchema } from "./shared/sql-resource-schemas";@@ -14,6 +13,7 @@ import { MetadataFields } from "./MetadataFields";type Props = {resource?: TPostgresResource;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const formSchema = genericResourceFieldsSchema.extend({@@ -23,16 +23,19 @@ const formSchema = genericResourceFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const PostgresResourceForm = ({ resource, onSubmit }: Props) => {+export const PostgresResourceForm = ({ resource, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(resource);- const [selectedTabIndex, setSelectedTabIndex] = useState(0);const form = useForm<FormData>({resolver: zodResolver(formSchema),defaultValues: resource- ? { ...resource }+ ? {+ ...resource,+ gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined+ }: {resourceType: PamResourceType.Postgres,+ gateway: undefined,connectionDetails: {host: "",port: 5432,@@ -52,34 +55,27 @@ export const PostgresResourceForm = ({ resource, onSubmit }: Props) => {return (<FormProvider {...form}><form- onSubmit={(e) => {- setSelectedTabIndex(0);- handleSubmit(onSubmit)(e);- }}+ onSubmit={handleSubmit((data) => onSubmit(data as FormData))}+ className="flex flex-1 flex-col overflow-hidden">- <GenericResourceFields />- <SqlResourceFields- selectedTabIndex={selectedTabIndex}- setSelectedTabIndex={setSelectedTabIndex}- />- <MetadataFields />- <div className="mt-6 flex items-center">+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericResourceFields />+ <SqlResourceFields />+ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Details" : "Create Resource"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={closeSheet} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/RedisResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/RedisResourceForm.tsxindex bc6b8843b9..d5a829797f 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/RedisResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/RedisResourceForm.tsx@@ -1,20 +1,23 @@-import { useState } from "react";import { Controller, FormProvider, useForm } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { Tab } from "@headlessui/react";import { zodResolver } from "@hookform/resolvers/zod";+import { InfoIcon } from "lucide-react";import { z } from "zod";import {Button,- FormControl,- Input,- ModalClose,+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ Label,+ SheetFooter,Switch,TextArea,- Tooltip-} from "@app/components/v2";+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ UnstableInput+} from "@app/components/v3";import { PamResourceType, TRedisResource } from "@app/hooks/api/pam";import { GenericResourceFields, genericResourceFieldsSchema } from "./GenericResourceFields";@@ -23,41 +26,43 @@ import { MetadataFields } from "./MetadataFields";type Props = {resource?: TRedisResource;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const formSchema = genericResourceFieldsSchema.extend({resourceType: z.literal(PamResourceType.Redis),connectionDetails: z.object({- host: z.string().trim().min(1, "Host required"),- port: z.coerce.number().default(6379),+ host: z.string().trim().min(1, "Host is required"),+ port: z.coerce.number().int().min(1).max(65535),sslEnabled: z.boolean().default(true),sslRejectUnauthorized: z.boolean().default(true),- sslCertificate: z- .string()- .trim()- .transform((value) => value || undefined)- .optional()+ sslCertificate: z.string().trim().optional()})});type FormData = z.infer<typeof formSchema>;-export const RedisResourceForm = ({ resource, onSubmit }: Props) => {+export const RedisResourceForm = ({ resource, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(resource);- const [selectedTabIndex, setSelectedTabIndex] = useState(0);const form = useForm<FormData>({resolver: zodResolver(formSchema),- defaultValues: resource ?? {- resourceType: PamResourceType.Redis,- connectionDetails: {- host: "",- port: 6379,- sslEnabled: true,- sslRejectUnauthorized: true,- sslCertificate: undefined- }- }+ defaultValues: resource+ ? {+ ...resource,+ gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined+ }+ : {+ resourceType: PamResourceType.Redis,+ gateway: undefined,+ connectionDetails: {+ host: "",+ port: 6379,+ sslEnabled: true,+ sslRejectUnauthorized: true,+ sslCertificate: undefined+ }+ }});const {@@ -72,159 +77,124 @@ export const RedisResourceForm = ({ resource, onSubmit }: Props) => {return (<FormProvider {...form}><form- onSubmit={(e) => {- setSelectedTabIndex(0);- handleSubmit(onSubmit)(e);- }}+ onSubmit={handleSubmit((data) => onSubmit(data as FormData))}+ className="flex flex-1 flex-col overflow-hidden">- <GenericResourceFields />- <Tab.Group selectedIndex={selectedTabIndex} onChange={setSelectedTabIndex}>- <Tab.List className="-pb-1 mb-6 w-full border-b-2 border-mineshaft-600">- <Tab- className={({ selected }) =>- `-mb-[0.14rem] px-4 py-2 text-sm font-medium whitespace-nowrap outline-hidden disabled:opacity-60 ${- selected- ? "border-b-2 border-mineshaft-300 text-mineshaft-200"- : "text-bunker-300"- }`- }- >- Configuration- </Tab>- <Tab- className={({ selected }) =>- `-mb-[0.14rem] px-4 py-2 text-sm font-medium whitespace-nowrap outline-hidden disabled:opacity-60 ${- selected- ? "border-b-2 border-mineshaft-300 text-mineshaft-200"- : "text-bunker-300"- }`- }- >- SSL ({sslEnabled ? "Enabled" : "Disabled"})- </Tab>- </Tab.List>- <Tab.Panels className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3 pb-0">- <Tab.Panel>- <div className="mt-[0.675rem] flex items-start gap-2">- <Controller- name="connectionDetails.host"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Host"- >- <Input {...field} />- </FormControl>- )}- />- <Controller- name="connectionDetails.port"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-28"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Port"- >- <Input type="number" {...field} />- </FormControl>- )}- />- </div>- </Tab.Panel>- <Tab.Panel>- <Controller- name="connectionDetails.sslEnabled"- 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-enabled"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- Enable SSL- </Switch>- </FormControl>- )}- />+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericResourceFields />++ {/* Connection */}+ <div className="flex flex-col gap-3">+ <Label>Connection</Label>++ <div className="grid grid-cols-[1fr_auto] gap-2"><Controller- name="connectionDetails.sslCertificate"+ name="connectionDetails.host"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- className={sslEnabled ? "" : "opacity-50"}- label="Trusted CA SSL Certificate"- isOptional- >- <TextArea className="h-14 resize-none!" {...field} isDisabled={!sslEnabled} />- </FormControl>+ <Field>+ <FieldLabel>Host</FieldLabel>+ <FieldContent>+ <UnstableInput {...field} isError={Boolean(error)} />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/><Controller- name="connectionDetails.sslRejectUnauthorized"+ name="connectionDetails.port"control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- className={sslEnabled ? "" : "opacity-50"}- 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={sslEnabled ? value : false}- onCheckedChange={onChange}- isDisabled={!sslEnabled}- >- <p className="w-38">- Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, Infisical will only connect to the server if it has a- valid, trusted SSL certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>+ render={({ field, fieldState: { error } }) => (+ <Field className="w-24">+ <FieldLabel>Port</FieldLabel>+ <FieldContent>+ <UnstableInput type="number" {...field} isError={Boolean(error)} />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/>- </Tab.Panel>- </Tab.Panels>- </Tab.Group>- <MetadataFields />- <div className="mt-6 flex items-center">+ </div>+ </div>++ {/* SSL */}+ <div className="flex flex-col gap-3">+ <Label>SSL</Label>++ <Controller+ name="connectionDetails.sslEnabled"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field orientation="horizontal">+ <FieldLabel>Enable SSL</FieldLabel>+ <Switch variant="project" checked={value} onCheckedChange={onChange} />+ <FieldError errors={[error]} />+ </Field>+ )}+ />++ <Controller+ name="connectionDetails.sslCertificate"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>CA Certificate</FieldLabel>+ <FieldContent>+ <TextArea+ {...field}+ placeholder="-----BEGIN CERTIFICATE-----..."+ disabled={!sslEnabled}+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />++ <Controller+ name="connectionDetails.sslRejectUnauthorized"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field orientation="horizontal">+ <FieldLabel>+ Reject Unauthorized+ <Tooltip>+ <TooltipTrigger>+ <InfoIcon className="mb-0.5 inline-block size-3 text-accent" />+ </TooltipTrigger>+ <TooltipContent>+ If enabled, Infisical will only connect to the server if it has a valid,+ trusted SSL certificate.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Switch+ variant="project"+ disabled={!sslEnabled}+ checked={sslEnabled ? value : false}+ onCheckedChange={onChange}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ </div>++ <MetadataFields />+ </div>+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Details" : "Create Resource"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={closeSheet} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/SSHResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/SSHResourceForm.tsxindex da0d5523f5..ed47748ce0 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/SSHResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/SSHResourceForm.tsx@@ -2,7 +2,15 @@ import { Controller, FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, FormControl, Input, ModalClose } from "@app/components/v2";+import {+ Button,+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ SheetFooter,+ UnstableInput+} from "@app/components/v3";import { PamResourceType, TSSHResource } from "@app/hooks/api/pam";import { SshCaSetupSection } from "../../../components/SshCaSetupSection";@@ -12,6 +20,7 @@ import { MetadataFields } from "./MetadataFields";type Props = {resource?: TSSHResource;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const BaseSshConnectionDetailsSchema = z.object({@@ -26,18 +35,24 @@ const formSchema = genericResourceFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const SSHResourceForm = ({ resource, onSubmit }: Props) => {+export const SSHResourceForm = ({ resource, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(resource);const form = useForm<FormData>({resolver: zodResolver(formSchema),- defaultValues: resource ?? {- resourceType: PamResourceType.SSH,- connectionDetails: {- host: "",- port: 22- }- }+ defaultValues: resource+ ? {+ ...resource,+ gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined+ }+ : {+ resourceType: PamResourceType.SSH,+ gateway: undefined,+ connectionDetails: {+ host: "",+ port: 22+ }+ }});const {@@ -48,59 +63,60 @@ export const SSHResourceForm = ({ resource, onSubmit }: Props) => {return (<FormProvider {...form}>- <form onSubmit={handleSubmit(onSubmit)}>- <GenericResourceFields />- <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3 pb-0">- <div className="mt-[0.675rem] flex items-start gap-2">+ <form+ onSubmit={handleSubmit((data) => onSubmit(data as FormData))}+ className="flex flex-1 flex-col overflow-hidden"+ >+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericResourceFields />+ <div className="flex items-start gap-2"><Controllername="connectionDetails.host"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Host"- >- <Input placeholder="example.com or 192.168.1.1" {...field} />- </FormControl>+ <Field className="flex-1">+ <FieldLabel>Host</FieldLabel>+ <FieldContent>+ <UnstableInput+ {...field}+ isError={Boolean(error)}+ placeholder="example.com or 192.168.1.1"+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/><Controllername="connectionDetails.port"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- className="w-28"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Port"- >- <Input type="number" {...field} />- </FormControl>+ <Field className="w-28">+ <FieldLabel>Port</FieldLabel>+ <FieldContent>+ <UnstableInput type="number" {...field} isError={Boolean(error)} />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/></div>+ {isUpdate && <SshCaSetupSection resourceId={resource!.id} isOptional className="mb-4" />}+ <MetadataFields /></div>- {isUpdate && <SshCaSetupSection resourceId={resource!.id} isOptional className="mb-4" />}- <MetadataFields />- <div className="mt-6 flex items-center">+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Details" : "Create Resource"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={closeSheet} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/WindowsResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/WindowsResourceForm.tsxindex 117f0cdf97..e0046691e6 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/WindowsResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/WindowsResourceForm.tsx@@ -2,7 +2,16 @@ import { Controller, FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { Button, FormControl, Input, ModalClose, Select, SelectItem } from "@app/components/v2";+import { FormControl, Select, SelectItem } from "@app/components/v2";+import {+ Button,+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ SheetFooter,+ UnstableInput+} from "@app/components/v3";import { useProject } from "@app/context";import { PamResourceType, TWindowsResource, useListPamResources } from "@app/hooks/api/pam";import { WindowsProtocol } from "@app/hooks/api/pam/types/windows-server-resource";@@ -13,6 +22,7 @@ import { MetadataFields } from "./MetadataFields";type Props = {resource?: TWindowsResource;onSubmit: (formData: FormData) => Promise<void>;+ closeSheet: () => void;};const formSchema = genericResourceFieldsSchema.extend({@@ -27,7 +37,7 @@ const formSchema = genericResourceFieldsSchema.extend({type FormData = z.infer<typeof formSchema>;-export const WindowsResourceForm = ({ resource, onSubmit }: Props) => {+export const WindowsResourceForm = ({ resource, onSubmit, closeSheet }: Props) => {const isUpdate = Boolean(resource);const { projectId } = useProject();@@ -41,10 +51,12 @@ export const WindowsResourceForm = ({ resource, onSubmit }: Props) => {defaultValues: resource? {...resource,+ gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined,adServerResourceId: resource.adServerResourceId ?? null}: {resourceType: PamResourceType.Windows,+ gateway: undefined,connectionDetails: {protocol: WindowsProtocol.RDP,hostname: "",@@ -62,89 +74,90 @@ export const WindowsResourceForm = ({ resource, onSubmit }: Props) => {return (<FormProvider {...form}>- <form onSubmit={handleSubmit(onSubmit)}>- <GenericResourceFields />- <Controller- control={control}- name="adServerResourceId"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- isError={Boolean(error?.message)}- errorText={error?.message}- label="Active Directory Resource"- helperText="Optionally associate this server with an AD domain"- >- <Select- value={value || "none"}- onValueChange={(val) => onChange(val === "none" ? null : val)}- className="w-full border border-mineshaft-500"- dropdownContainerClassName="max-w-none"- isLoading={isAdResourcesLoading}- placeholder="None"- position="popper"+ <form+ onSubmit={handleSubmit((data) => onSubmit(data as FormData))}+ className="flex flex-1 flex-col overflow-hidden"+ >+ <div className="flex min-h-0 flex-1 shrink flex-col gap-4 overflow-y-auto p-4 pb-8">+ <GenericResourceFields />+ <Controller+ control={control}+ name="adServerResourceId"+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error?.message)}+ errorText={error?.message}+ label="Active Directory Resource"+ helperText="Optionally associate this server with an AD domain">- <SelectItem value="none" key="none">- None- </SelectItem>- {(adResources?.resources || []).map((adResource) => (- <SelectItem value={adResource.id} key={adResource.id}>- {adResource.name}+ <Select+ value={value || "none"}+ onValueChange={(val) => onChange(val === "none" ? null : val)}+ className="w-full border border-mineshaft-500"+ dropdownContainerClassName="max-w-none"+ isLoading={isAdResourcesLoading}+ placeholder="None"+ position="popper"+ >+ <SelectItem value="none" key="none">+ None</SelectItem>- ))}- </Select>- </FormControl>- )}- />- <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3 pb-0">- <div className="mt-[0.675rem] flex items-start gap-2">+ {(adResources?.resources || []).map((adResource) => (+ <SelectItem value={adResource.id} key={adResource.id}>+ {adResource.name}+ </SelectItem>+ ))}+ </Select>+ </FormControl>+ )}+ />+ <div className="flex items-start gap-2"><Controllername="connectionDetails.hostname"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Hostname"- >- <Input placeholder="example.com or 192.168.1.1" {...field} />- </FormControl>+ <Field className="flex-1">+ <FieldLabel>Hostname</FieldLabel>+ <FieldContent>+ <UnstableInput+ {...field}+ isError={Boolean(error)}+ placeholder="example.com or 192.168.1.1"+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/><Controllername="connectionDetails.port"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- className="w-28"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Port"- >- <Input type="number" {...field} />- </FormControl>+ <Field className="w-28">+ <FieldLabel>Port</FieldLabel>+ <FieldContent>+ <UnstableInput type="number" {...field} isError={Boolean(error)} />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/></div>+ <MetadataFields /></div>- <MetadataFields />- <div className="mt-6 flex items-center">+ <SheetFooter className="shrink-0 border-t"><Button- className="mr-4"- size="sm"- type="submit"- colorSchema="secondary"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting || !isDirty}+ variant="neutral"+ type="submit">{isUpdate ? "Update Details" : "Create Resource"}</Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">- Cancel- </Button>- </ModalClose>- </div>+ <Button onClick={closeSheet} variant="outline" className="mr-auto" type="button">+ Cancel+ </Button>+ </SheetFooter></form></FormProvider>);diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/shared/KubernetesResourceFields.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/shared/KubernetesResourceFields.tsxindex de255f1622..9b0eb88bc5 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/shared/KubernetesResourceFields.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/shared/KubernetesResourceFields.tsx@@ -1,77 +1,81 @@import { Controller, useFormContext } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import { InfoIcon } from "lucide-react";-import { FormControl, Input, Switch, TextArea, Tooltip } from "@app/components/v2";+import {+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ Label,+ Switch,+ TextArea,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ UnstableInput+} from "@app/components/v3";export const KubernetesResourceFields = () => {const { control } = useFormContext();return (- <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3">- <div className="mt-[0.675rem] flex flex-col gap-4">- <Controller- name="connectionDetails.url"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="Kubernetes API URL"- >- <Input placeholder="https://kubernetes.example.com:6443" {...field} />- </FormControl>- )}- />- <Controller- name="connectionDetails.sslCertificate"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- label="CA Certificate"- isOptional- >- <TextArea- className="h-14 resize-none!"+ <div className="flex flex-col gap-3">+ <Label>Connection</Label>++ <Controller+ name="connectionDetails.url"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>Kubernetes API URL</FieldLabel>+ <FieldContent>+ <UnstableInput{...field}- placeholder="-----BEGIN CERTIFICATE-----..."+ isError={Boolean(error)}+ placeholder="https://kubernetes.example.com:6443"/>- </FormControl>- )}- />- <Controller- name="connectionDetails.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-38">- Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, Infisical will only connect to the server if it has a valid,- trusted SSL certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />- </div>+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />++ <Controller+ name="connectionDetails.sslCertificate"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>CA Certificate</FieldLabel>+ <FieldContent>+ <TextArea {...field} placeholder="-----BEGIN CERTIFICATE-----..." />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />++ <Controller+ name="connectionDetails.sslRejectUnauthorized"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field orientation="horizontal">+ <FieldLabel>+ Reject Unauthorized+ <Tooltip>+ <TooltipTrigger>+ <InfoIcon className="mb-0.5 inline-block size-3 text-accent" />+ </TooltipTrigger>+ <TooltipContent>+ If enabled, Infisical will only connect to the server if it has a valid, trusted+ SSL certificate.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Switch variant="project" checked={value} onCheckedChange={onChange} />+ <FieldError errors={[error]} />+ </Field>+ )}+ /></div>);};diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/shared/SqlResourceFields.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/shared/SqlResourceFields.tsxindex c3f3982eca..bbd56787d9 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/shared/SqlResourceFields.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/shared/SqlResourceFields.tsx@@ -1,159 +1,135 @@-import { Dispatch, SetStateAction } from "react";import { Controller, useFormContext } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { Tab } from "@headlessui/react";+import { InfoIcon } from "lucide-react";-import { FormControl, Input, Switch, TextArea, Tooltip } from "@app/components/v2";+import {+ Field,+ FieldContent,+ FieldError,+ FieldLabel,+ Label,+ Switch,+ TextArea,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ UnstableInput+} from "@app/components/v3";-type Props = {- selectedTabIndex: number;- setSelectedTabIndex: Dispatch<SetStateAction<number>>;-};--export const SqlResourceFields = ({ setSelectedTabIndex, selectedTabIndex }: Props) => {+export const SqlResourceFields = () => {const { control, watch } = useFormContext();const sslEnabled = watch("connectionDetails.sslEnabled");return (- <Tab.Group selectedIndex={selectedTabIndex} onChange={setSelectedTabIndex}>- <Tab.List className="-pb-1 mb-6 w-full border-b-2 border-mineshaft-600">- <Tab- className={({ selected }) =>- `-mb-[0.14rem] px-4 py-2 text-sm font-medium whitespace-nowrap outline-hidden disabled:opacity-60 ${- selected ? "border-b-2 border-mineshaft-300 text-mineshaft-200" : "text-bunker-300"- }`- }- >- Configuration- </Tab>- <Tab- className={({ selected }) =>- `-mb-[0.14rem] px-4 py-2 text-sm font-medium whitespace-nowrap outline-hidden disabled:opacity-60 ${- selected ? "border-b-2 border-mineshaft-300 text-mineshaft-200" : "text-bunker-300"- }`- }- >- SSL ({sslEnabled ? "Enabled" : "Disabled"})- </Tab>- </Tab.List>- <Tab.Panels className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3 pb-0">- <Tab.Panel>- <div className="mt-[0.675rem] flex items-start gap-2">- <Controller- name="connectionDetails.host"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Host"- >- <Input {...field} />- </FormControl>- )}- />- <Controller- name="connectionDetails.database"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="flex-1"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Database Name"- >- <Input {...field} />- </FormControl>- )}- />- <Controller- name="connectionDetails.port"- control={control}- render={({ field, fieldState: { error } }) => (- <FormControl- className="w-28"- errorText={error?.message}- isError={Boolean(error?.message)}- label="Port"- >- <Input type="number" {...field} />- </FormControl>- )}- />- </div>- </Tab.Panel>- <Tab.Panel>+ <>+ {/* Connection */}+ <div className="flex flex-col gap-3">+ <Label>Connection</Label>++ <div className="grid grid-cols-[1fr_1fr_auto] gap-2"><Controller- name="connectionDetails.sslEnabled"+ name="connectionDetails.host"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-enabled"- thumbClassName="bg-mineshaft-800"- isChecked={value}- onCheckedChange={onChange}- >- Enable SSL- </Switch>- </FormControl>+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>Host</FieldLabel>+ <FieldContent>+ <UnstableInput {...field} placeholder="db.example.com" isError={Boolean(error)} />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/><Controller- name="connectionDetails.sslCertificate"+ name="connectionDetails.database"control={control}render={({ field, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error?.message)}- className={sslEnabled ? "" : "opacity-50"}- label="Trusted CA SSL Certificate"- isOptional- >- <TextArea className="h-14 resize-none!" {...field} isDisabled={!sslEnabled} />- </FormControl>+ <Field>+ <FieldLabel>Database Name</FieldLabel>+ <FieldContent>+ <UnstableInput {...field} isError={Boolean(error)} />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/><Controller- name="connectionDetails.sslRejectUnauthorized"+ name="connectionDetails.port"control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- className={sslEnabled ? "" : "opacity-50"}- 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={sslEnabled ? value : false}- onCheckedChange={onChange}- isDisabled={!sslEnabled}- >- <p className="w-38">- Reject Unauthorized- <Tooltip- className="max-w-md"- content={- <p>- If enabled, Infisical will only connect to the server if it has a valid,- trusted SSL certificate.- </p>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>+ render={({ field, fieldState: { error } }) => (+ <Field className="w-24">+ <FieldLabel>Port</FieldLabel>+ <FieldContent>+ <UnstableInput type="number" {...field} isError={Boolean(error)} />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>)}/>- </Tab.Panel>- </Tab.Panels>- </Tab.Group>+ </div>+ </div>++ {/* SSL */}+ <div className="flex flex-col gap-3">+ <Label>SSL</Label>++ <Controller+ name="connectionDetails.sslEnabled"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field orientation="horizontal">+ <FieldLabel>Enable SSL</FieldLabel>+ <Switch variant="project" checked={value} onCheckedChange={onChange} />+ <FieldError errors={[error]} />+ </Field>+ )}+ />++ <Controller+ name="connectionDetails.sslCertificate"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field>+ <FieldLabel>CA Certificate</FieldLabel>+ <FieldContent>+ <TextArea+ {...field}+ placeholder="-----BEGIN CERTIFICATE-----..."+ disabled={!sslEnabled}+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />++ <Controller+ name="connectionDetails.sslRejectUnauthorized"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field orientation="horizontal">+ <FieldLabel>+ Reject Unauthorized+ <Tooltip>+ <TooltipTrigger>+ <InfoIcon className="mb-0.5 inline-block size-3 text-accent" />+ </TooltipTrigger>+ <TooltipContent>+ If enabled, Infisical will only connect to the server if it has a valid, trusted+ SSL certificate.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Switch+ variant="project"+ disabled={!sslEnabled}+ checked={sslEnabled ? value : false}+ onCheckedChange={onChange}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ </div>+ </>);};diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceHeader.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceHeader.tsxindex 343f04c885..bc459db80c 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceHeader.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceHeader.tsx@@ -1,9 +1,17 @@-import { DocumentationLinkBadge } from "@app/components/v3";+import { PencilIcon } from "lucide-react";++import { Button, DocumentationLinkBadge, Label } from "@app/components/v3";import { PAM_RESOURCE_TYPE_MAP, PamResourceType } from "@app/hooks/api/pam";const PAM_RESOURCE_DOCS_MAP: Partial<Record<PamResourceType, string>> = {+ [PamResourceType.ActiveDirectory]: "active-directory#create-the-pam-resource",[PamResourceType.AwsIam]: "aws-iam#create-the-pam-resource",- [PamResourceType.Kubernetes]: "kubernetes"+ [PamResourceType.Kubernetes]: "kubernetes#create-the-pam-resource",+ [PamResourceType.MySQL]: "mysql#create-the-pam-resource",+ [PamResourceType.Postgres]: "postgresql#create-the-pam-resource",+ [PamResourceType.Redis]: "redis#create-the-pam-resource",+ [PamResourceType.SSH]: "ssh#create-the-pam-resource",+ [PamResourceType.Windows]: "windows-server#create-the-pam-resource"};type Props = {@@ -16,31 +24,28 @@ export const PamResourceHeader = ({ resourceType, onBack }: Props) => {const docsPath = PAM_RESOURCE_DOCS_MAP[resourceType];return (- <div className="mb-4 flex w-full items-start gap-2 border-b border-mineshaft-500 pb-4">+ <div className="flex w-full items-center gap-2.5 border-b border-border p-3"><imgalt={`${details.name} logo`}src={`/images/integrations/${details.image}`}- className="h-12 w-12 rounded-md bg-bunker-500 p-2"+ className="size-9"/>- <div>- <div className="flex items-center gap-x-2 text-mineshaft-300">+ <div className="flex w-full flex-col gap-1">+ <Label>{details.name}{docsPath && (<DocumentationLinkBadge- href={`https://infisical.com/docs/documentation/platform/pam/resources/${docsPath}`}+ href={`https://infisical.com/docs/documentation/platform/pam/getting-started/resources/${docsPath}`}/>)}- </div>- <p className="text-sm leading-4 text-mineshaft-400">Resource</p>+ </Label>+ <p className="text-xs text-muted">Resoure</p></div>{onBack && (- <button- type="button"- className="mt-1 ml-auto text-xs text-mineshaft-400 underline underline-offset-2 hover:text-mineshaft-300"- onClick={onBack}- >- Select another resource type- </button>+ <Button size="xs" variant="neutral" onClick={onBack}>+ <PencilIcon />+ Change+ </Button>)}</div>);diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamUpdateResourceModal.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamUpdateResourceModal.tsxindex 38dea092aa..ab5af099b7 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamUpdateResourceModal.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamUpdateResourceModal.tsx@@ -1,4 +1,4 @@-import { Modal, ModalContent } from "@app/components/v2";+import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@app/components/v3";import { PAM_RESOURCE_TYPE_MAP, TPamResource } from "@app/hooks/api/pam";import { PamResourceForm } from "./PamResourceForm";@@ -13,20 +13,20 @@ export const PamUpdateResourceModal = ({ isOpen, onOpenChange, resource }: Propsif (!resource) return null;return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent- className="max-w-2xl"- title="Edit Resource"- subTitle={`Update details for this ${- PAM_RESOURCE_TYPE_MAP[resource.resourceType].name- } resource.`}- >+ <Sheet open={isOpen} onOpenChange={onOpenChange} modal={false}>+ <SheetContent className="flex h-full max-h-full flex-col gap-y-0 sm:max-w-lg">+ <SheetHeader className="border-b">+ <SheetTitle>Edit Resource</SheetTitle>+ <SheetDescription>+ Update details for this {PAM_RESOURCE_TYPE_MAP[resource.resourceType].name} resource.+ </SheetDescription>+ </SheetHeader><PamResourceForm- onComplete={() => onOpenChange(false)}+ closeSheet={() => onOpenChange(false)}resource={resource}projectId={resource.projectId}/>- </ModalContent>- </Modal>+ </SheetContent>+ </Sheet>);};diff --git a/frontend/src/pages/pam/PamResourcesPage/components/ResourceTypeSelect.tsx b/frontend/src/pages/pam/PamResourcesPage/components/ResourceTypeSelect.tsxindex 6ddd95d7bd..a5d79c59cc 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/ResourceTypeSelect.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/ResourceTypeSelect.tsx@@ -1,10 +1,8 @@import { useMemo } from "react";-import { faInfoCircle, faMagnifyingGlass, faSearch } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";-import { EmptyState, Input, Pagination, Spinner, Tooltip } from "@app/components/v2";-import { usePagination, usePopUp, useResetPageHelper } from "@app/hooks";+import { Button, Label } from "@app/components/v3";+import { usePopUp } from "@app/hooks";import {PAM_RESOURCE_TYPE_MAP,PamResourceType,@@ -15,66 +13,36 @@ type Props = {onSelect: (resource: PamResourceType) => void;};+const COMING_SOON_RESOURCES = [+ { name: "OracleDB", resource: PamResourceType.OracleDB },+ { name: "SQLite", resource: PamResourceType.SQLite },+ { name: "Microsoft SQL Server", resource: PamResourceType.MsSQL },+ { name: "MongoDB", resource: PamResourceType.MongoDB },+ { name: "Cassandra", resource: PamResourceType.Cassandra },+ { name: "CockroachDB", resource: PamResourceType.CockroachDB },+ { name: "DynamoDB", resource: PamResourceType.DynamoDB },+ { name: "Snowflake", resource: PamResourceType.Snowflake },+ { name: "Elasticsearch", resource: PamResourceType.Elasticsearch },+ { name: "RDP", resource: PamResourceType.RDP },+ { name: "MCP", resource: PamResourceType.MCP },+ { name: "Web Application", resource: PamResourceType.WebApp }+];++const COMING_SOON_SET = new Set(COMING_SOON_RESOURCES.map((r) => r.resource));+export const ResourceTypeSelect = ({ onSelect }: Props) => {const { isPending, data: resourceOptions } = useListPamResourceOptions();const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const);- const appendedResourceOptions = useMemo(() => {+ const allOptions = useMemo(() => {if (!resourceOptions) return [];- return [- ...resourceOptions,- // We are temporarily showing these resources so that we can gauge interest before committing- { name: "OracleDB", resource: PamResourceType.OracleDB },- { name: "SQLite", resource: PamResourceType.SQLite },- { name: "Microsoft SQL Server", resource: PamResourceType.MsSQL },- { name: "MongoDB", resource: PamResourceType.MongoDB },- { name: "Cassandra", resource: PamResourceType.Cassandra },- { name: "CockroachDB", resource: PamResourceType.CockroachDB },- { name: "DynamoDB", resource: PamResourceType.DynamoDB },- { name: "Snowflake", resource: PamResourceType.Snowflake },- { name: "Elasticsearch", resource: PamResourceType.Elasticsearch },- { name: "RDP", resource: PamResourceType.RDP },- { name: "SSH", resource: PamResourceType.SSH },- { name: "MCP", resource: PamResourceType.MCP },- { name: "Web Application", resource: PamResourceType.WebApp }- ];+ return [...resourceOptions, ...COMING_SOON_RESOURCES].sort((a, b) =>+ a.name.localeCompare(b.name)+ );}, [resourceOptions]);- const { search, setSearch, setPage, page, perPage, setPerPage, offset } = usePagination("", {- initPerPage: 16- });-- const filteredOptions = useMemo(- () =>- appendedResourceOptions- ?.filter(- ({ name, resource }) =>- name.toLowerCase().includes(search.trim().toLowerCase()) ||- resource.toLowerCase().includes(search.trim().toLowerCase())- )- .sort((a, b) => a.name.localeCompare(b.name)) ?? [],- [appendedResourceOptions, search]- );-- useResetPageHelper({- totalCount: filteredOptions.length,- offset,- setPage- });-const handleResourceSelect = (resource: PamResourceType) => {- // We temporarily show a special license modal for these because we will have to write some code to complete the integration- if (- resource === PamResourceType.RDP ||- resource === PamResourceType.MCP ||- resource === PamResourceType.MongoDB ||- resource === PamResourceType.WebApp ||- resource === PamResourceType.Cassandra ||- resource === PamResourceType.CockroachDB ||- resource === PamResourceType.Elasticsearch ||- resource === PamResourceType.Snowflake ||- resource === PamResourceType.DynamoDB- ) {+ if (COMING_SOON_SET.has(resource)) {handlePopUpOpen("upgradePlan", {text: "Your current plan does not include access to this resource type. To unlock this feature, please upgrade to Infisical Enterprise plan.",isEnterpriseFeature: true@@ -87,109 +55,46 @@ export const ResourceTypeSelect = ({ onSelect }: Props) => {if (isPending) {return (- <div className="flex h-full flex-col items-center justify-center py-2.5">- <Spinner size="lg" className="text-mineshaft-500" />- <p className="mt-4 text-sm text-mineshaft-400">Loading options...</p>+ <div className="flex h-full items-center justify-center">+ <Label>Loading options...</Label></div>);}return (- <div className="flex flex-col gap-4">- <Input- value={search}- onChange={(e) => setSearch(e.target.value)}- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}- placeholder="Search options..."- className="bg-mineshaft-800 placeholder:text-mineshaft-400"- />- <div className="grid h-118 grid-cols-4 content-start gap-2">- {filteredOptions.slice(offset, perPage * page)?.map((option) => {- const { image, name, size = 50 } = PAM_RESOURCE_TYPE_MAP[option.resource];+ <>+ <div className="flex overflow-y-auto">+ <div className="flex h-fit w-full flex-col gap-2 p-4">+ {allOptions.map((option) => {+ const details = PAM_RESOURCE_TYPE_MAP[option.resource];+ const isComingSoon = COMING_SOON_SET.has(option.resource);- return (- <button- key={option.resource}- type="button"- onClick={() => handleResourceSelect(option.resource)}- className="group relative flex h-28 cursor-pointer flex-col items-center justify-center rounded-md border border-mineshaft-600 bg-mineshaft-700 p-4 duration-200 hover:bg-mineshaft-600"- >- <div className="relative my-auto">+ return (+ <Button+ key={option.resource}+ onClick={() => handleResourceSelect(option.resource)}+ size="lg"+ variant="neutral"+ className="w-full justify-start"+ ><img- src={`/images/integrations/${image}`}- style={{- width: `${size}px`- }}- alt={`${name} logo`}+ src={`/images/integrations/${details.image}`}+ className="size-6"+ alt={`${details.name} logo`}/>- </div>- <div className="max-w-xs text-center text-xs font-medium text-gray-300 duration-200 group-hover:text-gray-200">- {name}- </div>- </button>- );- })}- {!filteredOptions?.length && (- <EmptyState- className="col-span-full mt-40"- title="No resources match search"- icon={faSearch}- />- )}+ <Label className="pointer-events-none">{details.name}</Label>+ {isComingSoon && <span className="ml-auto text-xs text-muted">Coming Soon</span>}+ </Button>+ );+ })}+ </div></div>- {Boolean(filteredOptions.length) && (- <Pagination- startAdornment={- <Tooltip- side="bottom"- className="max-w-sm py-4"- content={- <>- <p className="mb-2">Infisical is constantly adding support for more resources.</p>- <p>- {"If you don't see the resource you're looking for,"}{" "}- <a- target="_blank"- className="underline hover:text-mineshaft-300"- href="https://infisical.com/slack"- rel="noopener noreferrer"- >- let us know on Slack- </a>{" "}- or{" "}- <a- target="_blank"- className="underline hover:text-mineshaft-300"- href="https://github.com/Infisical/infisical/discussions"- rel="noopener noreferrer"- >- make a request on GitHub- </a>- .- </p>- </>- }- >- <div className="-ml-3 flex items-center gap-1.5 text-mineshaft-400">- <span className="text-xs">Don't see the resource you're looking for?</span>- <FontAwesomeIcon size="xs" icon={faInfoCircle} />- </div>- </Tooltip>- }- count={filteredOptions.length}- page={page}- perPage={perPage}- onChangePage={setPage}- onChangePerPage={setPerPage}- perPageList={[16]}- />- )}<UpgradePlanModalisOpen={popUp.upgradePlan.isOpen}onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}text={popUp.upgradePlan.data?.text}isEnterpriseFeature={popUp.upgradePlan.data?.isEnterpriseFeature}/>- </div>+ </>);};