From 74d859b877ad68c954ef038d989f192bd7a1b303 Mon Sep 17 00:00:00 2001 From: gorkem-bwl Date: Sat, 29 Aug 2026 10:33:05 -0400 Subject: [PATCH] feat(client): redesign the Monitor status and Incident stats cards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both cards were laying data out rather than saying anything with it. Monitor status showed six equal-weight tiles, so "11 up" and "1 down" carried identical visual weight and four of the six were usually zero. It now leads with how much of the fleet is healthy — the count against the total — over a segmented bar showing the whole fleet's composition at a glance. Below it, only states that actually have monitors appear, worst first. A fully healthy fleet collapses to one line and a solid green bar instead of a row of empty counters. Incident stats showed one figure and two label lines, and ignored three fields the endpoint already returns. Open incidents still leads but is now paired with the all-time total, because two open reads very differently against 12 incidents than against 183. Beneath that, the automatic-versus-manual resolution split gets a bar of its own: it was computed server-side and said nothing on the card before, and a high manual share is worth seeing — it means people are doing work the system could be doing. Adds CardSegmentedBar to the shared primitives for both. Zero-value segments are dropped so they cannot render as hairlines, and each segment carries a tooltip since the bar has no room for labels. Verified the proportions across a healthy fleet, an all-down fleet, an empty one, and a fully-automatic resolution history. Claude-Session: https://claude.ai/code/session_01AbYLvwpEaZFXktHVcqrFRd --- .../Dashboard/Components/CardPrimitives.tsx | 51 +++++++ .../Components/Cards/MonitorStatusCard.tsx | 143 ++++++++++++------ .../Components/Cards/SummaryCards.tsx | 89 ++++++++--- client/src/locales/en.json | 10 +- 4 files changed, 223 insertions(+), 70 deletions(-) diff --git a/client/src/Pages/Dashboard/Components/CardPrimitives.tsx b/client/src/Pages/Dashboard/Components/CardPrimitives.tsx index 71c0d59ab..497d91ec3 100644 --- a/client/src/Pages/Dashboard/Components/CardPrimitives.tsx +++ b/client/src/Pages/Dashboard/Components/CardPrimitives.tsx @@ -4,6 +4,7 @@ import Typography from "@mui/material/Typography"; import { useTheme } from "@mui/material/styles"; import { Link as RouterLink } from "react-router-dom"; +import { Tooltip } from "@/Components/design-elements"; import { LAYOUT } from "@/Utils/Theme/constants"; import { typographyLevels } from "@/Utils/Theme/Palette"; @@ -11,6 +12,16 @@ import type { ReactNode } from "react"; /** Thin enough to read as a proportion indicator, not a progress bar. */ const BAR_HEIGHT = 4; +/** The segmented bar carries more meaning, so it gets a little more presence. */ +const SEGMENTED_BAR_HEIGHT = 8; + +export interface BarSegment { + key: string; + value: number; + color: string; + /** Tooltip text, since the segments themselves carry no labels. */ + label: string; +} /** * A proportional bar. `value` and `max` share whatever unit the caller uses; @@ -46,6 +57,46 @@ export const CardBar = ({ ); }; +/** + * One bar divided into proportional segments — the shape of a whole split into + * parts, where the relative sizes are the point rather than any single value. + * + * Zero-value segments are dropped so they cannot appear as hairlines, and each + * segment carries a tooltip because the bar itself has no room for labels. + */ +export const CardSegmentedBar = ({ segments }: { segments: BarSegment[] }) => { + const theme = useTheme(); + const visible = segments.filter((segment) => segment.value > 0); + const total = visible.reduce((sum, segment) => sum + segment.value, 0); + + return ( + + {total > 0 && + visible.map((segment) => ( + + + + ))} + + ); +}; + /** A clickable list row. Rows link to the entity they describe. */ export const CardRow = ({ to, children }: { to?: string; children: ReactNode }) => { const theme = useTheme(); diff --git a/client/src/Pages/Dashboard/Components/Cards/MonitorStatusCard.tsx b/client/src/Pages/Dashboard/Components/Cards/MonitorStatusCard.tsx index 7a0997e2a..20994eacd 100644 --- a/client/src/Pages/Dashboard/Components/Cards/MonitorStatusCard.tsx +++ b/client/src/Pages/Dashboard/Components/Cards/MonitorStatusCard.tsx @@ -9,23 +9,20 @@ import { LAYOUT } from "@/Utils/Theme/constants"; import { typographyLevels } from "@/Utils/Theme/Palette"; import { getStatusColor } from "@/Utils/MonitorUtils"; import { DashboardCard, CardMessage } from "../DashboardCard"; +import { CardSegmentedBar, type BarSegment } from "../CardPrimitives"; import { useMonitors } from "../../useDashboardData"; import type { MonitorStatus, MonitorsSummary } from "@/Types/Monitor"; -// Wide enough for a three-digit count beside its label before the tiles wrap. -const TILE_MIN_WIDTH = 96; - -// Every state the summary reports, in the order they read: healthy first, then -// what is wrong, then what is not being checked. All six are listed so the -// tiles always sum to totalMonitors — omitting one leaves an unexplained gap. -const COUNTS: { key: string; status: MonitorStatus; field: keyof MonitorsSummary }[] = [ - { key: "up", status: "up", field: "upMonitors" }, +// Every state the summary reports, ordered worst first so the bar reads +// problems-to-healthy left to right and the chips below list what is wrong +// before what is merely idle. `up` is handled separately as the headline. +const STATES: { key: string; status: MonitorStatus; field: keyof MonitorsSummary }[] = [ { key: "down", status: "down", field: "downMonitors" }, { key: "breached", status: "breached", field: "breachedMonitors" }, + { key: "initializing", status: "initializing", field: "initializingMonitors" }, { key: "maintenance", status: "maintenance", field: "maintenanceMonitors" }, { key: "paused", status: "paused", field: "pausedMonitors" }, - { key: "initializing", status: "initializing", field: "initializingMonitors" }, ]; export const MonitorStatusCard = () => { @@ -34,6 +31,32 @@ export const MonitorStatusCard = () => { const { data, isLoading, isValidating, error } = useMonitors(); const summary = data?.summary ?? null; + // Only states that actually have monitors are shown. Padding the card with + // zeros says nothing, and a healthy fleet should read as calm rather than as + // a row of empty counters. + const present = summary + ? STATES.map((state) => ({ ...state, count: summary[state.field] })).filter( + (state) => state.count > 0 + ) + : []; + + const segments: BarSegment[] = summary + ? [ + { + key: "up", + value: summary.upMonitors, + color: getStatusColor("up", theme), + label: `${t("pages.common.monitors.status.up")} — ${summary.upMonitors}`, + }, + ...present.map((state) => ({ + key: state.key, + value: state.count, + color: getStatusColor(state.status, theme), + label: `${t(`pages.common.monitors.status.${state.key}`)} — ${state.count}`, + })), + ] + : []; + return ( { {!summary || summary.totalMonitors === 0 ? ( ) : ( - - {COUNTS.map(({ key, status, field }) => ( + + - - - - {t(`pages.common.monitors.status.${key}`)} - - - {summary[field]} + {summary.upMonitors} + + + {t("pages.dashboard.cards.monitorStatus.upOfTotal", { + total: summary.totalMonitors, + })} - ))} + + + {present.length > 0 && ( + + {present.map((state) => ( + + + + {t(`pages.common.monitors.status.${state.key}`)} + + + {state.count} + + + ))} + + )} )} diff --git a/client/src/Pages/Dashboard/Components/Cards/SummaryCards.tsx b/client/src/Pages/Dashboard/Components/Cards/SummaryCards.tsx index f627ea122..edf6aefec 100644 --- a/client/src/Pages/Dashboard/Components/Cards/SummaryCards.tsx +++ b/client/src/Pages/Dashboard/Components/Cards/SummaryCards.tsx @@ -10,7 +10,13 @@ import { LAYOUT } from "@/Utils/Theme/constants"; import { typographyLevels } from "@/Utils/Theme/Palette"; import { formatTimestamp } from "@/Utils/TimeUtils"; import { DashboardCard, CardMessage } from "../DashboardCard"; -import { CardFigure, CardRow, CardRowLabel, CardStatLine } from "../CardPrimitives"; +import { + CardFigure, + CardRow, + CardRowLabel, + CardSegmentedBar, + CardStatLine, +} from "../CardPrimitives"; import type { IncidentSummary } from "@/Types/Incident"; import type { Notification } from "@/Types/Notification"; @@ -34,26 +40,71 @@ export const IncidentStatsCard = () => { isStale={isValidating && Boolean(data)} > {data && ( - - 0 ? theme.palette.error.main : theme.palette.text.primary - } - /> - - {data.topMonitor?.monitorName && ( - + {/* Open now leads, paired with the all-time total for context: two + open means something different against 12 incidents than 183. */} + + 0 + ? theme.palette.error.main + : theme.palette.success.main + } /> + + + {/* How much of the fleet heals itself — the automatic/manual split + is already computed server-side and said nothing on the card + before. A high manual share means people are doing the work. */} + {data.totalAutomaticResolutions + data.totalManualResolutions > 0 && ( + + + + )} + + + {data.topMonitor?.monitorName && ( + + )} + )} diff --git a/client/src/locales/en.json b/client/src/locales/en.json index 2c3967e2e..d8c817b4e 100644 --- a/client/src/locales/en.json +++ b/client/src/locales/en.json @@ -257,7 +257,8 @@ "cards": { "monitorStatus": { "title": "Monitor status", - "empty": "No monitors yet." + "empty": "No monitors yet.", + "upOfTotal": "of {{total}} up" }, "currentlyDown": { "title": "Currently down", @@ -316,7 +317,12 @@ "openNow": "Open now", "avgResolution": "Average time to resolve", "hours": "{{hours}} h", - "mostIncidents": "Most incidents" + "mostIncidents": "Most incidents", + "total": "total", + "resolved": "Resolved", + "automatic": "Automatic", + "manual": "Manual", + "autoManual": "{{automatic}} automatic · {{manual}} manual" }, "notificationChannels": { "title": "Notification channels",