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 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-01 02:51:14 +01:00
1 parent 2b0623531a
commit 8a9317772c
3 files changed
+105 -14

No files matched your search

+39
View File
@@ -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 (
<div className="card-customise">
<span className="small text-secondary">{label}</span>
<button type="button" className="btn btn-sm ms-auto d-inline-flex align-items-center gap-1" aria-pressed={hidden} onClick={() => void setCardHidden(label, !hidden)}>
{hidden ? <IconEye size={16} aria-hidden="true" /> : <IconEyeOff size={16} aria-hidden="true" />}
{hidden ? "Show" : "Hide"}
<span className="visually-hidden"> {label}</span>
</button>
</div>
);
}
/**
* 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 (
<div className={`hideable ${hidden ? "card-hidden" : ""}`}>
{editing && <HideBar label={label} hidden={hidden} />}
{children}
</div>
);
}
+48 -13
View File
@@ -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<IntegrationSummary[] | null>(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 }) {
</div>
{editing && (
<div className="alert alert-info d-flex flex-wrap align-items-center gap-2" role="status">
<span>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.</span>
<span>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.</span>
<label className="form-check mb-0 ms-auto">
<input type="checkbox" className="form-check-input" checked={problemsFirst} onChange={(e) => setProblemsFirst(e.target.checked)} />
<span className="form-check-label">Cards with a problem come first</span>
@@ -734,19 +742,46 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
</div>
</div>
<div className="row row-cards mb-3">
<div className="col-xl-6">
<StatusStrip />
{(user.role === "admin" || user.role === "operator") && <MyWorkStrip />}
<WhatChanged role={user.role} />
{isAdmin && integrations !== null && dnsStats !== null && serverSummary !== null && secrets !== null && notifyConfigured !== null && (
<SetupGuide steps={setupSteps} />
{(showTopLeft || todoCard.shown) && (
<div className="row row-cards mb-3">
{showTopLeft && (
<div className={showTopLeft && todoCard.shown ? "col-xl-6" : "col-12"}>
<Hideable label="Needs attention">
<StatusStrip />
</Hideable>
{(user.role === "admin" || user.role === "operator") && (
<Hideable label="My work">
<MyWorkStrip />
</Hideable>
)}
<Hideable label="Since you last looked">
<WhatChanged role={user.role} />
</Hideable>
{isAdmin && integrations !== null && dnsStats !== null && serverSummary !== null && secrets !== null && notifyConfigured !== null && (
<Hideable label="Getting started">
<SetupGuide steps={setupSteps} />
</Hideable>
)}
</div>
)}
{todoCard.shown &&
(showTopLeft ? (
<div className="col-xl-6 dash-side-col">
{todoCard.editing && <HideBar label={TODO_CARD} hidden={todoCard.hidden} />}
<div className={`dash-side ${todoCard.hidden ? "card-hidden" : ""}`}>
<DashboardTodos canEdit={user.role === "admin" || user.role === "operator"} />
</div>
</div>
) : (
<div className="col-12">
{todoCard.editing && <HideBar label={TODO_CARD} hidden={todoCard.hidden} />}
<div className={todoCard.hidden ? "card-hidden" : ""}>
<DashboardTodos canEdit={user.role === "admin" || user.role === "operator"} />
</div>
</div>
))}
</div>
<div className="col-xl-6 dash-side">
<DashboardTodos canEdit={user.role === "admin" || user.role === "operator"} />
</div>
</div>
)}
<SectionHeader title="Overview" hint="DNS, Secrets, Servers and Domains are built into this app rather than connected integrations, but get the same at-a-glance treatment." />
<div className="row row-cards mb-3">
+18 -1
View File
@@ -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;