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
fix(cert-manager): create CA install connections in a Combobox creation dialog
Claude99377adb0f68
diff --git a/AGENTS.md b/AGENTS.mdindex 6fe637991b..80fde2c7f3 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -28,7 +28,7 @@ When building frontend UI, follow [DESIGN.md](DESIGN.md) for the v3 design systeBefore changing a shared frontend component's lifecycle, read the [shared component lifecycle ledger](frontend/src/components/COMPONENT_LIFECYCLE.md) for current deprecations, blockers, and replacement decisions.-Pickers for entities a user may need to create first (app connections, gateways, and similar) must offer an inline "Create new X" row, gated on the create permission, so the user never has to leave the flow. Build them with the v3 `Combobox` and its `creation` prop, which renders that row; `Combobox` replaces both the deprecated `FilterableSelect` and `CreatableSelect`. For app connections, have `creation` open `AddAppConnectionModal` with the app preset and select the new connection on completion (see `CaInstallCertModal/VenafiCaInstallForm.tsx`).+Pickers for entities a user may need to create first (app connections, gateways, and similar) must offer an inline "Create new X" row, gated on the create permission, so the user never has to leave the flow. Build them with the v3 `Combobox` and its `creation` prop, which renders that row; `Combobox` replaces both the deprecated `FilterableSelect` and `CreatableSelect`. For app connections, use `creation.mode = "dialog"` and have `renderForm` render `AppConnectionForm` with the app preset, selecting the new connection and calling `complete` in its `onComplete` (see `CaInstallCertModal/VenafiCaInstallForm.tsx`).## Issue and PR Guidelinesdiff --git a/frontend/src/components/v3/generic/Combobox/Combobox.regression.stories.tsx b/frontend/src/components/v3/generic/Combobox/Combobox.regression.stories.tsxindex 8ca18c7f9d..914723d5fb 100644--- a/frontend/src/components/v3/generic/Combobox/Combobox.regression.stories.tsx+++ b/frontend/src/components/v3/generic/Combobox/Combobox.regression.stories.tsx@@ -3,6 +3,7 @@ import type { Meta, StoryObj } from "@storybook/react-vite";import { Combobox } from "./Combobox";import {ComboboxStoryFrame,+ DialogCreationFromEmptyQuery as DialogCreationFromEmptyQueryStory,DismissedPendingCreation as DismissedPendingCreationStory,OpaqueOptionFields as OpaqueOptionFieldsStory,PreserveNewQueryDuringCreation as PreserveNewQueryDuringCreationStory,@@ -46,3 +47,4 @@ export const PreserveNewQueryDuringCreation: Story = {};export const UnmountedPendingCreation: Story = { ...UnmountedPendingCreationStory };export const ValidatedCreation: Story = { ...ValidatedCreationStory };+export const DialogCreationFromEmptyQuery: Story = { ...DialogCreationFromEmptyQueryStory };diff --git a/frontend/src/components/v3/generic/Combobox/Combobox.stories.tsx b/frontend/src/components/v3/generic/Combobox/Combobox.stories.tsxindex 3d59aca794..36e7e6b168 100644--- a/frontend/src/components/v3/generic/Combobox/Combobox.stories.tsx+++ b/frontend/src/components/v3/generic/Combobox/Combobox.stories.tsx@@ -1740,6 +1740,58 @@ export const DialogCreation: Story = {}};+export const DialogCreationFromEmptyQuery: Story = {+ name: "Creation: Dialog From Empty Query",+ parameters: {+ docs: {+ description: {+ story:+ "Dialog creation collects its own fields, so its Create row is enabled with an empty query and opens the dialog with an empty `initialInput`. Inline creation still needs a query."+ }+ }+ },+ render: () => (+ <div className="flex w-80 flex-col gap-8">+ <SingleDialogCreationRender />+ <MultipleDialogCreationRender />+ </div>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);+ const primaryInput = canvas.getByRole("combobox", { name: "Primary tag" });+ const additionalInput = canvas.getByRole("combobox", { name: "Additional tags" });++ await userEvent.click(primaryInput);+ await expect(canvas.getByRole("option", { name: "Create" })).not.toHaveAttribute(+ "aria-disabled",+ "true"+ );+ await userEvent.click(canvas.getByRole("option", { name: "Create" }));+ let dialog = await body.findByRole("dialog", { name: "Create Tag" });+ await expect(within(dialog).getByLabelText("Name")).toHaveValue("");+ await userEvent.type(within(dialog).getByLabelText("Name"), "Release workflow");+ await userEvent.type(within(dialog).getByLabelText("Slug"), "release-workflow");+ await userEvent.click(within(dialog).getByRole("button", { name: "Create Tag" }));+ await expect(await canvas.findByLabelText("Release workflow metadata")).toBeInTheDocument();+ await waitFor(() =>+ expect(body.queryByRole("dialog", { name: "Create Tag" })).not.toBeInTheDocument()+ );+ await waitFor(() => expect(primaryInput).toHaveFocus());++ await userEvent.click(additionalInput);+ await userEvent.click(canvas.getByRole("option", { name: "Create" }));+ dialog = await body.findByRole("dialog", { name: "Create Tag" });+ await expect(within(dialog).getByLabelText("Name")).toHaveValue("");+ await userEvent.click(within(dialog).getByRole("button", { name: "Cancel" }));+ await waitFor(() =>+ expect(body.queryByRole("dialog", { name: "Create Tag" })).not.toBeInTheDocument()+ );+ await waitFor(() => expect(additionalInput).toHaveFocus());+ await waitFor(() => expect(additionalInput).toHaveAttribute("aria-expanded", "true"));+ }+};+const GroupedRemoteCreationRender = () => {const [query, setQuery] = useState("");const [options, setOptions] = useState(TAGS);diff --git a/frontend/src/components/v3/generic/Combobox/Combobox.tsx b/frontend/src/components/v3/generic/Combobox/Combobox.tsxindex 033777bd6d..7cc02fc7e9 100644--- a/frontend/src/components/v3/generic/Combobox/Combobox.tsx+++ b/frontend/src/components/v3/generic/Combobox/Combobox.tsx@@ -920,8 +920,9 @@ const SingleCombobox = <TOption,>(props: ComboboxSingleProps<TOption>) => {onSearchChange?.(nextSearch);onInputValueChange?.(nextSearch);};+ // Dialog creation collects its own fields, so its create row also opens from an empty query.const creationInput =- creation && isEditing+ (creation && isEditing? getComboboxCreationInput({inputValue: search,options,@@ -930,7 +931,7 @@ const SingleCombobox = <TOption,>(props: ComboboxSingleProps<TOption>) => {isDuplicate: creation.isDuplicate,isValid: creation.isValid})- : null;+ : null) ?? (isDialogCreationConfig(creation) && !(isEditing && search.trim()) ? "" : null);const handleCreationSuccess = React.useCallback((inputValue: string) => {if (searchRef.current.trim() !== inputValue) return;@@ -1006,7 +1007,7 @@ const SingleCombobox = <TOption,>(props: ComboboxSingleProps<TOption>) => {}if (nextValue.type === "create") {eventDetails.cancel();- if (!creationInput || nextValue.inputValue !== creationInput) return;+ if (creationInput === null || nextValue.inputValue !== creationInput) return;if (dialogCreation.creation) {isDialogCreationActiveRef.current = true;setOpen(false);@@ -1178,7 +1179,7 @@ const SingleCombobox = <TOption,>(props: ComboboxSingleProps<TOption>) => {showEmptyMessage={!creation}creation={creation}creationItem={creationItem}- canCreate={Boolean(creationInput)}+ canCreate={creationInput !== null}creationError={creationError}isCreationPending={isCreationPending}selectedValues={selectedValues}@@ -1314,16 +1315,18 @@ const MultipleCombobox = <TOption,>({const areAllOptionsSelected =selectAllOptions.length > 0 &&selectAllOptions.every((option) => selectedValues.has(getOptionValue(option)));- const creationInput = creation- ? getComboboxCreationInput({- inputValue: search,- options,- selectedOptions,- getOptionLabel,- isDuplicate: creation.isDuplicate,- isValid: creation.isValid- })- : null;+ // Dialog creation collects its own fields, so its create row also opens from an empty query.+ const creationInput =+ (creation+ ? getComboboxCreationInput({+ inputValue: search,+ options,+ selectedOptions,+ getOptionLabel,+ isDuplicate: creation.isDuplicate,+ isValid: creation.isValid+ })+ : null) ?? (isDialogCreationConfig(creation) && !search.trim() ? "" : null);const handleCreationSuccess = React.useCallback((inputValue: string) => {if (searchRef.current.trim() !== inputValue) return;@@ -1412,7 +1415,7 @@ const MultipleCombobox = <TOption,>({const createItem = nextValue.find((item) => item.type === "create");if (createItem) {eventDetails.cancel();- if (!creationInput || createItem.inputValue !== creationInput) return;+ if (creationInput === null || createItem.inputValue !== creationInput) return;if (dialogCreation.creation) {isDialogCreationActiveRef.current = true;openRef.current = false;@@ -1597,7 +1600,7 @@ const MultipleCombobox = <TOption,>({showEmptyMessage={!creation}creation={creation}creationItem={creationItem}- canCreate={Boolean(creationInput)}+ canCreate={creationInput !== null}creationError={creationError}isCreationPending={isCreationPending}selectedValues={selectedValues}diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/AdcsCaInstallForm.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/AdcsCaInstallForm.tsxindex bb64149a91..fb3ddfc630 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/AdcsCaInstallForm.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/AdcsCaInstallForm.tsx@@ -1,4 +1,3 @@-import { useState } from "react";import { Controller, useForm } from "react-hook-form";import { SingleValue } from "react-select";import { zodResolver } from "@hookform/resolvers/zod";@@ -28,7 +27,7 @@ import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";import { useAzureAdcsConnectionListTemplates } from "@app/hooks/api/appConnections/azure-adcs";import { AppConnection } from "@app/hooks/api/appConnections/enums";import { UsePopUpState } from "@app/hooks/usePopUp";-import { AddAppConnectionModal } from "@app/pages/organization/AppConnections/AppConnectionsPage/components";+import { AppConnectionForm } from "@app/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm";const schema = z.object({appConnectionId: z.string().min(1, "App connection is required"),@@ -55,7 +54,7 @@ export const AdcsCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {const { data: availableAdcsConnections, isPending: isAdcsPending } =useListAvailableAppConnections(AppConnection.AzureADCS, currentProject.id);const { permission } = useProjectPermission();- const [isCreateConnectionOpen, setIsCreateConnectionOpen] = useState(false);+ const createConnectionLabel = `Create ${APP_CONNECTION_MAP[AppConnection.AzureADCS].name} Connection`;const canCreateConnection = permission.can(ProjectPermissionAppConnectionActions.Create,ProjectPermissionSub.AppConnections@@ -66,7 +65,6 @@ export const AdcsCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {handleSubmit,reset,watch,- setValue,formState: { isSubmitting }} = useForm<FormData>({resolver: zodResolver(schema),@@ -163,10 +161,23 @@ export const AdcsCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {creation={canCreateConnection? {- emptyLabel: `Create ${APP_CONNECTION_MAP[AppConnection.AzureADCS].name} Connection`,- formatLabel: () =>- `Create ${APP_CONNECTION_MAP[AppConnection.AzureADCS].name} Connection`,- onCreate: () => setIsCreateConnectionOpen(true)+ mode: "dialog",+ title: createConnectionLabel,+ description: "The new connection is selected once it is created.",+ emptyLabel: createConnectionLabel,+ formatLabel: () => createConnectionLabel,+ renderForm: ({ complete, cancel }) => (+ <AppConnectionForm+ app={AppConnection.AzureADCS}+ projectId={currentProject.id}+ projectType={currentProject.type}+ onComplete={(connection) => {+ onChange(connection.id);+ complete();+ }}+ onCancel={cancel}+ />+ )}: undefined}@@ -175,19 +186,6 @@ export const AdcsCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {</Field>)}/>- {/* the modal portals out of the DOM but React still bubbles its submit to this form */}- <div className="contents" onSubmit={(e) => e.stopPropagation()}>- <AddAppConnectionModal- isOpen={isCreateConnectionOpen}- onOpenChange={setIsCreateConnectionOpen}- projectType={currentProject.type}- projectId={currentProject.id}- app={AppConnection.AzureADCS}- onComplete={(connection) => {- setValue("appConnectionId", connection.id, { shouldValidate: true });- }}- />- </div><Controllercontrol={control}name="template"diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/AdcsNativeCaInstallForm.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/AdcsNativeCaInstallForm.tsxindex cb25f2177b..40b5dbe5d0 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/AdcsNativeCaInstallForm.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/AdcsNativeCaInstallForm.tsx@@ -1,4 +1,3 @@-import { useState } from "react";import { Controller, useForm } from "react-hook-form";import { SingleValue } from "react-select";import { zodResolver } from "@hookform/resolvers/zod";@@ -28,7 +27,7 @@ import { useListAvailableAppConnections } from "@app/hooks/api/appConnections";import { useAdcsConnectionListCertificateTemplates } from "@app/hooks/api/appConnections/adcs";import { AppConnection } from "@app/hooks/api/appConnections/enums";import { UsePopUpState } from "@app/hooks/usePopUp";-import { AddAppConnectionModal } from "@app/pages/organization/AppConnections/AppConnectionsPage/components";+import { AppConnectionForm } from "@app/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm";const schema = z.object({appConnectionId: z.string().min(1, "App connection is required"),@@ -49,7 +48,7 @@ export const AdcsNativeCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {const { data: availableAdcsConnections, isPending: isAdcsPending } =useListAvailableAppConnections(AppConnection.ADCS, currentProject.id);const { permission } = useProjectPermission();- const [isCreateConnectionOpen, setIsCreateConnectionOpen] = useState(false);+ const createConnectionLabel = `Create ${APP_CONNECTION_MAP[AppConnection.ADCS].name} Connection`;const canCreateConnection = permission.can(ProjectPermissionAppConnectionActions.Create,ProjectPermissionSub.AppConnections@@ -60,7 +59,6 @@ export const AdcsNativeCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {handleSubmit,reset,watch,- setValue,formState: { isSubmitting }} = useForm<FormData>({resolver: zodResolver(schema),@@ -149,10 +147,23 @@ export const AdcsNativeCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {creation={canCreateConnection? {- emptyLabel: `Create ${APP_CONNECTION_MAP[AppConnection.ADCS].name} Connection`,- formatLabel: () =>- `Create ${APP_CONNECTION_MAP[AppConnection.ADCS].name} Connection`,- onCreate: () => setIsCreateConnectionOpen(true)+ mode: "dialog",+ title: createConnectionLabel,+ description: "The new connection is selected once it is created.",+ emptyLabel: createConnectionLabel,+ formatLabel: () => createConnectionLabel,+ renderForm: ({ complete, cancel }) => (+ <AppConnectionForm+ app={AppConnection.ADCS}+ projectId={currentProject.id}+ projectType={currentProject.type}+ onComplete={(connection) => {+ onChange(connection.id);+ complete();+ }}+ onCancel={cancel}+ />+ )}: undefined}@@ -161,19 +172,6 @@ export const AdcsNativeCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {</Field>)}/>- {/* the modal portals out of the DOM but React still bubbles its submit to this form */}- <div className="contents" onSubmit={(e) => e.stopPropagation()}>- <AddAppConnectionModal- isOpen={isCreateConnectionOpen}- onOpenChange={setIsCreateConnectionOpen}- projectType={currentProject.type}- projectId={currentProject.id}- app={AppConnection.ADCS}- onComplete={(connection) => {- setValue("appConnectionId", connection.id, { shouldValidate: true });- }}- />- </div><Controllercontrol={control}name="template"diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/VenafiCaInstallForm.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/VenafiCaInstallForm.tsxindex ed22261d9d..7118de234d 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/VenafiCaInstallForm.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/VenafiCaInstallForm.tsx@@ -1,4 +1,3 @@-import { useState } from "react";import { Controller, useForm } from "react-hook-form";import { SingleValue } from "react-select";import { zodResolver } from "@hookform/resolvers/zod";@@ -33,7 +32,7 @@ import {useVenafiConnectionListIssuingTemplates} from "@app/hooks/api/appConnections/venafi";import { UsePopUpState } from "@app/hooks/usePopUp";-import { AddAppConnectionModal } from "@app/pages/organization/AppConnections/AppConnectionsPage/components";+import { AppConnectionForm } from "@app/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm";const schema = z.object({appConnectionId: z.string().min(1, "App connection is required"),@@ -61,7 +60,7 @@ export const VenafiCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {const { data: availableVenafiConnections, isPending: isVenafiPending } =useListAvailableAppConnections(AppConnection.Venafi, currentProject.id);const { permission } = useProjectPermission();- const [isCreateConnectionOpen, setIsCreateConnectionOpen] = useState(false);+ const createConnectionLabel = `Create ${APP_CONNECTION_MAP[AppConnection.Venafi].name} Connection`;const canCreateConnection = permission.can(ProjectPermissionAppConnectionActions.Create,ProjectPermissionSub.AppConnections@@ -183,10 +182,25 @@ export const VenafiCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {creation={canCreateConnection? {- emptyLabel: `Create ${APP_CONNECTION_MAP[AppConnection.Venafi].name} Connection`,- formatLabel: () =>- `Create ${APP_CONNECTION_MAP[AppConnection.Venafi].name} Connection`,- onCreate: () => setIsCreateConnectionOpen(true)+ mode: "dialog",+ title: createConnectionLabel,+ description: "The new connection is selected once it is created.",+ emptyLabel: createConnectionLabel,+ formatLabel: () => createConnectionLabel,+ renderForm: ({ complete, cancel }) => (+ <AppConnectionForm+ app={AppConnection.Venafi}+ projectId={currentProject.id}+ projectType={currentProject.type}+ onComplete={(connection) => {+ onChange(connection.id);+ setValue("applicationId", "");+ setValue("issuingTemplateId", "");+ complete();+ }}+ onCancel={cancel}+ />+ )}: undefined}@@ -195,21 +209,6 @@ export const VenafiCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {</Field>)}/>- {/* the modal portals out of the DOM but React still bubbles its submit to this form */}- <div className="contents" onSubmit={(e) => e.stopPropagation()}>- <AddAppConnectionModal- isOpen={isCreateConnectionOpen}- onOpenChange={setIsCreateConnectionOpen}- projectType={currentProject.type}- projectId={currentProject.id}- app={AppConnection.Venafi}- onComplete={(connection) => {- setValue("appConnectionId", connection.id, { shouldValidate: true });- setValue("applicationId", "");- setValue("issuingTemplateId", "");- }}- />- </div><Controllercontrol={control}name="applicationId"