Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
chore: apply feedback (#1297)
Maximilian Kaskeab17c980dda2
diff --git a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsxindex 43f0cf8a0..90ac5af4a 100644--- a/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx+++ b/apps/dashboard/src/app/(dashboard)/monitors/[id]/overview/client.tsx@@ -146,21 +146,21 @@ export function Client() {</Section><Section><SectionHeader>- <SectionTitle>Timeline</SectionTitle>+ <SectionTitle>Regions</SectionTitle><SectionDescription>- What happened to your monitor over the last {TIMELINE_INTERVAL} days+ Every region's latency over the last 24 hours</SectionDescription></SectionHeader>- <AuditLogsWrapper monitorId={id} interval={TIMELINE_INTERVAL} />+ <DataTable data={regionMetrics} columns={regionColumns} /></Section><Section><SectionHeader>- <SectionTitle>Regions</SectionTitle>+ <SectionTitle>Timeline</SectionTitle><SectionDescription>- Every region's latency over the last 24 hours+ What happened to your monitor over the last {TIMELINE_INTERVAL} days</SectionDescription></SectionHeader>- <DataTable data={regionMetrics} columns={regionColumns} />+ <AuditLogsWrapper monitorId={id} interval={TIMELINE_INTERVAL} /></Section></SectionGroup>);diff --git a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/maintenances/page.tsx b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/maintenances/page.tsxindex 26aa831e1..d7b5e6975 100644--- a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/maintenances/page.tsx+++ b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/maintenances/page.tsx@@ -1,5 +1,6 @@"use client";+import { Link } from "@/components/common/link";import {Section,SectionDescription,@@ -41,9 +42,13 @@ export default function Page() {<Section><SectionHeaderRow><SectionHeader>- <SectionTitle>Maintenances</SectionTitle>+ <SectionTitle>{statusPage.title}</SectionTitle><SectionDescription>- See our maintenances and scheduled downtimes.+ List of all maintenances. Looking for{" "}+ <Link href={`/status-pages/${id}/status-reports`}>+ status reports+ </Link>+ ?</SectionDescription></SectionHeader><div>@@ -60,7 +65,7 @@ export default function Page() {});}}>- <Button data-section="action" size="sm" variant="ghost">+ <Button data-section="action" size="sm"><Plus />Create Maintenance</Button>diff --git a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/page.tsx b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/page.tsxindex 4633a4936..fe0a30eb5 100644--- a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/page.tsx+++ b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/page.tsx@@ -1,5 +1,6 @@"use client";+import { Link } from "@/components/common/link";import {Section,SectionDescription,@@ -59,7 +60,11 @@ export default function Page() {<SectionHeader><SectionTitle>{page.title}</SectionTitle><SectionDescription>- See our uptime history and status reports.+ List of all status reports. Looking for{" "}+ <Link href={`/status-pages/${id}/maintenances`}>+ maintenances+ </Link>+ ?</SectionDescription></SectionHeader><div>diff --git a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/subscribers/page.tsx b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/subscribers/page.tsxindex e97f9b793..504a46b6b 100644--- a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/subscribers/page.tsx+++ b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/subscribers/page.tsx@@ -68,9 +68,7 @@ export default function Page() {<Section><SectionHeader><SectionTitle>{page?.title}</SectionTitle>- <SectionDescription>- Allow your users to subscribe to status page updates.- </SectionDescription>+ <SectionDescription>List of all subscribers.</SectionDescription></SectionHeader></Section><Section>diff --git a/apps/dashboard/src/components/data-table/settings/members/data-table.tsx b/apps/dashboard/src/components/data-table/settings/members/data-table.tsxindex 10d2f8c88..a5270d0f7 100644--- a/apps/dashboard/src/components/data-table/settings/members/data-table.tsx+++ b/apps/dashboard/src/components/data-table/settings/members/data-table.tsx@@ -45,7 +45,9 @@ export function DataTable() {</TableCell><TableCell>{item.user.email}</TableCell><TableCell>{item.role}</TableCell>- <TableCell>{formatDate(item.createdAt)}</TableCell>+ <TableCell>+ {formatDate(item.user.createdAt ?? item.createdAt)}+ </TableCell><TableCell><div className="flex justify-end"><QuickActionsdiff --git a/apps/dashboard/src/components/data-table/status-reports/data-table-row-actions.tsx b/apps/dashboard/src/components/data-table/status-reports/data-table-row-actions.tsxindex 3b7bad095..b9ff5e345 100644--- a/apps/dashboard/src/components/data-table/status-reports/data-table-row-actions.tsx+++ b/apps/dashboard/src/components/data-table/status-reports/data-table-row-actions.tsx@@ -26,7 +26,7 @@ export function DataTableRowActions({ row }: DataTableRowActionsProps) {"view-report": () => {if (typeof window !== "undefined") {window.open(- `https://${row.original.page.customDomain || `${row.original.page.slug}.openstatus.dev/events/report/${row.original.id}`}`,+ `https://${row.original.page.customDomain || `${row.original.page.slug}.openstatus.dev`}/events/report/${row.original.id}`,"_blank",);}diff --git a/apps/dashboard/src/components/forms/maintenance/form.tsx b/apps/dashboard/src/components/forms/maintenance/form.tsxindex 4e1677811..d25c42d1f 100644--- a/apps/dashboard/src/components/forms/maintenance/form.tsx+++ b/apps/dashboard/src/components/forms/maintenance/form.tsx@@ -34,7 +34,7 @@ import { Textarea } from "@/components/ui/textarea";import { cn } from "@/lib/utils";import { zodResolver } from "@hookform/resolvers/zod";import { isTRPCClientError } from "@trpc/client";-import { format } from "date-fns";+import { addDays, format } from "date-fns";import { CalendarIcon, ClockIcon } from "lucide-react";import type React from "react";import { useTransition } from "react";@@ -42,13 +42,18 @@ import { useForm } from "react-hook-form";import { toast } from "sonner";import { z } from "zod";-const schema = z.object({- title: z.string(),- message: z.string(),- startDate: z.date(),- endDate: z.date(),- monitors: z.array(z.number()),-});+const schema = z+ .object({+ title: z.string().min(1, "Title is required"),+ message: z.string(),+ startDate: z.date(),+ endDate: z.date(),+ monitors: z.array(z.number()),+ })+ .refine((data) => data.endDate > data.startDate, {+ message: "End date cannot be earlier than start date.",+ path: ["endDate"],+ });export type FormValues = z.infer<typeof schema>;@@ -69,7 +74,7 @@ export function FormMaintenance({title: "",message: "",startDate: new Date(),- endDate: new Date(),+ endDate: addDays(new Date(), 1),monitors: [],},});@@ -276,7 +281,7 @@ export function FormMaintenance({</div></PopoverContent></Popover>- <FormDescription>When the maintenance ends</FormDescription>+ <FormDescription>When the maintenance ends.</FormDescription><FormMessage /></FormItem>)}diff --git a/apps/dashboard/src/components/forms/status-page/form-appearance.tsx b/apps/dashboard/src/components/forms/status-page/form-appearance.tsxnew file mode 100644index 000000000..f8d115a0c--- /dev/null+++ b/apps/dashboard/src/components/forms/status-page/form-appearance.tsx@@ -0,0 +1,144 @@+import { useTransition } from "react";+import { z } from "zod";++import {+ FormCard,+ FormCardContent,+ FormCardDescription,+ FormCardFooter,+ FormCardFooterInfo,+ FormCardHeader,+ FormCardTitle,+} from "@/components/forms/form-card";+import { Button } from "@/components/ui/button";+import {+ Form,+ FormControl,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+} from "@/components/ui/form";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { zodResolver } from "@hookform/resolvers/zod";+import { isTRPCClientError } from "@trpc/client";+import { Laptop, Moon, Sun } from "lucide-react";+import { useForm } from "react-hook-form";+import { toast } from "sonner";++const schema = z.object({+ forceTheme: z.enum(["light", "dark", "system"]),+});++type FormValues = z.infer<typeof schema>;++export function FormAppearance({+ defaultValues,+ onSubmit,+}: {+ defaultValues?: FormValues;+ onSubmit: (values: FormValues) => Promise<void>;+}) {+ const [isPending, startTransition] = useTransition();+ const form = useForm<FormValues>({+ resolver: zodResolver(schema),+ defaultValues: defaultValues ?? {+ forceTheme: "system",+ },+ });++ 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>Appearance</FormCardTitle>+ <FormCardDescription>+ Forced theme will override the user's preference.+ </FormCardDescription>+ </FormCardHeader>+ <FormCardContent>+ <FormField+ control={form.control}+ name="forceTheme"+ render={({ field }) => (+ <FormItem>+ <FormLabel className="sr-only">Theme</FormLabel>+ <Select+ onValueChange={field.onChange}+ defaultValue={field.value}+ >+ <FormControl>+ <SelectTrigger>+ <SelectValue placeholder="Select a theme" />+ </SelectTrigger>+ </FormControl>+ <SelectContent>+ <SelectItem value="light">+ <div className="flex items-center gap-2">+ <Sun className="h-4 w-4" />+ <span>Light</span>+ </div>+ </SelectItem>+ <SelectItem value="dark">+ <div className="flex items-center gap-2">+ <Moon className="h-4 w-4" />+ <span>Dark</span>+ </div>+ </SelectItem>+ <SelectItem value="system">+ <div className="flex items-center gap-2">+ <Laptop className="h-4 w-4" />+ <span>System</span>+ </div>+ </SelectItem>+ </SelectContent>+ </Select>+ <FormMessage />+ </FormItem>+ )}+ />+ </FormCardContent>+ <FormCardFooter>+ <FormCardFooterInfo>+ Your user will still be able to change the theme via the theme+ toggle.+ </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 d2f56db8c..c408a9385 100644--- a/apps/dashboard/src/components/forms/status-page/update.tsx+++ b/apps/dashboard/src/components/forms/status-page/update.tsx@@ -2,6 +2,7 @@ import { FormCardGroup } from "@/components/forms/form-card";import { useTRPC } from "@/lib/trpc/client";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { useParams, useRouter } from "next/navigation";+import { FormAppearance } from "./form-appearance";import { FormCustomDomain } from "./form-custom-domain";import { FormDangerZone } from "./form-danger-zone";import { FormGeneral } from "./form-general";@@ -48,6 +49,12 @@ export function FormStatusPageUpdate() {}),);+ const updatePageAppearanceMutation = useMutation(+ trpc.page.updateAppearance.mutationOptions({+ onSuccess: () => refetch(),+ }),+ );+const deleteStatusPageMutation = useMutation(trpc.page.delete.mutationOptions({onSuccess: () => {@@ -114,6 +121,17 @@ export function FormStatusPageUpdate() {});}}/>+ <FormAppearance+ defaultValues={{+ forceTheme: statusPage.forceTheme ?? "system",+ }}+ onSubmit={async (values) => {+ await updatePageAppearanceMutation.mutateAsync({+ id: Number.parseInt(id),+ forceTheme: values.forceTheme,+ });+ }}+ /><FormPasswordProtectionlocked={workspace.limits["password-protection"] === false}defaultValues={{diff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.tsindex 3d824b2fa..f135b64bc 100644--- a/packages/api/src/router/page.ts+++ b/packages/api/src/router/page.ts@@ -733,6 +733,27 @@ export const pageRouter = createTRPCRouter({.run();}),+ updateAppearance: protectedProcedure+ .meta({ track: Events.UpdatePage })+ .input(+ z.object({+ id: z.number(),+ forceTheme: z.enum(["light", "dark", "system"]),+ }),+ )+ .mutation(async (opts) => {+ const whereConditions: SQL[] = [+ eq(page.workspaceId, opts.ctx.workspace.id),+ eq(page.id, opts.input.id),+ ];++ await opts.ctx.db+ .update(page)+ .set({ forceTheme: opts.input.forceTheme, updatedAt: new Date() })+ .where(and(...whereConditions))+ .run();+ }),+updateMonitors: protectedProcedure.meta({ track: Events.UpdatePage }).input(