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
+45 -11
View File
@@ -1,6 +1,6 @@
# cookie scanner
Fills the cookie list (Cookie banner → Cookie list) from the admin panel. A scan lists the cookies of
Fills the cookie list (Cookies → Cookie list) from the admin panel. A scan lists the cookies of
every integration the project switches on, plus any extra names, in a review list. The editor then
sees **one summary** — *Approve cookies*, grouped by consent category, new / changed / unknown marked —
and one button, **Approve and add**, puts every ticked cookie everywhere it is listed: the cookie list,
@@ -30,8 +30,10 @@ ipalKit({
Then, in the project:
1. **Import map** — the "Scan cookies" box above the list is an admin component
(`@intecion/ipal-kit/admin#CookieScanButton`). Run `pnpm generate:importmap`.
1. **Import map** — the scan box, the *Review and approve* / *Site check* tabs and the approval view
are admin components (`@intecion/ipal-kit/admin#CookieScanButton`, `#CookieReviewTab`,
`#CookieSiteCheckTab`, `#CookieApprovalView`). Run `pnpm generate:importmap` (again after upgrading
to the combined layout — the two tab components are new).
2. **Postgres / SQLite migration** — the option adds the `cookie-review` collection (with localized
`purpose` and `retention`). Run `pnpm payload migrate:create cookie-scanner`, commit the migration;
Coolify runs `payload migrate` on deploy (deployment.md). MongoDB: nothing to do.
@@ -39,11 +41,37 @@ Then, in the project:
fields to `cookie-review` — `change` (select) and `needsDescription` (checkbox). Run
`pnpm payload migrate:create cookie-approval` and commit it. Existing entries keep their status;
accepted ones are not re-approved, drafts show up on the approval page without a marker.
3. **Verify** — log in as an editor, open *Privacy → Cookie review*. The box lists "Integrations in
use" (e.g. Cookie banner, Admin panel login, Google Analytics 4). Click **Scan cookies**: the box
says "Waiting for approval: N" with **Review and approve**. Open it (`/admin/cookie-approval`): the
cookies are grouped by category. Click **Approve and add**, then open *Cookie banner → Cookie
list*: the cookies are there, with purpose and retention in every language.
3. **Verify** — log in as an editor, open *Privacy → Cookies → Review and approve*. The box lists
"Integrations in use" (e.g. Cookie banner, Admin panel login, Google Analytics 4). Click **Scan
cookies**: the cookies found appear below, grouped by category. Click **Approve and add**; the page
reloads — open the *Cookie list* tab: the cookies are there, with purpose and duration in every
language.
## Admin layout
One **Cookies** entry in *Privacy* holds everything (`adminLayout: 'combined'`, the default):
| Tab | What it is |
|---|---|
| Banner, Settings window, Categories | the banner texts ([consent.md](./consent.md)) |
| Cookie list | the cookies shown in the banner's detailed window and the cookie policy table |
| Review and approve | the scan box and the approval list inline; **Edit cookies one by one** opens the review entries |
| Site check | only with `crawl`: start a check, its status, the violations of the latest check, a link to the warning e-mail settings |
The review list (`cookie-review`) and the site check result (`cookie-crawl`) leave the navigation
(`admin.group: false`) but keep their pages, data and API — links from the dashboard, the e-mail and
**Edit** still open them, and `/admin/cookie-approval` still works. The two tabs are `ui` fields: no data,
no schema change, **no migration** — only `pnpm generate:importmap`. Approving in the tab writes the
cookie list of the same screen, so the page reloads afterwards; while the screen has unsaved changes the
button waits ("Save your changes first.").
`adminLayout: 'separate'` keeps the older layout: *Cookie review* and *Cookie check* as their own
navigation entries, no extra tabs. A project's `collectionOverrides` / `crawl.globalOverride` (e.g. its own
`admin.group`) win in both layouts.
Every language is filled: text written in one language (in the cookie list or a review entry) goes to
the languages where that field is still empty, never over a language's own text
([consent.md → Every language filled](./consent.md#every-language-filled-fillemptylocales)).
## How editors use it
@@ -51,9 +79,9 @@ Then, in the project:
|---|---|
| **Scan cookies** | Every cookie of the integrations in use goes into the review list, marked **New**. Rows typed into the cookie list by hand are looked up once (*In the cookie list* is ticked). Nothing is added to the cookie banner yet. |
| **More cookie names** (optional text box) | Names seen in the browser (DevTools → Application → Cookies), one per line. Each is looked up in the project's declarations, every built-in integration, then the Open Cookie Database. A name nothing knows is marked **Needs description**. |
| **Review and approve** | The *Approve cookies* view (`/admin/cookie-approval`, linked from the box and the dashboard): one table per consent category (Necessary, Functional, Analytics, Marketing, then *Not yet described*), each cookie with provider, purpose and duration in the content language that matches the admin language, markers **New**, **Changed**, **Needs description**, an **Edit** link and a tick box. |
| **Review and approve** | The *Review and approve* tab of *Cookies* (the same list is also at `/admin/cookie-approval`, linked from the dashboard and the e-mail): one table per consent category (Necessary, Functional, Analytics, Marketing, then *Not yet described*), each cookie with provider, purpose and duration in the content language that matches the admin language, markers **New**, **Changed**, **Needs description**, an **Edit** link and a tick box. |
| Untick or edit | Untick a cookie to leave it waiting; **Edit** opens its review entry (provider, category, purpose, duration per language). A later scan keeps every value you changed and still updates values you left as suggested. |
| **Approve and add** | Every ticked cookie becomes *Accepted* and is added to *Cookie banner → Cookie list* in every language, with the plugin's English and Polish texts (other languages get the English text). A row that already lists the cookie — the same name, or a pattern that covers it, e.g. `_ga_*` and `_ga_XYZ123` — is never duplicated: only its empty provider / purpose / duration are filled, its text and category stay. The cookie list feeds the cookie policy table and the banner's detailed window, so the cookie appears there too. |
| **Approve and add** | Every ticked cookie becomes *Accepted* and is added to *Cookies → Cookie list* in every language, with the plugin's English and Polish texts (a language without its own text gets the default language's text). A row that already lists the cookie — the same name, or a pattern that covers it, e.g. `_ga_*` and `_ga_XYZ123` — is never duplicated: only its empty provider / purpose / duration are filled, its text and category stay. The cookie list feeds the cookie policy table and the banner's detailed window, so the cookie appears there too. |
| Unknown cookies | Approved into a category that needs consent (`approval.unknownCategory`, default `marketing`) and flagged **Needs description** on the review entry; writing a purpose clears the flag. |
| A scan finds a change | An accepted cookie whose suggested text changed is marked **Changed** and waits for approval again; approving it fills only empty text in the cookie list. |
| A cookie disappears | An integration switched off, a declaration removed, or a cookie the site check no longer sees: the entry is marked **No longer found** and listed under that heading on the approval page. Nothing is deleted — the cookie list keeps its row until an editor removes it there. Found again → the mark goes away. |
@@ -148,6 +176,7 @@ run the tests, commit.
| `approval.unknownCategory` | `'marketing'` | category given to cookies nothing knows when they are approved; pick one that needs consent (`functional`, `analytics`, `marketing`) |
| `approval.dashboard` | `true` | `false` = no "Waiting for approval" reminder on the dashboard |
| `crawl` | off | browser crawl through the scanner service — [Browser crawl](#browser-crawl) |
| `adminLayout` | `'combined'` | one *Cookies* entry with *Review and approve* and *Site check* tabs; `'separate'` = own navigation entries — [Admin layout](#admin-layout) |
A project declaration:
@@ -235,6 +264,10 @@ All from `@intecion/ipal-kit` (server-safe), for your own admin view, a CLI or a
| `buildCookieReviewCollection(options)`, `buildCookieScanEndpoints(options, plugin)` | the collection and endpoints, to wire by hand |
| `COOKIE_SCAN_LABELS`, `mergeCookieScanLabels(overrides)` | admin labels |
| `CookieScanButton` (`/admin`) | the box above the list (with **Check site** when `crawl` is on) |
| `CookieReviewTab`, `CookieSiteCheckTab` (`/admin`) | the two tabs of the combined layout (client components; props `approval`, `labels`, `unknownCategory` / `labels`) |
| `addCookieScannerTabs(global, { approval, crawl, labels, unknownCategory? })` | adds those tabs to a global with a `tabs` field — for a project that builds its own cookie global |
| `CookieScanButton` props `scan` / `onChange` | hide the scan part (the Site check tab) / called after a scan or a finished check |
| `CookieApprovalForm` props `onApproved` / `blockedReason` | after approving (the tab reloads the page) / why the button waits |
| `CookieCrawlAlert` (`/admin`) | the dashboard warning: cookies waiting for approval, and with `crawl` violations or a failed check (props `approval`, `crawl`) |
| `buildCookieCrawlGlobal(labels)`, `buildCookieCrawlEndpoints({ labels, options, plugin })` | the crawl's global and endpoints, to wire by hand |
| `resolveCrawlConfig(crawlOptions, payload)` | options + env + `serverURL` → `ResolvedCrawlConfig` (what is missing) |
@@ -420,12 +453,13 @@ as unknown into **More cookie names**.
## Turn off, override, extend
- **Separate screens:** `adminLayout: 'separate'`.
- **Turn off one approval:** `approval: false` — per-entry review only (set *Accepted* on each entry), no
approval view, endpoint or reminder.
- **Turn off the crawl only:** omit `crawl` (default) — no `cookie-crawl` global, no crawl endpoints, no
dashboard warning, no violation fields; `dashboard: false` keeps the crawl without the warning.
- **Turn off:** omit `cookieScanner` (default). Turning it off later keeps no endpoint and no
collection; Cookie banner → Cookie list keeps every row (it is still edited by hand or by the skill's
collection; Cookies → Cookie list keeps every row (it is still edited by hand or by the skill's
import script).
- **Override:** `collectionOverrides` (access, admin, hooks), `access` (who scans), `labels`,
`databaseCategories`, `integrations` (change or drop a built-in), `syncAccepted: false`,