Migration 085 adds people.pco_id and Site settings' list. Data -> Planning Center fetches the list, suggests matches (linked, same email, same name), shows each field that would change (Planning Center wins), and applies the chosen links, updates and new unpublished people in one transaction. Needs PCO_APP_ID and PCO_SECRET. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
264 lines
9.1 KiB
TypeScript
264 lines
9.1 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
|
ADMIN NAVIGATION: src/pages/admin/adminNav.ts
|
|
|
|
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.
|
|
|
|
`superOnly` hides an entry from anyone below superadmin. It
|
|
hides, nothing more: the route still has to be guarded and the
|
|
API still has to say no. Treating a filtered menu as access
|
|
control is how you end up with a URL that works.
|
|
|
|
Three areas, three titles. The area is derived from the path
|
|
rather than declared per route, so a page added under
|
|
/admin/panel/… inherits the right title without registering
|
|
anything.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
import { atLeast, isSuper } from "../../lib/roles.ts";
|
|
|
|
export const ADMIN_HOME = "/admin/home";
|
|
export const ADMIN_PANEL = "/admin/panel";
|
|
|
|
export const AREA_TITLES = {
|
|
home: "NGU Admin Home",
|
|
cms: "NGU Admin CMS",
|
|
panel: "NGU Admin Panel",
|
|
};
|
|
|
|
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, groups and partners.",
|
|
},
|
|
{
|
|
to: "/admin/contact_types",
|
|
label: "Contact types",
|
|
blurb: "Roles an organization's contacts hold, eg. Minister. Contacts are added on the organization.",
|
|
},
|
|
{
|
|
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.",
|
|
},
|
|
{
|
|
to: "/admin/person_tag_types",
|
|
label: "People tags",
|
|
blurb: "Directories people can be tagged into, eg. Musicians. Who carries a tag is edited on the person.",
|
|
},
|
|
{
|
|
to: "/admin/tags",
|
|
label: "Tags",
|
|
blurb: "Descriptors for organizations and events, eg. Online, In-Person. Who carries a tag is edited on the record.",
|
|
},
|
|
{
|
|
to: "/admin/redirects",
|
|
label: "Links/redirects",
|
|
blurb: "Short /go/ links for the newsletter, with click counts, Plausible and UTM tracking.",
|
|
},
|
|
{
|
|
to: "/admin/profiles",
|
|
label: "Profile accounts",
|
|
blurb: "Invite people to make a profile account, approve their claims to a People record, and link their Discord.",
|
|
minRole: "admin",
|
|
},
|
|
{
|
|
to: "/admin/pco",
|
|
label: "Planning Center",
|
|
blurb: "Bring a Planning Center People list into People: compare each person, then link, update or add them.",
|
|
minRole: "admin",
|
|
},
|
|
{
|
|
to: "/admin/blog_posts",
|
|
label: "Blog posts",
|
|
blurb: "Posts of our own, each at /blog/…, written here or imported from Word.",
|
|
},
|
|
// A timeline entry can point at an event, an organization, an
|
|
// award, a person or a team, so it's its own kind of record.
|
|
{
|
|
to: "/admin/timeline",
|
|
label: "Timeline",
|
|
blurb: "The History page's entries: milestones and the records they point at.",
|
|
},
|
|
],
|
|
};
|
|
|
|
export const PAGES_NAV = {
|
|
label: "Pages",
|
|
blurb: "What a page shows and in what order.",
|
|
children: [
|
|
// The banner on the admin home: every page, new ones, the menus.
|
|
// Each page's own card follows it there (AdminHome.tsx).
|
|
{
|
|
to: "/admin/pages",
|
|
label: "Page management",
|
|
blurb: "Every page of the site: make new ones, change an address, title or intro, and hide or disable any of them. Then each page's sections.",
|
|
banner: true,
|
|
children: [
|
|
{ to: "/admin/pages/home", label: "Front page" },
|
|
{ to: "/admin/pages/new", label: "New page" },
|
|
{ to: "/admin/navigation", label: "Menus (Navigation)" },
|
|
],
|
|
},
|
|
{
|
|
to: "/admin/navigation",
|
|
label: "Navigation",
|
|
blurb: "The header's pages and buttons and the footer's links.",
|
|
},
|
|
],
|
|
};
|
|
|
|
/* Submissions coming in rather than content going out. */
|
|
export const FORMS_NAV = {
|
|
label: "Forms",
|
|
blurb: "Whatever the public site has sent us.",
|
|
children: [
|
|
{
|
|
to: "/admin/feedback",
|
|
label: "Website feedback",
|
|
blurb: "The triage queue for the feedback form.",
|
|
},
|
|
{
|
|
to: "/admin/requests",
|
|
label: "Content requests",
|
|
blurb: "Requests for blog posts, events, and new or updated organizations, teams, awards and people, with their files.",
|
|
},
|
|
{
|
|
to: "/admin/data-requests",
|
|
label: "Data requests",
|
|
blurb: "Requests to see, correct or delete someone's information, from the Privacy page.",
|
|
},
|
|
],
|
|
};
|
|
|
|
/* 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: "/admin/convert",
|
|
label: "Image converter",
|
|
blurb: "Turn pictures into JPG, PNG or WebP, in your browser. Images in Media can also be downloaded as any of them.",
|
|
},
|
|
{
|
|
to: "/admin/clips",
|
|
label: "Video clips",
|
|
blurb: "Cut clips from our YouTube and Facebook videos: trimmed, reshaped for Reels, or audio only.",
|
|
minRole: "admin",
|
|
},
|
|
{
|
|
to: "/admin/thumbnails",
|
|
label: "Video thumbnails",
|
|
blurb: "A still from one of our YouTube or Facebook videos at any moment, saved to the media library.",
|
|
minRole: "editor",
|
|
},
|
|
{
|
|
to: "/admin/newsletter",
|
|
label: "Newsletter",
|
|
blurb: "An email newsletter from upcoming events, blog posts, featured cards and blocks of its own, ready to paste into Mailchimp or Gmail. Saved as drafts, and can become a blog post.",
|
|
},
|
|
{
|
|
to: "/qr",
|
|
label: "QR code generator",
|
|
blurb: "Codes for flyers, slides and signs: any page or link, in your choice of colors.",
|
|
},
|
|
],
|
|
};
|
|
|
|
/* Accounts, server state and what the site says about itself: the
|
|
superadmin's area, its own area rather than a group of CMS pages. */
|
|
export const SITE_SETTINGS = "/admin/site_settings";
|
|
|
|
export const PANEL_NAV = {
|
|
label: "Panel",
|
|
blurb: "Only superadmins see this.",
|
|
separated: true,
|
|
superOnly: true,
|
|
children: [
|
|
{
|
|
to: ADMIN_PANEL,
|
|
label: "Accounts and server",
|
|
blurb: "Accounts, sessions and the state of the server.",
|
|
},
|
|
{
|
|
to: SITE_SETTINGS,
|
|
label: "Site settings",
|
|
blurb: "The site's name, description, preview image, icons, colors, access groups and search indexing.",
|
|
},
|
|
],
|
|
};
|
|
|
|
export const NAV: any[] = [DATA_NAV, PAGES_NAV, FORMS_NAV, TOOLS_NAV, PANEL_NAV];
|
|
|
|
/* A group's items this user may see: one with `minRole` is left out
|
|
below that rank (Video clips is admin and up). */
|
|
export function visibleItems(items, user) {
|
|
return (items ?? []).filter((item) => !item.minRole || atLeast(user, item.minRole));
|
|
}
|
|
|
|
/* What this user may see. Call it with the user from useAuth. */
|
|
export function navFor(user) {
|
|
return NAV.filter((item) => !item.superOnly || isSuper(user)).map((item) =>
|
|
item.children ? { ...item, children: visibleItems(item.children, user) } : item,
|
|
);
|
|
}
|
|
|
|
/* 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) {
|
|
if (matches(pathname, ADMIN_HOME)) return "home";
|
|
if (matches(pathname, ADMIN_PANEL) || matches(pathname, SITE_SETTINGS)) return "panel";
|
|
return "cms";
|
|
}
|