From 8a9317772cd55a9b2dc023ca4f1e5f51b64ad455 Mon Sep 17 00:00:00 2001 From: Bobban Rydh Date: Sun, 1 Nov 2026 02:51:14 +0100 Subject: [PATCH] Let the cards at the top of the dashboard be hidden Customise now puts a name bar with Hide / Show above Needs attention, My work, Since you last looked, Getting started and the To do list, like the Overview cards. Hidden cards are gone outside Customise (dimmed inside it), the choice is saved on the user record and Reset to default clears it. When every card of one side of the top row is hidden the other takes the full width; hiding all removes the row. The standalone To do card is an ordinary card rather than the side-by-side one. Co-Authored-By: Claude Sonnet 5.5 --- web/src/components/Hideable.tsx | 39 +++++++++++++++++++++ web/src/pages/Dashboard.tsx | 61 ++++++++++++++++++++++++++------- web/src/styles.css | 19 +++++++++- 3 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 web/src/components/Hideable.tsx diff --git a/web/src/components/Hideable.tsx b/web/src/components/Hideable.tsx new file mode 100644 index 0000000..b9814f4 --- /dev/null +++ b/web/src/components/Hideable.tsx @@ -0,0 +1,39 @@ +import type { ReactNode } from "react"; +import { IconEye, IconEyeOff } from "@tabler/icons-react"; +import { setCardHidden, useDashboardLayout } from "../utils/dashboardLayout"; + +/** Whether the person has hidden a dashboard card, whether they are arranging the dashboard, and so whether the card is to be drawn (hidden ones are drawn, dimmed, while arranging). */ +export function useCardState(label: string): { hidden: boolean; editing: boolean; shown: boolean } { + const { layout, editing } = useDashboardLayout(); + const hidden = layout.hidden.includes(label); + return { hidden, editing, shown: !hidden || editing }; +} + +/** The bar above a card while the dashboard is being arranged: its name and a button to hide it or bring it back. */ +export function HideBar({ label, hidden }: { label: string; hidden: boolean }) { + return ( +
+ {label} + +
+ ); +} + +/** + * A card at the top of the dashboard that the person can hide. Hidden, it is gone; while they arrange the dashboard (Customise) it is there, dimmed, under a bar that hides it or brings it back. + * It is kept the same way as the other cards' arrangement — on their user record, so it follows them to any browser — and Reset to default shows it again. + */ +export default function Hideable({ label, children }: { label: string; children: ReactNode }) { + const { hidden, editing, shown } = useCardState(label); + if (!shown) return null; + return ( +
+ {editing &&
+ ); +} diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx index c490e7a..49a119e 100644 --- a/web/src/pages/Dashboard.tsx +++ b/web/src/pages/Dashboard.tsx @@ -4,6 +4,7 @@ import { IconArrowLeft, IconArrowRight, IconEye, IconEyeOff } from "@tabler/icon import TimeAgo from "../components/TimeAgo"; import WhatChanged from "../components/WhatChanged"; import DashboardTodos from "../components/DashboardTodos"; +import Hideable, { HideBar, useCardState } from "../components/Hideable"; import { setProblemsFirst, useProblemsFirst } from "../utils/problemsFirst"; import { UNPLACED, moveCard, resetDashboardLayout, setCardHidden, setEditingDashboard, useDashboardLayout } from "../utils/dashboardLayout"; import { Link } from "react-router-dom"; @@ -353,8 +354,15 @@ function MyWorkStrip() { ); } +/** The cards down the left of the top of the dashboard, and the to-do list on the right: the names the person hides them by. */ +const TOP_LEFT_CARDS = ["Needs attention", "My work", "Since you last looked", "Getting started"]; +const TODO_CARD = "To do list"; + export default function Dashboard({ user }: { user: CurrentUser }) { - const { editing } = useDashboardLayout(); + const { editing, layout: arranged } = useDashboardLayout(); + // The top of the dashboard is two columns while both have something to show; when the person has hidden every card of one, the other takes the whole width. + const showTopLeft = editing || TOP_LEFT_CARDS.some((c) => !arranged.hidden.includes(c)); + const todoCard = useCardState(TODO_CARD); const problemsFirst = useProblemsFirst(); const [integrations, setIntegrations] = useState(null); // How many alerts each integration has open that nobody has put aside, for the tiles of the integrations that have no widget of their own. @@ -718,7 +726,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) { {editing && (
- Move the cards with the arrows and hide the ones you don't use. It saves as you go, for you only, and follows you to other browsers. + Move the Overview cards with the arrows, and hide any card you don't use — the ones at the top too. It saves as you go, for you only, and follows you to other browsers.
-
-
- - {(user.role === "admin" || user.role === "operator") && } - - {isAdmin && integrations !== null && dnsStats !== null && serverSummary !== null && secrets !== null && notifyConfigured !== null && ( - + {(showTopLeft || todoCard.shown) && ( +
+ {showTopLeft && ( +
+ + + + {(user.role === "admin" || user.role === "operator") && ( + + + + )} + + + + {isAdmin && integrations !== null && dnsStats !== null && serverSummary !== null && secrets !== null && notifyConfigured !== null && ( + + + + )} +
)} + {todoCard.shown && + (showTopLeft ? ( +
+ {todoCard.editing &&
+ ) : ( +
+ {todoCard.editing &&
+ ))}
-
- -
-
+ )}
diff --git a/web/src/styles.css b/web/src/styles.css index 5d0681e..47d4135 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -1701,6 +1701,22 @@ html[data-density="roomy"] .table > :not(caption) > * > * { opacity: 0.5; } +/* The cards at the top of the dashboard have no card round the bar, so it gets its own frame. */ +.hideable > .card-customise { + margin-bottom: 0.5rem; + border: 1px dashed var(--tblr-border-color); + border-radius: var(--tblr-border-radius); +} + +.dash-side-col { + display: flex; + flex-direction: column; +} + +.dash-side-col > .dash-side { + flex: 1 1 auto; +} + /* ── Comparing servers: the chart fills its card and takes the text colour for its axes. ── */ .multi-chart { display: block; @@ -2008,7 +2024,8 @@ tr.alert-row-child > td:first-child { position: relative; } - .dash-todos { + /* Only beside the other cards: on its own (they are hidden) it is an ordinary card. */ + .dash-side > .dash-todos { position: absolute; inset: 0 calc(var(--tblr-gutter-x, 1.5rem) / 2) 0; max-height: none;