diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index 8c09e41..e876f9f 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -28,12 +28,12 @@ what a dropdown in the admin editor says. | If it's… | It lives in… | Change it by… | | ------------------------------------------------------------ | ---------------- | ------------------------------------ | | A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin | -| The front page's words, photos, bands, stats and paths | the database | Admin → Front page | -| Blog posts, and the Community page's blog section (headings, pins, feeds) | the database | Admin → Blog | +| The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page | +| Blog posts, and the Community page's blog section (headings, pins, feeds) | the database | Admin → Pages → Blog posts, and Community blog section | | The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) | | The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) | | Navigation, page section titles, colours, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) | -| Uploaded images | disk + the `media` table | Admin → Media, or any image field. See `docs/media-uploads.md` | +| Uploaded images | disk + the `media` table | Admin → Tools → Media, or any image field. See `docs/media-uploads.md` | The rule of thumb from `CLAUDE.md`: data belongs in the database, presentation belongs in code. A dropdown's *values* are data the @@ -184,7 +184,7 @@ also in `admin-schema.js` and a CHECK): | Front page → Feature | none, livestream, video | **yes** | `HeroStage.tsx` | | Front page → Sections → Section | countdown, retreats, calendar, stats, timeline, connect, featured | **yes**, `FRONT_PAGE_SECTIONS` | `SECTIONS` in `src/pages/Home.tsx`; see [below](#front-page-section-names) | | Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) | -| Front page → Featured cards → Card type (Blog → Community section → Pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` | +| Front page → Featured cards → Card type (Community blog section → Pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` | | Front page → Featured cards → Record type | event, organization, person, team, award | no | `FEATURED_REFS` in `server/src/shape.js` (what each fills the card with); the triggers in `030_featured_cards.sql` | | Every list → Published / Listed / Featured filter | 1, 0 | **yes** | n/a | @@ -200,7 +200,7 @@ code): | Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) | | Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labelled by name | | Event hosts / event people / team members / timeline people → Person | `people` | people | -| Blog → Community section → Pinned posts → Post | `blog_posts` | blog posts, newest first | +| Community blog section → Pinned posts → Post | `blog_posts` | blog posts, newest first | | Timeline → Record; Featured cards → Record | `record_refs` | every event, organization, award, person and team, narrowed by the type picked beside it | | Affiliations → Team | `teams` | teams, filtered to the chosen organization | | Person awards → Award | `awards` | awards, labelled "Award (Organization)" | @@ -216,7 +216,7 @@ each is changed in a different place: | What you see | Where it's set | | --- | --- | -| **The heading on the page** ("National Retreats", "What's on") | **Admin → Front page → Page sections → Heading.** Blank uses the default below. | +| **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. | | The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry | | **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema.ts` | | The subnav links under the header ("#Retreats", "#Calendar") | `PAGE_SECTIONS["/"]` in `src/navConfig.ts` | @@ -271,7 +271,7 @@ The numbers band's "Number Source" dropdown works the same way: | Section titles, blurbs and colours on Retreats, Community, Leadership, Resources, Feedback, Privacy, Terms | the page file in `src/pages/` | the `SECTIONS` array at the top. A section's `id` must match its subnav `hash`. | | Site-wide announcement banner | `src/data/bannerConfig.ts` | `enabled: false` hides it. Bump `id` when the message changes, so people who dismissed the old one see the new one. | | History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. | -| Chapter map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Organizations → a region → Map areas). | +| Chapter map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). | | Feedback form types | `src/data/feedbackTypes.ts` **and** `TYPES` in `server/src/routes/feedback.js` | Keep the ids identical in both; the server stores unknown ids as `general`. Labels and hints are client-only. | | Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. | | Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | | diff --git a/server/src/seed-showcase.js b/server/src/seed-showcase.js index 616fc47..747f7e4 100644 --- a/server/src/seed-showcase.js +++ b/server/src/seed-showcase.js @@ -37,7 +37,7 @@ Run without it again to take them back out. Images point at /uploads/showcase.jpg. Upload any photo in - Admin → Media and copy it to that name in the uploads directory, + Admin → Tools → Media and copy it to that name in the uploads directory, or leave it missing to check how each page copes without one. A database under /var/lib/ngu (where the deployed service keeps diff --git a/src/pages/Community.tsx b/src/pages/Community.tsx index fd0e449..f516c1a 100644 --- a/src/pages/Community.tsx +++ b/src/pages/Community.tsx @@ -13,7 +13,7 @@ import { useCommunityBlog } from "../lib/useBlog.ts"; map is filtered to chapters; the vertical list is filtered to regions. Same rows, same endpoint, different shape on the page. - The blog's heading and blurb are the admin's (Blog → Community + The blog's heading and blurb are the admin's (Pages → Community blog section), so that one entry is built here from the same cached request CommunityBlog makes for its posts. ═══════════════════════════════════════════════════════════════ */ diff --git a/src/pages/admin/AdminHome.tsx b/src/pages/admin/AdminHome.tsx index c1312ce..d21c1f6 100644 --- a/src/pages/admin/AdminHome.tsx +++ b/src/pages/admin/AdminHome.tsx @@ -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() {

Pick a section to work in.

-
- {CMS_NAV.map((item) => ( - - ))} -
- - - {FORMS_NAV.children.map((form) => ( - - ))} - - - - {TOOLS_NAV.children.map((tool) => ( - - ))} - + {GROUPS.map((group) => ( + + {group.children.map((item) => ( + + ))} + + ))} {isSuper(user) && ( diff --git a/src/pages/admin/AdminLayout.tsx b/src/pages/admin/AdminLayout.tsx index a3b5d2d..e68b59b 100644 --- a/src/pages/admin/AdminLayout.tsx +++ b/src/pages/admin/AdminLayout.tsx @@ -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 ( +
+ + {item.label} + {children.length > 1 && ( + + )} + + + {children.length > 1 && ( +
+
    + {children.map((child) => ( +
  • + + {child.label} + +
  • + ))} +
+
+ )} +
+ ); +} + 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" /> )} - - {item.label} - + ))} diff --git a/src/pages/admin/adminNav.ts b/src/pages/admin/adminNav.ts index d300267..40f7dc5 100644 --- a/src/pages/admin/adminNav.ts +++ b/src/pages/admin/adminNav.ts @@ -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) { diff --git a/src/pages/sections/CommunityBlog.tsx b/src/pages/sections/CommunityBlog.tsx index bb0916c..dacf3cf 100644 --- a/src/pages/sections/CommunityBlog.tsx +++ b/src/pages/sections/CommunityBlog.tsx @@ -1,7 +1,7 @@ /* ═══════════════════════════════════════════════════════════════ COMMUNITY BLOG - The Community page's blog section (Admin → Blog → Community + The Community page's blog section (Admin → Pages → Community blog section). Two halves, each pinned first and then newest, as routes/blog.js decides: