From 21e76f9ad75c5f8c1bcf01cf5ed0024b93f85cd0 Mon Sep 17 00:00:00 2001 From: Aditya Choudhari <48932219+adityachoudhari26@users.noreply.github.com> Date: Sun, 1 Dec 2024 00:07:17 -0800 Subject: [PATCH] fix: Settings page runbooks (#242) --- .../runbooks/EditRunbookDialog.tsx | 144 ++-------------- .../[systemSlug]/runbooks/EditRunbookForm.tsx | 160 ++++++++++++++++++ .../runbooks/[runbookId]/RunbookNavBar.tsx | 29 ++-- .../runbooks/[runbookId]/layout.tsx | 2 +- .../[runbookId]/settings/EditRunbook.tsx | 49 ++++++ .../runbooks/[runbookId]/settings/page.tsx | 32 ++++ packages/api/src/router/runbook.ts | 5 +- 7 files changed, 277 insertions(+), 144 deletions(-) create mode 100644 apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/runbooks/EditRunbookForm.tsx create mode 100644 apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/runbooks/[runbookId]/settings/EditRunbook.tsx create mode 100644 apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/runbooks/[runbookId]/settings/page.tsx diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/runbooks/EditRunbookDialog.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/runbooks/EditRunbookDialog.tsx index 3f59b10c..29f884ac 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/runbooks/EditRunbookDialog.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/runbooks/EditRunbookDialog.tsx @@ -7,7 +7,6 @@ import { useRouter } from "next/navigation"; import { z } from "zod"; import { createRunbookVariable } from "@ctrlplane/db/schema"; -import { Button } from "@ctrlplane/ui/button"; import { Dialog, DialogContent, @@ -15,23 +14,11 @@ import { DialogTitle, DialogTrigger, } from "@ctrlplane/ui/dialog"; -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, - FormRootError, - useForm, -} from "@ctrlplane/ui/form"; -import { Input } from "@ctrlplane/ui/input"; -import { Textarea } from "@ctrlplane/ui/textarea"; +import { useForm } from "@ctrlplane/ui/form"; -import { JobAgentConfig } from "~/components/form/job-agent/JobAgentConfig"; -import { JobAgentSelector } from "~/components/form/job-agent/JobAgentSelector"; +import type { EditRunbookFormSchema } from "./EditRunbookForm"; import { api } from "~/trpc/react"; -import { RunbookVariablesEditor } from "./create/RunbookVariableEditor"; +import { EditRunbookForm } from "./EditRunbookForm"; const updateRunbookSchema = z.object({ name: z.string().min(1), @@ -60,12 +47,12 @@ export const EditRunbookDialog: React.FC<{ }); const router = useRouter(); - const onSubmit = form.handleSubmit(async (data) => + + const onSubmit = (data: EditRunbookFormSchema) => update .mutateAsync({ id: runbook.id, data }) .then(() => router.refresh()) - .then(() => setOpen(false)), - ); + .then(() => setOpen(false)); const jobAgentId = form.watch("jobAgentId"); const jobAgent = jobAgents.find((j) => j.id === jobAgentId); @@ -76,118 +63,13 @@ export const EditRunbookDialog: React.FC<{ Edit Runbook -
- -
-
General
- ( - - Name - - - - - - )} - /> - ( - - Description - -