Cookies: fill empty languages, and one Cookies entry in the admin

Every language filled (fillEmptyLocales, default on): text saved in one
language goes to every language where the same field is still empty, never
over a language's own text. Applies to the cookie list (purpose, duration)
and the cookie review (purpose, duration). Scanner and approval writes give
a language without its own text the default language's text. Building
blocks: buildFillEmptyLocalesGlobalHook / CollectionHook, fillEmptyLocales,
withFillLocales.

One Cookies entry (cookieScanner.adminLayout, default combined): the
Cookie banner global is now labelled Cookies and gets Review and approve
(scan box and approval list inline) and Site check tabs, built from ui
fields. Cookie review and Cookie check leave the navigation
(admin.group false) but keep their pages, data and API. This is
presentation only: no schema change and no migration, only
generate:importmap. adminLayout separate keeps the old layout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-28 22:55:11 +01:00
co-authored by Claude Opus 5.5
parent a9e1adc03b
commit b10c2dc0e3
34 changed files with 812 additions and 96 deletions
+34 -9
View File
@@ -14,8 +14,10 @@ project.
## Config
The **CookieSettings** global (slug `cookie-settings`, group *Settings*) is always
built. Public read (`read: () => true` — the banner reads it for anonymous
The **CookieSettings** global — **Cookies** in the admin (slug `cookie-settings`, group *Privacy*) — is always
built. Tabs: *Banner*, *Settings window*, *Categories*, *Cookie list*; with the cookie scanner also
*Review and approve* and *Site check* (one entry for everything about cookies — see
[cookie-scanner.md → Admin layout](./cookie-scanner.md#admin-layout)). Public read (`read: () => true` — the banner reads it for anonymous
visitors); `update` is limited to the `admin` and `editor` roles (`adminOrEditor` —
consent texts are legal copy, not for plain `user` accounts). To change it:
`ipalKit({ globalOverrides: { 'cookie-settings': { access: { update } } } })`.
@@ -29,7 +31,7 @@ from a separate field.
| What | Where from |
|---|---|
| Where it leads | Site settings → System pages → Privacy Policy |
| Link text | Cookie banner → `privacyLinkLabel` (per language) |
| Link text | Cookies → `privacyLinkLabel` (per language) |
| When the text is empty | title of the policy page in that language |
`privacyPolicy` options in `getConsentTexts`: omit (automatic), `false` (no
@@ -65,7 +67,7 @@ export default async function Layout({ children, params }) {
const payload = await getPayload({ config })
// texts from Cookie banner; the policy link is automatic:
// target = System pages → Privacy Policy, text = Cookie banner → privacyLinkLabel
// target = System pages → Privacy Policy, text = Cookies → privacyLinkLabel
const texts = await getConsentTexts({ payload, config: i18nConfig, locale })
return (
@@ -248,7 +250,7 @@ Three settings modes to pick in the project — one prop:
<CookieBanner equalChoice controls="switch" settings="detailed" />
```
The cookie list comes from **Cookie banner → Cookie list** (the same source as `<CookieTable>` on the policy
The cookie list comes from **Cookies → Cookie list** (the same source as `<CookieTable>` on the policy
page), filtered by category — a category without entries has no expandable list. List labels: **Cookie
Settings → Detail labels** (`cookies` — e.g. "Cookies used", the counter is added automatically; `provider`,
`purpose`, `duration`), per language; empty → English. `getConsentTexts` passes this in `texts.cookies` /
@@ -266,7 +268,7 @@ Recommendation (AGENT.md §7): tokens and `classNames` first — then fixes from
project. When you need a completely different layout, you can build your own window; the data is in the
context: `useConsentContext()` → `texts.cookies`, `texts.details`, `state`, `savePreferences`.
Texts from the panel (**Cookie banner**, per language) — empty field = the element is not shown:
Texts from the panel (**Cookies**, per language) — empty field = the element is not shown:
| Field | Where |
|---|---|
@@ -286,7 +288,7 @@ The elements also have stable `data-ipal` handles for CSS and e2e tests (used by
`accept`, `back`, `save`; in modal mode also `consent-overlay`, `consent-dialog`, `close`; in detailed mode
additionally `category-<category>` (card) and `cookies` (expandable list).
Accessibility: the banner dialog and `CookieButton` have an `aria-label` from **Cookie banner →
Accessibility: the banner dialog and `CookieButton` have an `aria-label` from **Cookies →
title** or **settingsTitle** (per language) — no hard-coded texts in the components. The modal has
`aria-modal`, focus on ✕ after opening and closes on Escape; switches have `role="switch"` and `aria-checked`.
@@ -330,9 +332,32 @@ independent consent state).
> The consent mechanism for the locale is also described from the i18n side:
> [i18n.md](./i18n.md#locale-cookie-and-consent-gdpr).
## Every language filled (`fillEmptyLocales`)
The cookie list's **Purpose** and **Duration** are per language. Text an editor writes in one language
is copied to every language where that field is still empty, when the document is saved — a cookie
added in Polish is not blank on the English page. A language that already has its own text is never
overwritten, so each language can still be changed on its own. The same applies to the cookie review
entries (purpose, duration). Cookie scanner and approval writes do the same with their own texts:
English and Polish where they exist, the default language's text for any other language.
Payload's `localization.fallback` covers only part of this: an empty language *reads* as the default
language's text, but nothing is stored, the admin shows the field empty, and the text always comes
from the default language, not from the one just edited.
| Option | Default | |
|---|---|---|
| `fillEmptyLocales` | `true` | `false` = off; `{ 'cookie-settings': ['cookies.purpose'], 'cookie-review': [] }` = choose the fields per slug (`[]` = off for that slug). Field paths: `'field'` or `'arrayField.subField'` |
Building blocks for your own globals and collections (`@intecion/ipal-kit`):
`buildFillEmptyLocalesGlobalHook({ global, fields })`, `buildFillEmptyLocalesCollectionHook({ collection, fields })`
(afterChange hooks), `fillEmptyLocales({ payload, target, source, sourceLocale, fields, req? })` (the
core, `FillEmptyLocalesTarget` = `{ global }` or `{ collection, id }`), and `withFillLocales(kind, config, fields)`
to add the hook to a config. Nothing to migrate.
## Policy version, withdrawing consent, consent log, cookie table (1.9.1)
- **New consent after a policy change:** Cookie banner → *Consent version* (sidebar). Raise it by 1
- **New consent after a policy change:** Cookies → *Consent version* (sidebar). Raise it by 1
after adding a tool or changing the policy — every visitor will see the banner again.
`getConsentTexts` passes the version to `<ConsentProvider texts>` automatically.
- **Withdrawing consent deletes the tools' cookies** (`_ga`, `_ga_*`, `_gid`, `_fbp`, `_gcl_*`, Clarity,
@@ -348,7 +373,7 @@ independent consent state).
choices, the policy version and the time — **no IP and no user agent**. *Consent records* collection
(admin only), automatic cleanup after `retentionDays` (default 1095). Details below. Postgres:
`migrate:create`.
- **Cookie table** for the policy page: Cookie banner → *Cookie list* + `getCookieTable` + `<CookieTable>` from `/rsc`.
- **Cookie table** for the policy page: Cookies → *Cookie list* + `getCookieTable` + `<CookieTable>` from `/rsc`.
Fill the list from the panel with the cookie scanner (`cookieScanner` option — one approval adds every cookie found to the list, the table and the detailed window,
[cookie-scanner.md](./cookie-scanner.md)) and check the real site with `ipal-consent-check` → cookie-scan.
- Consent cookie: `cookie-consent` (`CONSENT_COOKIE`), JSON `{ id, state, timestamp, version }`,