diff --git a/apps/webservice/src/app/[workspaceSlug]/systems/[systemSlug]/_components/variables/ConfigFields.tsx b/apps/webservice/src/app/[workspaceSlug]/systems/[systemSlug]/_components/variables/ConfigFields.tsx index 79b2c953..89a6586c 100644 --- a/apps/webservice/src/app/[workspaceSlug]/systems/[systemSlug]/_components/variables/ConfigFields.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/systems/[systemSlug]/_components/variables/ConfigFields.tsx @@ -34,16 +34,25 @@ import { TargetConditionDialog } from "~/app/[workspaceSlug]/_components/target- export const ConfigTypeSelector: React.FC<{ value: string | undefined; onChange: (type: string) => void; -}> = ({ value, onChange }) => ( + exclude?: string[]; +}> = ({ value, onChange, exclude }) => ( ); diff --git a/apps/webservice/src/app/[workspaceSlug]/systems/[systemSlug]/deployments/[deploymentSlug]/releases/CreateVariableDialog.tsx b/apps/webservice/src/app/[workspaceSlug]/systems/[systemSlug]/deployments/[deploymentSlug]/releases/CreateVariableDialog.tsx index af347036..fd6d3d6a 100644 --- a/apps/webservice/src/app/[workspaceSlug]/systems/[systemSlug]/deployments/[deploymentSlug]/releases/CreateVariableDialog.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/systems/[systemSlug]/deployments/[deploymentSlug]/releases/CreateVariableDialog.tsx @@ -3,7 +3,6 @@ import { useState } from "react"; import { useRouter } from "next/navigation"; import { IconBulb } from "@tabler/icons-react"; -import _ from "lodash"; import { z } from "zod"; import { Alert, AlertTitle } from "@ctrlplane/ui/alert"; @@ -32,7 +31,6 @@ import { VariableConfig } from "@ctrlplane/validators/variables"; import { BooleanConfigFields, - ChoiceConfigFields, ConfigTypeSelector, NumberConfigFields, StringConfigFields, @@ -60,8 +58,6 @@ export const CreateVariableDialog: React.FC<{ }, }); - const { config } = form.watch(); - const onSubmit = form.handleSubmit(async (values) => { await create.mutateAsync({ ...values, @@ -118,13 +114,8 @@ export const CreateVariableDialog: React.FC<{ { - if (type === "choice") { - onChange({ type, options: [] }); - return; - } - onChange({ type }); - }} + onChange={(type: string) => onChange({ type })} + exclude={["choice"]} /> @@ -155,21 +146,10 @@ export const CreateVariableDialog: React.FC<{ } /> )} - - {value.type === "choice" && ( - - onChange({ ...value, ...updates }) - } - /> - )} )} /> -
{JSON.stringify(config, null, 2)}
- = ({ workspace, jobAgents, runbook, children }) => { + const [open, setOpen] = useState(false); + const update = api.runbook.update.useMutation(); + const form = useForm({ + schema: updateRunbookSchema, + disabled: update.isPending, + defaultValues: { + ...runbook, + description: runbook.description ?? "", + jobAgentId: runbook.jobAgentId ?? "", + }, + }); + + const router = useRouter(); + const onSubmit = form.handleSubmit(async (data) => + update + .mutateAsync({ id: runbook.id, data }) + .then(() => router.refresh()) + .then(() => setOpen(false)), + ); + + const jobAgentId = form.watch("jobAgentId"); + const jobAgent = jobAgents.find((j) => j.id === jobAgentId); + return ( + + {children} + + + Edit Runbook + +
+ +
+
General
+ ( + + Name + + + + + + )} + /> + ( + + Description + +