import { useEffect, useState, type ReactNode } from "react"; import { api } from "../api/client"; import DetailDrawer from "./DetailDrawer"; import { t } from "../i18n"; /** The little forms behind the bulk bar: each says what will be done and to how many, collects the one or two answers it needs, and hands them back. */ function Shell({ title, subtitle, onClose, onSubmit, submitLabel, busy, disabled, children }: { title: string; subtitle: string; onClose: () => void; onSubmit: () => void; submitLabel: string; busy: boolean; disabled?: boolean; children: ReactNode }) { return (
{ e.preventDefault(); onSubmit(); }} > {children}
Afterwards there is an Undo button for a little while; it puts back what was changed.
); } const MINUTES = [ { minutes: 30, label: "30 minutes" }, { minutes: 60, label: "1 hour" }, { minutes: 180, label: "3 hours" }, { minutes: 480, label: "8 hours" }, { minutes: 1440, label: "1 day" }, { minutes: 4320, label: "3 days" }, ]; /** Maintenance on everything picked: for how long, and why. */ export function SilenceBulkDrawer({ noun, count, canSilenceDependents, onSubmit, onClose }: { noun: string; count: number; canSilenceDependents: boolean; onSubmit: (v: { minutes: number; reason: string; withDependents: boolean }) => Promise; onClose: () => void }) { const [minutes, setMinutes] = useState(60); const [reason, setReason] = useState(""); const [withDependents, setWithDependents] = useState(false); const [busy, setBusy] = useState(false); return ( { setBusy(true); await onSubmit({ minutes, reason: reason.trim(), withDependents }); setBusy(false); }} >

Alerts about each are held back for this long; anything still wrong when it ends alerts then. One already under maintenance has its time restarted.

setReason(e.target.value)} placeholder="e.g. Firmware update" /> {canSilenceDependents && ( )}
); } const LENGTHS: { hours: number | null; label: string }[] = [ { hours: null, get label() { return t("Until the alert is gone"); } }, { hours: 1, label: "1 hour" }, { hours: 4, label: "4 hours" }, { hours: 24, label: "1 day" }, { hours: 72, label: "3 days" }, { hours: 168, label: "1 week" }, ]; /** "I'm on these": the same note, person and length for every alert picked. */ export function AckBulkDrawer({ count, onSubmit, onClose }: { count: number; onSubmit: (v: { note: string; assigneeId: number | null; hours: number | null }) => Promise; onClose: () => void }) { const [note, setNote] = useState(""); const [assignee, setAssignee] = useState(""); const [hours, setHours] = useState(""); const [people, setPeople] = useState<{ id: number; name: string }[]>([]); const [busy, setBusy] = useState(false); useEffect(() => { let alive = true; api.alerts .assignees() .then((res) => alive && setPeople(res.users)) .catch(() => {}); return () => { alive = false; }; }, []); return ( { setBusy(true); await onSubmit({ note: note.trim(), assigneeId: assignee === "" ? null : Number(assignee), hours: hours === "" ? null : Number(hours) }); setBusy(false); }} >

Says that somebody has seen them. The alerts stay, and are still counted by /metrics, but they are no longer ones nobody has looked at. One that was already acknowledged has its note replaced.