Bulk close can close the osTicket tickets; Alerts top-level, Records group

Closing several alerts together can now also close their osTicket tickets
(one by one, each written on its incident and in the audit log; one that
fails does not stop the rest; Undo does not reopen tickets). The single
and bulk close share one helper. Alerts moves to the top of the sidebar,
and Monthly report and Change log move to a new Records group. Docs updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-26 20:20:28 +01:00
1 parent 215c0de8bf
commit 78822346b1
13 files changed
+234 -37

No files matched your search

+2
View File
@@ -2047,6 +2047,8 @@ export interface BulkResult {
skipped: { id: string | number; name: string; reason: string }[];
undo: Record<string, unknown> | null;
silenced?: { type: string; id: number; name: string }[];
/** Closing several alerts with "also close their osTicket tickets": how the tickets went (not undone by Undo). */
tickets?: { closed: number; alreadyClosed: number; failed: { alertId: string; number: string | null; message: string }[]; notClosable: number } | null;
}
/** One alert that fires often, from the incident record. */
+27 -4
View File
@@ -79,20 +79,43 @@ export default function CloseDrawer({ alert, onClose, onSaved }: { alert: AlertI
);
}
/** The same for several alerts at once: one reason for all, written on each one's incident. `onSubmit` does it (and says how it went); the tickets of these alerts are not closed from here. */
export function CloseBulkDrawer({ count, onSubmit, onClose }: { count: number; onSubmit: (note: string | null) => Promise<void>; onClose: () => void }) {
/**
* The same for several alerts at once: one reason for all, written on each one's incident. `onSubmit` does it (and says how it went). `tickets` says what the picked alerts have in
* osTicket: the numbers that can be closed from here, and how many more have a ticket that cannot (a summary ticket, or an osTicket with no login for closing).
*/
export function CloseBulkDrawer({ count, tickets, onSubmit, onClose }: { count: number; tickets: { closable: string[]; other: number }; onSubmit: (note: string | null, closeTickets: boolean) => Promise<void>; onClose: () => void }) {
const [note, setNote] = useState("");
const [closeTickets, setCloseTickets] = useState(false);
const [busy, setBusy] = useState(false);
const shown = tickets.closable.slice(0, 8).map((n) => "#" + n).join(", ") + (tickets.closable.length > 8 ? " and " + (tickets.closable.length - 8) + " more" : "");
return (
<DetailDrawer title={`Close ${count} alert${count === 1 ? "" : "s"}`} onClose={onClose}>
<div className="text-secondary mb-3">
Hide them, with no end. Each comes back only if it <strong>gets worse</strong> than it is now, or if its problem goes away for half an hour and then returns. Until then they are not counted and nothing is sent about them. The reason goes on each one&rsquo;s
incident. Nothing about the things themselves is promised — use <em>Silence</em> for planned work. Their osTicket tickets are not closed from here; close an alert on its own for that.
incident. Nothing about the things themselves is promised — use <em>Silence</em> for planned work.
</div>
<label className="form-label" htmlFor="close-bulk-note">
Why? (optional)
</label>
<textarea id="close-bulk-note" className="form-control mb-3" rows={3} maxLength={500} value={note} onChange={(e) => setNote(e.target.value)} placeholder="All retired with the old host · accepted · fixed outside the app…" autoFocus />
{tickets.closable.length > 0 && (
<div className="mb-3">
<label className="form-check">
<input type="checkbox" className="form-check-input" checked={closeTickets} onChange={(e) => setCloseTickets(e.target.checked)} />
<span className="form-check-label">
Also close {tickets.closable.length === 1 ? "osTicket ticket" : `${tickets.closable.length} osTicket tickets`} <strong>{shown}</strong>
<span className="d-block text-secondary small">
Each is set to Closed in osTicket, with a note in its thread saying who closed it from here and why (your reason above). <strong>Undo opens the alerts again but cannot reopen the tickets.</strong>
</span>
</span>
</label>
</div>
)}
{tickets.other > 0 && (
<div className="text-secondary small mb-3">
{tickets.other === 1 ? "One more has a ticket that stays open" : `${tickets.other} more have tickets that stay open`}: a summary ticket that covers several alerts, or an osTicket with no login for closing tickets (an administrator adds one under Integrations).
</div>
)}
<div className="d-flex gap-2">
<button
type="button"
@@ -100,7 +123,7 @@ export function CloseBulkDrawer({ count, onSubmit, onClose }: { count: number; o
disabled={busy}
onClick={() => {
setBusy(true);
void onSubmit(note.trim() === "" ? null : note.trim()).finally(() => setBusy(false));
void onSubmit(note.trim() === "" ? null : note.trim(), closeTickets && tickets.closable.length > 0).finally(() => setBusy(false));
}}
>
{busy ? "Closing…" : `Close ${count === 1 ? "the alert" : `all ${count}`}`}
+10 -2
View File
@@ -37,6 +37,7 @@ import {
IconListCheck,
IconRefresh,
IconApps,
IconHistory,
IconBooks,
IconDownload,
IconBox,
@@ -82,6 +83,7 @@ export const isGroup = (entry: NavEntry): entry is NavGroup => "items" in entry;
export const NAV: NavEntry[] = [
{ to: "/", label: "Dashboard", icon: <IconLayoutDashboard size={20} /> },
{ to: "/alerts", label: "Alerts", icon: <IconAlertTriangle size={20} /> },
{ to: "/my-work", label: "My work", icon: <IconChecklist size={20} />, minRole: "operator" },
{
id: "infrastructure",
@@ -163,14 +165,20 @@ export const NAV: NavEntry[] = [
label: "Operations",
icon: <IconTool size={20} />,
items: [
{ to: "/alerts", label: "Alerts", icon: <IconAlertTriangle size={20} /> },
{ to: "/maintenance", label: "Maintenance", icon: <IconTool size={20} /> },
{ to: "/updates", label: "Updates", icon: <IconDownload size={20} /> },
{ to: "/coming-up", label: "Coming up", icon: <IconCalendarEvent size={20} /> },
{ to: "/todo", label: "To do", icon: <IconListDetails size={20} /> },
{ to: "/osticket", label: "osTicket", icon: <IconTicket size={20} /> },
],
},
{
id: "records",
label: "Records",
icon: <IconHistory size={20} />,
items: [
{ to: "/reports", label: "Monthly report", icon: <IconReportAnalytics size={20} /> },
{ to: "/changes", label: "Change log", icon: <IconGitCommit size={20} />, minRole: "operator" },
{ to: "/osticket", label: "osTicket", icon: <IconTicket size={20} /> },
],
},
{
+20 -4
View File
@@ -1,6 +1,6 @@
import { Fragment, useEffect, useMemo, useState } from "react";
import { Link, useSearchParams } from "react-router-dom";
import { api, type AlertCategory, type AlertItem, type AlertSeverity, type AlertsReport, type CurrentUser } from "../api/client";
import { api, type AlertCategory, type BulkResult, type AlertItem, type AlertSeverity, type AlertsReport, type CurrentUser } from "../api/client";
import { useSortable } from "../hooks/useSortable";
import SortableTh from "../components/SortableTh";
import { usePagination } from "../hooks/usePagination";
@@ -61,6 +61,16 @@ const alertTabs = (view: "now" | "history" | "noise") => (
/>
);
/** What happened to the osTicket tickets when several alerts were closed with them, as a sentence to follow "N alerts closed." */
function ticketSentence(t: BulkResult["tickets"]): string {
if (!t) return "";
const parts: string[] = [];
if (t.closed > 0) parts.push(`${plural(t.closed, "osTicket ticket")} closed too — Undo opens the alerts again, not the tickets.`);
if (t.alreadyClosed > 0) parts.push(`${plural(t.alreadyClosed, "ticket")} ${t.alreadyClosed === 1 ? "was" : "were"} already closed.`);
if (t.failed.length > 0) parts.push(`${plural(t.failed.length, "ticket")} could not be closed (${t.failed[0].message}${t.failed.length > 1 ? "…" : ""}).`);
return parts.length > 0 ? " " + parts.join(" ") : "";
}
export default function Alerts({ user }: { user: CurrentUser }) {
const [params] = useSearchParams();
const view = params.get("view");
@@ -186,6 +196,12 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
const here = new Set((report?.alerts ?? []).map((a) => a.id));
return [...picked].filter((id) => here.has(id));
}, [picked, report]);
// What the picked alerts have in osTicket: the tickets that can be closed from here, and how many more have one that cannot.
const ticketsOfPicked = useMemo(() => {
const ids = new Set(pickedIds);
const withTicket = (report?.alerts ?? []).filter((a) => ids.has(a.id) && a.ticket?.number && !a.ticket.closedAt);
return { closable: withTicket.filter((a) => a.ticket?.canClose).map((a) => a.ticket!.number as string), other: withTicket.filter((a) => !a.ticket?.canClose).length };
}, [pickedIds, report]);
const shownIds = useMemo(() => (sorted ?? []).filter((a) => !a.silenced).map((a) => a.id), [sorted]);
const allShownPicked = shownIds.length > 0 && shownIds.every((id) => picked.has(id));
function togglePicked(id: string) {
@@ -239,8 +255,8 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
setPicked(new Set());
}
}
async function bulkClose(note: string | null) {
const ok = await doBulk({ call: api.bulk.alerts, body: { action: "close", alertIds: pickedIds, note }, done: (r) => `${plural(r.changed, "alert")} closed.`, reload: afterBulk });
async function bulkClose(note: string | null, closeTickets: boolean) {
const ok = await doBulk({ call: api.bulk.alerts, body: { action: "close", alertIds: pickedIds, note, ...(closeTickets ? { closeTickets: true } : {}) }, done: (r) => `${plural(r.changed, "alert")} closed.${ticketSentence(r.tickets)}`, reload: afterBulk });
if (ok) {
setBulkForm(null);
setPicked(new Set());
@@ -653,7 +669,7 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
</>
)}
{bulkForm === "ack" && <AckBulkDrawer count={pickedIds.length} onSubmit={bulkAck} onClose={() => setBulkForm(null)} />}
{bulkForm === "close" && <CloseBulkDrawer count={pickedIds.length} onSubmit={bulkClose} onClose={() => setBulkForm(null)} />}
{bulkForm === "close" && <CloseBulkDrawer count={pickedIds.length} tickets={ticketsOfPicked} onSubmit={bulkClose} onClose={() => setBulkForm(null)} />}
{bulkForm === "snooze" && <SnoozeBulkDrawer count={pickedIds.length} onSubmit={bulkSnooze} onClose={() => setBulkForm(null)} />}
{bulkForm === "silence" && <SilenceBulkDrawer noun={pickedIds.length === 1 ? "alert" : "alerts"} count={pickedIds.length} canSilenceDependents={false} onSubmit={bulkSilence} onClose={() => setBulkForm(null)} />}