Codebase audits, privacy, dark mode, palette (v1.9.0 to v1.9.4-audit) #14

Merged
ngu-git-admin merged 30 commits from audit into main 2026-09-29 18:07:25 +01:00
2 changed files with 9 additions and 9 deletions
Showing only changes of commit f94f1a6584 - Show all commits

View file

@ -71,7 +71,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu
- **Admin editor text:** blank select options read `Default: …` (what blank means), examples in help text start with `eg.`, and record ids are called "URL ID". Cut-off preview text uses `preview()` from `src/lib/text.ts`, which ends it with an ellipsis. See `docs/updating-data-in-code.md`. - **Admin editor text:** blank select options read `Default: …` (what blank means), examples in help text start with `eg.`, and record ids are called "URL ID". Cut-off preview text uses `preview()` from `src/lib/text.ts`, which ends it with an ellipsis. See `docs/updating-data-in-code.md`.
## Admin CRUD engine ## Admin CRUD engine
Descriptor-driven: `server/src/admin-crud.js` and `server/src/admin-schema.js` (server) and `adminSchema.ts` (client) generate SQL and form fields from declarative entity configs. Adding an entity should mean adding a descriptor, not new CRUD code. Descriptor-driven: `server/src/admin-crud.js` and `server/src/admin-schema.js` (server) and `src/lib/adminSchema/` (client, one file per entity, registered in `adminSchema.ts`) generate SQL and form fields from declarative entity configs. Adding an entity should mean adding a descriptor, not new CRUD code.
- Child collections are deleted and reinserted wholesale. Unsafe for entities referenced by foreign keys elsewhere. - Child collections are deleted and reinserted wholesale. Unsafe for entities referenced by foreign keys elsewhere.
- `reindex: false` prevents cross-entity sort order collisions. - `reindex: false` prevents cross-entity sort order collisions.
- The `OMIT` sentinel distinguishes unsent fields from deliberate clears. - The `OMIT` sentinel distinguishes unsent fields from deliberate clears.

View file

@ -49,7 +49,7 @@ each entity:
| File | What it holds | | File | What it holds |
| ----------------------------- | ----------------------------------------------------- | | ----------------------------- | ----------------------------------------------------- |
| `src/lib/adminSchema.ts` | The **form**: field labels, help text, dropdown labels, list columns and filters | | `src/lib/adminSchema/` (one file per entity, `shared.ts` for common fields; `src/lib/adminSchema.ts` lists them) | The **form**: field labels, help text, dropdown labels, list columns and filters |
| `server/src/admin-schema.js` | What the server **accepts**: columns, types, the allowed values of each `enumeration(...)` | | `server/src/admin-schema.js` | What the server **accepts**: columns, types, the allowed values of each `enumeration(...)` |
And the database itself holds the final word: most fixed lists are a And the database itself holds the final word: most fixed lists are a
@ -76,7 +76,7 @@ organization name in the label, as the `awards` query does.
> are changed with a migration: `UPDATE event_scopes SET name = '…' WHERE id = '…';` > are changed with a migration: `UPDATE event_scopes SET name = '…' WHERE id = '…';`
**2. A fixed list in code (`options`).** The choices are written in **2. A fixed list in code (`options`).** The choices are written in
`src/lib/adminSchema.ts`. Each option is one of two shapes: the entity's file in `src/lib/adminSchema/`. Each option is one of two shapes:
```ts ```ts
options: ["speaker", "leader", "host"] // shows: speaker, leader, host options: ["speaker", "leader", "host"] // shows: speaker, leader, host
@ -90,7 +90,7 @@ relabelling cheap.
### Renaming what a dropdown shows ### Renaming what a dropdown shows
If the stored value stays the same and you only want the dropdown to If the stored value stays the same and you only want the dropdown to
read differently, **only `src/lib/adminSchema.ts` changes**. No read differently, **only the file in `src/lib/adminSchema/` changes**. No
migration, no server change, and every existing row keeps working. migration, no server change, and every existing row keeps working.
Find the field (search for its column name) and give the option a Find the field (search for its column name) and give the option a
@ -147,7 +147,7 @@ together, in one branch:
decide what existing rows become first. decide what existing rows become first.
2. **`server/src/admin-schema.js`**: the `enumeration("column", [...])` 2. **`server/src/admin-schema.js`**: the `enumeration("column", [...])`
list for that column. list for that column.
3. **`src/lib/adminSchema.ts`**: the `options` on the form field, and on 3. **`src/lib/adminSchema/<entity>.ts`**: the `options` on the form field, and on
the list filter if there is one. the list filter if there is one.
4. **Anywhere the public site renders or relies on the value**, listed in 4. **Anywhere the public site renders or relies on the value**, listed in
the table below (for example `EVENT_TYPES` for event types, or the the table below (for example `EVENT_TYPES` for event types, or the
@ -160,7 +160,7 @@ wrong rather than working around it.
### Every dropdown in the editor ### Every dropdown in the editor
**Fixed lists** (`options`: labels in `src/lib/adminSchema.ts`, values **Fixed lists** (`options`: labels in `src/lib/adminSchema/`, values
also in `admin-schema.js` and a CHECK): also in `admin-schema.js` and a CHECK):
| Entity → field | Stored values | Labelled? | Also used on the public site by | | Entity → field | Stored values | Labelled? | Also used on the public site by |
@ -176,7 +176,7 @@ also in `admin-schema.js` and a CHECK):
| Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` | | Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` |
| Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. | | Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. |
| Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) | | Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) |
| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema.ts`). | | Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). |
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` | | Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` |
| Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` | | Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` |
| Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping | | Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |
@ -219,7 +219,7 @@ each is changed in a different place:
| --- | --- | | --- | --- |
| **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. | | **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. |
| The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry | | The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry |
| **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema.ts` | | **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema/frontPage.ts` |
| The subnav links under the header ("#Retreats", "#Calendar") | `PAGE_SECTIONS["/"]` in `src/navConfig.ts` | | The subnav links under the header ("#Retreats", "#Calendar") | `PAGE_SECTIONS["/"]` in `src/navConfig.ts` |
To rename a band **for visitors**, use the admin. To rename how it To rename a band **for visitors**, use the admin. To rename how it
@ -253,7 +253,7 @@ CHECK on `front_page_sections.section` via a migration.
The numbers band's "Number Source" dropdown works the same way: The numbers band's "Number Source" dropdown works the same way:
- **Relabel a source:** `STAT_SOURCES` in `src/lib/adminSchema.ts`. - **Relabel a source:** `STAT_SOURCES` in `src/lib/adminSchema/frontPage.ts`.
- **Change what a count counts:** its query in `STAT_QUERIES` in - **Change what a count counts:** its query in `STAT_QUERIES` in
`server/src/routes/home.js`. Keep it counting exactly what the `server/src/routes/home.js`. Keep it counting exactly what the
matching public page shows (published rows), or the number and the matching public page shows (published rows), or the number and the