Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b22e89001a | ||
|
|
689a485fce | ||
|
|
c142c45edf | ||
|
|
61e0393f01 | ||
|
|
1971d2bd6f |
No files matched your search
+18
-24
@@ -12,28 +12,12 @@ on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
# Same major as Passenger on the server (26.13.0 as of 2026-11-08).
|
||||
node-version-file: .nvmrc
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
- run: npx tsc --noEmit
|
||||
- run: npm test
|
||||
# Proves the production build works, with the production values: NEXT_PUBLIC_* are inlined
|
||||
# at build time, and lib/env.ts fails the build if one is missing.
|
||||
- run: npm run build
|
||||
env:
|
||||
NEXT_PUBLIC_API_BASE_URL: ${{ vars.NEXT_PUBLIC_API_BASE_URL }}
|
||||
NEXT_PUBLIC_ADMIN_APP_URL: ${{ vars.NEXT_PUBLIC_ADMIN_APP_URL }}
|
||||
|
||||
deploy:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
# One job, not test + deploy: every job starts in a fresh container, so two jobs meant checking out,
|
||||
# setting up Node, `npm ci` and building twice (~2 min each, 2026-11-08). The deploy steps only run
|
||||
# for pushes to master; on pull requests the job ends after the build. The condition is spelled out
|
||||
# on every deploy step rather than stored in an env flag: a flag compared as a string ('true') would
|
||||
# skip the deploy silently - and green - if the runner ever rendered the boolean differently.
|
||||
test-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
|
||||
@@ -48,8 +32,14 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
# Same major as Passenger on the server (26.13.0 as of 2026-11-08).
|
||||
node-version-file: .nvmrc
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
- run: npx tsc --noEmit
|
||||
- run: npm test
|
||||
# The production build, with the production values: NEXT_PUBLIC_* are inlined at build time,
|
||||
# and lib/env.ts fails the build if one is missing. On master this is also what gets deployed.
|
||||
- name: Build
|
||||
run: npm run build
|
||||
env:
|
||||
@@ -60,9 +50,11 @@ jobs:
|
||||
# own there (server.js serves .next/static), so an empty public/ is enough. Created here so
|
||||
# rsync --delete doesn't remove it on the server.
|
||||
- name: Prepare bundle
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
run: mkdir -p .next/standalone/public
|
||||
|
||||
- name: SSH setup
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
env:
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
|
||||
@@ -79,6 +71,7 @@ jobs:
|
||||
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$SSH_DIR/known_hosts"
|
||||
|
||||
- name: Upload
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
# Straight into the app folder (no release folders - decided 2026-11-08; a rollback is a
|
||||
# redeploy of an older commit). That folder is the one Plesk created for the subdomain,
|
||||
@@ -89,6 +82,7 @@ jobs:
|
||||
.next/standalone/ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/"
|
||||
|
||||
- name: Restart
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
# Passenger restarts the app on its next request when tmp/restart.txt is touched.
|
||||
ssh -p "${DEPLOY_PORT:-22}" -i "$SSH_DIR/key" -o "UserKnownHostsFile=$SSH_DIR/known_hosts" \
|
||||
@@ -98,7 +92,7 @@ jobs:
|
||||
# Optional until Plesk serves the Node app: set DEPLOY_SMOKE_URL then. Checks the page loads
|
||||
# and references the build's static files (the classic standalone failure is missing CSS/JS).
|
||||
- name: Smoke test
|
||||
if: vars.DEPLOY_SMOKE_URL != ''
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && vars.DEPLOY_SMOKE_URL != ''
|
||||
env:
|
||||
DEPLOY_SMOKE_URL: ${{ vars.DEPLOY_SMOKE_URL }}
|
||||
run: |
|
||||
@@ -112,5 +106,5 @@ jobs:
|
||||
echo "OK: page and $asset served"
|
||||
|
||||
- name: Remove key
|
||||
if: always()
|
||||
if: always() && github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
run: rm -f "$SSH_DIR/key"
|
||||
@@ -66,6 +66,9 @@ around:
|
||||
- This app can never read or verify the session. It calls `GET /admin/me` and believes the
|
||||
answer; the API's `requireAppAccess('calendar')` is the actual gate. `/admin/me` answers 200
|
||||
for an account without the calendar permission - check `apps`.
|
||||
- A calendar grant is `access` (may change things) or `read` (only look). Hide write controls
|
||||
with `useCanEdit()` / `canEditCalendar` (`lib/permissions.ts`), which mirrors the API's
|
||||
`canWrite`. Any new write control must check it.
|
||||
- 401 and 403 mean different things and must not be collapsed. 401 means "nobody is signed
|
||||
in" and is the only one worth redirecting to the login page - redirecting on 403 produces a
|
||||
loop where signing in succeeds and lands straight back on the refusal. See `app/admin/layout.tsx`.
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { LogOutIcon, RefreshCwIcon } from "lucide-react";
|
||||
import { EyeIcon, LogOutIcon, RefreshCwIcon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
@@ -11,6 +11,7 @@ import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Toaster } from "@/components/ui/sonner";
|
||||
import { goToAdminLogin, signOut } from "@/lib/admin-auth";
|
||||
import { api, ApiError } from "@/lib/api";
|
||||
import { canEditCalendar } from "@/lib/permissions";
|
||||
import type { AdminUser } from "@/lib/types";
|
||||
|
||||
type Failure = "denied" | "unavailable";
|
||||
@@ -82,6 +83,15 @@ export default function AdminLayout({ children }: { children: React.ReactNode })
|
||||
) : (
|
||||
<Skeleton className="hidden h-4 w-24 sm:block" />
|
||||
)}
|
||||
{me && !canEditCalendar(me) && (
|
||||
<span
|
||||
className="inline-flex h-6 items-center gap-1 rounded-full bg-muted px-2 text-xs font-medium text-muted-foreground"
|
||||
title="Dein Konto darf den Kalender ansehen, aber nichts ändern."
|
||||
>
|
||||
<EyeIcon aria-hidden className="size-3.5" />
|
||||
Nur lesen
|
||||
</span>
|
||||
)}
|
||||
{me && <SubscriptionsDialog />}
|
||||
<Button variant="ghost" size="sm" onClick={() => void signOut()} aria-label="Abmelden">
|
||||
<LogOutIcon />
|
||||
|
||||
+20
-13
@@ -6,6 +6,7 @@ import { toast } from "sonner";
|
||||
import { CalendarChips } from "@/components/admin/CalendarChips";
|
||||
import { EventList } from "@/components/admin/EventList";
|
||||
import { EventSheet, type SheetMode } from "@/components/admin/EventSheet";
|
||||
import { useCanEdit } from "@/components/admin/AdminSession";
|
||||
import { EventsToolbar } from "@/components/admin/EventsToolbar";
|
||||
import { PublishDialog } from "@/components/admin/PublishDialog";
|
||||
import { useEvents } from "@/components/admin/useEvents";
|
||||
@@ -32,6 +33,8 @@ export default function AdminPage() {
|
||||
|
||||
function EventsPage() {
|
||||
const [state, update] = useListState();
|
||||
// Read-only role: everything visible, no way to change it (the API refuses writes anyway).
|
||||
const canEdit = useCanEdit();
|
||||
const { events, loads, reload, refresh, upsertEvent, removeEvent } = useEvents();
|
||||
// Fixed per visit: "upcoming" should not reshuffle while someone is looking at it.
|
||||
const [now] = useState(() => new Date());
|
||||
@@ -138,10 +141,12 @@ function EventsPage() {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Button onClick={newEvent} className="hidden sm:inline-flex">
|
||||
<PlusIcon />
|
||||
Neuer Termin
|
||||
</Button>
|
||||
{canEdit && (
|
||||
<Button onClick={newEvent} className="hidden sm:inline-flex">
|
||||
<PlusIcon />
|
||||
Neuer Termin
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<EventsToolbar
|
||||
@@ -183,19 +188,21 @@ function EventsPage() {
|
||||
publishingId={publishingId}
|
||||
todayMarker={todayMarker}
|
||||
onOpen={(event) => openSheet({ kind: "edit", event })}
|
||||
onPublish={setConfirmPublish}
|
||||
onPublish={canEdit ? setConfirmPublish : undefined}
|
||||
onClearQuery={() => update({ query: "" })}
|
||||
/>
|
||||
|
||||
{/* Phones: a thumb-reach button instead of the header one. */}
|
||||
<Button
|
||||
onClick={newEvent}
|
||||
size="icon-lg"
|
||||
aria-label="Neuer Termin"
|
||||
className="fixed right-5 bottom-[calc(1.25rem+env(safe-area-inset-bottom))] z-20 size-14 rounded-full shadow-lg sm:hidden [&_svg:not([class*='size-'])]:size-6"
|
||||
>
|
||||
<PlusIcon />
|
||||
</Button>
|
||||
{canEdit && (
|
||||
<Button
|
||||
onClick={newEvent}
|
||||
size="icon-lg"
|
||||
aria-label="Neuer Termin"
|
||||
className="fixed right-5 bottom-[calc(1.25rem+env(safe-area-inset-bottom))] z-20 size-14 rounded-full shadow-lg sm:hidden [&_svg:not([class*='size-'])]:size-6"
|
||||
>
|
||||
<PlusIcon />
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<EventSheet
|
||||
key={sheet.key}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { createContext, useContext } from "react";
|
||||
import { canEditCalendar } from "@/lib/permissions";
|
||||
import type { AdminUser } from "@/lib/types";
|
||||
|
||||
/**
|
||||
@@ -19,3 +20,9 @@ export const useAdminUser = (): AdminUser => {
|
||||
}
|
||||
return user;
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether the account may change events. False for the read-only role: then
|
||||
* the admin area shows everything but offers no way to change it.
|
||||
*/
|
||||
export const useCanEdit = (): boolean => canEditCalendar(useAdminUser());
|
||||
@@ -39,7 +39,7 @@ export function EventList({
|
||||
/** Index into `events` to show the "Heute" marker in front of (`events.length` = after the last); null for none. */
|
||||
todayMarker: number | null;
|
||||
onOpen?: (event: CalendarEvent) => void;
|
||||
onPublish: (event: CalendarEvent) => void;
|
||||
onPublish?: (event: CalendarEvent) => void;
|
||||
onClearQuery: () => void;
|
||||
}) {
|
||||
if (noCalendars) {
|
||||
|
||||
@@ -23,7 +23,8 @@ export function EventListItem({
|
||||
now: Date;
|
||||
publishing: boolean;
|
||||
onOpen?: (event: CalendarEvent) => void;
|
||||
onPublish: (event: CalendarEvent) => void;
|
||||
/** Absent for a read-only account: then drafts show no publish button. */
|
||||
onPublish?: (event: CalendarEvent) => void;
|
||||
}) {
|
||||
const { start } = occurrence(event, now);
|
||||
const block = dateBlock(start);
|
||||
@@ -86,7 +87,7 @@ export function EventListItem({
|
||||
{repeat}
|
||||
</span>
|
||||
)}
|
||||
{event.status === "DRAFT" && (
|
||||
{event.status === "DRAFT" && onPublish && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { CircleAlertIcon, CopyIcon, LoaderCircleIcon, Trash2Icon, XIcon } from "lucide-react";
|
||||
import { CircleAlertIcon, CopyIcon, EyeIcon, LoaderCircleIcon, Trash2Icon, XIcon } from "lucide-react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { useAdminUser } from "@/components/admin/AdminSession";
|
||||
import { useAdminUser, useCanEdit } from "@/components/admin/AdminSession";
|
||||
import { EventForm, fieldId } from "@/components/admin/EventForm";
|
||||
import { useMediaQuery } from "@/components/admin/useMediaQuery";
|
||||
import {
|
||||
@@ -84,6 +84,9 @@ export function EventSheet({
|
||||
onDuplicate: (event: CalendarEvent) => void;
|
||||
}) {
|
||||
const user = useAdminUser();
|
||||
// Read-only role: the sheet becomes a view - same fields, nothing to save, delete or duplicate.
|
||||
// The page never opens it in "new" or "duplicate" mode for such an account.
|
||||
const readOnly = !useCanEdit();
|
||||
const desktop = useMediaQuery("(min-width: 640px)");
|
||||
|
||||
// What "unchanged" means. Moves forward after a partial save (moved, but the
|
||||
@@ -223,13 +226,13 @@ export function EventSheet({
|
||||
noValidate
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
void save();
|
||||
if (!readOnly) void save();
|
||||
}}
|
||||
className="flex min-h-0 flex-1 flex-col"
|
||||
>
|
||||
<SheetHeader className="flex-row items-start justify-between gap-3 border-b p-4">
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<SheetTitle>{TITLES[mode.kind]}</SheetTitle>
|
||||
<SheetTitle>{readOnly ? "Termin ansehen" : TITLES[mode.kind]}</SheetTitle>
|
||||
<SheetDescription className={mode.kind === "edit" ? "line-clamp-1" : undefined}>
|
||||
{mode.kind === "edit"
|
||||
? mode.event.name
|
||||
@@ -244,7 +247,7 @@ export function EventSheet({
|
||||
</SheetHeader>
|
||||
|
||||
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-5">
|
||||
<EventForm form={form} errors={showErrors ? errors : {}} disabled={busy} onChange={setForm} />
|
||||
<EventForm form={form} errors={showErrors ? errors : {}} disabled={busy || readOnly} onChange={setForm} />
|
||||
{original && <Metadata event={original} />}
|
||||
</div>
|
||||
|
||||
@@ -257,6 +260,17 @@ export function EventSheet({
|
||||
)}
|
||||
{/* Labels follow the footer's own width (container query), not the window's: the
|
||||
side panel is capped, so a wide window says nothing about the room in here. */}
|
||||
{readOnly ? (
|
||||
<div className="flex items-center gap-3">
|
||||
<p className="flex flex-1 items-center gap-2 text-sm text-muted-foreground">
|
||||
<EyeIcon aria-hidden className="size-4 shrink-0" />
|
||||
Du hast für den Kalender nur Lesezugriff.
|
||||
</p>
|
||||
<Button type="button" variant="outline" onClick={requestClose}>
|
||||
Schließen
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="@container flex items-center gap-2">
|
||||
{original && (
|
||||
<>
|
||||
@@ -298,6 +312,7 @@ export function EventSheet({
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { CalendarPlusIcon, CheckIcon, CircleAlertIcon, CopyIcon, RefreshCwIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -114,16 +114,19 @@ export function SubscriptionsDialog() {
|
||||
{subscription.icalUrl}
|
||||
</code>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button variant="outline" size="xs" render={<a href={toWebcal(subscription.icalUrl)} />}>
|
||||
{/* Plain links that only look like buttons. Rendering them through Base UI's
|
||||
Button made them role="button" (and warned without nativeButton={false}). */}
|
||||
<a href={toWebcal(subscription.icalUrl)} className={buttonVariants({ variant: "outline", size: "xs" })}>
|
||||
Apple Kalender
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
render={<a href={toGoogleCalendar(subscription.icalUrl)} target="_blank" rel="noopener noreferrer" />}
|
||||
</a>
|
||||
<a
|
||||
href={toGoogleCalendar(subscription.icalUrl)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={buttonVariants({ variant: "outline", size: "xs" })}
|
||||
>
|
||||
Google Kalender
|
||||
</Button>
|
||||
</a>
|
||||
<Button variant="outline" size="xs" onClick={() => void copy(subscription)}>
|
||||
{copied === calendar.slug ? <CheckIcon /> : <CopyIcon />}
|
||||
{copied === calendar.slug ? "Kopiert" : "Link kopieren"}
|
||||
|
||||
@@ -8,9 +8,17 @@ Done items move to the bottom.
|
||||
- **List the calendars.** Ids, slugs and names are hardcoded in `lib/calendars.ts` and must be kept in
|
||||
step with `calendarNames` in `events.router.ts`. An endpoint would make a new calendar a data change.
|
||||
- **All calendars in one request.** The admin list makes five parallel requests on every load.
|
||||
- **Restore / history.** Every save already writes a row to `event_versions`, and delete is a
|
||||
- **Restore.** Every save already writes a row to `event_versions`, and delete is a
|
||||
`DELETED` version - so "Wiederherstellen" and a change history are possible without schema changes,
|
||||
only endpoints are missing. The UI's delete dialog says it can't be undone "hier".
|
||||
- **Log moves.** Create, edit and delete each append a full version to `event_versions` with who
|
||||
(`version_created_by_user_id`) and when - but `PUT /move/:id` only runs
|
||||
`UPDATE events SET calendar_id = …`: who moved an event, when, and from which calendar is recorded
|
||||
nowhere (`event_versions` has no calendar column). Found 2026-11-08; deferred by the user. Fix:
|
||||
add `calendar_id` to `event_versions` and write a version on move too.
|
||||
- **Show the history in the UI.** With an endpoint like `GET /calendar/events/:id/versions`, the edit
|
||||
sheet could list who changed what and when. Today the UI shows only "Erstellt von" and "Zuletzt
|
||||
geändert von"; the full history is only reachable via SQL on `event_versions`.
|
||||
- **Don't return deleted events** from the admin feed (or behind a flag). They arrive as rows with
|
||||
every field `null` except `status`, and the client has to know to drop them.
|
||||
- **Richer recurrence.** `repeatFrequency` goes out as `RRULE:FREQ=<value>` with no interval, end
|
||||
|
||||
@@ -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
|
||||
|
||||
+7
-5
@@ -7,13 +7,15 @@ real deploy settles them - record the outcome here.
|
||||
|
||||
```
|
||||
push to master ──▶ Gitea ──▶ runner (Docker container on the Plesk server)
|
||||
├─ test job: npm ci, lint, tsc, test, build
|
||||
└─ deploy job: build ─ rsync over SSH ─▶ plesk-nachklang@server:<app root>
|
||||
└─ touch tmp/restart.txt
|
||||
└─ one job: npm ci, lint, tsc, test, build
|
||||
└─ (master only) rsync over SSH ─▶ plesk-nachklang@server:<app root>
|
||||
└─ touch tmp/restart.txt
|
||||
browser ──https──▶ Plesk (nginx + Passenger) ──▶ <app root>/server.js
|
||||
```
|
||||
|
||||
Pull requests only run the test job.
|
||||
Pull requests run the same job up to the build; the deploy steps only run for pushes to master.
|
||||
It used to be two jobs (test, then deploy); since every job starts in a fresh container that meant
|
||||
`npm ci` and the build twice (~2 min each), so they were merged on 2026-11-08.
|
||||
|
||||
## Why SSH and not mounted paths
|
||||
|
||||
@@ -155,7 +157,7 @@ to port 3000 if Passenger doesn't intercept.
|
||||
4. **Back up the Angular build**: download `calendar.nachklang.art/` as a ZIP in Plesk's file
|
||||
manager. The first deploy replaces those files, and this backup is the quick way back.
|
||||
5. **Merge** `feature/nextjs-rewrite` into master and watch the run under *Actions*. When the
|
||||
deploy job has finished, the folder holds the Next app but Plesk still serves it as static
|
||||
deploy steps have finished, the folder holds the Next app but Plesk still serves it as static
|
||||
files - **the subdomain is down from here until step 6** (no `index.html` any more).
|
||||
6. **Step 5 above, right away** - switch the subdomain to the Node app. This is the moment the new
|
||||
app goes live; doing it right after the run keeps the gap to a few minutes. (Plesk might accept
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -62,6 +62,15 @@ Collected during the rewrite (September 2026); the progress log in
|
||||
an `ssh host 'cmd'` never runs, exit 255). The deploy user uses plain `/bin/bash` instead.
|
||||
- **SSH is on port 42069**, not 22 (22 is closed); the deploy user is `plesk-nachklang`, not
|
||||
`nachklang`.
|
||||
- **Jenkins deployed as root.** Files it copied into an app folder belong to `root:root`, so the
|
||||
first Gitea deploy (as `plesk-nachklang`) fails with rsync "Operation not permitted" / "Permission
|
||||
denied". Before switching an app, run `find . ! -user plesk-nachklang` in its folder and
|
||||
`chown -R plesk-nachklang:psacln` what it lists (hit on the API, 2026-11-08; the calendar folder
|
||||
only held files directly in a folder the user owned, so deleting them worked).
|
||||
- **Every Gitea Actions job starts in a fresh container.** Splitting test and deploy into two jobs
|
||||
repeats checkout, Node setup and `npm ci` (and here the build); one job with the deploy steps
|
||||
conditioned on push-to-master is faster. Spell the condition out on each step instead of comparing
|
||||
an env flag to `'true'` - a mismatch there skips the deploy silently and the run stays green.
|
||||
- **Disable the Jenkins job before merging to master**, or it runs `ng build` on the next push.
|
||||
|
||||
## shadcn / Base UI
|
||||
@@ -73,6 +82,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
|
||||
|
||||
+2
-1
@@ -59,7 +59,8 @@ export const CALENDARS: readonly Calendar[] = [
|
||||
{
|
||||
id: 3,
|
||||
slug: "management",
|
||||
label: "Management",
|
||||
// Shown as "Vorstand" (user's wording, 2026-11-08); the slug stays "management" - it's the API's name.
|
||||
label: "Vorstand",
|
||||
defaultVisible: true,
|
||||
dotClass: "bg-amber-500",
|
||||
badgeClass: "bg-amber-50 text-amber-900 ring-amber-200",
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { AdminUser } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* May this account change calendar events? Mirrors `canWrite` in the API's
|
||||
* admin.schema.ts (docs/admin-roles.md there): only a grant with the role
|
||||
* `access` allows changes; `read` ("Nur lesen") sees everything and changes
|
||||
* nothing. The API refuses the writes regardless - this only decides which
|
||||
* controls to show.
|
||||
*
|
||||
* An API that predates roles sends no `permissions`. Then every calendar user
|
||||
* could write, so that is what this answers too.
|
||||
*/
|
||||
export const canEditCalendar = (user: Pick<AdminUser, "apps" | "permissions">): boolean => {
|
||||
if (!user.permissions) {
|
||||
return user.apps.includes("calendar");
|
||||
}
|
||||
return user.permissions.some((p) => p.app === "calendar" && p.role === "access");
|
||||
};
|
||||
@@ -82,5 +82,12 @@ export interface AdminUser {
|
||||
id: string;
|
||||
email: string;
|
||||
fullName: string;
|
||||
/** The distinct apps the account may open at all, whatever the role. */
|
||||
apps: string[];
|
||||
/**
|
||||
* The full (app, role) grants: `access` = may change things, `read` = may only
|
||||
* look. Missing on an API from before the read-only role (2026-10-29).
|
||||
* See lib/permissions.ts.
|
||||
*/
|
||||
permissions?: { app: string; role: string }[];
|
||||
}
|
||||
Reference in new issue
Block a user