Skip to content

Open-source status page, incident response and uptime monitoring

fix: small stuff (#1406)

Maximilian Kaskec53522ce0cc4
diff --git a/apps/dashboard/src/components/forms/status-page/form-configuration.tsx b/apps/dashboard/src/components/forms/status-page/form-configuration.tsx
index d1396d761..e283e837c 100644
--- a/apps/dashboard/src/components/forms/status-page/form-configuration.tsx
+++ b/apps/dashboard/src/components/forms/status-page/form-configuration.tsx
@@ -44,7 +44,7 @@ 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 { ArrowUpRight, Info } from "lucide-react";
import { parseAsStringLiteral, useQueryStates } from "nuqs";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
@@ -155,7 +155,7 @@ export function FormConfiguration({
Use the latest version of the status page and customize it.
</FormCardDescription>
</FormCardHeader>
- <FormCardContent className="grid gap-4 sm:grid-cols-2">
+ <FormCardContent className="grid gap-4 md:grid-cols-3">
<FormField
control={form.control}
name="new"
@@ -176,8 +176,8 @@ export function FormConfiguration({
</FormItem>
)}
/>
- <div className="flex items-center sm:justify-end">
- <Button variant="secondary" size="sm" asChild>
+ <div className="flex items-center md:col-span-2 md:justify-end">
+ <Button size="sm" asChild>
<Link
href={configLink}
rel="noreferrer"
@@ -189,21 +189,6 @@ export function FormConfiguration({
</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 && (
<>
diff --git a/apps/status-page/src/components/chart/chart-legend-badge.tsx b/apps/status-page/src/components/chart/chart-legend-badge.tsx
index 54e91a462..f6f0a692a 100644
--- a/apps/status-page/src/components/chart/chart-legend-badge.tsx
+++ b/apps/status-page/src/components/chart/chart-legend-badge.tsx
@@ -7,6 +7,7 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";
+import * as React from "react";
import type * as RechartsPrimitive from "recharts";
import type { Payload } from "recharts/types/component/DefaultLegendContent";
@@ -33,13 +34,34 @@ export function ChartLegendBadge({
tooltip?: Record<string, string | undefined>;
}) {
const { config } = useChart();
+ const [focusedIndex, setFocusedIndex] = React.useState(0);
+ const buttonRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
if (!payload?.length) {
return null;
}
+ const filteredPayload = payload.filter((item) => item.type !== "none");
const hasMaxActive = active && maxActive ? active.length >= maxActive : false;
+ const handleKeyDown = (event: React.KeyboardEvent) => {
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
+ event.preventDefault();
+ const direction = event.key === "ArrowLeft" ? -1 : 1;
+ let nextIndex = 0;
+ nextIndex =
+ (focusedIndex + direction + filteredPayload.length) %
+ filteredPayload.length;
+ setFocusedIndex(nextIndex);
+ while (buttonRefs.current[nextIndex]?.disabled === true) {
+ nextIndex =
+ (nextIndex + direction + filteredPayload.length) %
+ filteredPayload.length;
+ }
+ buttonRefs.current[nextIndex]?.focus();
+ }
+ };
+
return (
<div
className={cn(
@@ -47,64 +69,71 @@ export function ChartLegendBadge({
verticalAlign === "top" ? "pb-3" : "pt-3",
className,
)}
+ onKeyDown={handleKeyDown}
+ role="group"
+ aria-label="Chart legend"
>
- {payload
- // NOTE: recharts supports "none" type for legend items
- .filter((item) => item.type !== "none")
- .map((item) => {
- const key = `${nameKey || item.dataKey || "value"}`;
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
- const suffix = annotation?.[item.dataKey as string];
- const tooltipLabel = tooltip?.[item.dataKey as string];
- const isActive = active?.includes(item.dataKey);
+ {filteredPayload.map((item, index) => {
+ const key = `${nameKey || item.dataKey || "value"}`;
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
+ const suffix = annotation?.[item.dataKey as string];
+ const tooltipLabel = tooltip?.[item.dataKey as string];
+ const isActive = active ? active?.includes(item.dataKey) : true;
+ const isFocused = index === focusedIndex;
- const badge = (
- <button
- key={item.value}
- type="button"
- className={cn(
- badgeVariants({ variant: "outline" }),
- "outline-none",
- "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",
- !isActive && "opacity-60",
- !isActive && hasMaxActive && "cursor-not-allowed opacity-40",
- )}
- onClick={(e) => {
- e.stopPropagation();
- e.preventDefault();
- handleActive?.(item);
- }}
- disabled={!isActive && hasMaxActive}
- >
- {itemConfig?.icon && !hideIcon ? (
- <itemConfig.icon />
- ) : (
- <div
- className="h-2 w-2 shrink-0 rounded-(--radius-xs)"
- style={{
- backgroundColor: item.color,
- }}
- />
- )}
- {itemConfig?.label}
- {suffix !== undefined ? (
- <span className="font-mono text-[10px] text-muted-foreground">
- {suffix}
- </span>
- ) : null}
- </button>
- );
+ const badge = (
+ <button
+ key={item.value}
+ type="button"
+ ref={(el) => {
+ buttonRefs.current[index] = el;
+ }}
+ className={cn(
+ badgeVariants({ variant: "outline" }),
+ "outline-none",
+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",
+ !isActive && "opacity-60",
+ !isActive && hasMaxActive && "cursor-not-allowed opacity-40",
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ e.preventDefault();
+ setFocusedIndex(index);
+ handleActive?.(item);
+ }}
+ onFocus={() => setFocusedIndex(index)}
+ disabled={!isActive && hasMaxActive}
+ tabIndex={isFocused ? 0 : -1}
+ >
+ {itemConfig?.icon && !hideIcon ? (
+ <itemConfig.icon />
+ ) : (
+ <div
+ className="h-2 w-2 shrink-0 rounded-[2px]"
+ style={{
+ backgroundColor: item.color,
+ }}
+ />
+ )}
+ {itemConfig?.label}
+ {suffix !== undefined ? (
+ <span className="font-mono text-[10px] text-muted-foreground">
+ {suffix}
+ </span>
+ ) : null}
+ </button>
+ );
- if (tooltipLabel) {
- return (
- <ChartLegendTooltip key={item.value} tooltip={tooltipLabel}>
- {badge}
- </ChartLegendTooltip>
- );
- }
+ if (tooltipLabel) {
+ return (
+ <ChartLegendTooltip key={item.value} tooltip={tooltipLabel}>
+ {badge}
+ </ChartLegendTooltip>
+ );
+ }
- return badge;
- })}
+ return badge;
+ })}
</div>
);
}
diff --git a/apps/status-page/src/components/chart/chart-line-regions.tsx b/apps/status-page/src/components/chart/chart-line-regions.tsx
index f99d903b0..ff79304c5 100644
--- a/apps/status-page/src/components/chart/chart-line-regions.tsx
+++ b/apps/status-page/src/components/chart/chart-line-regions.tsx
@@ -90,7 +90,13 @@ export function ChartLineRegions({
{} as Record<string, string>,
);
- // TODO: tooltip
+ const tooltip = regions.reduce(
+ (acc, region) => {
+ acc[region.code] = region.location;
+ return acc;
+ },
+ {} as Record<string, string>,
+ );
return (
<ChartContainer
@@ -171,6 +177,7 @@ export function ChartLineRegions({
}}
active={activeSeries}
annotation={annotation}
+ tooltip={tooltip}
maxActive={6}
className="justify-start overflow-x-scroll ps-1 pt-1 font-mono"
/>
diff --git a/apps/status-page/src/components/nav/footer.tsx b/apps/status-page/src/components/nav/footer.tsx
index 31a8ab54b..5c9af32a5 100644
--- a/apps/status-page/src/components/nav/footer.tsx
+++ b/apps/status-page/src/components/nav/footer.tsx
@@ -22,7 +22,7 @@ export function Footer(props: React.ComponentProps<"footer">) {
<div className="mx-auto flex max-w-2xl items-center justify-between gap-4 px-3 py-2">
<div>
<p className="font-mono text-muted-foreground text-sm leading-none">
- powered by <Link href="#">openstatus</Link>
+ powered by <Link href="https://openstatus.dev">openstatus</Link>
</p>
<TimestampHoverCard date={new Date(dataUpdatedAt)} side="top">
<span className="text-muted-foreground/70 text-xs">
diff --git a/apps/status-page/src/components/status-page/floating-button.tsx b/apps/status-page/src/components/status-page/floating-button.tsx
index c4419394e..d1f26ddcb 100644
--- a/apps/status-page/src/components/status-page/floating-button.tsx
+++ b/apps/status-page/src/components/status-page/floating-button.tsx
@@ -194,7 +194,7 @@ export function FloatingButton({
}
if (configToken) setConfigToken(null);
- }, [open, token]);
+ }, [token]);
if (!display) return null;
@@ -348,7 +348,7 @@ export function FloatingButton({
target="_blank"
rel="noreferrer"
>
- Dashboard
+ Save Configuration
</a>
</Button>
</div>
diff --git a/packages/api/src/router/statusPage.ts b/packages/api/src/router/statusPage.ts
index 3fee486d0..1058eaf9b 100644
--- a/packages/api/src/router/statusPage.ts
+++ b/packages/api/src/router/statusPage.ts
@@ -232,7 +232,7 @@ export const statusPageRouter = createTRPCRouter({
if (!_page) return null;
const monitors = _page.monitorsToPages.filter(
- (m) => m.monitor.active && !m.monitor.deletedAt,
+ (m) => !m.monitor.deletedAt,
);
if (monitors.length !== opts.input.monitorIds.length) return null;
diff --git a/packages/api/src/router/statusPage.utils.ts b/packages/api/src/router/statusPage.utils.ts
index fd0e8f3b7..271a44786 100644
--- a/packages/api/src/router/statusPage.utils.ts
+++ b/packages/api/src/router/statusPage.utils.ts
@@ -404,7 +404,8 @@ export function setDataByType({
return segments.map((segment) => ({
status: segment.status,
- height: (segment.count / totalDuration) * 100,
+ // NOTE: if totalDuration is 0 (single event without duration), we want to show 100% for the segment
+ height: totalDuration > 0 ? (segment.count / totalDuration) * 100 : 100,
}));
}