Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: alerts and the issue report are folded cards on a reports tab

The alerts and issues tabs are one reports tab in the nav. Each page, unchanged
inside, is a card that starts shut and reads nothing until opened; the alerts
header's link, button and refresh picker move into the card's body. /alerts and
/issues redirect to /reports. Docs follow.
This commit is contained in:
iris 2026-10-26 21:16:05 +01:00 • committed by mara
commit 599747bacb

View file

@ -1,4 +1,4 @@
// <AlertsPage> — `/alerts`' content: the alerts the swarm's Grafana holds
// <AlertsCard> — a card of the reports tab: the alerts the swarm's Grafana holds
// now, from swarm-controller's `GET /api/alerts`. Only the firing ones show at
// first; a button in the header adds the pending, no-data and errored ones.
// Same shape as `HivesCard`: one fetch on a `RefreshIntervalPicker` cadence,
@ -7,7 +7,7 @@ import { useState } from "preact/hooks";
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
import { Badge, type BadgeTone } from "@hive/shared/badge.js";
import { Button } from "../ui/button/Button.js";
import { Panel } from "../ui/panel/Panel.js";
import { LazyDisclosure } from "../ui/disclosure/LazyDisclosure.js";
import { RelativeTime } from "../ui/relative-time/RelativeTime.js";
import {
RefreshIntervalPicker,
@ -71,7 +71,7 @@ const COLUMNS: TableColumn<Alert>[] = [
const DEFAULT_INTERVAL_MS: RefreshIntervalMs = 30_000;
export function AlertsPage() {
function AlertsBody() {
const [showAll, setShowAll] = useState(false);
const [intervalMs, setIntervalMs] =
useState<RefreshIntervalMs>(DEFAULT_INTERVAL_MS);
@ -82,31 +82,22 @@ export function AlertsPage() {
const hidden = alerts && listed ? alerts.length - listed.length : 0;
return (
<Panel
title="alerts"
icon="🚨"
actions={
<>
<a
href={GRAFANA_ALERTS_URL}
target="_blank"
rel="noopener noreferrer"
>
Grafana's alert list
</a>
{showAll || hidden > 0 ? (
<Button onClick={() => setShowAll(!showAll)}>
{showAll ? "only firing" : `show ${hidden} more`}
</Button>
) : null}
<RefreshIntervalPicker
id="alerts-refresh"
value={intervalMs}
onChange={setIntervalMs}
/>
</>
}
>
<>
<div class="ui-alerts-bar">
<a href={GRAFANA_ALERTS_URL} target="_blank" rel="noopener noreferrer">
Grafana's alert list
</a>
{showAll || hidden > 0 ? (
<Button onClick={() => setShowAll(!showAll)}>
{showAll ? "only firing" : `show ${hidden} more`}
</Button>
) : null}
<RefreshIntervalPicker
id="alerts-refresh"
value={intervalMs}
onChange={setIntervalMs}
/>
</div>
{error ? (
<ApiErrorPanel
context="failed to load Grafana's alerts"
@ -125,6 +116,19 @@ export function AlertsPage() {
storageKey="swarm-ui:alerts:table-filters"
/>
) : null}
</Panel>
</>
);
}
// A folded card on the reports tab: read and polled only once it is opened.
export function AlertsCard() {
return (
<LazyDisclosure
title="alerts"
icon="🚨"
hint="what the swarm's Grafana holds now"
>
<AlertsBody />
</LazyDisclosure>
);
}