Admin settings page (#5) #31

Merged
miko merged 1 commit from feature/5-admin-settings into development 2026-11-02 11:55:36 +01:00
Owner

Closes #5.

What

  • Prisma model Setting (key/value) with typed access and defaults in src/settings/settings.ts. A missing or invalid stored value falls back to its default.
  • Settings: session lifetime (days, 1–365), instance name, default UI locale (en/de), top-level child order.
  • /admin/settings, admins only (404 for everyone else, in both the page and the action). It shows the group → role mapping from KATABA_ADMIN_GROUP / KATABA_AUTHOR_GROUP read-only.
  • Auth.js lazy configuration reads maxAge from the settings. A change applies to sessions from their next sign-in or renewal.
  • The instance name is the Titlebar wordmark and the page title (%s · name template).

Beyond the ticket

  • With manual top-level child order, the settings page also lists the top-level categories with move buttons. The top level has no category page of its own, so without this a manual order couldn't be set. ArrangeChildren was pulled out of the category edit page for this.
  • A Settings link in the Titlebar for admins.

Notes

  • The default UI locale is stored but nothing reads it yet. Lingui isn't wired up (#3).
  • The instance name and metadata are rendered per request (connection() + cached loader), so next build doesn't need the database.
  • A running dev server needs a restart after this migration, because the Prisma client is cached on globalThis.

Checks

typecheck, lint, 209 tests and next build all pass. Tested manually against next start: the instance name shows in the title and Titlebar, and a guest gets a 404 on /admin/settings.

🤖 Generated with Claude Code

Closes #5. ## What - Prisma model `Setting` (key/value) with typed access and defaults in `src/settings/settings.ts`. A missing or invalid stored value falls back to its default. - Settings: session lifetime (days, 1–365), instance name, default UI locale (en/de), top-level child order. - `/admin/settings`, admins only (404 for everyone else, in both the page and the action). It shows the group → role mapping from `KATABA_ADMIN_GROUP` / `KATABA_AUTHOR_GROUP` read-only. - Auth.js lazy configuration reads `maxAge` from the settings. A change applies to sessions from their next sign-in or renewal. - The instance name is the Titlebar wordmark and the page title (`%s · name` template). ## Beyond the ticket - With manual top-level child order, the settings page also lists the top-level categories with move buttons. The top level has no category page of its own, so without this a manual order couldn't be set. `ArrangeChildren` was pulled out of the category edit page for this. - A Settings link in the Titlebar for admins. ## Notes - **The default UI locale is stored but nothing reads it yet.** Lingui isn't wired up (#3). - The instance name and metadata are rendered per request (`connection()` + cached loader), so `next build` doesn't need the database. - A running dev server needs a restart after this migration, because the Prisma client is cached on `globalThis`. ## Checks typecheck, lint, 209 tests and `next build` all pass. Tested manually against `next start`: the instance name shows in the title and Titlebar, and a guest gets a 404 on `/admin/settings`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Instance-wide settings stored as key/value rows in a new Setting model,
read typed with defaults (invalid stored values fall back to the default):
session lifetime, instance name, default UI locale and the top level's
child order.

- /admin/settings (admins only) edits them and shows the group → role
  mapping from the environment read-only; with manual top-level child
  order it also arranges the top-level categories
- Auth.js uses lazy configuration and reads the session lifetime from the
  settings
- The instance name is the Titlebar wordmark and the page title
- Admins get a Settings link in the Titlebar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit 65fd7be1d1 into development 2026-11-02 11:55:36 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!31
No description provided.