From 6cfee68b72cb01ed946a69cf01b50efdfa455f5f Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Fri, 2 Aug 2024 19:47:01 +0200 Subject: [PATCH] Nicer panel health colors for both light and dark modes Signed-off-by: Julius Volz --- web/ui/mantine-ui/src/Badge.module.css | 2 +- web/ui/mantine-ui/src/Panel.module.css | 19 ++++++++++++++ web/ui/mantine-ui/src/pages/AlertsPage.tsx | 25 +++++++++++++------ web/ui/mantine-ui/src/pages/RulesPage.tsx | 13 ++++++++-- .../src/pages/targets/ScrapePoolsList.tsx | 25 +++++++++++-------- 5 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 web/ui/mantine-ui/src/Panel.module.css diff --git a/web/ui/mantine-ui/src/Badge.module.css b/web/ui/mantine-ui/src/Badge.module.css index bc5e38b267..812974fc67 100644 --- a/web/ui/mantine-ui/src/Badge.module.css +++ b/web/ui/mantine-ui/src/Badge.module.css @@ -9,7 +9,7 @@ .labelBadge { background-color: light-dark( var(--mantine-color-gray-1), - var(--mantine-color-gray-9) + var(--mantine-color-gray-8) ); color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-gray-5)); } diff --git a/web/ui/mantine-ui/src/Panel.module.css b/web/ui/mantine-ui/src/Panel.module.css new file mode 100644 index 0000000000..0c90b70de0 --- /dev/null +++ b/web/ui/mantine-ui/src/Panel.module.css @@ -0,0 +1,19 @@ +.panelHealthOk { + border-left: 5px solid + light-dark(var(--mantine-color-green-3), var(--mantine-color-green-8)) !important; +} + +.panelHealthErr { + border-left: 5px solid + light-dark(var(--mantine-color-red-3), var(--mantine-color-red-9)) !important; +} + +.panelHealthWarn { + border-left: 5px solid + light-dark(var(--mantine-color-orange-3), var(--mantine-color-yellow-9)) !important; +} + +.panelHealthUnknown { + border-left: 5px solid + light-dark(var(--mantine-color-gray-3), var(--mantine-color-gray-6)) !important; +} diff --git a/web/ui/mantine-ui/src/pages/AlertsPage.tsx b/web/ui/mantine-ui/src/pages/AlertsPage.tsx index 25f1ecc326..a963fcd93a 100644 --- a/web/ui/mantine-ui/src/pages/AlertsPage.tsx +++ b/web/ui/mantine-ui/src/pages/AlertsPage.tsx @@ -14,6 +14,7 @@ import { import { useSuspenseAPIQuery } from "../api/api"; import { AlertingRulesResult } from "../api/responseTypes/rules"; import badgeClasses from "../Badge.module.css"; +import panelClasses from "../Panel.module.css"; import RuleDefinition from "../components/RuleDefinition"; import { humanizeDurationRelative, now } from "../lib/formatTime"; import { Fragment } from "react"; @@ -113,16 +114,24 @@ export default function AlertsPage() { return ( 0 - ? "5px solid var(--mantine-color-red-4)" - : numPending > 0 - ? "5px solid var(--mantine-color-orange-5)" - : "5px solid var(--mantine-color-green-4)", - }} + className={ + numFiring > 0 + ? panelClasses.panelHealthErr + : numPending > 0 + ? panelClasses.panelHealthWarn + : panelClasses.panelHealthOk + } > diff --git a/web/ui/mantine-ui/src/pages/RulesPage.tsx b/web/ui/mantine-ui/src/pages/RulesPage.tsx index d1baf87afc..a96f1a8315 100644 --- a/web/ui/mantine-ui/src/pages/RulesPage.tsx +++ b/web/ui/mantine-ui/src/pages/RulesPage.tsx @@ -109,6 +109,15 @@ export default function RulesPage() { {g.rules.map((r, j) => ( diff --git a/web/ui/mantine-ui/src/pages/targets/ScrapePoolsList.tsx b/web/ui/mantine-ui/src/pages/targets/ScrapePoolsList.tsx index a6554ac634..a547a80696 100644 --- a/web/ui/mantine-ui/src/pages/targets/ScrapePoolsList.tsx +++ b/web/ui/mantine-ui/src/pages/targets/ScrapePoolsList.tsx @@ -14,7 +14,6 @@ import { IconAlertTriangle, IconInfoCircle } from "@tabler/icons-react"; import { useSuspenseAPIQuery } from "../../api/api"; import { Target, TargetsResult } from "../../api/responseTypes/targets"; import React, { FC, useState } from "react"; -import badgeClasses from "../../Badge.module.css"; import { humanizeDurationRelative, humanizeDuration, @@ -26,6 +25,9 @@ import { setCollapsedPools } from "../../state/targetsPageSlice"; import EndpointLink from "../../components/EndpointLink"; import CustomInfiniteScroll from "../../components/CustomInfiniteScroll"; +import badgeClasses from "../../Badge.module.css"; +import panelClasses from "../../Panel.module.css"; + type ScrapePool = { targets: Target[]; count: number; @@ -38,6 +40,15 @@ type ScrapePools = { [scrapePool: string]: ScrapePool; }; +const poolPanelHealthClass = (pool: ScrapePool) => + pool.count > 1 && pool.downCount === pool.count + ? panelClasses.panelHealthErr + : pool.downCount >= 1 + ? panelClasses.panelHealthWarn + : pool.unknownCount === pool.count + ? panelClasses.panelHealthUnknown + : panelClasses.panelHealthOk; + const healthBadgeClass = (state: string) => { switch (state.toLowerCase()) { case "up": @@ -47,7 +58,8 @@ const healthBadgeClass = (state: string) => { case "unknown": return badgeClasses.healthUnknown; default: - return badgeClasses.warn; + // Should never happen. + return badgeClasses.healthWarn; } }; @@ -206,14 +218,7 @@ const ScrapePoolList: FC = ({