diff --git a/apps/webservice/src/app/[workspaceSlug]/_components/ReleaseBadgeList.tsx b/apps/webservice/src/app/[workspaceSlug]/_components/ReleaseBadgeList.tsx new file mode 100644 index 00000000..053a4131 --- /dev/null +++ b/apps/webservice/src/app/[workspaceSlug]/_components/ReleaseBadgeList.tsx @@ -0,0 +1,31 @@ +import type * as SCHEMA from "@ctrlplane/db/schema"; + +import { Badge } from "@ctrlplane/ui/badge"; + +type ReleaseBadgeListProps = { + releases: { + items: SCHEMA.Release[]; + total: number; + }; +}; + +export const ReleaseBadgeList: React.FC = ({ + releases, +}) => ( +
+ {releases.items.map((release) => ( + + + {release.name} + + + ))} + {releases.total > releases.items.length && ( + + + +{releases.total - releases.items.length} + + + )} +
+); diff --git a/apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Overview.tsx b/apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Overview.tsx new file mode 100644 index 00000000..422b073d --- /dev/null +++ b/apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Overview.tsx @@ -0,0 +1,91 @@ +import type * as SCHEMA from "@ctrlplane/db/schema"; +import type React from "react"; +import { useRouter } from "next/navigation"; +import { z } from "zod"; + +import { Button } from "@ctrlplane/ui/button"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, + useForm, +} from "@ctrlplane/ui/form"; +import { Input } from "@ctrlplane/ui/input"; +import { Textarea } from "@ctrlplane/ui/textarea"; + +import { api } from "~/trpc/react"; + +type OverviewProps = { + releaseChannel: SCHEMA.ReleaseChannel; +}; + +const schema = z.object({ + name: z.string().min(1).max(50), + description: z.string().max(1000).optional(), +}); + +export const Overview: React.FC = ({ releaseChannel }) => { + const defaultValues = { + name: releaseChannel.name, + description: releaseChannel.description ?? undefined, + }; + const form = useForm({ schema, defaultValues }); + const router = useRouter(); + const utils = api.useUtils(); + + const updateReleaseChannel = + api.deployment.releaseChannel.update.useMutation(); + const onSubmit = form.handleSubmit((data) => + updateReleaseChannel + .mutateAsync({ id: releaseChannel.id, data }) + .then(() => form.reset(data)) + .then(() => + utils.deployment.releaseChannel.byId.invalidate(releaseChannel.id), + ) + .then(() => router.refresh()), + ); + + return ( +
+ + ( + + Name + + + + + + )} + /> + + ( + + Description + +