Skip to content

Open-source status page, incident response and uptime monitoring

fix: group components in dropdown (#2267)

Colin Ozanne4ef2f6deae4b
diff --git a/apps/web/src/app/(landing)/status/[id]/report-issue.tsx b/apps/web/src/app/(landing)/status/[id]/report-issue.tsx
index 183ebea88..d3ed1de27 100644
--- a/apps/web/src/app/(landing)/status/[id]/report-issue.tsx
+++ b/apps/web/src/app/(landing)/status/[id]/report-issue.tsx
@@ -4,7 +4,9 @@ import { Button } from "@openstatus/ui/components/ui/button";
import {
Select,
SelectContent,
+ SelectGroup,
SelectItem,
+ SelectLabel,
SelectTrigger,
SelectValue,
} from "@openstatus/ui/components/ui/select";
@@ -12,6 +14,8 @@ import { useState } from "react";
import { api } from "@/trpc/rq-client";
+import { buildSections } from "../external-service-components";
+
const WHOLE_SERVICE = "all";
function Box({ children }: { children: React.ReactNode }) {
@@ -54,6 +58,7 @@ export function ReportIssue({
allowComponentSelect && components.data?.supported
? components.data.components
: [];
+ const sections = buildSections(componentOptions);
if (mutation.isSuccess) {
return (
@@ -91,15 +96,30 @@ export function ReportIssue({
<SelectItem value={WHOLE_SERVICE} className="rounded-none">
Whole service
</SelectItem>
- {componentOptions.map((c) => (
- <SelectItem
- key={c.slug}
- value={c.slug}
- className="rounded-none"
- >
- {c.name}
- </SelectItem>
- ))}
+ {sections.length === 1 && sections[0].name === null
+ ? sections[0].components.map((c) => (
+ <SelectItem
+ key={c.slug}
+ value={c.slug}
+ className="rounded-none"
+ >
+ {c.name}
+ </SelectItem>
+ ))
+ : sections.map((section) => (
+ <SelectGroup key={section.key}>
+ <SelectLabel>{section.name ?? "Other"}</SelectLabel>
+ {section.components.map((c) => (
+ <SelectItem
+ key={c.slug}
+ value={c.slug}
+ className="rounded-none"
+ >
+ {c.name}
+ </SelectItem>
+ ))}
+ </SelectGroup>
+ ))}
</SelectContent>
</Select>
) : null}
diff --git a/apps/web/src/app/(landing)/status/external-service-components.tsx b/apps/web/src/app/(landing)/status/external-service-components.tsx
index c000140b7..6bdd0be15 100644
--- a/apps/web/src/app/(landing)/status/external-service-components.tsx
+++ b/apps/web/src/app/(landing)/status/external-service-components.tsx
@@ -126,7 +126,9 @@ type Section = {
worst: number;
};
-function buildSections(components: ExternalServiceComponentItem[]): Section[] {
+export function buildSections(
+ components: ExternalServiceComponentItem[],
+): Section[] {
const byGroup = new Map<string | null, ExternalServiceComponentItem[]>();
for (const c of components) {
const key = c.groupName ?? null;