Group the admin nav into Data, Pages, Forms, Tools and Panel

The header now has one menu per group: its name opens the first
item, and hovering or tabbing into it drops down the rest. The strip
under the header lists the open group's items, which is also the way
around on a touch screen. The admin home shows the same groups as
card blocks, from the same list in adminNav.ts.

Data holds the record types, Pages the front page, timeline, blog
posts and the Community blog section, Tools the media library and QR
codes. Docs and comments name the new menu paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-27 20:56:16 -05:00
parent 06e443ba23
commit 29202f2eb1
7 changed files with 173 additions and 121 deletions

View file

@ -7,10 +7,8 @@
The cards come from adminNav.ts, the same list the CMS header
reads, so a new entity shows up here the moment it's registered.
Forms sit in their own block below: they're submissions coming
in rather than content going out, and there'll be more of them
than the feedback queue eventually. Tools come next, and the
Panel block below that only exists for superadmins.
One block per header group, in the same order: Data, Pages,
Forms, Tools, and Panel, which only exists for superadmins.
The right-hand panel is deliberately inert. Nothing here
fetches, so the landing page can't be slow or half-broken on
@ -22,7 +20,7 @@ import { Link } from "react-router-dom";
import { useAuth } from "../../lib/auth.tsx";
import { SITE_VERSION } from "../../lib/version.ts";
import { ROLE_LABELS, isSuper } from "../../lib/roles.ts";
import { CMS_NAV, FORMS_NAV, PANEL_NAV, TOOLS_NAV, target } from "./adminNav.ts";
import { DATA_NAV, FORMS_NAV, PAGES_NAV, PANEL_NAV, TOOLS_NAV, target } from "./adminNav.ts";
/* One card. The title link is stretched over the whole card with
`after:absolute`, which makes the card clickable without nesting
@ -98,6 +96,10 @@ function PanelSection({ title, children }) {
);
}
/* The header's groups, in its order. Panel is drawn separately
below, since only superadmins get it. */
const GROUPS = [DATA_NAV, PAGES_NAV, FORMS_NAV, TOOLS_NAV];
const QUICK_ADD = [
{ to: "/admin/events/new", label: "New event" },
{ to: "/admin/people/new", label: "New person" },
@ -117,23 +119,13 @@ export default function AdminHome() {
</h1>
<p className="mt-1 text-[#4a6b72]">Pick a section to work in.</p>
<div className="mt-6 grid gap-4 sm:grid-cols-2">
{CMS_NAV.map((item) => (
<NavCard key={item.label} item={item} />
))}
</div>
<CardBlock title={FORMS_NAV.label} blurb={FORMS_NAV.blurb}>
{FORMS_NAV.children.map((form) => (
<NavCard key={form.to} item={form} />
))}
</CardBlock>
<CardBlock title={TOOLS_NAV.label} blurb={TOOLS_NAV.blurb}>
{TOOLS_NAV.children.map((tool) => (
<NavCard key={tool.to} item={tool} />
))}
</CardBlock>
{GROUPS.map((group) => (
<CardBlock key={group.label} title={group.label} blurb={group.blurb}>
{group.children.map((item) => (
<NavCard key={item.to} item={item} />
))}
</CardBlock>
))}
{isSuper(user) && (
<CardBlock title="Superadmin" blurb="Only superadmins see this block.">

View file

@ -9,10 +9,14 @@
wordmark names whichever one you're in, and from anywhere but
Home it's the way back to Home.
The tab row is drawn everywhere except Home, where the card grid
is the navigation and drawing both would say the same thing
twice. Which tabs appear depends on the signed-in user
(navFor() drops the superadmin-only ones), but that's cosmetics.
The group menus (Data, Pages, Forms, Tools, Panel: adminNav.ts)
are drawn everywhere except Home, where the card grid is the
navigation and drawing both would say the same thing twice. Each
group's name opens its first item and hovering it lists the rest;
the strip under the header lists the open group's items, which is
also the way around on a touch screen. Which groups appear depends
on the signed-in user (navFor() drops the superadmin-only ones),
but that's cosmetics.
The route guard and the API are what actually say no.
═══════════════════════════════════════════════════════════════ */
@ -33,6 +37,52 @@ import {
target,
} from "./adminNav.ts";
/* One group in the header. The name opens the group's first item;
hovering it, or tabbing into it, drops down the rest. The menu is
CSS only (group-hover, group-focus-within), so it can't get stuck
open, and a keyboard reaches every item by tabbing on from the
name. A group of one has nothing to drop down. */
function GroupMenu({ item, lit, pathname }) {
const children = item.children ?? [];
const link = lit
? "font-semibold text-[#138ba0]"
: "text-[#4a6b72] transition-colors hover:text-[#138ba0]";
return (
<div className="group relative">
<NavLink to={target(item)} className={`flex items-center gap-1 ${link}`}>
{item.label}
{children.length > 1 && (
<span aria-hidden="true" className="text-[10px] opacity-60">
▾
</span>
)}
</NavLink>
{children.length > 1 && (
<div className="invisible absolute left-0 top-full z-30 pt-2 opacity-0 transition-opacity group-focus-within:visible group-focus-within:opacity-100 group-hover:visible group-hover:opacity-100">
<ul className="min-w-52 rounded-xl border border-[#138ba0]/20 bg-white p-1.5 shadow-lg">
{children.map((child) => (
<li key={child.to}>
<NavLink
to={child.to}
className={`block rounded-lg px-3 py-2 text-sm transition-colors hover:bg-[#eef9fb] ${
matches(pathname, child.to)
? "font-semibold text-[#138ba0]"
: "text-[#26454c]"
}`}
>
{child.label}
</NavLink>
</li>
))}
</ul>
</div>
)}
</div>
);
}
export default function AdminLayout() {
const { user, logout } = useAuth();
const navigate = useNavigate();
@ -109,16 +159,7 @@ export default function AdminLayout() {
className="h-4 w-px bg-[#4a6b72]/25"
/>
)}
<NavLink
to={target(item)}
className={
item === active
? "font-semibold text-[#138ba0]"
: "text-[#4a6b72] transition-colors hover:text-[#138ba0]"
}
>
{item.label}
</NavLink>
<GroupMenu item={item} lit={item === active} pathname={pathname} />
</div>
))}
</nav>

View file

@ -1,11 +1,26 @@
/* ═══════════════════════════════════════════════════════════════
ADMIN NAVIGATION: src/pages/admin/adminNav.ts
Lifted out of AdminLayout because two things read it now: the
header tabs and the card grid on the home page. Adding an entity
stays one entry here plus a descriptor; there's still no second
list to keep in step, it just isn't inside the layout file
any more.
One list, read by two things: the header (a menu per group, its
items on hover or focus, and the open group's items in the strip
below) and the admin home page (a block of cards per group).
Adding an entity stays one entry here plus a descriptor; there's
no second list to keep in step.
Five groups, each a menu in the header and a block on the home
page:
Data the records: events, organizations, teams, awards, people
Pages what edits a page rather than a record type: the front
page, the history timeline, the blog and its Community
section
Forms what the public site has sent us
Tools pages that make something: the media library, QR codes
Panel accounts and the server (superadmins only)
Clicking a group's name opens its first item. That's also the
touch path, where hover doesn't exist: the strip under the header
lists the rest of the open group.
`blurb` is only read by the home cards. The header ignores it.
@ -31,73 +46,72 @@ export const AREA_TITLES = {
panel: "NGU Admin Panel",
};
/* The CMS tabs. Teams and Awards live under Organizations because
that's where they belong conceptually (a team is part of an org,
an award is given by one), even though each is its own table and
its own page. */
export const CMS_NAV = [
{
to: "/admin/events",
label: "Events",
blurb: "Retreats, conferences and gatherings, with their sections and rosters.",
},
{
to: "/admin/organizations",
label: "Organizations",
blurb: "Regions, chapters and partners, plus the teams and awards they own.",
children: [
{ to: "/admin/organizations", label: "All organizations" },
{ to: "/admin/teams", label: "Teams" },
{ to: "/admin/awards", label: "Awards" },
],
},
{
to: "/admin/people",
label: "People",
blurb: "Bios, contact details, affiliations and awards received.",
},
// Its own tab rather than a child of anything: a timeline entry can
// point at an event, an organization, an award, a person or a team,
// so filing it under one of them would be arbitrary.
{
to: "/admin/timeline",
label: "Timeline",
blurb: "What the history page shows, and the order it shows it in.",
},
// One record, not a list: the tab opens it directly.
{
to: "/admin/front_page",
label: "Front page",
blurb: "The hero, its photos or livestream, and which bands the home page draws.",
},
// Posts, and the Community page section that lists them. Two
// entities, one tab, like Organizations with Teams and Awards.
{
to: "/admin/blog_posts",
label: "Blog",
blurb: "Posts of our own, and the Community page's blog section.",
children: [
{ to: "/admin/blog_posts", label: "Posts" },
{ to: "/admin/community_page", label: "Community section" },
],
},
// Not an entity: the uploaded-image library every image field
// picks from. Its own page, AdminMedia.tsx.
{
to: "/admin/media",
label: "Media",
blurb: "Uploaded images: logos, photos and backgrounds, ready to reuse.",
},
];
export const DATA_NAV = {
label: "Data",
blurb: "The records the site is built from.",
children: [
{
to: "/admin/events",
label: "Events",
blurb: "Retreats, conferences and gatherings, with their sections and rosters.",
},
{
to: "/admin/organizations",
label: "Organizations",
blurb: "The national organization, regions, chapters and partners.",
},
{
to: "/admin/teams",
label: "Teams",
blurb: "Boards, committees and leadership teams within an organization.",
},
{
to: "/admin/awards",
label: "Awards",
blurb: "Awards an organization gives. Who received one is edited on the person.",
},
{
to: "/admin/people",
label: "People",
blurb: "Bios, contact details, affiliations and awards received.",
},
],
};
/* Forms are submissions coming in rather than content going out, so
they get their own group in the header and their own block on the
home page. A group with no `to` of its own opens its first child,
so clicking the word Forms goes somewhere rather than nowhere. */
export const PAGES_NAV = {
label: "Pages",
blurb: "What a page shows and in what order.",
children: [
// One record, not a list: the item opens it directly.
{
to: "/admin/front_page",
label: "Front page",
blurb: "The hero, its photos or livestream, and which bands the home page draws.",
},
// A timeline entry can point at an event, an organization, an
// award, a person or a team, so it isn't filed under any of them.
{
to: "/admin/timeline",
label: "Timeline",
blurb: "What the history page shows, and the order it shows it in.",
},
{
to: "/admin/blog_posts",
label: "Blog posts",
blurb: "Posts of our own, each at /blog/…",
},
{
to: "/admin/community_page",
label: "Community blog section",
blurb: "The Community page's blog: headings, pinned posts and feeds.",
},
],
};
/* Submissions coming in rather than content going out. */
export const FORMS_NAV = {
label: "Forms",
blurb: "Whatever the public site has sent us.",
separated: true,
children: [
{
to: "/admin/feedback",
@ -107,13 +121,17 @@ export const FORMS_NAV = {
],
};
/* Tools are pages that make something rather than edit a record.
They live on the public site, so they're on the home page only:
a header tab would leave the admin area. */
/* Pages that make something rather than edit a record. The QR page
lives on the public site, so opening it leaves the admin. */
export const TOOLS_NAV = {
label: "Tools",
blurb: "Handy pages for making things.",
children: [
{
to: "/admin/media",
label: "Media",
blurb: "Uploaded images: logos, photos and backgrounds, ready to reuse.",
},
{
to: "/qr",
label: "QR code generator",
@ -122,8 +140,8 @@ export const TOOLS_NAV = {
],
};
/* Accounts and server state, not content, which is why it sits
outside the CMS rather than as another tab within it. */
/* Accounts and server state, not content, which is why it's its
own area rather than a group of CMS pages. */
export const PANEL_NAV = {
to: ADMIN_PANEL,
label: "Panel",
@ -132,18 +150,19 @@ export const PANEL_NAV = {
superOnly: true,
};
export const NAV: any[] = [...CMS_NAV, FORMS_NAV, PANEL_NAV];
export const NAV: any[] = [DATA_NAV, PAGES_NAV, FORMS_NAV, TOOLS_NAV, PANEL_NAV];
/* What this user may see. Call it with the user from useAuth. */
export function navFor(user) {
return NAV.filter((item) => !item.superOnly || isSuper(user));
}
/* A tab owns its own page and everything below it, so editing
/* An item owns its own page and everything below it, so editing
/admin/teams/ngu-board keeps Teams lit. */
export const matches = (pathname, to) =>
Boolean(to) && (pathname === to || pathname.startsWith(`${to}/`));
/* Where a group's name goes: its own page, else its first item. */
export const target = (item) => item.to ?? item.children?.[0]?.to;
export function areaFor(pathname) {