diff --git a/CHANGELOG.md b/CHANGELOG.md index b1d8b1a..219705a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …). +## accounts@1.8.0 + website@1.1.0 - 2026-11-26 + +The admins of both, redesigned as Cross Events' admin dashboard and settings. Details in each app's +CHANGELOG.md. No migrations, no backend changes. + +- **Accounts 1.8.0:** `/admin` is an overview (cards, "Needs you", a tile per section); People + moved to `/admin/people`; the sidebar shows the part you're in, grouped; People redesigned. +- **Website 1.1.0:** an icon sidebar in groups, a dashboard, steps to the first publish across the + top, and a live preview beside the page editor and Template and style (drafts in a frame, no + preview cookie). + ## accounts@1.7.1 + website@1.0.2 + events@3.7.1 - 2026-11-26 Found installing the Website for cross-demo2. Details in each app's CHANGELOG.md. No migrations. diff --git a/apps/accounts/CHANGELOG.md b/apps/accounts/CHANGELOG.md index 47406e8..7302e04 100644 --- a/apps/accounts/CHANGELOG.md +++ b/apps/accounts/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog — Accounts +## [1.8.0] - 2026-11-26 + +No migrations, no new settings, no backend changes. The admin redesigned as Cross Events' admin +dashboard and settings. + +### Changed + +- **`/admin` is an overview:** four cards (people with an account, deletion requests waiting, + sites that sign in here, last backup), a "Needs you" list with buttons to act, and a tile with a + line about every section. **People moved to `/admin/people`.** +- **The sidebar shows the part you're in** (your account or admin, with a link to the other), and + admin's sections are grouped: People, Church, Signing in, System. Deletion requests shows how many + are waiting. The phone menu shows both parts. Every page title has its section's icon. +- **People:** a search box, a row per person with initials, admin and status badges, two-step + sign-in and last sign-in; the person's card stays in view while scrolling. Deactivating someone + asks to confirm first. +- **Email and WhatsApp** are two cards, each with its own Save. +- Group labels are a darker grey (WCAG AA contrast). + ## [1.7.1] - 2026-11-26 No migrations, no new settings. diff --git a/apps/accounts/WHATS-NEW.md b/apps/accounts/WHATS-NEW.md index 7ca7bba..a0b771f 100644 --- a/apps/accounts/WHATS-NEW.md +++ b/apps/accounts/WHATS-NEW.md @@ -3,6 +3,13 @@ What each version changes for the church, in plain language (read by the Hub like Cross Events' WHATS-NEW.md; a section shows once its version is tagged). +## 1.8.0 + +- **An easier admin.** Admin opens on an overview: how many people have an account, anything that + needs you (like deletion requests waiting), and a tile for every setting. The menu down the side + is grouped and shows only the part you're in. People has moved to Admin → **People**, with a + search box and a clearer list; deactivating someone now asks you to confirm. + ## 1.7.1 - **New sites connect to your sign-in straight away.** A Church Website or Cross Events installed diff --git a/apps/accounts/backend/package.json b/apps/accounts/backend/package.json index fd377dd..445d928 100644 --- a/apps/accounts/backend/package.json +++ b/apps/accounts/backend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/accounts-backend", - "version": "1.7.1", + "version": "1.8.0", "description": "Cross Code Accounts: the church's sign-in (OpenID Connect provider), account pages API and admin API", "private": true, "type": "module", diff --git a/apps/accounts/e2e/signin.spec.ts b/apps/accounts/e2e/signin.spec.ts index 84fa69d..2c798a9 100644 --- a/apps/accounts/e2e/signin.spec.ts +++ b/apps/accounts/e2e/signin.spec.ts @@ -102,6 +102,10 @@ test("admin: needs two-step sign-in, then lists people", async ({ page }) => { await page.getByLabel("Code").fill(await helper(page, `/test/totp?secret=${key}`)); await page.getByRole("button", { name: "Turn on" }).click(); await page.getByRole("button", { name: "I've saved them" }).click(); + // 1.8.0: /admin is the overview, with a tile for every section; People is one. + await expect(page.getByRole("heading", { name: "Admin", level: 1 })).toBeVisible(); + await expect(page.getByText("People with an account")).toBeVisible(); + await page.getByRole("navigation", { name: "Admin" }).getByRole("link", { name: "People", exact: true }).click(); await expect(page.getByRole("heading", { name: "People", level: 1 })).toBeVisible(); await expect(page.getByText("thandi@hope.test")).toBeVisible(); // 1.3.0: every admin section has its own address, down the side; Backups is one. diff --git a/apps/accounts/frontend/package.json b/apps/accounts/frontend/package.json index 2d90f21..80afe78 100644 --- a/apps/accounts/frontend/package.json +++ b/apps/accounts/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/accounts-frontend", - "version": "1.7.1", + "version": "1.8.0", "private": true, "description": "Cross Code Accounts: the church's sign-in pages, the account page and admin", "scripts": { diff --git a/apps/accounts/frontend/src/app/account/Account.tsx b/apps/accounts/frontend/src/app/account/Account.tsx index e0fbf78..ced986e 100644 --- a/apps/accounts/frontend/src/app/account/Account.tsx +++ b/apps/accounts/frontend/src/app/account/Account.tsx @@ -6,7 +6,7 @@ import QRCode from "qrcode"; import { Activity as ActivityIcon, ArrowUpRight, Calendar, CheckCircle2, Globe, Lock, Mail, ShieldAlert, ShieldCheck, Smartphone, User, type LucideIcon } from "lucide-react"; import { Button, Checkbox, Field, Notice } from "@crosscode/ui"; import { useBranding } from "@/components/BrandingProvider"; -import { AppShell, PageTitle, ShellLoading } from "@/components/AppShell"; +import { ACCOUNT_NAV, AppShell, PageTitle, ShellLoading } from "@/components/AppShell"; import { Card, Heading } from "@/components/Panel"; import { call, selfSignIn } from "@/lib/api"; import { useExternalEffect } from "@/lib/hooks"; @@ -62,7 +62,7 @@ export function Account({ section = "overview" }: { section?: AccountSection }) const first = me.name.split(" ")[0] || me.name; return ( - {section === "overview" ? `Hi, ${first}` : s.title} + n.href === s.path)?.icon} sub={s.sub(branding.name)}>{section === "overview" ? `Hi, ${first}` : s.title} {msg && {msg.text}} {section === "overview" && } {section === "details" &&
} diff --git a/apps/accounts/frontend/src/app/admin/Admin.tsx b/apps/accounts/frontend/src/app/admin/Admin.tsx index 6e2008a..3394c25 100644 --- a/apps/accounts/frontend/src/app/admin/Admin.tsx +++ b/apps/accounts/frontend/src/app/admin/Admin.tsx @@ -2,9 +2,12 @@ import Link from "next/link"; import React, { useCallback, useState } from "react"; -import { DatabaseBackup, Download, Play, RefreshCw, Timer } from "lucide-react"; +import { + AlertTriangle, ArrowRight, Building2, CheckCircle2, ChevronRight, DatabaseBackup, Download, Eye, FileText, KeyRound, Link2, LogIn, Mail, MessageCircle, Play, + RefreshCw, ScrollText, Search, ShieldCheck, Timer, UserX, Users, +} from "lucide-react"; import { Button, Checkbox, Field, Notice } from "@crosscode/ui"; -import { AppShell, PageTitle, ShellLoading, type ShellUser } from "@/components/AppShell"; +import { ADMIN_GROUPS, ADMIN_NAV, AppShell, PageTitle, ShellLoading, type ShellUser } from "@/components/AppShell"; import { NoticeText } from "@/components/NoticeText"; import { Card, Heading } from "@/components/Panel"; import { call, selfSignIn } from "@/lib/api"; @@ -26,6 +29,7 @@ export function Admin({ section = "people" }: { section?: AdminSection }) { const [me, setMe] = useState(null); const [allowed, setAllowed] = useState(null); const [msg, setMsg] = useState<{ tone: "success" | "error"; text: string } | null>(null); + const [waiting, setWaiting] = useState(0); useExternalEffect(() => { let alive = true; @@ -35,11 +39,15 @@ export function Admin({ section = "people" }: { section?: AdminSection }) { if (!r.ok && r.error.code === "MFA_REQUIRED") return window.location.assign(selfSignIn(s.path, "&acr=mfa")); if (who.ok) setMe(who.data); setAllowed(r.ok); + // The count beside Deletion requests. + if (r.ok) void call<{ items: Deletion[] }>("GET", "/admin/deletions").then((d) => { if (alive && d.ok) setWaiting(d.data.items.filter((x) => x.status === "waiting_approval").length); }); }); return () => { alive = false; }; }, [s.path]); const flash: Flash = (tone, text) => setMsg({ tone, text }); + const icon = ADMIN_NAV.find((n) => n.href === s.path)?.icon; + const badges = { "/admin/deletions": waiting }; if (allowed === null || !me) return ; if (!allowed) { return ( @@ -50,16 +58,20 @@ export function Admin({ section = "people" }: { section?: AdminSection }) { } return ( - - {s.title} + + {s.title} {msg && {msg.text}} + {section === "overview" && } {section === "people" && } -
- {section === "deletions" && } +
+ {section === "deletions" && } {section === "church" && <>} {section === "linked" && } - {section === "signin" && } - {section === "messages" && } + {section === "signin" && } sub="For everyone with an account at the church." keys={["signup_enabled", "two_factor_required_for_admins", "signin_notices", "session_days"]} />} + {section === "messages" && <> + } sub="The server Accounts sends email through (SMTP): sign-in codes, password links, security notices. Leave it empty to use the server's .env." keys={["smtp_host", "smtp_port", "smtp_user", "smtp_pass", "smtp_from", "smtp_secure"]} /> + } sub="Optional: sign-in codes and notices on WhatsApp, through WAWP." keys={["wawp_access_token", "wawp_instance_id"]} /> + } {section === "notice" && } {section === "backups" && } {section === "jobs" && } @@ -70,11 +82,118 @@ export function Admin({ section = "people" }: { section?: AdminSection }) { ); } +// ─── Overview (1.8.0, as Cross Events' admin dashboard) ───────────────────── + +type Linked = { hubConnected: boolean; items: { installId: string; name: string; listed: boolean; signsInHere: boolean }[] }; +type OverviewData = { people: number | null; deletions: number | null; linked: Linked | null; licence: { connected: boolean; state: string } | null; backups: BackupList | null }; + +const TILE: Record = Object.fromEntries(Object.values(ADMIN_SECTIONS).map((x) => [x.path, x.tile])); + +function Stat({ icon, label, value, detail, href, warn }: { icon: React.ReactNode; label: string; value: React.ReactNode; detail?: React.ReactNode; href: string; warn?: boolean }) { + return ( + +
+ {icon} + + {label} + {value} + +
+ {detail &&

{detail}

} + + ); +} + +function Overview() { + const [d, setD] = useState(null); + useExternalEffect(() => { + let alive = true; + Promise.all([ + call<{ total: number }>("GET", "/admin/people?q="), call<{ items: Deletion[] }>("GET", "/admin/deletions"), call("GET", "/admin/linked-products"), + call<{ connected: boolean; state: string }>("GET", "/admin/licence"), call("GET", "/admin/backups"), + ]).then(([people, dels, linked, licence, backups]) => { + if (!alive) return; + setD({ + people: people.ok ? people.data.total : null, + deletions: dels.ok ? dels.data.items.filter((x) => x.status === "waiting_approval").length : null, + linked: linked.ok ? linked.data : null, + licence: licence.ok ? licence.data : null, + backups: backups.ok ? backups.data : null, + }); + }); + return () => { alive = false; }; + }, []); + if (!d) return

Loading…

; + + const connected = d.linked?.items.filter((l) => l.signsInHere).length ?? 0; + const notConnected = d.linked?.items.filter((l) => !l.signsInHere && l.listed) ?? []; + const lastBackup = d.backups?.items[0]?.createdAt ?? null; + const todo: { text: string; href: string; action: string }[] = [ + ...(d.deletions ? [{ text: `${d.deletions} ${d.deletions === 1 ? "person has" : "people have"} asked to delete their account.`, href: "/admin/deletions", action: "Review" }] : []), + ...(d.licence && !d.licence.connected ? [{ text: "Accounts isn't connected to Cross Code yet, so the church's sites can't find it.", href: "/admin/licence", action: "Connect" }] : []), + ...(notConnected.length ? [{ text: `${notConnected.map((l) => l.name).join(", ")} ${notConnected.length === 1 ? "doesn't" : "don't"} sign people in here yet.`, href: "/admin/linked", action: "Connect" }] : []), + ...(d.backups?.lastError ? [{ text: "The last backup didn't work.", href: "/admin/backups", action: "See why" }] : []), + ]; + + return ( +
+
+ } label="People with an account" value={d.people ?? "—"} href="/admin/people" detail="Find someone" /> + } label="Deletion requests waiting" value={d.deletions ?? "—"} warn={!!d.deletions} href="/admin/deletions" detail={d.deletions ? "They need your answer" : "None waiting"} /> + } label="Sites that sign in here" value={d.linked ? `${connected} of ${d.linked.items.length}` : "—"} warn={notConnected.length > 0} href="/admin/linked" detail={d.linked && !d.linked.hubConnected ? "Not connected to the Hub" : "Linked products"} /> + } label="Last backup" value={lastBackup ? when(lastBackup) : "None yet"} warn={!!d.backups?.lastError} href="/admin/backups" detail={d.backups ? (d.backups.nightly ? "Every night at 02:00" : "Nightly backups are off") : undefined} /> +
+ + + : }>{todo.length ? "Needs you" : "Nothing needs you right now"} + {todo.length > 0 ? ( +
    + {todo.map((t) => ( +
  • + {t.text} + {t.action} +
  • + ))} +
+ ) :

Nothing is waiting for an admin. Anything that is (a deletion request, a site to connect, a backup that failed) shows here.

} +
+ + + All settings +
+ {ADMIN_GROUPS.filter((g) => g.title).map((g) => ( +
+

{g.title}

+
+ {g.items.map((n) => { + const Icon = n.icon; + return ( + + + + {n.label} + {TILE[n.href]} + + + ); + })} +
+
+ ))} +
+
+
+ ); +} + // ─── People ────────────────────────────────────────────────────────────────── type Person = { id: string; name: string; email: string; role: string; status: string; twoFactor: string | null; lastSignInAt: string | null }; type PersonDetail = Person & { phone: string | null; emailVerified: boolean; recoveryCodesLeft: number; createdAt: string; lockedUntil: string | null; signIns: { type: string; at: string; ip: string | null }[] }; +const initials = (name: string) => name.split(/\s+/).filter(Boolean).slice(0, 2).map((x) => x[0]!.toUpperCase()).join("") || "?"; +const chip = "inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium"; + function People({ flash }: { flash: Flash }) { const [q, setQ] = useState(""); const [list, setList] = useState<{ items: Person[]; total: number } | null>(null); @@ -94,28 +213,47 @@ function People({ flash }: { flash: Flash }) { }; return ( -
+
-
{ e.preventDefault(); void search(q); }} className="mb-4 flex gap-2"> - setQ(e.target.value)} placeholder="Name or email" className="flex-1 rounded-lg border px-3 py-2" /> + { e.preventDefault(); void search(q); }} className="mb-3 flex gap-2"> + + + setQ(e.target.value)} placeholder="Name or email" className="w-full rounded-lg border py-2 pl-9 pr-3" /> +
-

{list?.total ?? 0} people

-
    +

    {list?.total ?? 0} {list?.total === 1 ? "person" : "people"}

    +
      {list?.items.map((p) => (
    • -
    • ))}
    - {open && ( - - {open.name} -
    + {open ? ( + +
    + {initials(open.name)} +
    +

    {open.name}

    +

    {open.email}

    +
    +
    +
    Phone
    {open.phone ?? "—"}
    Email confirmed
    {open.emailVerified ? "yes" : "no"}
    Two-step sign-in
    {open.twoFactor ?? "off"}{open.twoFactor ? ` (${open.recoveryCodesLeft} codes left)` : ""}
    @@ -126,12 +264,18 @@ function People({ flash }: { flash: Flash }) { {open.twoFactor && } {open.lockedUntil && } - +

Roles in each product (an Events supervisor, for example) are set in that product, not here.

Recent sign-ins

-
    {open.signIns.map((s, i) =>
  • {s.type} · {when(s.at)} {s.ip && · {s.ip}}
  • )}
+
    {open.signIns.map((x, i) =>
  • {x.type} · {when(x.at)} {x.ip && · {x.ip}}
  • )}
+ {!open.signIns.length &&

None yet.

} + ) : ( +
+ + Choose someone to see their account and what you can do for them. +
)}
); @@ -141,16 +285,16 @@ function People({ flash }: { flash: Flash }) { type Deletion = { id: string; status: string; requestedAt: string; products: Record; person: { name: string; email: string } }; -function Deletions({ flash }: { flash: Flash }) { +function Deletions({ flash, onChange }: { flash: Flash; onChange: (waiting: number) => void }) { const [items, setItems] = useState([]); const load = useCallback(async () => { const r = await call<{ items: Deletion[] }>("GET", "/admin/deletions"); - if (r.ok) setItems(r.data.items); - }, []); + if (r.ok) { setItems(r.data.items); onChange(r.data.items.filter((x) => x.status === "waiting_approval").length); } + }, [onChange]); useExternalEffect(() => { void load(); }, [load]); return ( - Deletion requests + } sub="People who asked to delete their account. They're signed out and can't sign in while this is open.">Deletion requests {!items.length &&

None waiting.

}
    {items.map((d) => ( @@ -189,7 +333,8 @@ function Church({ flash }: { flash: Flash }) { const nul = (v: FormDataEntryValue | null) => (v ? String(v) : null); return ( - Church profile + } sub="Shared with all the church's products: the sign-in pages, the website and the app use it.">Church profile + {c.branding.logoUrl && The church's logo}
    { e.preventDefault(); const f = new FormData(e.currentTarget); @@ -230,7 +375,7 @@ function Linked({ flash }: { flash: Flash }) { if (!data) return

    Loading…

    ; return ( - Linked products + } sub="Connected products sign people in here. Usually each product connects from its own settings; you can connect from here too.">Linked products {!data.hubConnected && Accounts isn't connected to the Hub yet (Licence).} {!data.items.length &&

    The church has no other Cross Code products yet.

    }
      @@ -260,7 +405,7 @@ const SETTING_LABELS: Record | null>(null); useExternalEffect(() => { let alive = true; @@ -271,6 +416,7 @@ function Settings({ flash, keys }: { flash: Flash; keys: string[] }) { const defaults: Record = { signup_enabled: true, two_factor_required_for_admins: true, signin_notices: true }; return ( + {title} { e.preventDefault(); const f = new FormData(e.currentTarget); @@ -281,7 +427,7 @@ function Settings({ flash, keys }: { flash: Flash; keys: string[] }) { else body[k] = String(f.get(k) ?? ""); } const r = await call("PUT", "/admin/settings", body); - if (r.ok) flash("success", "Saved."); else flash("error", r.error.message); + if (r.ok) flash("success", `${title}: saved.`); else flash("error", r.error.message); }}> {keys.map((k) => { const [label, kind] = SETTING_LABELS[k]!; @@ -318,7 +464,7 @@ function NoticeTab({ flash }: { flash: Flash }) { return (
      - Edit and publish + } sub={`Version ${current.version}${isBuiltIn ? " (the built-in notice, filled in from the church profile)" : ""}. Publishing a new version asks everyone to read it the next time they sign in.`}>Edit and publish {builtIn && !isBuiltIn && (

      The built-in notice was rewritten in Accounts 1.3.0 to say more fully what Accounts does.{" "} @@ -339,7 +485,7 @@ function NoticeTab({ flash }: { flash: Flash }) {

      - Preview + } sub="As people will see it.">Preview

      {draft.title}

      @@ -357,7 +503,7 @@ function Licence({ flash }: { flash: Flash }) { if (!s) return

      Loading…

      ; return ( - Licence + } sub="Accounts is free with the church's other products. Members can always sign in, whatever the licence says.">Licence
      Connected to the Hub
      {s.connected ? "yes" : "no"}
      Licence
      {s.state}
      @@ -388,7 +534,7 @@ function Audit() { }, []); return ( - Audit log + }>Audit log
        {items.map((a) =>
      • {a.action.replace(/_/g, " ")} ({a.actorRole}{a.targetId ? ` · ${a.targetType}` : ""}){when(a.createdAt)}
      • )} {!items.length &&
      • Nothing yet.
      • } diff --git a/apps/accounts/frontend/src/app/admin/[section]/page.tsx b/apps/accounts/frontend/src/app/admin/[section]/page.tsx index 3d04392..14bd529 100644 --- a/apps/accounts/frontend/src/app/admin/[section]/page.tsx +++ b/apps/accounts/frontend/src/app/admin/[section]/page.tsx @@ -7,9 +7,9 @@ export async function generateMetadata({ params }: { params: Promise<{ section: return { title: ADMIN_SECTIONS[section as AdminSection]?.title ?? "Admin" }; } -/** One section of admin (1.3.0): /admin/deletions, /church, /linked, … (/admin itself is People). */ +/** One section of admin (1.3.0): /admin/people, /deletions, /church, … (1.8.0: /admin itself is the overview). */ export default async function AdminSectionPage({ params }: { params: Promise<{ section: string }> }) { const { section } = await params; - if (section === "people" || !(section in ADMIN_SECTIONS)) notFound(); + if (section === "overview" || !(section in ADMIN_SECTIONS)) notFound(); return ; } diff --git a/apps/accounts/frontend/src/app/admin/page.tsx b/apps/accounts/frontend/src/app/admin/page.tsx index e0c4379..33f7021 100644 --- a/apps/accounts/frontend/src/app/admin/page.tsx +++ b/apps/accounts/frontend/src/app/admin/page.tsx @@ -3,5 +3,5 @@ import { Admin } from "./Admin"; export const metadata = { title: "Admin" }; export default function AdminPage() { - return ; + return ; } diff --git a/apps/accounts/frontend/src/components/AppShell.tsx b/apps/accounts/frontend/src/components/AppShell.tsx index 407cb4a..3bc85ff 100644 --- a/apps/accounts/frontend/src/components/AppShell.tsx +++ b/apps/accounts/frontend/src/components/AppShell.tsx @@ -12,7 +12,7 @@ import { useBranding } from "@/components/BrandingProvider"; /** Who's signed in, as the shell shows them (null: a public page such as the privacy notice). */ export type ShellUser = { name: string; email: string; role: "member" | "admin" }; -type NavItem = { href: string; label: string; icon: LucideIcon }; +export type NavItem = { href: string; label: string; icon: LucideIcon }; export const ACCOUNT_NAV: NavItem[] = [ { href: "/account", label: "Overview", icon: LayoutDashboard }, @@ -22,19 +22,21 @@ export const ACCOUNT_NAV: NavItem[] = [ { href: "/account/activity", label: "Activity", icon: Activity }, ]; -export const ADMIN_NAV: NavItem[] = [ - { href: "/admin", label: "People", icon: Users }, - { href: "/admin/deletions", label: "Deletion requests", icon: UserX }, - { href: "/admin/church", label: "Church profile", icon: Building2 }, - { href: "/admin/linked", label: "Linked products", icon: Link2 }, - { href: "/admin/signin", label: "Sign-in settings", icon: LogIn }, - { href: "/admin/messages", label: "Email and WhatsApp", icon: Mail }, - { href: "/admin/notice", label: "Privacy notice", icon: FileText }, - { href: "/admin/backups", label: "Backups", icon: DatabaseBackup }, - { href: "/admin/jobs", label: "Background jobs", icon: Timer }, - { href: "/admin/licence", label: "Licence", icon: KeyRound }, - { href: "/admin/audit", label: "Audit log", icon: ScrollText }, +/** 1.8.0: the admin's sections in groups, as Cross Events' settings, with the overview first. */ +export const ADMIN_GROUPS: { title: string | null; items: NavItem[] }[] = [ + { title: null, items: [{ href: "/admin", label: "Overview", icon: LayoutDashboard }] }, + { title: "People", items: [{ href: "/admin/people", label: "People", icon: Users }, { href: "/admin/deletions", label: "Deletion requests", icon: UserX }] }, + { title: "Church", items: [{ href: "/admin/church", label: "Church profile", icon: Building2 }, { href: "/admin/linked", label: "Linked products", icon: Link2 }] }, + { + title: "Signing in", + items: [{ href: "/admin/signin", label: "Sign-in settings", icon: LogIn }, { href: "/admin/messages", label: "Email and WhatsApp", icon: Mail }, { href: "/admin/notice", label: "Privacy notice", icon: FileText }], + }, + { + title: "System", + items: [{ href: "/admin/backups", label: "Backups", icon: DatabaseBackup }, { href: "/admin/jobs", label: "Background jobs", icon: Timer }, { href: "/admin/licence", label: "Licence", icon: KeyRound }, { href: "/admin/audit", label: "Audit log", icon: ScrollText }], + }, ]; +export const ADMIN_NAV: NavItem[] = ADMIN_GROUPS.flatMap((g) => g.items); /** Signs out of Accounts and every site of the church (RP-initiated logout), ending on /signed-out. */ export function signOutHref() { @@ -53,28 +55,59 @@ function RoleBadge({ role }: { role: ShellUser["role"] }) { : Member; } -function NavList({ title, items, active, onNavigate }: { title: string; items: NavItem[]; active: string; onNavigate?: () => void }) { +/** Counts beside a section (deletion requests waiting, say), by its address. */ +export type Badges = Record; + +function NavLinks({ items, active, badges, onNavigate }: { items: NavItem[]; active: string; badges?: Badges; onNavigate?: () => void }) { + return ( +
          + {items.map((l) => { + const Icon = l.icon; + const on = active === l.href; + const n = badges?.[l.href] ?? 0; + return ( +
        • + + + {l.label} + {n > 0 && {n} waiting} + +
        • + ); + })} +
        + ); +} + +function AccountNav({ active, onNavigate }: { active: string; onNavigate?: () => void }) { return (
        -

        {title}

        - +

        Your account

        +
        ); } -function SidebarContent({ me, active, onNavigate }: { me: ShellUser; active: string; onNavigate?: () => void }) { +function AdminNav({ active, badges, onNavigate }: { active: string; badges?: Badges; onNavigate?: () => void }) { + return ( + + ); +} + +/** + * The sidebar: who's signed in, then the sections of the part you're in (1.8.0: your account or + * admin, not both at once; the bar across the top switches). In the phone menu, both. + */ +function SidebarContent({ me, active, badges, both, onNavigate }: { me: ShellUser; active: string; badges?: Badges; both?: boolean; onNavigate?: () => void }) { + const inAdmin = me.role === "admin" && active.startsWith("/admin"); return ( <>
        @@ -84,8 +117,14 @@ function SidebarContent({ me, active, onNavigate }: { me: ShellUser; active: str
      - - {me.role === "admin" && } + {(both || !inAdmin) && } + {me.role === "admin" && (both || inAdmin) && } + {!both && me.role === "admin" && ( + + {inAdmin ? : } + {inAdmin ? "Go to your account" : "Go to admin"} + + )} ); } @@ -95,7 +134,7 @@ function SidebarContent({ me, active, onNavigate }: { me: ShellUser; active: str * and name across the top, a sidebar of sections, the page on a light grey, and a dark footer. * Without `me` (a public page) there's no sidebar. `active` is the current section's address. */ -export function AppShell({ me, active = "", children }: { me: ShellUser | null; active?: string; children: React.ReactNode }) { +export function AppShell({ me, active = "", badges, children }: { me: ShellUser | null; active?: string; badges?: Badges; children: React.ReactNode }) { const b = useBranding(); const [open, setOpen] = useState(false); const top = "text-sm border-b-2 pb-0.5 transition-colors"; @@ -131,7 +170,7 @@ export function AppShell({ me, active = "", children }: { me: ShellUser | null; - setOpen(false)} /> + setOpen(false)} /> { e.preventDefault(); window.location.assign(signOutHref()); }} className="mt-auto flex items-center gap-3 rounded-lg px-3 py-2 text-sm text-gray-600 hover:bg-gray-50"> Sign out @@ -142,7 +181,7 @@ export function AppShell({ me, active = "", children }: { me: ShellUser | null;
      {me && ( )}
      {children}
      @@ -159,12 +198,15 @@ export function AppShell({ me, active = "", children }: { me: ShellUser | null; ); } -/** A page's title and a line under it, at the top of the main column. */ -export function PageTitle({ children, sub }: { children: React.ReactNode; sub?: React.ReactNode }) { +/** A page's title and a line under it, at the top of the main column; with the section's icon. */ +export function PageTitle({ children, sub, icon: Icon }: { children: React.ReactNode; sub?: React.ReactNode; icon?: LucideIcon }) { return ( -
      -

      {children}

      - {sub &&

      {sub}

      } +
      + {Icon && } +
      +

      {children}

      + {sub &&

      {sub}

      } +
      ); } diff --git a/apps/accounts/frontend/src/lib/sections.ts b/apps/accounts/frontend/src/lib/sections.ts index d1f976e..5767ea8 100644 --- a/apps/accounts/frontend/src/lib/sections.ts +++ b/apps/accounts/frontend/src/lib/sections.ts @@ -1,15 +1,20 @@ -/** The admin's sections (1.3.0): one address each, in the sidebar (components/AppShell.tsx). */ +/** + * The admin's sections: one address each, in groups down the side (components/AppShell.tsx), and a + * tile each on the overview. 1.8.0: /admin is the overview (as Cross Events' admin dashboard); + * People moved to /admin/people. + */ export const ADMIN_SECTIONS = { - people: { path: "/admin", title: "People", sub: "Everyone with a church account. Roles in each site (an Events supervisor, for example) are set in that site." }, - deletions: { path: "/admin/deletions", title: "Deletion requests", sub: "People who asked to delete their account." }, - church: { path: "/admin/church", title: "Church profile", sub: "The church's name, logo, colours and contact details, used by all its sites." }, - linked: { path: "/admin/linked", title: "Linked products", sub: "The church's sites and apps that sign people in here." }, - signin: { path: "/admin/signin", title: "Sign-in settings", sub: "Who may make an account, two-step sign-in for admins, and how long people stay signed in." }, - messages: { path: "/admin/messages", title: "Email and WhatsApp", sub: "How Accounts sends sign-in codes, password links and security notices." }, - notice: { path: "/admin/notice", title: "Privacy notice", sub: "What people read before they sign in for the first time, and after it changes." }, - backups: { path: "/admin/backups", title: "Backups", sub: "Copies of the Accounts database, kept on this server." }, - jobs: { path: "/admin/jobs", title: "Background jobs", sub: "What the server does on a schedule. Switch a job on or off or change when it runs: your choice wins over the server's .env and applies straight away." }, - licence: { path: "/admin/licence", title: "Licence", sub: "Accounts' connection to Cross Code." }, - audit: { path: "/admin/audit", title: "Audit log", sub: "What admins and the church's sites changed here." }, + overview: { path: "/admin", title: "Admin", sub: "How Accounts stands, what needs you, and every setting.", tile: "" }, + people: { path: "/admin/people", title: "People", sub: "Everyone with a church account. Roles in each site (an Events supervisor, for example) are set in that site.", tile: "Find someone, reset their two-step sign-in, make an admin" }, + deletions: { path: "/admin/deletions", title: "Deletion requests", sub: "People who asked to delete their account.", tile: "Approve or cancel people's requests to delete their account" }, + church: { path: "/admin/church", title: "Church profile", sub: "The church's name, logo, colours and contact details, used by all its sites.", tile: "Name, logo, colours and contact details for every site" }, + linked: { path: "/admin/linked", title: "Linked products", sub: "The church's sites and apps that sign people in here.", tile: "The sites and apps that sign people in here" }, + signin: { path: "/admin/signin", title: "Sign-in settings", sub: "Who may make an account, two-step sign-in for admins, and how long people stay signed in.", tile: "Who can make an account, two-step sign-in, staying signed in" }, + messages: { path: "/admin/messages", title: "Email and WhatsApp", sub: "How Accounts sends sign-in codes, password links and security notices.", tile: "How sign-in codes and password links are sent" }, + notice: { path: "/admin/notice", title: "Privacy notice", sub: "What people read before they sign in for the first time, and after it changes.", tile: "What people read before they first sign in" }, + backups: { path: "/admin/backups", title: "Backups", sub: "Copies of the Accounts database, kept on this server.", tile: "Back up now, download a copy, how many to keep" }, + jobs: { path: "/admin/jobs", title: "Background jobs", sub: "What the server does on a schedule. Switch a job on or off or change when it runs: your choice wins over the server's .env and applies straight away.", tile: "What runs on a schedule, and when" }, + licence: { path: "/admin/licence", title: "Licence", sub: "Accounts' connection to Cross Code.", tile: "The connection to Cross Code" }, + audit: { path: "/admin/audit", title: "Audit log", sub: "What admins and the church's sites changed here.", tile: "Who changed what, and when" }, } as const; export type AdminSection = keyof typeof ADMIN_SECTIONS; diff --git a/apps/website/CHANGELOG.md b/apps/website/CHANGELOG.md index ad2e5db..824ccd0 100644 --- a/apps/website/CHANGELOG.md +++ b/apps/website/CHANGELOG.md @@ -1,5 +1,35 @@ # Changelog — Church Website +## [1.1.0] — 2026-11-26 + +No migration, no new settings, no backend changes. The admin redesigned as Cross Events' admin +dashboard and settings. Adds `lucide-react` (the version Accounts uses). + +### Added + +- **Steps to the first publish** across the top of every admin page until the site is live (from + the setup checklist): each step is a link, done ones are ticked, "Next" goes to the first one to + do, and it folds to one line (remembered in the browser). It updates after every save. +- **A live preview beside the page editor** (home and custom pages) and Template and style: the + page at computer or phone width, scaled to fit, reloaded on each save at the same scroll position. + It folds to a tab on the right (remembered); on phones it's a Preview button that opens it full + screen. It shows drafts without the preview cookie: a request from a frame + (`Sec-Fetch-Dest: iframe`) with an admin session reads the drafts, so the live site in another + tab stays live. Links inside it load in full so they stay on drafts. `/preview/start` takes + `?to=` (a site path only) to open the full preview on that page. + +### Changed + +- **The admin's frame:** a sidebar with icons in groups (Your site, Content, Go live, Team), a + drawer on phones, and a bar across the top with the changes not published, Preview and who's + signed in. Publish shows the number of changes waiting. +- **The dashboard** as Cross Events': a welcome, four cards (site, changes waiting, storage, last + edit), a tile for every part of the admin, and recent edits. +- **The page editor** has tabs, Content and Page details (title, address, menu, search and + sharing); blocks are cards with a summary, icon buttons to move, hide and remove (asks first), and + "Add a block" is a grid of tiles. **Template and style** has tabs: Template, Home page layout, + Style. Every admin page has its icon. + ## [1.0.2] — 2026-11-26 No migration, no new settings. Works with Accounts 1.7.0; with Accounts 1.7.1 the first sign-in diff --git a/apps/website/WHATS-NEW.md b/apps/website/WHATS-NEW.md index 7ae0143..cf43d67 100644 --- a/apps/website/WHATS-NEW.md +++ b/apps/website/WHATS-NEW.md @@ -3,6 +3,15 @@ What each version changes for the church, in plain language (read by the Hub like Cross Events' WHATS-NEW.md; a section shows once its version is tagged). +## 1.1.0 + +- **An easier admin.** A menu with icons down the side, and a dashboard with a tile for every part + of your site. +- **Steps to get your site live:** until your site is published, the top of every admin page shows + what's left to do. Click a step to go there, or **Next** for the next one. +- **See your page as you edit it:** a live preview beside the editor, at computer or phone size. + It updates every time you save, and you can fold it away to the right. + ## 1.0.2 - **Preview works:** pressing Preview in the admin shows your site with your changes, instead of diff --git a/apps/website/backend/package.json b/apps/website/backend/package.json index baf610a..7806e74 100644 --- a/apps/website/backend/package.json +++ b/apps/website/backend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/website-backend", - "version": "1.0.2", + "version": "1.1.0", "description": "Church Website: the public site's content API, the admin API, publishing and uploads", "private": true, "type": "module", diff --git a/apps/website/e2e/admin.spec.ts b/apps/website/e2e/admin.spec.ts index 6a6e00f..fbd14ad 100644 --- a/apps/website/e2e/admin.spec.ts +++ b/apps/website/e2e/admin.spec.ts @@ -21,10 +21,12 @@ async function signIn(context: BrowserContext, role = "editor") { async function aboutTitle(page: Page, title: string) { await page.goto("/admin/pages"); - await page.getByRole("link", { name: "About us", exact: true }).first().click(); + await page.getByRole("link", { name: /^About us\b/ }).first().click(); // The list page has a Title field too (Add a page): wait for the page's own editor. await expect(page).toHaveURL(/\/admin\/pages\/[0-9a-f-]+$/); await expect(page.getByRole("heading", { level: 1, name: "About us" })).toBeVisible(); + // The editor opens on the page's content; the title is under Page details. + await page.getByRole("tab", { name: "Page details" }).click(); await page.getByLabel("Title", { exact: true }).fill(title); await page.getByRole("button", { name: "Save details" }).click(); await expect(page.getByText("Saved as a draft.")).toBeVisible(); @@ -58,6 +60,23 @@ test("edit, preview the whole site, publish: then visitors see it", async ({ pag await visitor.close(); }); +test("the live preview beside the editor shows the draft; the site itself doesn't", async ({ page, context }) => { + await signIn(context); + await aboutTitle(page, "Draft title"); + const frame = page.frameLocator('iframe[title="Live preview of this page"]'); + await expect(frame.getByRole("heading", { level: 1, name: "Draft title" })).toBeVisible(); + // No preview cookie: the same browser, outside the frame, still sees the live site. + await page.goto("/about"); + await expect(page.getByRole("heading", { level: 1, name: "About us" })).toBeVisible(); + await expect(page.getByRole("region", { name: "Preview" })).toHaveCount(0); + // Folded away, it stays folded. + await page.goBack(); + await page.getByRole("button", { name: "Hide the preview" }).click(); + await expect(page.getByRole("button", { name: "Show the live preview" })).toBeVisible(); + await page.reload(); + await expect(page.getByRole("button", { name: "Show the live preview" })).toBeVisible(); +}); + test("discard one change", async ({ page, context }) => { await signIn(context); await aboutTitle(page, "Changed my mind"); @@ -159,4 +178,10 @@ test("the admin's screens are accessible", async ({ page, context }) => { const axe = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa", "wcag22aa"]).analyze(); expect(axe.violations.map((v) => `${path}: ${v.id} (${v.nodes.length}) ${v.nodes[0]?.target}`)).toEqual([]); } + // And a page's editor, with its live preview beside it. + await page.goto("/admin/pages"); + await page.getByRole("link", { name: /^Home\b/ }).first().click(); + await expect(page.frameLocator('iframe[title="Live preview of this page"]').getByRole("heading", { level: 1 })).toBeVisible(); + const axe = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa", "wcag22aa"]).analyze(); + expect(axe.violations.map((v) => `editor: ${v.id} (${v.nodes.length}) ${v.nodes[0]?.target}`)).toEqual([]); }); diff --git a/apps/website/frontend/package.json b/apps/website/frontend/package.json index 5bb56a8..9105d46 100644 --- a/apps/website/frontend/package.json +++ b/apps/website/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/website-frontend", - "version": "1.0.2", + "version": "1.1.0", "private": true, "description": "Church Website: the church's public site in its template, and the admin", "scripts": { @@ -14,6 +14,7 @@ "@crosscode/contracts": "*", "@crosscode/seo": "*", "@crosscode/ui": "*", + "lucide-react": "^0.536.0", "next": "^16.4.6", "react": "^19.3.1", "react-dom": "^19.3.1" diff --git a/apps/website/frontend/src/admin/LivePreview.tsx b/apps/website/frontend/src/admin/LivePreview.tsx new file mode 100644 index 0000000..a09f3dc --- /dev/null +++ b/apps/website/frontend/src/admin/LivePreview.tsx @@ -0,0 +1,152 @@ +"use client"; + +/** + * The live preview beside an editor: the page as it will look, with your saved drafts, on the right. + * It folds away to a tab on the right edge (remembered in this browser), shows a desktop or a phone + * width (the desktop scaled down to fit), and reloads where you were scrolled to each time + * something is saved. On a small screen it's a button that opens it full screen. + * + * The frame's pages are the working copy because they're framed and you're signed in (site/load.ts). + */ +import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react"; +import { Eye, ExternalLink, Monitor, PanelRightClose, PanelRightOpen, RotateCw, Smartphone, X } from "lucide-react"; +import { cx } from "./ui"; + +type Device = "desktop" | "phone"; +const WIDTH: Record = { desktop: 1280, phone: 390 }; +const OPEN_KEY = "ccw-admin-preview-open"; +const DEVICE_KEY = "ccw-admin-preview-device"; + +const read = (k: string) => { try { return window.localStorage.getItem(k); } catch { return null; } }; +const write = (k: string, v: string) => { try { window.localStorage.setItem(k, v); } catch { /* not kept */ } }; + +function Frame({ path, version, device }: { path: string; version: string; device: Device }) { + const box = useRef(null); + const frame = useRef(null); + const scroll = useRef(0); + const shown = useRef(version); + const [size, setSize] = useState({ w: 0, h: 0 }); + const [loading, setLoading] = useState(true); + + useLayoutEffect(() => { + const el = box.current; + if (!el) return; + const ro = new ResizeObserver(([e]) => setSize({ w: e!.contentRect.width, h: e!.contentRect.height })); + ro.observe(el); + return () => ro.disconnect(); + }, []); + + // A save: reload the page in the frame (wherever it was clicked to), back at the same place. + useEffect(() => { + if (shown.current === version) return; + shown.current = version; + const w = frame.current?.contentWindow; + if (!w) return; + try { + scroll.current = w.scrollY; + // eslint-disable-next-line react-hooks/set-state-in-effect + setLoading(true); + w.location.reload(); + } catch { + // Not the site's own page any more (a link out): leave it. + } + }, [version]); + + const onLoad = useCallback(() => { + setLoading(false); + const w = frame.current?.contentWindow; + if (w && scroll.current) { + try { w.scrollTo(0, scroll.current); } catch { /* elsewhere */ } + scroll.current = 0; + } + }, []); + + // The page at its real width, scaled down to fit (a phone has a margin round it). + const logical = WIDTH[device]; + const pad = device === "phone" ? 12 : 0; + const scale = size.w ? Math.min(1, (size.w - pad * 2) / logical) : 1; + return ( +
      + {size.w > 0 && ( +