Dashboard status strip, "Not set up yet" list, sidebar badges and user menu
The dashboard opens with one line saying whether anything needs attention (from the same alert report as the Alerts page) and never claims "all clear" when some checks couldn't run. Widgets with nothing configured are listed once under "Not set up yet" instead of one grey card each. The sidebar shows the active alert count and open maintenance windows next to their pages (and on a closed group), and the foot of the sidebar is one user menu holding theme, privacy and sign-out. One shared alert poll serves the strip and the badge. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aab2f8cb4a
commit
7d56ad18b7
5 files changed
+369
-22
No files matched your search
@@ -0,0 +1,97 @@
|
||||
import { Link } from "react-router-dom";
|
||||
import { IconAlertTriangle, IconCircleCheck, IconInfoCircle } from "@tabler/icons-react";
|
||||
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
||||
|
||||
const SEVERITY_ORDER = { critical: 0, warning: 1, info: 2 } as const;
|
||||
|
||||
/** One line at the top of the dashboard: is anything wrong right now? Reads the same alert report as the Alerts page. */
|
||||
export default function StatusStrip() {
|
||||
const { report, failed, reload } = useAlertsReport();
|
||||
|
||||
if (!report) {
|
||||
return (
|
||||
<div className="alert alert-secondary d-flex align-items-center gap-2 mb-3" role="status">
|
||||
<IconInfoCircle size={18} />
|
||||
<div>{failed ? "Couldn't load the alert status." : "Checking status…"}</div>
|
||||
{failed && (
|
||||
<button type="button" className="btn btn-sm ms-auto" onClick={reload}>
|
||||
Try again
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const badge = alertBadge(report);
|
||||
const active = report.alerts
|
||||
.filter((a) => !a.silenced && a.severity !== "info")
|
||||
.sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity]);
|
||||
const silenced = report.counts.silenced;
|
||||
const blind = report.couldntCheck.length;
|
||||
|
||||
const notes: string[] = [];
|
||||
if (silenced > 0) notes.push(`${silenced} silenced by maintenance`);
|
||||
if (blind > 0 && badge) notes.push(`${blind} check${blind === 1 ? "" : "s"} couldn't run`);
|
||||
|
||||
if (!badge) {
|
||||
// Nothing is wrong that we can see — but if some checks couldn't run, "all clear" would claim more than is known.
|
||||
const unsure = blind > 0;
|
||||
return (
|
||||
<div className={`alert ${unsure ? "alert-warning" : "alert-success"} mb-3`} role="status">
|
||||
<div className="d-flex align-items-center gap-2">
|
||||
{unsure ? <IconAlertTriangle size={18} className="flex-shrink-0" /> : <IconCircleCheck size={18} className="flex-shrink-0" />}
|
||||
<div>
|
||||
<strong>{unsure ? "No active alerts, but some checks couldn't run." : "All clear."}</strong>{" "}
|
||||
{unsure ? (
|
||||
<span>
|
||||
{report.couldntCheck.map((c) => c.name).join(", ")} — see <Link to="/alerts">Alerts</Link> for what that leaves unchecked.
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-secondary">No active alerts.</span>
|
||||
)}
|
||||
{silenced > 0 && <span className="text-secondary"> {silenced} silenced by maintenance.</span>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const parts = [
|
||||
report.counts.critical > 0 ? `${report.counts.critical} critical` : null,
|
||||
report.counts.warning > 0 ? `${report.counts.warning} warning${report.counts.warning === 1 ? "" : "s"}` : null,
|
||||
].filter(Boolean);
|
||||
|
||||
return (
|
||||
<div className={`alert ${badge.level === "critical" ? "alert-danger" : "alert-warning"} mb-3`} role="alert">
|
||||
<div className="d-flex gap-2 w-100">
|
||||
<IconAlertTriangle size={18} className="flex-shrink-0 mt-1" />
|
||||
<div className="flex-fill">
|
||||
<div className="d-flex flex-wrap align-items-center gap-2">
|
||||
<div>
|
||||
<strong>
|
||||
{badge.count} {badge.count === 1 ? "thing needs" : "things need"} attention
|
||||
</strong>{" "}
|
||||
— {parts.join(", ")}
|
||||
{notes.length > 0 && <span className="opacity-75"> · {notes.join(" · ")}</span>}
|
||||
</div>
|
||||
<Link to="/alerts" className="btn btn-sm ms-auto flex-shrink-0">
|
||||
View all alerts
|
||||
</Link>
|
||||
</div>
|
||||
{active.length > 0 && (
|
||||
<ul className="mb-0 mt-2 ps-3">
|
||||
{active.slice(0, 3).map((a) => (
|
||||
<li key={a.id}>
|
||||
<Link to={a.link ?? "/alerts"} className="alert-link">
|
||||
{a.message}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
{active.length > 3 && <li className="opacity-75">and {active.length - 3} more</li>}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user