Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
chore: status page configuration settings (#1582)
Maximilian Kaske024ac9f2d1c3
diff --git a/apps/dashboard/src/components/common/note.tsx b/apps/dashboard/src/components/common/note.tsxindex 3f82faf56..550560186 100644--- a/apps/dashboard/src/components/common/note.tsx+++ b/apps/dashboard/src/components/common/note.tsx@@ -3,7 +3,7 @@ import { cn } from "@/lib/utils";import { type VariantProps, cva } from "class-variance-authority";const noteVariants = cva(- "flex items-center gap-2 rounded-md border px-3 py-2 [&>svg]:size-4 [&>svg]:text-current [&>svg]:shrink-0",+ "flex items-center gap-2 rounded-xl border px-3 py-2 [&>svg]:size-4 [&>svg]:text-current [&>svg]:shrink-0",{variants: {variant: {diff --git a/apps/dashboard/src/components/forms/form-alert-dialog.tsx b/apps/dashboard/src/components/forms/form-alert-dialog.tsxindex d8cc5e3ca..055f51106 100644--- a/apps/dashboard/src/components/forms/form-alert-dialog.tsx+++ b/apps/dashboard/src/components/forms/form-alert-dialog.tsx@@ -61,18 +61,17 @@ export function FormAlertDialog({<AlertDialogTrigger asChild>{children ?? (<Button variant="destructive" size="sm">- Revoke+ Delete</Button>)}</AlertDialogTrigger><AlertDialogContent><AlertDialogHeader><AlertDialogTitle>- Are you sure about revoking `{title}`?+ Are you sure about delete `{title}`?</AlertDialogTitle><AlertDialogDescription>- This action cannot be undone. This will permanently revoke the API- key.+ This action cannot be undone. This will permanently delete the item.</AlertDialogDescription></AlertDialogHeader><form id="form-alert-dialog" className="space-y-0.5">diff --git a/apps/dashboard/src/components/forms/monitor/form-danger-zone.tsx b/apps/dashboard/src/components/forms/monitor/form-danger-zone.tsxindex a990b0653..24dd8a5fe 100644--- a/apps/dashboard/src/components/forms/monitor/form-danger-zone.tsx+++ b/apps/dashboard/src/components/forms/monitor/form-danger-zone.tsx@@ -11,8 +11,10 @@ import {export function FormDangerZone({onSubmit,+ title,}: {onSubmit: () => Promise<void>;+ title: string;}) {return (<FormCard variant="destructive">@@ -22,7 +24,7 @@ export function FormDangerZone({</FormCardHeader><FormCardFooter variant="destructive" className="justify-end"><FormAlertDialog- title="OpenStatus API"+ title={title}confirmationValue="delete monitor"submitAction={onSubmit}/>diff --git a/apps/dashboard/src/components/forms/monitor/update.tsx b/apps/dashboard/src/components/forms/monitor/update.tsxindex 5789afcea..d514e6b92 100644--- a/apps/dashboard/src/components/forms/monitor/update.tsx+++ b/apps/dashboard/src/components/forms/monitor/update.tsx@@ -265,6 +265,7 @@ export function FormMonitorUpdate() {}}/><FormDangerZone+ title={monitor.name}onSubmit={async () => {await deleteMonitorMutation.mutateAsync({ id: Number.parseInt(id) });}}diff --git a/apps/dashboard/src/components/forms/status-page/form-appearance.tsx b/apps/dashboard/src/components/forms/status-page/form-appearance.tsxindex 74f552b6e..ab22bdf21 100644--- a/apps/dashboard/src/components/forms/status-page/form-appearance.tsx+++ b/apps/dashboard/src/components/forms/status-page/form-appearance.tsx@@ -1,6 +1,7 @@import { useTransition } from "react";import { z } from "zod";+import { Link } from "@/components/common/link";import {FormCard,FormCardContent,@@ -11,14 +12,28 @@ import {FormCardTitle,} from "@/components/forms/form-card";import { Button } from "@/components/ui/button";+import {+ Command,+ CommandEmpty,+ CommandGroup,+ CommandInput,+ CommandItem,+ CommandList,+} from "@/components/ui/command";import {Form,FormControl,+ FormDescription,FormField,FormItem,FormLabel,FormMessage,} from "@/components/ui/form";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";import {Select,SelectContent,@@ -26,14 +41,22 @@ import {SelectTrigger,SelectValue,} from "@/components/ui/select";+import { cn } from "@/lib/utils";import { zodResolver } from "@hookform/resolvers/zod";+import { THEME_KEYS } from "@openstatus/theme-store";+import { THEMES } from "@openstatus/theme-store";+import type { ThemeKey } from "@openstatus/theme-store";import { isTRPCClientError } from "@trpc/client";-import { Laptop, Moon, Sun } from "lucide-react";+import { ArrowUpRight, Laptop, Moon, Sun } from "lucide-react";+import { Check, ChevronsUpDown } from "lucide-react";import { useForm } from "react-hook-form";import { toast } from "sonner";const schema = z.object({forceTheme: z.enum(["light", "dark", "system"]),+ configuration: z.object({+ theme: z.string(),+ }),});type FormValues = z.infer<typeof schema>;@@ -92,7 +115,7 @@ export function FormAppearance({name="forceTheme"render={({ field }) => (<FormItem>- <FormLabel className="sr-only">Theme</FormLabel>+ <FormLabel>Mode</FormLabel><SelectonValueChange={field.onChange}defaultValue={field.value}@@ -124,18 +147,101 @@ export function FormAppearance({</SelectContent></Select><FormMessage />+ <FormDescription>+ Override the user's preference.+ </FormDescription>+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="configuration.theme"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Style</FormLabel>+ <Popover>+ <PopoverTrigger asChild>+ <FormControl>+ <Button+ id="community-theme"+ variant="outline"+ role="combobox"+ className={cn(+ "w-full justify-between",+ !field.value && "text-muted-foreground",+ )}+ >+ <span className="truncate">+ {THEMES[field.value as ThemeKey]?.name ||+ "Select a theme"}+ </span>+ <ChevronsUpDown className="opacity-50" />+ </Button>+ </FormControl>+ </PopoverTrigger>+ <PopoverContent className="p-0" align="start">+ <Command>+ <CommandInput+ placeholder="Search themes..."+ className="h-9"+ />+ <CommandList>+ <CommandEmpty>No themes found.</CommandEmpty>+ <CommandGroup>+ {THEME_KEYS.map((theme) => {+ const { name, author } = THEMES[theme];+ return (+ <CommandItem+ value={theme}+ key={theme}+ keywords={[theme, name, author.name]}+ onSelect={(v) => field.onChange(v)}+ >+ <span className="truncate">{name}</span>+ <span className="truncate font-commit-mono text-muted-foreground text-xs">+ by {author.name}+ </span>+ <Check+ className={cn(+ "ml-auto",+ theme === field.value+ ? "opacity-100"+ : "opacity-0",+ )}+ />+ </CommandItem>+ );+ })}+ </CommandGroup>+ </CommandList>+ </Command>+ </PopoverContent>+ </Popover>+ <FormMessage />+ <FormDescription>Choose a theme to apply.</FormDescription></FormItem>)}/></FormCardContent><FormCardFooter><FormCardFooterInfo>- Your user will still be able to change the theme via the theme+ Your user will still be able to change the mode via the themetoggle.</FormCardFooterInfo>- <Button type="submit" disabled={isPending}>- {isPending ? "Submitting..." : "Submit"}- </Button>+ <div className="flex items-center gap-2">+ <Button type="button" variant="ghost" asChild>+ <Link+ href="https://themes.openstatus.dev"+ rel="noreferrer"+ target="_blank"+ >+ View Theme Explorer <ArrowUpRight className="h-4 w-4" />+ </Link>+ </Button>+ <Button type="submit" disabled={isPending}>+ {isPending ? "Submitting..." : "Submit"}+ </Button>+ </div></FormCardFooter></FormCard></form>diff --git a/apps/dashboard/src/components/forms/status-page/form-configuration.tsx b/apps/dashboard/src/components/forms/status-page/form-configuration.tsxindex 5b69a6b9b..8ad2f8cc0 100644--- a/apps/dashboard/src/components/forms/status-page/form-configuration.tsx+++ b/apps/dashboard/src/components/forms/status-page/form-configuration.tsx@@ -14,14 +14,6 @@ import {FormCardTitle,} from "@/components/forms/form-card";import { Button } from "@/components/ui/button";-import {- Command,- CommandEmpty,- CommandGroup,- CommandInput,- CommandItem,- CommandList,-} from "@/components/ui/command";import {Dialog,DialogClose,@@ -34,18 +26,11 @@ import {import {Form,FormControl,- FormDescription,FormField,FormItem,FormLabel,FormMessage,} from "@/components/ui/form";-import { Input } from "@/components/ui/input";-import {- Popover,- PopoverContent,- PopoverTrigger,-} from "@/components/ui/popover";import {Select,SelectContent,@@ -53,24 +38,19 @@ import {SelectTrigger,SelectValue,} from "@/components/ui/select";-import { Switch } from "@/components/ui/switch";-import { cn } from "@/lib/utils";import { zodResolver } from "@hookform/resolvers/zod";-import { THEMES, THEME_KEYS, type ThemeKey } from "@openstatus/theme-store";+import { THEMES, THEME_KEYS } from "@openstatus/theme-store";import { isTRPCClientError } from "@trpc/client";-import { ArrowUpRight, Check, ChevronsUpDown, Info } from "lucide-react";+import { ArrowUpRight } from "lucide-react";import { parseAsStringLiteral, useQueryStates } from "nuqs";-import { useForm } from "react-hook-form";+import { type UseFormReturn, useForm } from "react-hook-form";import { toast } from "sonner";const schema = z.object({- new: z.boolean(),configuration: z.record(z.string(),z.string().or(z.boolean().nullish()).optional(),),- homepageUrl: z.string().optional(),- contactUrl: z.string().optional(),});const configurationSchema = z@@ -107,13 +87,9 @@ export function FormConfiguration({const form = useForm<FormValues>({resolver: zodResolver(schema),defaultValues: defaultValues ?? {- new: false,configuration: {},- homepageUrl: "",- contactUrl: "",},});- const watchNew = form.watch("new");const watchConfigurationType = form.watch("configuration.type") as| "manual"| "absolute";@@ -165,320 +141,141 @@ export function FormConfiguration({<form id="redesign" onSubmit={form.handleSubmit(submitAction)}><FormCard variant="info"><FormCardHeader>- <FormCardTitle>Status Page Redesign (beta)</FormCardTitle>+ <FormCardTitle>Tracker Configuration</FormCardTitle><FormCardDescription>- Use the latest version of the status page and customize it.+ Configure which data should be shown in the monitor tracker.</FormCardDescription></FormCardHeader>- <FormCardContent className="grid gap-4 md:grid-cols-3">+ <FormCardSeparator />+ <FormCardContent className="grid gap-4 sm:grid-cols-3"><FormFieldcontrol={form.control}- name="new"+ name="configuration.type"render={({ field }) => (- <FormItem className="flex flex-row items-center justify-between">- <div className="space-y-0.5">- <FormLabel>Enable New Version</FormLabel>- <FormDescription>- More controls, better UI.- </FormDescription>- </div>- <FormControl>- <Switch- checked={field.value}- onCheckedChange={field.onChange}- />- </FormControl>+ <FormItem>+ <FormLabel>Bar Type</FormLabel>+ <Select+ onValueChange={field.onChange}+ defaultValue={String(field.value) ?? "absolute"}+ >+ <FormControl>+ <SelectTrigger className="w-full capitalize">+ <SelectValue placeholder="Select a type" />+ </SelectTrigger>+ </FormControl>+ <SelectContent>+ {["absolute", "manual"].map((type) => (+ <SelectItem+ key={type}+ value={type}+ className="capitalize"+ >+ {type}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <FormMessage /></FormItem>)}/>- <div className="flex items-center md:col-span-2 md:justify-end">- <Button size="sm" asChild>- <Link- href={configLink}- rel="noreferrer"- target="_blank"- className="inline-flex items-center gap-1"- >- View and configure status page{" "}- <ArrowUpRight className="h-4 w-4" />- </Link>- </Button>- </div>+ <FormField+ control={form.control}+ name="configuration.value"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Card Value</FormLabel>+ <Select+ onValueChange={field.onChange}+ defaultValue={String(field.value) ?? "duration"}+ disabled={watchConfigurationType === "manual"}+ >+ <FormControl>+ <SelectTrigger className="w-full capitalize">+ <SelectValue placeholder="Select a type" />+ </SelectTrigger>+ </FormControl>+ <SelectContent>+ {["duration", "requests"].map((type) => (+ <SelectItem+ key={type}+ value={type}+ className="capitalize"+ >+ {type}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <FormMessage />+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="configuration.uptime"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Show Uptime</FormLabel>+ <Select+ onValueChange={field.onChange}+ defaultValue={String(field.value) ?? "true"}+ >+ <FormControl>+ <SelectTrigger className="w-full capitalize">+ <SelectValue placeholder="Select a type" />+ </SelectTrigger>+ </FormControl>+ <SelectContent>+ {["true", "false"].map((type) => (+ <SelectItem+ key={type}+ value={type}+ className="capitalize"+ >+ {type}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <FormMessage />+ </FormItem>+ )}+ />+ <Note className="col-span-full">+ <ul className="list-inside list-disc">+ <li>+ <span className="font-medium">+ Bar Type{" "}+ <span className="font-semibold">+ {watchConfigurationType}+ </span>+ </span>+ : {message.type[watchConfigurationType]}+ </li>+ <li>+ <span className="font-medium">+ Card Value{" "}+ <span className="font-semibold">+ {watchConfigurationValue}+ </span>+ </span>+ :{" "}+ {message.value[watchConfigurationValue] ??+ message.value.default}+ </li>+ <li>+ <span className="font-medium">+ Show Uptime{" "}+ <span className="font-semibold">+ {watchConfigurationUptime}+ </span>+ </span>+ : {message.uptime[watchConfigurationUptime]}+ </li>+ </ul>+ </Note></FormCardContent>- {watchNew && (- <>- <FormCardSeparator />- <FormCardContent className="grid gap-4 sm:grid-cols-3">- <FormCardHeader className="col-span-full px-0 pt-0 pb-0">- <FormCardTitle>Tracker Configuration</FormCardTitle>- <FormCardDescription>- Configure which data should be shown in the monitor- tracker.- </FormCardDescription>- </FormCardHeader>- <FormField- control={form.control}- name="configuration.type"- render={({ field }) => (- <FormItem>- <FormLabel>Bar Type</FormLabel>- <Select- onValueChange={field.onChange}- defaultValue={String(field.value) ?? "absolute"}- >- <FormControl>- <SelectTrigger className="w-full capitalize">- <SelectValue placeholder="Select a type" />- </SelectTrigger>- </FormControl>- <SelectContent>- {["absolute", "manual"].map((type) => (- <SelectItem- key={type}- value={type}- className="capitalize"- >- {type}- </SelectItem>- ))}- </SelectContent>- </Select>- <FormMessage />- </FormItem>- )}- />- <FormField- control={form.control}- name="configuration.value"- render={({ field }) => (- <FormItem>- <FormLabel>Card Value</FormLabel>- <Select- onValueChange={field.onChange}- defaultValue={String(field.value) ?? "duration"}- disabled={watchConfigurationType === "manual"}- >- <FormControl>- <SelectTrigger className="w-full capitalize">- <SelectValue placeholder="Select a type" />- </SelectTrigger>- </FormControl>- <SelectContent>- {["duration", "requests"].map((type) => (- <SelectItem- key={type}- value={type}- className="capitalize"- >- {type}- </SelectItem>- ))}- </SelectContent>- </Select>- <FormMessage />- </FormItem>- )}- />- <FormField- control={form.control}- name="configuration.uptime"- render={({ field }) => (- <FormItem>- <FormLabel>Show Uptime</FormLabel>- <Select- onValueChange={field.onChange}- defaultValue={String(field.value) ?? "true"}- >- <FormControl>- <SelectTrigger className="w-full capitalize">- <SelectValue placeholder="Select a type" />- </SelectTrigger>- </FormControl>- <SelectContent>- {["true", "false"].map((type) => (- <SelectItem- key={type}- value={type}- className="capitalize"- >- {type}- </SelectItem>- ))}- </SelectContent>- </Select>- <FormMessage />- </FormItem>- )}- />- <Note className="col-span-full">- <ul className="list-inside list-disc">- <li>- <span className="font-medium">- Bar Type{" "}- <span className="font-semibold">- {watchConfigurationType}- </span>- </span>- : {message.type[watchConfigurationType]}- </li>- <li>- <span className="font-medium">- Card Value{" "}- <span className="font-semibold">- {watchConfigurationValue}- </span>- </span>- :{" "}- {message.value[watchConfigurationValue] ??- message.value.default}- </li>- <li>- <span className="font-medium">- Show Uptime{" "}- <span className="font-semibold">- {watchConfigurationUptime}- </span>- </span>- : {message.uptime[watchConfigurationUptime]}- </li>- </ul>- </Note>- </FormCardContent>- <FormCardSeparator />- <FormCardContent className="grid gap-4 sm:grid-cols-3">- <FormCardHeader className="col-span-full px-0 pt-0 pb-0">- <FormCardTitle>Theme Explorer</FormCardTitle>- <FormCardDescription>- Configure the theme for the status page - or contribute- your own. Learn more about it at{" "}- <Link- href="https://themes.openstatus.dev"- rel="noreferrer"- target="_blank"- >- themes.openstatus.dev- </Link>- .- </FormCardDescription>- </FormCardHeader>- <FormField- control={form.control}- name="configuration.theme"- render={({ field }) => (- <FormItem>- <FormLabel>Theme</FormLabel>- <Popover>- <PopoverTrigger asChild>- <FormControl>- <Button- id="community-theme"- variant="outline"- role="combobox"- className={cn(- "w-full justify-between",- !field.value && "text-muted-foreground",- )}- >- <span className="truncate">- {THEMES[field.value as ThemeKey]?.name ||- "Select a theme"}- </span>- <ChevronsUpDown className="opacity-50" />- </Button>- </FormControl>- </PopoverTrigger>- <PopoverContent className="p-0" align="start">- <Command>- <CommandInput- placeholder="Search themes..."- className="h-9"- />- <CommandList>- <CommandEmpty>No themes found.</CommandEmpty>- <CommandGroup>- {THEME_KEYS.map((theme) => {- const { name, author } = THEMES[theme];- return (- <CommandItem- value={theme}- key={theme}- keywords={[theme, name, author.name]}- onSelect={(v) => field.onChange(v)}- >- <span className="truncate">{name}</span>- <span className="truncate font-commit-mono text-muted-foreground text-xs">- by {author.name}- </span>- <Check- className={cn(- "ml-auto",- theme === field.value- ? "opacity-100"- : "opacity-0",- )}- />- </CommandItem>- );- })}- </CommandGroup>- </CommandList>- </Command>- </PopoverContent>- </Popover>- </FormItem>- )}- />- </FormCardContent>- <FormCardSeparator />- <FormCardContent className="grid gap-4">- <FormCardHeader className="col-span-full px-0 pt-0 pb-0">- <FormCardTitle>Links</FormCardTitle>- <FormCardDescription>- Configure the links for the status page.- </FormCardDescription>- </FormCardHeader>- <FormField- control={form.control}- name="homepageUrl"- render={({ field }) => (- <FormItem>- <FormLabel>Homepage URL</FormLabel>- <FormControl>- <Input placeholder="https://acme.com" {...field} />- </FormControl>- <FormMessage />- <FormDescription>- What URL should the logo link to? Leave empty to hide.- </FormDescription>- </FormItem>- )}- />- <FormField- control={form.control}- name="contactUrl"- render={({ field }) => (- <FormItem>- <FormLabel>Contact URL</FormLabel>- <FormControl>- <Input- placeholder="https://acme.com/contact"- {...field}- />- </FormControl>- <FormMessage />- <FormDescription>- Enter the URL for your contact page. Or start with{" "}- <code className="rounded-md bg-muted px-1 py-0.5">- mailto:- </code>{" "}- to open the email client. Leave empty to hide.- </FormDescription>- </FormItem>- )}- />- </FormCardContent>- </>- )}<FormCardFooter variant="info"><FormCardFooterInfo>Learn more about{" "}@@ -487,19 +284,33 @@ export function FormConfiguration({rel="noreferrer"target="_blank">- Status Page Redesign (beta)+ Configuration</Link>.</FormCardFooterInfo>- <Button type="submit" disabled={isPending}>- {isPending ? "Submitting..." : "Submit"}- </Button>+ <div className="flex items-center gap-2">+ <Button type="button" variant="ghost" asChild>+ <Link+ href={configLink}+ rel="noreferrer"+ target="_blank"+ className="inline-flex items-center gap-1"+ >+ View and configure status page{" "}+ <ArrowUpRight className="h-4 w-4" />+ </Link>+ </Button>+ <Button type="submit" disabled={isPending}>+ {isPending ? "Submitting..." : "Submit"}+ </Button>+ </div></FormCardFooter></FormCard></form></Form><FormConfigurationDialogdefaultValues={defaultValues}+ form={form}onSubmit={async (e) => {await onSubmit(e);// NOTE: make sure to sync the form with the new values@@ -545,6 +356,7 @@ function FormConfigurationDialog({}: {defaultValues?: FormValues;onSubmit: (values: FormValues) => Promise<void>;+ form: UseFormReturn<FormValues>;}) {const [open, setOpen] = useState(false);const [isPending, startTransition] = useTransition();@@ -578,7 +390,7 @@ function FormConfigurationDialog({},});await promise;- setSearchParams({+ await setSearchParams({type: null,value: null,uptime: null,@@ -587,6 +399,10 @@ function FormConfigurationDialog({setOpen(false);} catch (error) {console.error(error);+ } finally {+ if (typeof window !== "undefined") {+ window.location.reload();+ }}});}@@ -595,22 +411,16 @@ function FormConfigurationDialog({<Dialog open={open} onOpenChange={setOpen}><DialogContent><DialogHeader>- <DialogTitle>Status Page Redesign (beta)</DialogTitle>+ <DialogTitle>Status Page Configuration</DialogTitle><DialogDescription>Do you want to update the status page based on the configured- settings?+ settings? You can always change the settings later.</DialogDescription></DialogHeader><div className="flex flex-col gap-2"><pre className="rounded-md border bg-muted/50 px-3 py-2 font-commit-mono text-sm">{JSON.stringify({ type, value, uptime, theme }, null, 2)}</pre>- {!defaultValues || !defaultValues.new ? (- <Note color="info" className="text-sm">- <Info />- <p>You will activate the new version of the status page.</p>- </Note>- ) : null}</div><DialogFooter><DialogClose asChild>@@ -621,7 +431,6 @@ function FormConfigurationDialog({onClick={() =>submitAction({...defaultValues,- new: true,configuration: {type: type ?? undefined,value: value ?? undefined,diff --git a/apps/dashboard/src/components/forms/status-page/form-danger-zone.tsx b/apps/dashboard/src/components/forms/status-page/form-danger-zone.tsxindex b08ff6032..44032ca66 100644--- a/apps/dashboard/src/components/forms/status-page/form-danger-zone.tsx+++ b/apps/dashboard/src/components/forms/status-page/form-danger-zone.tsx@@ -11,8 +11,10 @@ import {export function FormDangerZone({onSubmit,+ title,}: {onSubmit: () => Promise<void>;+ title: string;}) {return (<FormCard variant="destructive">@@ -22,7 +24,7 @@ export function FormDangerZone({</FormCardHeader><FormCardFooter variant="destructive" className="justify-end"><FormAlertDialog- title="OpenStatus API"+ title={title}confirmationValue="delete status page"submitAction={onSubmit}/>diff --git a/apps/dashboard/src/components/forms/status-page/form-links.tsx b/apps/dashboard/src/components/forms/status-page/form-links.tsxnew file mode 100644index 000000000..5a66c3b16--- /dev/null+++ b/apps/dashboard/src/components/forms/status-page/form-links.tsx@@ -0,0 +1,144 @@+import { useTransition } from "react";+import { z } from "zod";++import { Link } from "@/components/common/link";+import {+ FormCard,+ FormCardContent,+ FormCardDescription,+ FormCardFooter,+ FormCardFooterInfo,+ FormCardHeader,+ FormCardTitle,+} from "@/components/forms/form-card";+import { Button } from "@/components/ui/button";+import {+ Form,+ FormControl,+ FormDescription,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+} from "@/components/ui/form";+import { Input } from "@/components/ui/input";+import { zodResolver } from "@hookform/resolvers/zod";+import { isTRPCClientError } from "@trpc/client";+import { useForm } from "react-hook-form";+import { toast } from "sonner";++const schema = z.object({+ homepageUrl: z.string().optional(),+ contactUrl: z.string().optional(),+});++type FormValues = z.infer<typeof schema>;++export function FormLinks({+ defaultValues,+ onSubmit,+}: {+ defaultValues?: FormValues;+ onSubmit: (values: FormValues) => Promise<void>;+}) {+ const [isPending, startTransition] = useTransition();+ const form = useForm<FormValues>({+ resolver: zodResolver(schema),+ defaultValues: defaultValues ?? {+ homepageUrl: "",+ contactUrl: "",+ },+ });++ function submitAction(values: FormValues) {+ if (isPending) return;++ startTransition(async () => {+ try {+ const promise = onSubmit(values);+ toast.promise(promise, {+ loading: "Saving...",+ success: "Saved",+ error: (error) => {+ if (isTRPCClientError(error)) {+ return error.message;+ }+ return "Failed to save";+ },+ });+ await promise;+ } catch (error) {+ console.error(error);+ }+ });+ }++ return (+ <Form {...form}>+ <form onSubmit={form.handleSubmit(submitAction)}>+ <FormCard>+ <FormCardHeader>+ <FormCardTitle>Links</FormCardTitle>+ <FormCardDescription>+ Configure the links for the status page.+ </FormCardDescription>+ </FormCardHeader>+ <FormCardContent className="grid gap-4 sm:grid-cols-3">+ <FormField+ control={form.control}+ name="homepageUrl"+ render={({ field }) => (+ <FormItem className="sm:col-span-full">+ <FormLabel>Homepage URL</FormLabel>+ <FormControl>+ <Input placeholder="https://acme.com" {...field} />+ </FormControl>+ <FormMessage />+ <FormDescription>+ What URL should the logo link to? Leave empty to hide.+ </FormDescription>+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="contactUrl"+ render={({ field }) => (+ <FormItem className="sm:col-span-full">+ <FormLabel>Contact URL</FormLabel>+ <FormControl>+ <Input placeholder="https://acme.com/contact" {...field} />+ </FormControl>+ <FormMessage />+ <FormDescription>+ Enter the URL for your contact page. Or start with{" "}+ <code className="rounded-md bg-muted px-1 py-0.5">+ mailto:+ </code>{" "}+ to open the email client. Leave empty to hide.+ </FormDescription>+ </FormItem>+ )}+ />+ </FormCardContent>+ <FormCardFooter>+ <FormCardFooterInfo>+ Learn more about{" "}+ <Link+ href="https://docs.openstatus.dev/tutorial/how-to-configure-status-page/#3-links"+ rel="noreferrer"+ target="_blank"+ >+ links+ </Link>+ .+ </FormCardFooterInfo>+ <Button type="submit" disabled={isPending}>+ {isPending ? "Submitting..." : "Submit"}+ </Button>+ </FormCardFooter>+ </FormCard>+ </form>+ </Form>+ );+}diff --git a/apps/dashboard/src/components/forms/status-page/update.tsx b/apps/dashboard/src/components/forms/status-page/update.tsxindex b90948715..14231efb6 100644--- a/apps/dashboard/src/components/forms/status-page/update.tsx+++ b/apps/dashboard/src/components/forms/status-page/update.tsx@@ -10,6 +10,7 @@ import { FormConfiguration } from "./form-configuration";import { FormCustomDomain } from "./form-custom-domain";import { FormDangerZone } from "./form-danger-zone";import { FormGeneral } from "./form-general";+import { FormLinks } from "./form-links";import { FormMonitors } from "./form-monitors";import { FormPasswordProtection } from "./form-password-protection";@@ -81,6 +82,12 @@ export function FormStatusPageUpdate() {}),);+ const updateLinksMutation = useMutation(+ trpc.page.updateLinks.mutationOptions({+ onSuccess: () => refetch(),+ }),+ );+if (!statusPage || !monitors || !workspace) return null;const configLink = `https://${@@ -92,8 +99,15 @@ export function FormStatusPageUpdate() {<Note color="info"><Info /><p className="text-sm">- We've released a new version of the status page.{" "}- <Link href="#redesign">Go to the section</Link> below to enable it.+ We've enabled the new version of the status page. Read more about the{" "}+ <Link+ href="https://docs.openstatus.dev/tutorial/how-to-configure-status-page/"+ rel="noreferrer"+ target="_blank"+ >+ configuration+ </Link>+ .</p></Note><FormGeneral@@ -162,41 +176,50 @@ export function FormStatusPageUpdate() {});}}/>+ <FormLinks+ defaultValues={{+ homepageUrl: statusPage.homepageUrl ?? "",+ contactUrl: statusPage.contactUrl ?? "",+ }}+ onSubmit={async (values) => {+ await updateLinksMutation.mutateAsync({+ id: Number.parseInt(id),+ homepageUrl: values.homepageUrl ?? undefined,+ contactUrl: values.contactUrl ?? undefined,+ });+ }}+ /><FormAppearancedefaultValues={{forceTheme: statusPage.forceTheme ?? "system",+ configuration: {+ theme: statusPage.configuration?.theme ?? "default",+ },}}onSubmit={async (values) => {await updatePageAppearanceMutation.mutateAsync({id: Number.parseInt(id),forceTheme: values.forceTheme,+ configuration: values.configuration,});}}/><FormConfigurationdefaultValues={{- new: !statusPage.legacyPage,configuration: statusPage.configuration ?? {},- homepageUrl: statusPage.homepageUrl ?? "",- contactUrl: statusPage.contactUrl ?? "",}}onSubmit={async (values) => {await updatePageConfigurationMutation.mutateAsync({id: Number.parseInt(id),- configuration: values.new- ? {- uptime:- typeof values.configuration.uptime === "boolean"- ? values.configuration.uptime- : values.configuration.uptime === "true",- value: values.configuration.value ?? "duration",- type: values.configuration.type ?? "absolute",- theme: values.configuration.theme ?? "default",- }- : undefined,- legacyPage: !values.new,- homepageUrl: values.homepageUrl ?? undefined,- contactUrl: values.contactUrl ?? undefined,+ configuration: {+ uptime:+ typeof values.configuration.uptime === "boolean"+ ? values.configuration.uptime+ : values.configuration.uptime === "true",+ value: values.configuration.value ?? "duration",+ type: values.configuration.type ?? "absolute",+ theme: values.configuration.theme ?? undefined,+ },});}}configLink={configLink}@@ -216,6 +239,7 @@ export function FormStatusPageUpdate() {}}/><FormDangerZone+ title={statusPage.title}onSubmit={async () => {await deleteStatusPageMutation.mutateAsync({id: Number.parseInt(id),diff --git a/apps/dashboard/src/data/maintenances.client.ts b/apps/dashboard/src/data/maintenances.client.tsindex 013ede965..d0a79e431 100644--- a/apps/dashboard/src/data/maintenances.client.ts+++ b/apps/dashboard/src/data/maintenances.client.ts@@ -1,10 +1,10 @@-import { Pencil, Trash2 } from "lucide-react";+import { Cog, Trash2 } from "lucide-react";export const actions = [{id: "edit",- label: "Edit",- icon: Pencil,+ label: "Settings",+ icon: Cog,variant: "default" as const,},{diff --git a/apps/dashboard/src/data/monitors.client.ts b/apps/dashboard/src/data/monitors.client.tsindex 499cf5230..49bb6d479 100644--- a/apps/dashboard/src/data/monitors.client.ts+++ b/apps/dashboard/src/data/monitors.client.ts@@ -1,9 +1,9 @@import {+ Cog,Copy,CopyPlus,Globe,Network,- Pencil,Server,Trash2,} from "lucide-react";@@ -29,8 +29,8 @@ export const monitorTypes = [export const actions = [{id: "edit",- label: "Edit",- icon: Pencil,+ label: "Settings",+ icon: Cog,variant: "default" as const,},{diff --git a/apps/dashboard/src/data/notifications.client.ts b/apps/dashboard/src/data/notifications.client.tsindex 5ca57b1c9..9851920d5 100644--- a/apps/dashboard/src/data/notifications.client.ts+++ b/apps/dashboard/src/data/notifications.client.ts@@ -18,9 +18,9 @@ import { sendTestSlackMessage as sendTestSlack } from "@openstatus/notification-import { sendTest as sendTestWebhook } from "@openstatus/notification-webhook";import {BellIcon,+ Cog,Mail,MessageCircle,- Pencil,Trash2,Webhook,} from "lucide-react";@@ -28,8 +28,8 @@ import {export const actions = [{id: "edit",- label: "Edit",- icon: Pencil,+ label: "Settings",+ icon: Cog,variant: "default" as const,},{diff --git a/apps/dashboard/src/data/status-pages.client.ts b/apps/dashboard/src/data/status-pages.client.tsindex 59f4e9c7f..8f2c87bef 100644--- a/apps/dashboard/src/data/status-pages.client.ts+++ b/apps/dashboard/src/data/status-pages.client.ts@@ -1,10 +1,10 @@-import { Copy, Pencil, Trash2 } from "lucide-react";+import { Cog, Copy, Trash2 } from "lucide-react";export const actions = [{id: "edit",- label: "Edit",- icon: Pencil,+ label: "Settings",+ icon: Cog,variant: "default" as const,},{diff --git a/apps/dashboard/src/data/status-report-updates.client.ts b/apps/dashboard/src/data/status-report-updates.client.tsindex d6da1b542..37bf3331e 100644--- a/apps/dashboard/src/data/status-report-updates.client.ts+++ b/apps/dashboard/src/data/status-report-updates.client.ts@@ -1,11 +1,11 @@import type { StatusReportStatus } from "@openstatus/db/src/schema";-import { Pencil, Trash2 } from "lucide-react";+import { Cog, Trash2 } from "lucide-react";export const actions = [{id: "edit",- label: "Edit",- icon: Pencil,+ label: "Settings",+ icon: Cog,variant: "default" as const,},{diff --git a/apps/dashboard/src/data/status-reports.client.ts b/apps/dashboard/src/data/status-reports.client.tsindex 6aab79048..919b2b75e 100644--- a/apps/dashboard/src/data/status-reports.client.ts+++ b/apps/dashboard/src/data/status-reports.client.ts@@ -1,10 +1,10 @@-import { Eye, Pencil, Plus, Trash2 } from "lucide-react";+import { Cog, Eye, Plus, Trash2 } from "lucide-react";export const actions = [{id: "edit",- label: "Edit",- icon: Pencil,+ label: "Settings",+ icon: Cog,variant: "default" as const,},{diff --git a/apps/docs/src/content/docs/tutorial/how-to-configure-status-page.mdx b/apps/docs/src/content/docs/tutorial/how-to-configure-status-page.mdxindex 3be5dc0c2..d86e12762 100644--- a/apps/docs/src/content/docs/tutorial/how-to-configure-status-page.mdx+++ b/apps/docs/src/content/docs/tutorial/how-to-configure-status-page.mdx@@ -16,11 +16,7 @@ import StatusPageBeta4 from '../../../assets/tutorial/configure-status-page/statWe are releasing a new version of our status pages.-<Aside>Newly created pages will automatically run on the new version. For old pages, this is an **opt-in toggle**. We will keep the current status page until next year to allow you migrate or provide any feedback.</Aside>--You can always have a look how your status page will look like via `https://[slug].stpg.dev`.--Example: [https://themes.openstatus.dev/status](https://themes.openstatus.dev/status)+Explore the themes: [https://themes.openstatus.dev](https://themes.openstatus.dev)## Get starteddiff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.tsindex 46d0c0299..e5943e1d1 100644--- a/packages/api/src/router/page.ts+++ b/packages/api/src/router/page.ts@@ -776,6 +776,56 @@ export const pageRouter = createTRPCRouter({z.object({id: z.number(),forceTheme: z.enum(["light", "dark", "system"]),+ configuration: z.object({+ theme: z.string(),+ }),+ }),+ )+ .mutation(async (opts) => {+ const whereConditions: SQL[] = [+ eq(page.workspaceId, opts.ctx.workspace.id),+ eq(page.id, opts.input.id),+ ];++ const _page = await opts.ctx.db.query.page.findFirst({+ where: and(...whereConditions),+ });++ if (!_page) {+ throw new TRPCError({+ code: "NOT_FOUND",+ message: "Page not found",+ });+ }++ const currentConfiguration =+ (typeof _page.configuration === "object" &&+ _page.configuration !== null &&+ _page.configuration) ||+ {};+ const updatedConfiguration = {+ ...currentConfiguration,+ theme: opts.input.configuration.theme,+ };++ await opts.ctx.db+ .update(page)+ .set({+ forceTheme: opts.input.forceTheme,+ configuration: updatedConfiguration,+ updatedAt: new Date(),+ })+ .where(and(...whereConditions))+ .run();+ }),++ updateLinks: protectedProcedure+ .meta({ track: Events.UpdatePage })+ .input(+ z.object({+ id: z.number(),+ homepageUrl: z.string().nullish(),+ contactUrl: z.string().nullish(),}),).mutation(async (opts) => {@@ -786,7 +836,11 @@ export const pageRouter = createTRPCRouter({await opts.ctx.db.update(page)- .set({ forceTheme: opts.input.forceTheme, updatedAt: new Date() })+ .set({+ homepageUrl: opts.input.homepageUrl,+ contactUrl: opts.input.contactUrl,+ updatedAt: new Date(),+ }).where(and(...whereConditions)).run();}),@@ -799,9 +853,6 @@ export const pageRouter = createTRPCRouter({configuration: z.record(z.string(), z.string().or(z.boolean()).optional()).nullish(),- legacyPage: z.boolean(),- homepageUrl: z.string().nullish(),- contactUrl: z.string().nullish(),}),).mutation(async (opts) => {@@ -821,29 +872,24 @@ export const pageRouter = createTRPCRouter({});}+ const currentConfiguration =+ (typeof _page.configuration === "object" &&+ _page.configuration !== null &&+ _page.configuration) ||+ {};+ const updatedConfiguration = {+ ...currentConfiguration,+ ...opts.input.configuration,+ };+await opts.ctx.db.update(page).set({- configuration: opts.input.configuration,- legacyPage: opts.input.legacyPage,- homepageUrl: opts.input.homepageUrl,- contactUrl: opts.input.contactUrl,+ configuration: updatedConfiguration,updatedAt: new Date(),}).where(and(...whereConditions)).run();-- if (opts.input.legacyPage) {- await redis.del(`page:${_page.slug}`);- if (_page.customDomain) {- await redis.del(`page:${_page.customDomain}`);- }- } else {- await redis.set(`page:${_page.slug}`, 1);- if (_page.customDomain) {- await redis.set(`page:${_page.customDomain}`, 1);- }- }}),updateMonitors: protectedProcedure