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
import { Controller, useFormContext, useWatch } from "react-hook-form";
import { Info } from "lucide-react";
import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField";
import {
Combobox,
Field,
FieldContent,
FieldError,
FieldGroup,
FieldLabel,
Input,
Tooltip,
TooltipContent,
TooltipTrigger
} from "@app/components/v3";
import { useWindmillConnectionListWorkspaces } from "@app/hooks/api/appConnections/windmill";
import { SecretSync } from "@app/hooks/api/secretSyncs";
import { TSecretSyncForm } from "../schemas";
export const WindmillSyncFields = () => {
const { control, setValue } = useFormContext<
TSecretSyncForm & { destination: SecretSync.Windmill }
>();
const connectionId = useWatch({ name: "connection.id", control });
const { data: workspaces, isLoading: isWorkspacesLoading } = useWindmillConnectionListWorkspaces(
connectionId,
{
enabled: Boolean(connectionId)
}
);
return (
<FieldGroup>
<SecretSyncConnectionField
onChange={() => {
setValue("destinationConfig.workspace", "");
}}
/>
<Controller
name="destinationConfig.workspace"
control={control}
render={({ field: { value, onChange }, fieldState: { error } }) => (
<Field>
<FieldLabel
id="secret-sync-windmill-workspace-label"
htmlFor="secret-sync-windmill-workspace"
>
Workspace
<Tooltip>
<TooltipTrigger asChild>
<Info />
</TooltipTrigger>
<TooltipContent className="max-w-md">
Ensure the workspace exists in the connection's Windmill instance URL.
</TooltipContent>
</Tooltip>
</FieldLabel>
<FieldContent>
<Combobox
aria-labelledby="secret-sync-windmill-workspace-label"
aria-describedby={error ? "secret-sync-windmill-workspace-error" : undefined}
id="secret-sync-windmill-workspace"
isError={Boolean(error)}
isLoading={isWorkspacesLoading && Boolean(connectionId)}
isDisabled={!connectionId}
value={workspaces?.find((workspace) => workspace.name === value) ?? null}
onValueChange={(option) => onChange(option?.name ?? null)}
options={workspaces}
placeholder="Select a workspace..."
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.name}
modal
/>
<FieldError id="secret-sync-windmill-workspace-error" errors={[error]} />
</FieldContent>
</Field>
)}
/>
<Controller
name="destinationConfig.path"
control={control}
render={({ field: { value, onChange }, fieldState: { error } }) => (
<Field>
<FieldLabel>
Path
<Tooltip>
<TooltipTrigger asChild>
<Info />
</TooltipTrigger>
<TooltipContent className="max-w-sm">
The workspace path where secrets should be synced to. Path must follow Windmill{" "}
<a
target="_blank"
rel="noopener noreferrer"
href="https://www.windmill.dev/docs/core_concepts/roles_and_permissions#path"
>
<span className="cursor-pointer underline decoration-project underline-offset-2 hover:text-foreground-secondary">
owner path convention
</span>
.
</a>
</TooltipContent>
</Tooltip>
</FieldLabel>
<FieldContent>
<Input
value={value}
onChange={onChange}
placeholder="f/folder-name/"
isError={Boolean(error)}
/>
<FieldError errors={[error]} />
</FieldContent>
</Field>
)}
/>
</FieldGroup>
);
};