Support the read-only calendar role, show "Vorstand", fix link buttons
- Read-only role: /admin/me's permissions decide via canEditCalendar (lib/permissions.ts, mirrors the API's canWrite: only `access` writes). Read-only accounts see everything but get no "Neuer Termin", no "+", no "Veröffentlichen"; an event opens as "Termin ansehen" with locked fields. A "Nur lesen" badge in the header explains why. The API refuses their writes regardless. - The management calendar is labelled "Vorstand"; the slug stays `management` for the API, URLs and iCal links. - The subscription dialog's Apple/Google links are plain anchors styled with buttonVariants instead of Base UI Buttons rendering an <a>, which warned in dev and would have given them role="button". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
16 files changed
+155
-32
No files matched your search
@@ -32,6 +32,14 @@ the **API** sets on `.nachklang.art`; it is shared by calendar, feedback, ticket
|
||||
`GET /admin/me` answers **200** for an account without the calendar permission; only `apps` shows
|
||||
it. The layout's `apps.includes("calendar")` check is load-bearing.
|
||||
|
||||
**Read-only role.** `/admin/me` also returns `permissions: [{app, role}]`. `lib/permissions.ts`
|
||||
(`canEditCalendar`) mirrors the API's `canWrite`: only a calendar grant with role `access` may
|
||||
change anything; `read` - or any role the app doesn't know - is read-only. Without `permissions`
|
||||
(an API from before the role) it falls back to `apps`. The UI reads it through `useCanEdit()`
|
||||
(`AdminSession.tsx`) and hides every write control; `EventSheet` turns into a view. Enforcement
|
||||
is the API's: `requireAppAccess` refuses non-GET requests from `read` grants with 403. See the
|
||||
API's `docs/admin-roles.md`.
|
||||
|
||||
## Data flow (admin)
|
||||
|
||||
- `components/admin/useEvents.ts` loads all five calendars in parallel from
|
||||
|
||||
@@ -15,6 +15,12 @@ What the calendar app does, as of the Next.js rewrite (September 2026).
|
||||
Sign-in happens in the admin app (one account for all Nachklang apps). Accounts need the calendar
|
||||
permission; without it the page says so instead of redirecting.
|
||||
|
||||
**Two levels** (granted in the admin app): *Vollzugriff* (`access`) can do everything below;
|
||||
*Nur lesen* (`read`, since 2026-11-08 in this app) sees every calendar, draft and subscription link
|
||||
but changes nothing - no "Neuer Termin", no "+", no "Veröffentlichen", and opening an event shows
|
||||
"Termin ansehen" with locked fields and only "Schließen". A "Nur lesen" badge in the header says
|
||||
why. The API refuses read-only writes anyway (403); the UI just doesn't offer them.
|
||||
|
||||
**List**
|
||||
- All calendars in one list, grouped by month, colour-coded per calendar.
|
||||
- Calendar chips toggle calendars on and off, with a count each; Geburtstage is off by default.
|
||||
|
||||
@@ -73,6 +73,10 @@ Collected during the rewrite (September 2026); the progress log in
|
||||
and `sheet.tsx`.
|
||||
- **Base UI, not Radix:** toggles expose `aria-pressed` (not `data-state=on`), triggers take a
|
||||
`render` prop (not `asChild`), menu radio items stay open unless `closeOnClick` is set.
|
||||
- **A link that looks like a button is a plain `<a className={buttonVariants(…)}>`**, not
|
||||
`<Button render={<a …/>}>`. Through Base UI's Button it warns in dev ("expected a native
|
||||
<button>", shown as Next's "2 issues" badge) and, with `nativeButton={false}`, gets
|
||||
`role="button"` - screen readers then announce a link as a button.
|
||||
- **Base UI Select ignores synthetic `click()`s**; automated tests need real pointer or keyboard input.
|
||||
- **Closed dialogs stay in the DOM** with `data-closed` until their exit animation ends - in a hidden
|
||||
tab that never happens. Query `[data-open]` when checking what's open.
|
||||
|
||||
@@ -237,7 +237,7 @@ Decisions made while implementing (not asked explicitly - revisit if wrong):
|
||||
- Recurring events appear under "Kommend" and "Alle", never under "Vergangen".
|
||||
- A yearly event on 29 Feb falls on 28 Feb in common years.
|
||||
- An unknown `status` from the API is treated (and saved back) as `PRIVATE`, never as `PUBLIC`.
|
||||
- Calendar labels: Öffentlich, Mitglieder, Chor, Management, Geburtstage.
|
||||
- Calendar labels: Öffentlich, Mitglieder, Chor, Management, Geburtstage. (2026-11-08: "Management" renamed to "Vorstand" at the user's request; the slug stays `management`.)
|
||||
- New events default to `DRAFT`, like the Angular app.
|
||||
Facts found along the way (move to `docs/gotchas.md` in phase 8):
|
||||
- The API returns raw DB rows: `wholeDay` is most likely `0`/`1` (inferred from the MariaDB
|
||||
|
||||
Reference in new issue
Block a user