Support the read-only calendar role, show "Vorstand", fix link buttons
Test and deploy / test (pull_request) Successful in 2m18s
Test and deploy / deploy (pull_request) Skipped

- 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:
PaddyandClaude Opus 5.5 committed 2026-11-08 22:15:31 +01:00
1 parent 1971d2bd6f
commit 61e0393f01
16 files changed
+155 -32

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import { describe, expect, it } from "vitest";
import { canEditCalendar } from "@/lib/permissions";
describe("canEditCalendar", () => {
it("allows changes with the access role", () => {
expect(canEditCalendar({ apps: ["calendar"], permissions: [{ app: "calendar", role: "access" }] })).toBe(true);
});
it("refuses them with the read role", () => {
expect(canEditCalendar({ apps: ["calendar"], permissions: [{ app: "calendar", role: "read" }] })).toBe(false);
});
it("only counts calendar grants - full access elsewhere doesn't help", () => {
const user = {
apps: ["calendar", "tickets", "admin"],
permissions: [
{ app: "calendar", role: "read" },
{ app: "tickets", role: "access" },
{ app: "admin", role: "access" },
],
};
expect(canEditCalendar(user)).toBe(false);
});
it("treats an unknown future role as read-only, like the API's canWrite", () => {
expect(canEditCalendar({ apps: ["calendar"], permissions: [{ app: "calendar", role: "redeem" }] })).toBe(false);
});
it("falls back to apps when an older API sends no permissions", () => {
expect(canEditCalendar({ apps: ["calendar"] })).toBe(true);
expect(canEditCalendar({ apps: ["tickets"] })).toBe(false);
});
});