Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
chore: theme-store package (#1392)
Maximilian Kaske80dcdcf21880
diff --git a/apps/dashboard/package.json b/apps/dashboard/package.jsonindex d8faa87d1..4ba2e9666 100644--- a/apps/dashboard/package.json+++ b/apps/dashboard/package.json@@ -25,6 +25,7 @@"@openstatus/analytics": "workspace:*","@openstatus/api": "workspace:*","@openstatus/assertions": "workspace:*",+ "@openstatus/theme-store": "workspace:*","@openstatus/db": "workspace:*","@openstatus/emails": "workspace:*","@openstatus/error": "workspace:*",diff --git a/apps/dashboard/src/components/forms/status-page/form-configuration.tsx b/apps/dashboard/src/components/forms/status-page/form-configuration.tsxindex 053590b82..d1396d761 100644--- a/apps/dashboard/src/components/forms/status-page/form-configuration.tsx+++ b/apps/dashboard/src/components/forms/status-page/form-configuration.tsx@@ -1,4 +1,4 @@-import { useEffect, useTransition } from "react";+import { useEffect, useState, useTransition } from "react";import { z } from "zod";import { Link } from "@/components/common/link";@@ -14,6 +14,15 @@ import {FormCardTitle,} from "@/components/forms/form-card";import { Button } from "@/components/ui/button";+import {+ Dialog,+ DialogClose,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from "@/components/ui/dialog";import {Form,FormControl,@@ -33,7 +42,10 @@ import {} from "@/components/ui/select";import { Switch } from "@/components/ui/switch";import { zodResolver } from "@hookform/resolvers/zod";+import { THEMES, THEME_KEYS } from "@openstatus/theme-store";import { isTRPCClientError } from "@trpc/client";+import { ArrowUpRight, Globe, Info } from "lucide-react";+import { parseAsStringLiteral, useQueryStates } from "nuqs";import { useForm } from "react-hook-form";import { toast } from "sonner";@@ -44,14 +56,37 @@ const schema = z.object({contactUrl: z.string().optional(),});+const configurationSchema = z+ .object({+ type: z.enum(["manual", "absolute"]),+ value: z.enum(["duration", "requests"]).nullish(),+ uptime: z.boolean().or(z.literal("true").or(z.literal("false"))),+ theme: z.enum(THEME_KEYS as [string, ...string[]]),+ })+ .refine(+ (data) => {+ // If type is "manual", value must be null or undefined+ if (data.type === "manual") {+ return data.value === null || data.value === undefined;+ }+ return true;+ },+ {+ message: "Value must be null when type is manual",+ path: ["value"],+ },+ );+type FormValues = z.infer<typeof schema>;export function FormConfiguration({defaultValues,onSubmit,+ configLink,}: {defaultValues?: FormValues;onSubmit: (values: FormValues) => Promise<void>;+ configLink: string;}) {const [isPending, startTransition] = useTransition();const form = useForm<FormValues>({@@ -76,7 +111,6 @@ export function FormConfiguration({useEffect(() => {if (watchConfigurationType === "manual") {- // TODO: this is not workingform.setValue("configuration.value", undefined);} else {form.setValue("configuration.value", "duration");@@ -111,239 +145,333 @@ export function FormConfiguration({}return (- <Form {...form}>- <form onSubmit={form.handleSubmit(submitAction)}>- <FormCard>- <FormCardHeader>- <FormCardTitle>Status Page Redesign (beta)</FormCardTitle>- <FormCardDescription>- Use the latest version of the status page and customize it.- </FormCardDescription>- </FormCardHeader>- <FormCardContent>- <FormField- control={form.control}- name="new"- render={({ field }) => (- <FormItem className="flex flex-row items-center">- <FormLabel>Enable New Version</FormLabel>- <FormControl>- <Switch- checked={field.value}- onCheckedChange={field.onChange}- />- </FormControl>- </FormItem>- )}- />- </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"}+ <>+ <Form {...form}>+ <form id="redesign" onSubmit={form.handleSubmit(submitAction)}>+ <FormCard>+ <FormCardHeader>+ <FormCardTitle>Status Page Redesign (beta)</FormCardTitle>+ <FormCardDescription>+ Use the latest version of the status page and customize it.+ </FormCardDescription>+ </FormCardHeader>+ <FormCardContent className="grid gap-4 sm:grid-cols-2">+ <FormField+ control={form.control}+ name="new"+ 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>+ )}+ />+ <div className="flex items-center sm:justify-end">+ <Button variant="secondary" 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>+ <Note color="info" className="col-span-full">+ <Globe />+ <p className="text-sm">+ With that version, we provide a new shorter domain{" "}+ <code className="font-commit-mono">+ https://[slug].stpg.dev+ </code>+ . Once globally enabled, it will act as redirector for the old+ domain{" "}+ <code className="font-commit-mono">+ https://[slug].openstatus.dev+ </code>+ .+ </p>+ </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><FormControl>- <SelectTrigger className="w-full capitalize">- <SelectValue placeholder="Select a type" />- </SelectTrigger>+ <Select+ onValueChange={field.onChange}+ defaultValue={String(field.value) ?? "default"}+ >+ <FormControl>+ <SelectTrigger className="w-full capitalize">+ <SelectValue placeholder="Select a theme" />+ </SelectTrigger>+ </FormControl>+ <SelectContent>+ {Object.values(THEMES).map((theme) => (+ <SelectItem+ key={theme.id}+ value={theme.id}+ className="capitalize"+ >+ {theme.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select></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"}- >+ </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>- <SelectTrigger className="w-full capitalize">- <SelectValue placeholder="Select a type" />- </SelectTrigger>+ <Input placeholder="https://acme.com" {...field} /></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"}- >+ <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>- <SelectTrigger className="w-full capitalize">- <SelectValue placeholder="Select a type" />- </SelectTrigger>+ <Input+ placeholder="https://acme.com/contact"+ {...field}+ /></FormControl>- <SelectContent>- {["true", "false"].map((type) => (- <SelectItem- key={type}- value={type}- className="capitalize"- >- {type}- </SelectItem>- ))}- </SelectContent>- </Select>- <FormMessage />- </FormItem>- )}- />- <Note color="info" 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">- <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>- <FormCardFooterInfo>- Learn more about{" "}- <Link- href="https://docs.openstatus.dev/tutorial/how-to-configure-status-page"- rel="noreferrer"- target="_blank"- >- Status Page Redesign (beta)- </Link>- .- </FormCardFooterInfo>- <Button type="submit" disabled={isPending}>- {isPending ? "Submitting..." : "Submit"}- </Button>- </FormCardFooter>- </FormCard>- </form>- </Form>+ <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"+ rel="noreferrer"+ target="_blank"+ >+ Status Page Redesign (beta)+ </Link>+ .+ </FormCardFooterInfo>+ <Button type="submit" disabled={isPending}>+ {isPending ? "Submitting..." : "Submit"}+ </Button>+ </FormCardFooter>+ </FormCard>+ </form>+ </Form>+ <FormConfigurationDialog+ defaultValues={defaultValues}+ onSubmit={async (e) => {+ await onSubmit(e);+ // NOTE: make sure to sync the form with the new values+ form.reset(e);+ }}+ />+ </>);}@@ -366,3 +494,113 @@ const message = {false: "shares only the current status.",},} as const;++// ?type=manual&value=manual&uptime=true&theme=default++const searchParams = {+ type: parseAsStringLiteral(["manual", "absolute"]),+ value: parseAsStringLiteral(["duration", "requests"]),+ uptime: parseAsStringLiteral(["true", "false"]),+ theme: parseAsStringLiteral(Object.keys(THEMES)),+};++function FormConfigurationDialog({+ defaultValues,+ onSubmit,+}: {+ defaultValues?: FormValues;+ onSubmit: (values: FormValues) => Promise<void>;+}) {+ const [open, setOpen] = useState(false);+ const [isPending, startTransition] = useTransition();+ const [{ type, value, uptime, theme }, setSearchParams] =+ useQueryStates(searchParams);++ useEffect(() => {+ if (type) setOpen(true);+ }, [type]);++ function submitAction(values: FormValues) {+ if (isPending) return;++ const data = configurationSchema.safeParse(values.configuration);+ if (!data.success) {+ toast.error(data.error.message);+ 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;+ setSearchParams({+ type: null,+ value: null,+ uptime: null,+ theme: null,+ });+ setOpen(false);+ } catch (error) {+ console.error(error);+ }+ });+ }++ return (+ <Dialog open={open} onOpenChange={setOpen}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>Status Page Redesign (beta)</DialogTitle>+ <DialogDescription>+ Do you want to update the status page based on the configured+ settings?+ </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>+ <Button variant="outline">Cancel</Button>+ </DialogClose>+ <Button+ type="button"+ onClick={() =>+ submitAction({+ ...defaultValues,+ new: true,+ configuration: {+ type: type ?? undefined,+ value: value ?? undefined,+ uptime: uptime ?? undefined,+ theme: theme ?? undefined,+ },+ })+ }+ disabled={isPending}+ >+ {isPending ? "Saving..." : "Save"}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ );+}diff --git a/apps/dashboard/src/components/forms/status-page/form-monitors.tsx b/apps/dashboard/src/components/forms/status-page/form-monitors.tsxindex 00698feed..bbec37fec 100644--- a/apps/dashboard/src/components/forms/status-page/form-monitors.tsx+++ b/apps/dashboard/src/components/forms/status-page/form-monitors.tsx@@ -35,13 +35,6 @@ import {} from "@/components/ui/form";import { PopoverContent } from "@/components/ui/popover";import { Popover, PopoverTrigger } from "@/components/ui/popover";-import {- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,-} from "@/components/ui/select";import {Sortable,SortableContent,@@ -63,16 +56,15 @@ type Monitor = {id: number;name: string;url: string;+ active: boolean | null;};-const DISABLED_TYPES = ["none"];-const schema = z.object({monitors: z.array(z.object({id: z.number(),order: z.number(),- type: z.enum(["all", "hide", "none"]),+ active: z.boolean().nullable(),}),),});@@ -130,7 +122,7 @@ export function FormMonitors({newMonitors.map((m, index) => ({id: m.id,order: index,- type: "none" as const,+ active: m.active,})),);},@@ -239,7 +231,7 @@ export function FormMonitors({{id: monitor.id,order: watchMonitors.length,- type: "none",+ active: monitor.active,},]);}@@ -309,18 +301,6 @@ export function FormMonitors({);}-const types = {- all: {- label: "Show all uptime",- },- hide: {- label: "Hide values",- },- none: {- label: "Only status reports",- },-};-interface MonitorRowPropsextends Omit<React.ComponentPropsWithoutRef<typeof SortableItem>, "value"> {monitor: Monitor;@@ -344,26 +324,8 @@ function MonitorRow({ monitor, ...props }: MonitorRowProps) {<div className="self-center truncate text-muted-foreground text-sm">{monitor.url}</div>- <div>- <Select>- <SelectTrigger className="h-7 w-full shadow-none" disabled>- <SelectValue placeholder="Select type (coming soon)" />- </SelectTrigger>- <SelectContent>- {Object.entries(types).map(([key, value]) => (- <SelectItem- key={key}- value={key}- disabled={DISABLED_TYPES.includes(key)}- >- {value.label}{" "}- {DISABLED_TYPES.includes(key) && (- <span className="text-foreground text-xs">(Upgrade)</span>- )}- </SelectItem>- ))}- </SelectContent>- </Select>+ <div className="truncate text-muted-foreground text-sm">+ {monitor.active ? "Active" : "Inactive"}</div></div></SortableItem>diff --git a/apps/dashboard/src/components/forms/status-page/update.tsx b/apps/dashboard/src/components/forms/status-page/update.tsxindex 0fcdbc053..5cb3df25e 100644--- a/apps/dashboard/src/components/forms/status-page/update.tsx+++ b/apps/dashboard/src/components/forms/status-page/update.tsx@@ -1,6 +1,9 @@+import { Link } from "@/components/common/link";+import { Note } from "@/components/common/note";import { FormCardGroup } from "@/components/forms/form-card";import { useTRPC } from "@/lib/trpc/client";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import { Info } from "lucide-react";import { useParams, useRouter } from "next/navigation";import { FormAppearance } from "./form-appearance";import { FormConfiguration } from "./form-configuration";@@ -80,8 +83,19 @@ export function FormStatusPageUpdate() {if (!statusPage || !monitors || !workspace) return null;+ const configLink = `https://${+ statusPage.slug+ }.stpg.dev?configuration-token=${statusPage.createdAt?.getTime().toString()}`;+return (<FormCardGroup>+ <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.+ </p>+ </Note><FormGeneraldefaultValues={{title: statusPage.title,@@ -105,8 +119,7 @@ export function FormStatusPageUpdate() {monitors: statusPage.monitors.map((monitor) => ({id: monitor.id,order: monitor.order,- // type: monitor.type,- type: "none" as const,+ active: monitor.active ?? null,})),}}onSubmit={async (values) => {@@ -139,34 +152,34 @@ export function FormStatusPageUpdate() {});}}/>- {/* TODO: feature flagged - remove once we have the new version in production */}- {process.env.NEXT_PUBLIC_STATUS_PAGE_V2 === "true" ||- process.env.NODE_ENV === "development" ? (- <FormConfiguration- defaultValues={{- 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- ? {- // NOTE: convert to boolean- uptime: values.configuration.uptime === "true",- value: values.configuration.value ?? "duration",- type: values.configuration.type ?? "absolute",- }- : undefined,- legacyPage: !values.new,- homepageUrl: values.homepageUrl ?? undefined,- contactUrl: values.contactUrl ?? undefined,- });- }}- />- ) : null}+ <FormConfiguration+ defaultValues={{+ 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,+ });+ }}+ configLink={configLink}+ /><FormPasswordProtectionlocked={workspace.limits["password-protection"] === false}defaultValues={{diff --git a/apps/status-page/package.json b/apps/status-page/package.jsonindex 379dbcec7..8e69193d9 100644--- a/apps/status-page/package.json+++ b/apps/status-page/package.json@@ -25,6 +25,7 @@"@openstatus/analytics": "workspace:*","@openstatus/api": "workspace:*","@openstatus/assertions": "workspace:*",+ "@openstatus/theme-store": "workspace:*","@openstatus/db": "workspace:*","@openstatus/emails": "workspace:*","@openstatus/error": "workspace:*",diff --git a/apps/status-page/src/app/(public)/page.tsx b/apps/status-page/src/app/(public)/page.tsxindex 352dbd9b7..0bd46d1f2 100644--- a/apps/status-page/src/app/(public)/page.tsx+++ b/apps/status-page/src/app/(public)/page.tsx@@ -19,9 +19,9 @@ import { StatusBanner } from "@/components/status-page/status-banner";import { StatusMonitor } from "@/components/status-page/status-monitor";import { Button } from "@/components/ui/button";import { monitors } from "@/data/monitors";-import { THEMES, THEME_KEYS } from "@/lib/community-themes";import { useTRPC } from "@/lib/trpc/client";import { cn } from "@/lib/utils";+import { THEMES, THEME_KEYS } from "@openstatus/theme-store";import { useQuery } from "@tanstack/react-query";export default function Page() {@@ -72,13 +72,13 @@ export default function Page() {<div className="prose dark:prose-invert prose-sm max-w-none"><p>You can contribute your own theme by creating a new file in the{" "}- <code>src/lib/community-themes</code> directory. You'll only- need to override css variables. Make sure your object is satisfiying- the <code>Theme</code> interface.+ <code>@openstatus.theme-store</code> package. You'll only need+ to override css variables. Make sure your object is satisfiying the{" "}+ <code>Theme</code> interface.</p><p>Go to the{" "}- <Link href="https://github.com/openstatusHQ/openstatus/tree/main/apps/status-page/src/lib/community-themes">+ <Link href="https://github.com/openstatusHQ/openstatus/tree/main/packages/theme-store">GitHub directory</Link>{" "}to see the existing themes and create a new one by forking anddiff --git a/apps/status-page/src/app/(status-page)/[domain]/layout.tsx b/apps/status-page/src/app/(status-page)/[domain]/layout.tsxindex 9343c549c..39d687106 100644--- a/apps/status-page/src/app/(status-page)/[domain]/layout.tsx+++ b/apps/status-page/src/app/(status-page)/[domain]/layout.tsx@@ -48,7 +48,12 @@ export default async function Layout({defaultCommunityTheme={validation.data?.theme}>{children}- <FloatingButton />+ <FloatingButton+ pageId={page?.id}+ // NOTE: token to avoid showing the floating button to random users+ // timestamp is our token - it is hard to guess+ token={page?.createdAt?.getTime().toString()}+ /><FloatingTheme /><ToastertoastOptions={{diff --git a/apps/status-page/src/components/status-page/floating-button.tsx b/apps/status-page/src/components/status-page/floating-button.tsxindex b2f9f51e0..c4419394e 100644--- a/apps/status-page/src/components/status-page/floating-button.tsx+++ b/apps/status-page/src/components/status-page/floating-button.tsx@@ -16,25 +16,23 @@ import {SelectValue,} from "@/components/ui/select";import { Separator } from "@/components/ui/separator";-import { THEMES, THEME_KEYS } from "@/lib/community-themes";import { cn } from "@/lib/utils";+import { THEMES, THEME_KEYS } from "@openstatus/theme-store";import { Settings } from "lucide-react";import { useTheme } from "next-themes";+import { parseAsString, useQueryState } from "nuqs";import type React from "react";import { createContext, useContext, useEffect, useState } from "react";+export const IS_DEV = process.env.NODE_ENV === "development";+export const VARIANT = ["success", "degraded", "error", "info"] as const;export type VariantType = (typeof VARIANT)[number];-export const CARD_TYPE = [- "duration",- "requests",- "dominant",- "manual",-] as const;+export const CARD_TYPE = ["duration", "requests", "manual"] as const;export type CardType = (typeof CARD_TYPE)[number];-export const BAR_TYPE = ["absolute", "dominant", "manual"] as const;+export const BAR_TYPE = ["absolute", "manual"] as const;export type BarType = (typeof BAR_TYPE)[number];export const COMMUNITY_THEME = THEME_KEYS;@@ -149,7 +147,15 @@ export function StatusPageProvider({);}-export function FloatingButton({ className }: { className?: string }) {+export function FloatingButton({+ className,+ pageId,+ token,+}: {+ className?: string;+ pageId?: number;+ token?: string;+}) {const {cardType,setCardType,@@ -163,10 +169,16 @@ export function FloatingButton({ className }: { className?: string }) {setRadius,} = useStatusPage();const [display, setDisplay] = useState(false);+ const [configToken, setConfigToken] = useQueryState(+ "configuration-token",+ parseAsString,+ );+ // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>useEffect(() => {const enabled =- sessionStorage.getItem("status-page-configuration") === "true";+ localStorage.getItem("configuration-token") === token ||+ configToken === token;const host = window.location.host;if ((host.includes("localhost") ||@@ -176,10 +188,13 @@ export function FloatingButton({ className }: { className?: string }) {enabled) {setDisplay(true);- } else if (process.env.NODE_ENV === "development") {+ localStorage.setItem("configuration-token", token);+ } else if (IS_DEV) {setDisplay(true);}- }, []);++ if (configToken) setConfigToken(null);+ }, [open, token]);if (!display) return null;@@ -189,8 +204,8 @@ export function FloatingButton({ className }: { className?: string }) {<PopoverTrigger asChild><Buttonsize="icon"- variant="outline"- className="size-12 rounded-full dark:bg-background"+ variant="secondary"+ className="size-12 rounded-full border"><Settings className="size-5" /><span className="sr-only">Open status page settings</span>@@ -205,24 +220,6 @@ export function FloatingButton({ className }: { className?: string }) {</p></div><div className="grid grid-cols-2 gap-4">- <div className="space-y-2">- <Label htmlFor="show-uptime">Show Uptime</Label>- <Select- value={showUptime ? "true" : "false"}- onValueChange={(v) => setShowUptime(v === "true")}- >- <SelectTrigger id="show-uptime" className="w-full capitalize">- <SelectValue />- </SelectTrigger>- <SelectContent>- {["true", "false"].map((v) => (- <SelectItem key={v} value={v} className="capitalize">- {v}- </SelectItem>- ))}- </SelectContent>- </Select>- </div><div className="space-y-2"><Label htmlFor="bar-type">Bar Type</Label><Select@@ -273,23 +270,16 @@ export function FloatingButton({ className }: { className?: string }) {</Select></div><div className="space-y-2">- <Label htmlFor="theme">Theme</Label>- <ThemeToggle id="theme" className="w-full" />- </div>- <div className="space-y-2">- <Label htmlFor="community-theme">Community Theme</Label>+ <Label htmlFor="show-uptime">Show Uptime</Label><Select- value={communityTheme}- onValueChange={(v) => setCommunityTheme(v as CommunityTheme)}+ value={showUptime ? "true" : "false"}+ onValueChange={(v) => setShowUptime(v === "true")}>- <SelectTrigger- id="community-theme"- className="w-full capitalize"- >+ <SelectTrigger id="show-uptime" className="w-full capitalize"><SelectValue /></SelectTrigger><SelectContent>- {COMMUNITY_THEME.map((v) => (+ {["true", "false"].map((v) => (<SelectItem key={v} value={v} className="capitalize">{v}</SelectItem>@@ -297,17 +287,46 @@ export function FloatingButton({ className }: { className?: string }) {</SelectContent></Select></div>+ {IS_DEV ? (+ <div className="space-y-2">+ <Label htmlFor="radius">Radius</Label>+ <Select+ value={radius}+ onValueChange={(v) => setRadius(v as Radius)}+ >+ <SelectTrigger id="radius" className="w-full capitalize">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {RADIUS.map((v) => (+ <SelectItem key={v} value={v} className="capitalize">+ {v}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>+ ) : null}+ {IS_DEV ? (+ <div className="space-y-2">+ <Label htmlFor="theme">Theme</Label>+ <ThemeToggle id="theme" className="w-full" />+ </div>+ ) : null}<div className="space-y-2">- <Label htmlFor="radius">Radius</Label>+ <Label htmlFor="community-theme">Community Theme</Label><Select- value={radius}- onValueChange={(v) => setRadius(v as Radius)}+ value={communityTheme}+ onValueChange={(v) => setCommunityTheme(v as CommunityTheme)}>- <SelectTrigger id="radius" className="w-full capitalize">+ <SelectTrigger+ id="community-theme"+ className="w-full capitalize"+ ><SelectValue /></SelectTrigger><SelectContent>- {RADIUS.map((v) => (+ {COMMUNITY_THEME.map((v) => (<SelectItem key={v} value={v} className="capitalize">{v}</SelectItem>@@ -321,11 +340,15 @@ export function FloatingButton({ className }: { className?: string }) {<div className="p-4"><Button className="w-full" size="sm" asChild><a- href="https://github.com/openstatusHQ/openstatus-template"+ href={+ pageId+ ? `https://app.openstatus.dev/status-pages/${pageId}/edit?type=${barType}&value=${cardType}&uptime=${showUptime}&theme=${communityTheme}`+ : "https://app.openstatus.dev/status-pages"+ }target="_blank"rel="noreferrer">- GitHub Repo+ Dashboard</a></Button></div>diff --git a/apps/status-page/src/components/status-page/floating-theme.tsx b/apps/status-page/src/components/status-page/floating-theme.tsxindex c41b749b8..9d45b589d 100644--- a/apps/status-page/src/components/status-page/floating-theme.tsx+++ b/apps/status-page/src/components/status-page/floating-theme.tsx@@ -15,8 +15,8 @@ import {SelectTrigger,SelectValue,} from "@/components/ui/select";-import { THEMES, THEME_KEYS } from "@/lib/community-themes";import { cn } from "@/lib/utils";+import { THEMES, THEME_KEYS } from "@openstatus/theme-store";import { Palette } from "lucide-react";import { useEffect } from "react";import { useState } from "react";diff --git a/packages/api/src/router/statusPage.ts b/packages/api/src/router/statusPage.tsindex c623d928c..3fee486d0 100644--- a/packages/api/src/router/statusPage.ts+++ b/packages/api/src/router/statusPage.ts@@ -79,7 +79,7 @@ export const statusPageRouter = createTRPCRouter({const monitors = _page.monitorsToPages// NOTE: we cannot nested `where` in drizzle to filter active monitors- .filter((m) => m.monitor.active && !m.monitor.deletedAt)+ .filter((m) => !m.monitor.deletedAt).map((m) => {const events = getEvents({maintenances: _page.maintenances,diff --git a/packages/db/src/schema/shared.ts b/packages/db/src/schema/shared.tsindex 712e3ab70..725a950b7 100644--- a/packages/db/src/schema/shared.ts+++ b/packages/db/src/schema/shared.ts@@ -129,7 +129,7 @@ export const selectPublicPageSchemaWithRelation = selectPageSchema}).omit({// workspaceId: true,- id: true,+ // id: true,password: true,});diff --git a/apps/status-page/src/lib/community-themes/README.md b/packages/theme-store/README.mdsimilarity index 100%rename from apps/status-page/src/lib/community-themes/README.mdrename to packages/theme-store/README.mddiff --git a/packages/theme-store/package.json b/packages/theme-store/package.jsonnew file mode 100644index 000000000..544ab441a--- /dev/null+++ b/packages/theme-store/package.json@@ -0,0 +1,15 @@+{+ "name": "@openstatus/theme-store",+ "version": "1.0.0",+ "description": "",+ "main": "src/index.ts",+ "scripts": {},+ "dependencies": {},+ "devDependencies": {+ "@openstatus/tsconfig": "workspace:*",+ "typescript": "5.7.2"+ },+ "keywords": [],+ "author": "",+ "license": "ISC"+}diff --git a/apps/status-page/src/lib/community-themes/github-contrast.ts b/packages/theme-store/src/github-contrast.tssimilarity index 100%rename from apps/status-page/src/lib/community-themes/github-contrast.tsrename to packages/theme-store/src/github-contrast.tsdiff --git a/apps/status-page/src/lib/community-themes/index.ts b/packages/theme-store/src/index.tssimilarity index 100%rename from apps/status-page/src/lib/community-themes/index.tsrename to packages/theme-store/src/index.tsdiff --git a/apps/status-page/src/lib/community-themes/supabase.ts b/packages/theme-store/src/supabase.tssimilarity index 100%rename from apps/status-page/src/lib/community-themes/supabase.tsrename to packages/theme-store/src/supabase.tsdiff --git a/apps/status-page/src/lib/community-themes/types.ts b/packages/theme-store/src/types.tssimilarity index 100%rename from apps/status-page/src/lib/community-themes/types.tsrename to packages/theme-store/src/types.tsdiff --git a/packages/theme-store/tsconfig.json b/packages/theme-store/tsconfig.jsonnew file mode 100644index 000000000..aed15c74a--- /dev/null+++ b/packages/theme-store/tsconfig.json@@ -0,0 +1,4 @@+{+ "extends": "@openstatus/tsconfig/base.json",+ "include": ["src", "*.ts"]+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 1709cc65a..0ee317e6c 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -113,6 +113,9 @@ importers:'@openstatus/react':specifier: workspace:*version: link:../../packages/react+ '@openstatus/theme-store':+ specifier: workspace:*+ version: link:../../packages/theme-store'@openstatus/tinybird':specifier: workspace:*version: link:../../packages/tinybird@@ -573,6 +576,9 @@ importers:'@openstatus/react':specifier: workspace:*version: link:../../packages/react+ '@openstatus/theme-store':+ specifier: workspace:*+ version: link:../../packages/theme-store'@openstatus/tinybird':specifier: workspace:*version: link:../../packages/tinybird@@ -1619,6 +1625,15 @@ importers:specifier: 5.7.2version: 5.7.2+ packages/theme-store:+ devDependencies:+ '@openstatus/tsconfig':+ specifier: workspace:*+ version: link:../tsconfig+ typescript:+ specifier: 5.7.2+ version: 5.7.2+packages/tinybird:dependencies:'@chronark/zod-bird':