Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: manual validation (#1407)

* fix: status page provider validation

* fix: manual value

authored by

Maximilian Kaske and committed by
GitHub
5017778b c53522ce

+11 -12
+6 -8
apps/dashboard/src/components/forms/status-page/form-configuration.tsx
··· 59 59 const configurationSchema = z 60 60 .object({ 61 61 type: z.enum(["manual", "absolute"]), 62 - value: z.enum(["duration", "requests"]).nullish(), 62 + value: z.enum(["duration", "requests", "manual"]).nullish(), 63 63 uptime: z.boolean().or(z.literal("true").or(z.literal("false"))), 64 64 theme: z.enum(THEME_KEYS as [string, ...string[]]), 65 65 }) 66 66 .refine( 67 67 (data) => { 68 - // If type is "manual", value must be null or undefined 69 - if (data.type === "manual") { 70 - return data.value === null || data.value === undefined; 71 - } 68 + // If type is "manual", value must be "manual" 69 + if (data.type === "manual") return data.value === "manual"; 72 70 return true; 73 71 }, 74 72 { 75 - message: "Value must be null when type is manual", 73 + message: "Value must be manual when type is manual", 76 74 path: ["value"], 77 75 }, 78 76 ); ··· 111 109 112 110 useEffect(() => { 113 111 if (watchConfigurationType === "manual") { 114 - form.setValue("configuration.value", undefined); 112 + form.setValue("configuration.value", "manual"); 115 113 } else { 116 114 form.setValue("configuration.value", "duration"); 117 115 form.setValue("configuration.type", "absolute"); ··· 484 482 485 483 const searchParams = { 486 484 type: parseAsStringLiteral(["manual", "absolute"]), 487 - value: parseAsStringLiteral(["duration", "requests"]), 485 + value: parseAsStringLiteral(["duration", "requests", "manual"]), 488 486 uptime: parseAsStringLiteral(["true", "false"]), 489 487 theme: parseAsStringLiteral(Object.keys(THEMES)), 490 488 };
+1
apps/status-page/src/app/(status-page)/[domain]/(public)/page.tsx
··· 36 36 const { data: page } = useQuery( 37 37 trpc.statusPage.get.queryOptions({ slug: domain }), 38 38 ); 39 + 39 40 // NOTE: we can prefetch that to avoid loading state 40 41 const { data: uptimeData, isLoading } = useQuery( 41 42 trpc.statusPage.getUptime.queryOptions({
+4 -4
apps/status-page/src/app/(status-page)/[domain]/layout.tsx
··· 12 12 import { z } from "zod"; 13 13 14 14 export const schema = z.object({ 15 - card: z.enum(["duration", "requests", "manual"]).default("duration"), 16 - bar: z.enum(["absolute", "manual"]).default("absolute"), 15 + value: z.enum(["duration", "requests", "manual"]).default("duration"), 16 + type: z.enum(["absolute", "manual"]).default("absolute"), 17 17 uptime: z.coerce.boolean().default(true), 18 18 theme: z.enum(["default"]).default("default"), 19 19 }); ··· 42 42 disableTransitionOnChange 43 43 > 44 44 <StatusPageProvider 45 - defaultBarType={validation.data?.bar} 46 - defaultCardType={validation.data?.card} 45 + defaultBarType={validation.data?.type} 46 + defaultCardType={validation.data?.value} 47 47 defaultShowUptime={validation.data?.uptime} 48 48 defaultCommunityTheme={validation.data?.theme} 49 49 >