@simmalugnt-se/payload-consent 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.3
4
+
5
+ - The Scan tab's findings follow the card above them. Each group (Needs action, Not in the Cookie
6
+ services, In order) is a Payload Collapsible with its count in the card's colours; In order
7
+ starts closed. A finding shows its name and where it was seen as a short list, the Open Cookie
8
+ Database's suggestion in a box of its own, and Add to service with Payload's text and select
9
+ fields in place of the browser's. Enter in Service adds the finding instead of saving the
10
+ Cookies form. The groups' explanations say what to do rather than repeat the card.
11
+ - A finding reads in plain words. It leads with its service, or "Looks like Meta Pixel" from the
12
+ Open Cookie Database, and says in one sentence what it is and when it appeared: "Cookie set for
13
+ new visitors before they choose, although Statistics is not allowed then. Also after the visitor
14
+ accepts." The raw name, domain, category, tracker lists and a page it was seen on follow on a
15
+ quieter line. "Stored in the browser" and "Contacts another site" replace "localStorage" and
16
+ "Third-party host", in the card's counts too.
17
+
18
+ ## 0.6.2
19
+
20
+ - The Scan tab opens with a card for the scan. While it runs, the card follows it page by page
21
+ (`New visitor · page 3 of 10 · state 1 of 3`), with a progress bar, the time taken and a rough
22
+ time left; before, it showed only the state. When it ends, the card says what it means, such as
23
+ "Nothing to fix" or "2 need action", counts the pages visited, states, cookies, localStorage
24
+ keys and other sites, lists the pages, and puts what kept a scan from being complete in words.
25
+ The scan's settings follow the card. Page by page progress needs `consent-scanner` at `1274a32`
26
+ or later; with an older one the card shows the state alone.
27
+
3
28
  ## 0.6.1
4
29
 
5
30
  - `scanner.pages` sends a list per collection, and the scanner picks from each as from one sitemap:
package/README.md CHANGED
@@ -139,11 +139,16 @@ Each collection goes as its own list, and the scanner picks from each as from on
139
139
  thousand news articles do not crowd out the pages; the lists share at most 500 addresses, each
140
140
  thinned evenly. Without the option, or when no page is left, the scanner reads the sitemaps.
141
141
 
142
- Scan now scans the site's address (the field above the button, or `serverURL`) as a new visitor,
142
+ Scan now scans the site's address (the Site address field, or `serverURL`) as a new visitor,
143
143
  after rejecting, after accepting and, with several optional categories, with each one alone. The
144
- plugin presets c15t's cookie for each state, so no click is needed. The scanner posts the result
145
- back to `/api/consent-scans/result`, and the tab shows every cookie, localStorage key and
146
- third-party host:
144
+ plugin presets c15t's cookie for each state, so no click is needed. While it runs, the card at the
145
+ top of the Scan tab follows it page by page, with the time it has taken and a rough time left.
146
+
147
+ The scanner posts the result back to `/api/consent-scans/result`. The card then says what it
148
+ means: nothing to fix, how many need action or are not explained, or that the scan could not see
149
+ everything and why, in words rather than the scanner's errors. It counts the pages visited, the
150
+ states, cookies, localStorage keys and other sites, and lists the pages. Below it, the tab shows
151
+ every cookie, localStorage key and third-party host:
147
152
 
148
153
  - **Needs action**: a service seen in a state that does not allow its category, such as analytics
149
154
  before consent.
@@ -1,44 +1,111 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { Button, Pill, useConfig, useFormFields, useLocale, useTranslation } from "@payloadcms/ui";
3
+ import { Button, Collapsible, Pill, SelectInput, TextInput, useConfig, useFormFields, useLocale, useTranslation, } from "@payloadcms/ui";
4
4
  import { useCallback, useEffect, useState } from "react";
5
5
  import { CATEGORIES } from "../defaults.js";
6
6
  import { CONSENT_SCANS } from "../types.js";
7
+ import { describeProblem, estimateLeft, findingHeading, finishedPages, formatElapsed, pagePath, scanVerdict, } from "./scan-view.js";
7
8
  import "../styles/admin.css";
8
9
  const COPY = {
9
10
  en: {
10
11
  noScanner: "No scanner is set up. Give the plugin `scanner: { url, token }` (see the README), then scan from here.",
11
12
  scan: "Scan now",
12
13
  starting: "Starting…",
13
- none: "The site has not been scanned yet.",
14
- queued: (position) => position
15
- ? `Waiting for the scanner, number ${position} in line.`
16
- : "Waiting for the scanner.",
17
- running: (progress) => `Scanning${progress ? `: ${progress}` : "…"}`,
18
- failed: "The scan failed:",
19
- incomplete: "The scan is incomplete, so it may have missed something. Fix what is listed and scan again:",
20
- done: (date, pages) => `Scanned ${date}, ${pages} pages.`,
14
+ card: {
15
+ pills: {
16
+ none: "Not scanned",
17
+ queued: "Waiting",
18
+ running: "Scanning",
19
+ failed: "Failed",
20
+ action: "Needs action",
21
+ unknown: "Not explained",
22
+ incomplete: "Incomplete",
23
+ ok: "In order",
24
+ clean: "In order",
25
+ },
26
+ newPill: (n) => `${n} new`,
27
+ title: {
28
+ none: "The site has not been scanned yet",
29
+ queued: "Waiting for the scanner",
30
+ running: "Scanning the site",
31
+ failed: "The scan failed",
32
+ action: (n) => `${n} ${n === 1 ? "needs" : "need"} action`,
33
+ unknown: (n) => `${n} not in the Cookie services`,
34
+ incomplete: "The scan could not see everything",
35
+ ok: "Nothing to fix",
36
+ clean: "Nothing to fix",
37
+ },
38
+ text: {
39
+ none: "Scan now to see which cookies, storage and other sites the published site uses, before and after the visitor's choice.",
40
+ queued: (position) => position ? `Number ${position} in line.` : "It starts when the scanner is free.",
41
+ choosing: "Choosing the pages to visit…",
42
+ action: "Services load where the visitor has not allowed their category.",
43
+ unknown: "The scan found storage or other sites that no Cookie service explains.",
44
+ incomplete: "It may have missed something. Scan again once this is fixed:",
45
+ ok: "Everything the scan found is in the Cookie services and loads only where its category is allowed.",
46
+ clean: "The scan found no cookies, no storage and no requests to other sites.",
47
+ },
48
+ stage: (state, stage) => [
49
+ state,
50
+ stage.page ? `page ${stage.page} of ${stage.pages}` : "starting",
51
+ ...(stage.states > 1 ? [`state ${stage.stateNumber} of ${stage.states}`] : []),
52
+ ].join(" · "),
53
+ elapsed: (time, left) => (left ? `${time} · about ${left} left` : time),
54
+ progress: (finished, total) => `${finished} of ${total} page visits done`,
55
+ stats: {
56
+ pages: (n, of) => n === of ? (n === 1 ? "page" : "pages") : `of ${of} ${of === 1 ? "page" : "pages"}`,
57
+ states: (n) => (n === 1 ? "state" : "states"),
58
+ cookies: (n) => (n === 1 ? "cookie" : "cookies"),
59
+ storage: () => "stored in the browser",
60
+ hosts: (n) => (n === 1 ? "other site" : "other sites"),
61
+ },
62
+ scanned: (date, took) => `Scanned ${date}${took ? ` · took ${took}` : ""}`,
63
+ states: (count, states) => `${count === 1 ? "State" : "States"}: ${states}`,
64
+ pages: (n) => `Scanned pages (${n})`,
65
+ all: "All scans",
66
+ problems: {
67
+ notScanned: (state) => `${state}: not scanned`,
68
+ noPages: (state) => `${state}: no page could be visited`,
69
+ outOfTime: (state) => `${state}: the scan ran out of time`,
70
+ pagesFailed: (state) => `${state}: some pages could not be scanned`,
71
+ sitemap: (sitemap) => `The sitemap ${sitemap} could not be read`,
72
+ other: () => "The scanner reported a problem",
73
+ },
74
+ },
21
75
  groups: {
22
76
  action: "Needs action",
23
77
  unknown: "Not in the Cookie services",
24
78
  ok: "In order",
25
79
  },
26
80
  explain: {
27
- action: "These services load in a state where their category is not allowed. Load them through the plugin (Loaded by: this plugin) or make the site's code wait for consent.",
28
- unknown: "Nothing in the Cookie services explains these. Add each to a service, or remove it from the site.",
29
- ok: "Explained by the Cookie services and seen only where their category is allowed.",
81
+ action: "Seen where their category is not allowed. Set Loaded by on the service to “This plugin, after consent”, or make the site's code wait for consent.",
82
+ unknown: "Add each to a service, new or existing, or remove it from the site.",
83
+ ok: "In a Cookie service, and seen only where its category is allowed.",
84
+ },
85
+ // What the finding is, leading the sentence of when it was seen.
86
+ seen: {
87
+ cookie: "Cookie set",
88
+ localStorage: "Stored in the browser",
89
+ host: "Contacts another site",
30
90
  },
31
- kinds: { cookie: "Cookie", localStorage: "localStorage", host: "Third-party host" },
91
+ when: {
92
+ "no-choice": "for new visitors before they choose",
93
+ "reject-all": "after the visitor rejects",
94
+ "accept-all": "after the visitor accepts",
95
+ },
96
+ whenOnly: (category) => `when only ${category} is allowed`,
97
+ notAllowed: (category) => `, although ${category} is not allowed then`,
98
+ also: (when) => `Also ${when}.`,
99
+ looksLike: (platform) => `Looks like ${platform}`,
100
+ database: "Open Cookie Database",
101
+ trackerLists: (lists) => `On tracker lists: ${lists}`,
102
+ seenOn: "A page it was seen on",
32
103
  beforeConsent: "Before consent",
33
104
  isNew: "New",
34
- seenIn: "Seen in",
35
- withoutConsent: "without consent in",
36
105
  service: "Service",
37
106
  category: "Category",
38
107
  add: "Add to service",
39
108
  adding: "Adding…",
40
- suggestion: "Suggestion",
41
- trackerList: "On tracker list",
42
109
  states: {
43
110
  "no-choice": "new visitor",
44
111
  "reject-all": "after rejecting",
@@ -51,39 +118,105 @@ const COPY = {
51
118
  measurement: "Statistics",
52
119
  marketing: "Marketing",
53
120
  },
54
- summary: (s) => `${s.action} need action · ${s.unknown} unknown · ${s.ok} in order${s.new ? ` · ${s.new} new` : ""}`,
55
121
  },
56
122
  sv: {
57
123
  noScanner: "Ingen skanner är inställd. Ge pluginet `scanner: { url, token }` (se README), och skanna sedan härifrån.",
58
124
  scan: "Skanna nu",
59
125
  starting: "Startar…",
60
- none: "Webbplatsen har inte skannats än.",
61
- queued: (position) => position ? `Väntar på skannern, nummer ${position} i kön.` : "Väntar på skannern.",
62
- running: (progress) => `Skannar${progress ? `: ${progress}` : "…"}`,
63
- incomplete: "Skanningen är ofullständig och kan ha missat något. Åtgärda det som står här och skanna igen:",
64
- failed: "Skanningen misslyckades:",
65
- done: (date, pages) => `Skannad ${date}, ${pages} sidor.`,
126
+ card: {
127
+ pills: {
128
+ none: "Inte skannad",
129
+ queued: "Väntar",
130
+ running: "Skannar",
131
+ failed: "Misslyckades",
132
+ action: "Åtgärd krävs",
133
+ unknown: "Okänt",
134
+ incomplete: "Ofullständig",
135
+ ok: "I ordning",
136
+ clean: "I ordning",
137
+ },
138
+ newPill: (n) => `${n} nya`,
139
+ title: {
140
+ none: "Webbplatsen har inte skannats än",
141
+ queued: "Väntar på skannern",
142
+ running: "Skannar webbplatsen",
143
+ failed: "Skanningen misslyckades",
144
+ action: (n) => `${n} kräver åtgärd`,
145
+ unknown: (n) => `${n} finns inte bland Cookietjänsterna`,
146
+ incomplete: "Skanningen kunde inte se allt",
147
+ ok: "Inget att åtgärda",
148
+ clean: "Inget att åtgärda",
149
+ },
150
+ text: {
151
+ none: "Skanna nu för att se vilka cookies, vilken lagring och vilka andra webbplatser den publicerade webbplatsen använder, före och efter besökarens val.",
152
+ queued: (position) => position ? `Nummer ${position} i kön.` : "Den startar när skannern är ledig.",
153
+ choosing: "Väljer vilka sidor som ska besökas…",
154
+ action: "Tjänster laddas där besökaren inte har tillåtit kategorin.",
155
+ unknown: "Skanningen hittade lagring eller andra webbplatser som ingen Cookietjänst förklarar.",
156
+ incomplete: "Den kan ha missat något. Skanna igen när det här är åtgärdat:",
157
+ ok: "Allt skanningen hittade finns bland Cookietjänsterna och laddas bara där kategorin är tillåten.",
158
+ clean: "Skanningen hittade inga cookies, ingen lagring och inga anrop till andra webbplatser.",
159
+ },
160
+ stage: (state, stage) => [
161
+ state,
162
+ stage.page ? `sida ${stage.page} av ${stage.pages}` : "startar",
163
+ ...(stage.states > 1 ? [`läge ${stage.stateNumber} av ${stage.states}`] : []),
164
+ ].join(" · "),
165
+ elapsed: (time, left) => (left ? `${time} · ungefär ${left} kvar` : time),
166
+ progress: (finished, total) => `${finished} av ${total} sidbesök klara`,
167
+ stats: {
168
+ pages: (n, of) => n === of ? (n === 1 ? "sida" : "sidor") : `av ${of} ${of === 1 ? "sida" : "sidor"}`,
169
+ states: (n) => (n === 1 ? "läge" : "lägen"),
170
+ cookies: (n) => (n === 1 ? "cookie" : "cookies"),
171
+ storage: () => "sparat i webbläsaren",
172
+ hosts: (n) => (n === 1 ? "annan webbplats" : "andra webbplatser"),
173
+ },
174
+ scanned: (date, took) => `Skannad ${date}${took ? ` · tog ${took}` : ""}`,
175
+ states: (count, states) => `${count === 1 ? "Läge" : "Lägen"}: ${states}`,
176
+ pages: (n) => `Skannade sidor (${n})`,
177
+ all: "Alla skanningar",
178
+ problems: {
179
+ notScanned: (state) => `${state}: skannades inte`,
180
+ noPages: (state) => `${state}: ingen sida kunde besökas`,
181
+ outOfTime: (state) => `${state}: skanningen hann inte klart`,
182
+ pagesFailed: (state) => `${state}: några sidor kunde inte skannas`,
183
+ sitemap: (sitemap) => `Sitemapen ${sitemap} kunde inte läsas`,
184
+ other: () => "Skannern rapporterade ett problem",
185
+ },
186
+ },
66
187
  groups: {
67
188
  action: "Åtgärd krävs",
68
189
  unknown: "Finns inte bland Cookietjänsterna",
69
190
  ok: "I ordning",
70
191
  },
71
192
  explain: {
72
- action: "De här tjänsterna laddas i ett läge där deras kategori inte är tillåten. Ladda dem via pluginet (Laddas av: det här pluginet) eller låt webbplatsens kod vänta på samtycke.",
73
- unknown: "Inget bland Cookietjänsterna förklarar de här. Lägg till var och en i en tjänst, eller ta bort den från webbplatsen.",
74
- ok: "Förklaras av Cookietjänsterna och syns bara där deras kategori är tillåten.",
193
+ action: "Syns där kategorin inte är tillåten. Välj ”Det här pluginet, efter samtycke” under Laddas av i tjänsten, eller låt webbplatsens kod vänta på samtycke.",
194
+ unknown: "Lägg till var och en i en tjänst, ny eller befintlig, eller ta bort den från webbplatsen.",
195
+ ok: "Finns i en Cookietjänst och syns bara där kategorin är tillåten.",
75
196
  },
76
- kinds: { cookie: "Cookie", localStorage: "localStorage", host: "Tredjepartsvärd" },
197
+ seen: {
198
+ cookie: "Cookie som sätts",
199
+ localStorage: "Sparas i webbläsaren",
200
+ host: "Kontaktar en annan webbplats",
201
+ },
202
+ when: {
203
+ "no-choice": "för nya besökare innan de valt",
204
+ "reject-all": "när besökaren avvisat",
205
+ "accept-all": "när besökaren godkänt",
206
+ },
207
+ whenOnly: (category) => `när bara ${category.toLowerCase()} är tillåten`,
208
+ notAllowed: (category) => `, fast ${category.toLowerCase()} inte är tillåten då`,
209
+ also: (when) => `Även ${when}.`,
210
+ looksLike: (platform) => `Ser ut som ${platform}`,
211
+ database: "Open Cookie Database",
212
+ trackerLists: (lists) => `På spårningslistor: ${lists}`,
213
+ seenOn: "En sida där den syns",
77
214
  beforeConsent: "Före samtycke",
78
215
  isNew: "Ny",
79
- seenIn: "Sågs",
80
- withoutConsent: "utan samtycke",
81
216
  service: "Tjänst",
82
217
  category: "Kategori",
83
218
  add: "Lägg till i tjänst",
84
219
  adding: "Lägger till…",
85
- suggestion: "Förslag",
86
- trackerList: "På spårningslista",
87
220
  states: {
88
221
  "no-choice": "ny besökare",
89
222
  "reject-all": "efter avvisa",
@@ -96,15 +229,120 @@ const COPY = {
96
229
  measurement: "Statistik",
97
230
  marketing: "Marknadsföring",
98
231
  },
99
- summary: (s) => `${s.action} kräver åtgärd · ${s.unknown} okända · ${s.ok} i ordning${s.new ? ` · ${s.new} nya` : ""}`,
100
232
  },
101
233
  };
234
+ /** `new visitor, after rejecting and after accepting`. */
235
+ function statesLabel(copy, ids, language) {
236
+ const labels = ids.map((id) => stateLabel(copy, id));
237
+ return new Intl.ListFormat(language === "sv" ? "sv-SE" : "en-GB", { type: "conjunction" }).format(labels);
238
+ }
102
239
  function stateLabel(copy, id) {
103
240
  if (copy.states[id])
104
241
  return copy.states[id];
105
242
  const category = id.replace(/^only-/, "");
106
243
  return copy.categories[category] ? `${copy.categories[category]}` : id;
107
244
  }
245
+ /** `for new visitors before they choose and after the visitor accepts`. */
246
+ function whenLabel(copy, ids, language) {
247
+ const labels = ids.map((id) => {
248
+ if (copy.when[id])
249
+ return copy.when[id];
250
+ const category = id.replace(/^only-/, "");
251
+ return copy.categories[category] ? copy.whenOnly(copy.categories[category]) : id;
252
+ });
253
+ return new Intl.ListFormat(language === "sv" ? "sv-SE" : "en-GB", { type: "conjunction" }).format(labels);
254
+ }
255
+ function dateLabel(value, language) {
256
+ return new Date(value ?? "").toLocaleString(language === "sv" ? "sv-SE" : "en-GB");
257
+ }
258
+ /** The card's pill: Payload's pill styles. */
259
+ const CARD_PILL = {
260
+ none: "light-gray",
261
+ queued: "light-gray",
262
+ running: "light-gray",
263
+ failed: "error",
264
+ action: "error",
265
+ unknown: "warning",
266
+ incomplete: "warning",
267
+ ok: "success",
268
+ clean: "success",
269
+ };
270
+ /** A group's count, in the colour the card gives the same verdict. */
271
+ const GROUP_PILL = {
272
+ action: CARD_PILL.action,
273
+ unknown: CARD_PILL.unknown,
274
+ ok: CARD_PILL.ok,
275
+ };
276
+ /**
277
+ * The scan at a glance: where it stands or what it found, with Scan now. A panel of our own like
278
+ * the dashboard widget's: Payload's `Card` is a link, not a status.
279
+ */
280
+ function ScanCard({ active, busy, copy, current, error, language, live, now, onStart, scan, scansUrl, }) {
281
+ const card = copy.card;
282
+ const summary = scan?.status === "done" ? scan.summary : undefined;
283
+ const state = active
284
+ ? current === "running"
285
+ ? "running"
286
+ : "queued"
287
+ : !scan
288
+ ? "none"
289
+ : scan.status === "failed"
290
+ ? "failed"
291
+ : summary
292
+ ? scanVerdict(summary)
293
+ : "clean";
294
+ const title = state === "action"
295
+ ? card.title.action(summary?.action ?? 0)
296
+ : state === "unknown"
297
+ ? card.title.unknown(summary?.unknown ?? 0)
298
+ : card.title[state];
299
+ const elapsed = live.startedAt ? now - Date.parse(live.startedAt) : undefined;
300
+ const left = live.stage && elapsed !== undefined ? estimateLeft(elapsed, live.stage) : undefined;
301
+ const findings = scan?.findings ?? [];
302
+ const count = (kind) => findings.filter((f) => f.kind === kind).length;
303
+ const pages = scan?.pages?.selected ?? [];
304
+ const stateIds = (scan?.states ?? []).map((entry) => entry.id);
305
+ // Pages visited in any state; fewer than were picked when the scan could not reach some. WEC
306
+ // lists a page at the address it ended on, so a redirect must not count as one more.
307
+ const visited = Math.min(pages.length, new Set((scan?.results ?? []).flatMap((result) => result.visited ?? [])).size);
308
+ const stats = summary
309
+ ? [
310
+ [visited, card.stats.pages(visited, pages.length)],
311
+ [stateIds.length, card.stats.states(stateIds.length)],
312
+ [count("cookie"), card.stats.cookies(count("cookie"))],
313
+ [count("localStorage"), card.stats.storage()],
314
+ [count("host"), card.stats.hosts(count("host"))],
315
+ ]
316
+ : [];
317
+ const took = scan?.startedAt && scan.finishedAt
318
+ ? formatElapsed(Date.parse(scan.finishedAt) - Date.parse(scan.startedAt))
319
+ : undefined;
320
+ return (_jsxs("section", { className: `consent-scan__card consent-scan__card--${CARD_PILL[state]}`, children: [_jsxs("div", { className: "consent-scan__head", children: [_jsxs("div", { className: "consent-scan__pills", children: [_jsx(Pill, { pillStyle: CARD_PILL[state], size: "small", children: card.pills[state] }), summary?.new ? (_jsx(Pill, { pillStyle: "light", size: "small", children: card.newPill(summary.new) })) : null] }), _jsx(Button, { buttonStyle: state === "none" ? "primary" : "secondary", disabled: busy || active, margin: false, onClick: onStart, size: "small", children: busy ? copy.starting : copy.scan })] }), _jsxs("div", { "aria-live": "polite", className: "consent-scan__body", children: [_jsx("h3", { className: "consent-scan__title", children: title }), state === "none" ? _jsx("p", { children: card.text.none }) : null, state === "queued" ? _jsx("p", { children: card.text.queued(live.position) }) : null, state === "running" ? (_jsx("p", { children: live.stage
321
+ ? card.stage(capitalize(stateLabel(copy, live.stage.state)), live.stage)
322
+ : live.progress
323
+ ? progressLabel(copy, live.progress)
324
+ : card.text.choosing })) : null, state === "failed" ? _jsx("p", { children: scan?.error }) : null, state === "action" ||
325
+ state === "unknown" ||
326
+ state === "incomplete" ||
327
+ state === "ok" ||
328
+ state === "clean" ? (_jsx("p", { children: card.text[state] })) : null] }), state === "running" && live.stage ? (
329
+ // Payload has no progress bar for content (its ProgressBar follows route changes).
330
+ _jsx("progress", { "aria-label": card.progress(finishedPages(live.stage), live.stage.total), className: "consent-scan__progress", max: live.stage.total, value: finishedPages(live.stage) })) : null, state === "running" && elapsed !== undefined ? (_jsx("p", { className: "consent-scan__meta", children: card.elapsed(formatElapsed(elapsed), left === undefined ? undefined : formatElapsed(left)) })) : null, summary?.problems?.length ? (_jsx("ul", { className: "consent-scan__problems", children: summary.problems.map((raw) => {
331
+ const problem = describeProblem(raw, stateIds);
332
+ const label = problem.state ? stateLabel(copy, problem.state) : "";
333
+ const text = problem.kind === "sitemap"
334
+ ? card.problems.sitemap(problem.sitemap ?? "")
335
+ : problem.kind === "other"
336
+ ? card.problems.other()
337
+ : card.problems[problem.kind](capitalize(label));
338
+ return (_jsxs("li", { children: [text, problem.kind === "notScanned" || problem.kind === "noPages" ? null : (_jsx("span", { className: "consent-scan__detail", children: problem.detail }))] }, raw));
339
+ }) })) : null, error ? _jsx("p", { className: "consent-scan__error", children: error }) : null, stats.length ? (_jsx("dl", { className: "consent-scan__stats", children: stats.map(([value, label]) => (_jsxs("div", { children: [_jsx("dt", { children: label }), _jsx("dd", { children: value })] }, String(label)))) })) : null, summary ? (_jsxs("div", { className: "consent-scan__foot", children: [_jsxs("p", { className: "consent-scan__meta", children: [card.scanned(dateLabel(scan?.finishedAt, language), took), stateIds.length
340
+ ? ` · ${card.states(stateIds.length, statesLabel(copy, stateIds, language))}`
341
+ : "", " · ", _jsx("a", { href: scansUrl, children: card.all })] }), pages.length ? (_jsx(Collapsible, { className: "consent-scan__pages", header: card.pages(pages.length), initCollapsed: true, children: _jsx("ul", { children: pages.map((page) => (_jsx("li", { children: _jsx("a", { href: page, rel: "noopener noreferrer", target: "_blank", title: page, children: pagePath(page) }) }, page))) }) })) : null] })) : scan ? (_jsx("p", { className: "consent-scan__meta", children: _jsx("a", { href: scansUrl, children: card.all }) })) : null] }));
342
+ }
343
+ function capitalize(value) {
344
+ return value ? `${value[0]?.toUpperCase()}${value.slice(1)}` : value;
345
+ }
108
346
  /** `accept-all (3/3)` from the scanner, in the editor's words. */
109
347
  function progressLabel(copy, progress) {
110
348
  const match = progress?.match(/^(\S+) \((\d+\/\d+)\)$/);
@@ -124,6 +362,7 @@ export function ScanPanel() {
124
362
  const [live, setLive] = useState({});
125
363
  const [busy, setBusy] = useState(false);
126
364
  const [error, setError] = useState();
365
+ const [now, setNow] = useState(() => Date.now());
127
366
  const load = useCallback(async () => {
128
367
  const response = await fetch(`${api}?sort=-createdAt&limit=1&depth=0`, {
129
368
  credentials: "include",
@@ -155,6 +394,14 @@ export function ScanPanel() {
155
394
  clearInterval(timer);
156
395
  };
157
396
  }, [api, load, scan]);
397
+ // A running scan's clock ticks each second between the scanner's answers.
398
+ const running = scan?.status === "running" || live.status === "running";
399
+ useEffect(() => {
400
+ if (!running)
401
+ return;
402
+ const timer = setInterval(() => setNow(Date.now()), 1000);
403
+ return () => clearInterval(timer);
404
+ }, [running]);
158
405
  async function start() {
159
406
  setBusy(true);
160
407
  setError(undefined);
@@ -179,19 +426,18 @@ export function ScanPanel() {
179
426
  // The scanner knows first when a queued scan starts running.
180
427
  const current = active ? (live.status ?? scan?.status) : scan?.status;
181
428
  const findings = scan?.findings ?? [];
182
- return (_jsxs("div", { className: "consent-scan", children: [_jsxs("div", { className: "consent-scan__bar", children: [_jsx(Button, { buttonStyle: "primary", disabled: busy || active, margin: false, onClick: start, size: "medium", children: busy ? copy.starting : copy.scan }), _jsxs("span", { "aria-live": "polite", className: "consent-scan__status", children: [scan === null ? copy.none : null, current === "queued" ? copy.queued(live.position) : null, current === "running" ? copy.running(progressLabel(copy, live.progress)) : null, scan?.status === "failed" ? `${copy.failed} ${scan.error ?? ""}` : null, scan?.status === "done"
183
- ? copy.done(new Date(scan.finishedAt ?? "").toLocaleString(language === "sv" ? "sv-SE" : "en-GB"), scan.pages?.selected?.length ?? 0)
184
- : null] })] }), error ? _jsx("p", { className: "consent-scan__error", children: error }) : null, scan?.status === "done" && scan.summary ? (_jsx("p", { className: "consent-scan__summary", children: copy.summary(scan.summary) })) : null, scan?.status === "done" && scan.summary?.problems?.length ? (_jsxs("div", { className: "consent-scan__error", children: [_jsx("p", { children: copy.incomplete }), _jsx("ul", { children: scan.summary.problems.map((problem) => (_jsx("li", { children: problem }, problem))) })] })) : null, scan?.status === "done"
429
+ return (_jsxs("div", { className: "consent-scan", children: [_jsx(ScanCard, { active: active, busy: busy, copy: copy, current: current, error: error, language: language, live: live, now: now, onStart: start, scan: scan ?? null, scansUrl: `${config.routes.admin}/collections/${CONSENT_SCANS}` }), scan?.status === "done"
185
430
  ? ["action", "unknown", "ok"].map((status) => {
186
431
  const rows = findings.filter((finding) => finding.status === status);
187
432
  if (!rows.length)
188
433
  return null;
189
- const list = (_jsx("ul", { className: "consent-scan__list", children: rows.map((finding) => (_jsx(FindingRow, { copy: copy, finding: finding, locale: locale.code, onAdded: load, api: api }, finding.key))) }));
190
- return (_jsx("section", { className: `consent-scan__group consent-scan__group--${status}`, children: status === "ok" ? (_jsxs("details", { children: [_jsx("summary", { children: _jsxs("h4", { children: [copy.groups[status], " (", rows.length, ")"] }) }), _jsx("p", { className: "consent-scan__note", children: copy.explain[status] }), list] })) : (_jsxs(_Fragment, { children: [_jsxs("h4", { children: [copy.groups[status], " (", rows.length, ")"] }), _jsx("p", { className: "consent-scan__note", children: copy.explain[status] }), list] })) }, status));
434
+ return (_jsxs(Collapsible, { className: `consent-scan__group consent-scan__group--${status}`, header: _jsxs("span", { className: "consent-scan__group-head", children: [_jsx("span", { className: "consent-scan__group-title", children: copy.groups[status] }), _jsx(Pill, { pillStyle: GROUP_PILL[status], size: "small", children: rows.length })] }),
435
+ // What is in order is there to look up, not to act on.
436
+ initCollapsed: status === "ok", children: [_jsx("p", { className: "consent-scan__note", children: copy.explain[status] }), _jsx("ul", { className: "consent-scan__list", children: rows.map((finding) => (_jsx(FindingRow, { api: api, copy: copy, finding: finding, language: language, locale: locale.code, onAdded: load }, finding.key))) })] }, status));
191
437
  })
192
438
  : null] }));
193
439
  }
194
- function FindingRow({ api, copy, finding, locale, onAdded, }) {
440
+ function FindingRow({ api, copy, finding, language, locale, onAdded, }) {
195
441
  const suggestion = finding.suggestion;
196
442
  const [service, setService] = useState(suggestion?.platform ?? (finding.kind === "host" ? finding.name : ""));
197
443
  const [category, setCategory] = useState(suggestion?.category ?? "necessary");
@@ -224,9 +470,38 @@ function FindingRow({ api, copy, finding, locale, onAdded, }) {
224
470
  else
225
471
  await onAdded();
226
472
  }
227
- const seen = finding.states.map((id) => stateLabel(copy, id)).join(", ");
228
- const without = finding.withoutConsent.map((id) => stateLabel(copy, id)).join(", ");
229
- return (_jsxs("li", { className: "consent-scan__row", children: [_jsxs("div", { className: "consent-scan__name", children: [_jsx("span", { className: "consent-scan__kind", children: copy.kinds[finding.kind] }), _jsx("code", { children: finding.name }), finding.where ? _jsx("span", { className: "consent-scan__where", children: finding.where }) : null, finding.beforeConsent && finding.status !== "ok" ? (_jsx(Pill, { pillStyle: "error", size: "small", children: copy.beforeConsent })) : null, finding.isNew ? (_jsx(Pill, { pillStyle: "warning", size: "small", children: copy.isNew })) : null] }), _jsxs("p", { className: "consent-scan__detail", children: [copy.seenIn, ": ", seen, without ? ` · ${copy.withoutConsent}: ${without}` : "", finding.service ? ` · ${copy.service}: ${finding.service}` : "", finding.category ? ` (${copy.categories[finding.category]})` : "", finding.trackerLists?.length
230
- ? ` · ${copy.trackerList}: ${finding.trackerLists.join(", ")}`
231
- : ""] }), suggestion?.platform ? (_jsxs("p", { className: "consent-scan__detail", children: [copy.suggestion, ": ", suggestion.platform, suggestion.category ? `, ${copy.categories[suggestion.category]}` : "", suggestion.retention ? `, ${suggestion.retention}` : "", suggestion.description ? ` · ${suggestion.description}` : ""] })) : null, finding.status === "unknown" ? (_jsxs("div", { className: "consent-scan__classify", children: [_jsxs("label", { children: [_jsx("span", { children: copy.service }), _jsx("input", { onChange: (event) => setService(event.target.value), type: "text", value: service })] }), _jsxs("label", { children: [_jsx("span", { children: copy.category }), _jsx("select", { onChange: (event) => setCategory(event.target.value), value: category, children: CATEGORIES.map((value) => (_jsx("option", { value: value, children: copy.categories[value] }, value))) })] }), _jsx(Button, { buttonStyle: "secondary", disabled: busy || !service.trim(), margin: false, onClick: add, size: "small", children: busy ? copy.adding : copy.add }), error ? _jsx("span", { className: "consent-scan__error", children: error }) : null] })) : null] }));
473
+ const heading = findingHeading(finding);
474
+ const serviceCategory = finding.category ? copy.categories[finding.category] : "";
475
+ const suggested = [
476
+ suggestion?.category ? copy.categories[suggestion.category] : "",
477
+ suggestion?.retention,
478
+ ].filter(Boolean);
479
+ // The raw facts a developer looks for, after what the editor reads.
480
+ const details = [
481
+ heading.from === "name" ? null : _jsx("code", { children: finding.name }, "name"),
482
+ finding.where || null,
483
+ heading.from === "service"
484
+ ? serviceCategory || null
485
+ : heading.from === "suggestion" && suggested.length
486
+ ? `${copy.database}: ${suggested.join(", ")}`
487
+ : null,
488
+ finding.trackerLists?.length ? copy.trackerLists(finding.trackerLists.join(", ")) : null,
489
+ finding.page ? (_jsx("a", { href: finding.page, rel: "noopener noreferrer", target: "_blank", children: copy.seenOn }, "page")) : null,
490
+ ].filter(Boolean);
491
+ // Where it loaded without consent comes first, in the error colour; the rest after it.
492
+ const without = serviceCategory ? finding.withoutConsent : [];
493
+ const rest = finding.states.filter((id) => !without.includes(id));
494
+ const path = `consent-scan-${finding.key}`;
495
+ return (_jsxs("li", { className: "consent-scan__row", children: [_jsxs("div", { className: "consent-scan__row-head", children: [_jsx("h4", { className: "consent-scan__name", children: heading.from === "name" ? (_jsx("code", { children: heading.text })) : heading.from === "suggestion" ? (copy.looksLike(heading.text)) : (heading.text) }), (finding.beforeConsent && finding.status !== "ok") || finding.isNew ? (_jsxs("div", { className: "consent-scan__pills", children: [finding.beforeConsent && finding.status !== "ok" ? (_jsx(Pill, { pillStyle: "error", size: "small", children: copy.beforeConsent })) : null, finding.isNew ? (_jsx(Pill, { pillStyle: "light", size: "small", children: copy.isNew })) : null] })) : null] }), _jsx("p", { className: "consent-scan__seen", children: without.length ? (_jsxs(_Fragment, { children: [`${copy.seen[finding.kind]} ${whenLabel(copy, without, language)}`, _jsx("strong", { children: copy.notAllowed(serviceCategory) }), ".", rest.length ? ` ${copy.also(whenLabel(copy, rest, language))}` : null] })) : (`${copy.seen[finding.kind]} ${whenLabel(copy, finding.states, language)}.`) }), suggestion?.description && heading.from === "suggestion" ? (_jsx("p", { className: "consent-scan__note", children: suggestion.description })) : null, details.length ? (_jsx("p", { className: "consent-scan__details", children: details.map((detail, index) => (_jsx("span", { children: detail }, typeof detail === "string" ? detail : index))) })) : null, finding.status === "unknown" ? (_jsxs("div", { className: "consent-scan__classify", children: [_jsx(TextInput, { label: copy.service, onChange: (event) => setService(event.target.value), onKeyDown: (event) => {
496
+ // Enter adds the finding; it would otherwise submit the Cookies form around the tab.
497
+ if (event.key !== "Enter")
498
+ return;
499
+ event.preventDefault();
500
+ if (!busy && service.trim())
501
+ add();
502
+ }, path: `${path}-service`, readOnly: busy, value: service }), _jsx(SelectInput, { isClearable: false, label: copy.category, name: `${path}-category`, onChange: (selected) => {
503
+ const option = Array.isArray(selected) ? selected[0] : selected;
504
+ if (option && typeof option === "object" && "value" in option)
505
+ setCategory(option.value);
506
+ }, options: CATEGORIES.map((value) => ({ label: copy.categories[value], value })), path: `${path}-category`, readOnly: busy, value: category }), _jsx(Button, { buttonStyle: "secondary", disabled: busy || !service.trim(), margin: false, onClick: add, size: "large", children: busy ? copy.adding : copy.add }), error ? (_jsx("p", { className: "consent-scan__error", role: "alert", children: error })) : null] })) : null] }));
232
507
  }
@@ -8,4 +8,5 @@ export declare function ServicesPanel(): import("react").JSX.Element;
8
8
  /** The Consent log tab: how many choices are on record, with links to the records and policies. */
9
9
  export declare function ConsentLogPanel(): import("react").JSX.Element;
10
10
  /** Links under the Scan tab to every scan, since the collection is not in the navigation. */
11
+ /** No longer placed by the plugin (the scan card links to the scans); kept for import maps. */
11
12
  export declare function ScanLinks(): import("react").JSX.Element;
@@ -129,6 +129,7 @@ export function ConsentLogPanel() {
129
129
  return (_jsxs("ul", { className: "consent-panel__links", children: [_jsxs("li", { children: [_jsx("a", { href: `${admin}/${CONSENT_RECORDS}`, children: copy.openRecords }), _jsx("span", { className: "consent-scan__note", children: records === undefined ? copy.loading : copy.records(records) })] }), _jsxs("li", { children: [_jsx("a", { href: `${admin}/${CONSENT_POLICIES}`, children: copy.openPolicies }), _jsx("span", { className: "consent-scan__note", children: policies === undefined ? copy.loading : copy.policies(policies) })] })] }));
130
130
  }
131
131
  /** Links under the Scan tab to every scan, since the collection is not in the navigation. */
132
+ /** No longer placed by the plugin (the scan card links to the scans); kept for import maps. */
132
133
  export function ScanLinks() {
133
134
  const copy = useCopy();
134
135
  const { admin } = useRoutes();
@@ -0,0 +1,37 @@
1
+ import type { Finding, ScanSummary } from "../evaluate.ts";
2
+ import type { ScanStage } from "../scans.ts";
3
+ /**
4
+ * What a finished scan means for the editor, most urgent first: services loading without consent,
5
+ * findings no service explains, a scan that could not see everything, then nothing to fix, with
6
+ * (`ok`) or without (`clean`) anything found.
7
+ */
8
+ export type ScanVerdict = "action" | "unknown" | "incomplete" | "ok" | "clean";
9
+ export declare function scanVerdict(summary: ScanSummary): ScanVerdict;
10
+ /**
11
+ * What a finding's row leads with, in the editor's words: the Cookie service that explains it, the
12
+ * platform the Open Cookie Database suggests, or only its raw name when neither knows it.
13
+ */
14
+ export type FindingHeading = {
15
+ from: "service" | "suggestion" | "name";
16
+ text: string;
17
+ };
18
+ export declare function findingHeading(finding: Finding): FindingHeading;
19
+ /** Pages finished in all states, for the progress bar: the page being visited is not yet. */
20
+ export declare function finishedPages(stage: ScanStage): number;
21
+ /** `0:07`, `12:30`, `1:02:03`. */
22
+ export declare function formatElapsed(ms: number): string;
23
+ /** A problem from `scanProblems` sorted into what an editor can read; `detail` is the raw text. */
24
+ export type ScanProblem = {
25
+ kind: "notScanned" | "noPages" | "outOfTime" | "pagesFailed" | "sitemap" | "other";
26
+ state?: string;
27
+ sitemap?: string;
28
+ detail: string;
29
+ };
30
+ export declare function describeProblem(problem: string, stateIds: string[]): ScanProblem;
31
+ /**
32
+ * Roughly how long a running scan has left, from the pace so far; `undefined` until a page is
33
+ * done, when there is no pace to go by.
34
+ */
35
+ export declare function estimateLeft(elapsedMs: number, stage: ScanStage): number | undefined;
36
+ /** `/about?x=1` for a page on the scanned site: the address without its origin. */
37
+ export declare function pagePath(url: string): string;
@@ -0,0 +1,66 @@
1
+ export function scanVerdict(summary) {
2
+ if (summary.action)
3
+ return "action";
4
+ if (summary.unknown)
5
+ return "unknown";
6
+ if (summary.problems?.length)
7
+ return "incomplete";
8
+ return summary.ok ? "ok" : "clean";
9
+ }
10
+ export function findingHeading(finding) {
11
+ if (finding.service)
12
+ return { from: "service", text: finding.service };
13
+ const platform = finding.suggestion?.platform;
14
+ if (platform && finding.status === "unknown")
15
+ return { from: "suggestion", text: platform };
16
+ return { from: "name", text: finding.name };
17
+ }
18
+ /** Pages finished in all states, for the progress bar: the page being visited is not yet. */
19
+ export function finishedPages(stage) {
20
+ return Math.max(0, stage.page > 0 ? stage.visited - 1 : stage.visited);
21
+ }
22
+ /** `0:07`, `12:30`, `1:02:03`. */
23
+ export function formatElapsed(ms) {
24
+ const seconds = Math.max(0, Math.floor(ms / 1000));
25
+ const h = Math.floor(seconds / 3600);
26
+ const m = Math.floor((seconds % 3600) / 60);
27
+ const s = String(seconds % 60).padStart(2, "0");
28
+ return h ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
29
+ }
30
+ export function describeProblem(problem, stateIds) {
31
+ const sitemap = problem.match(/^Sitemap (\S+): (.*)$/s);
32
+ if (sitemap)
33
+ return { kind: "sitemap", sitemap: sitemap[1], detail: sitemap[2] ?? "" };
34
+ const prefixed = problem.match(/^([a-z0-9-]+): (.*)$/s);
35
+ const state = prefixed?.[1];
36
+ if (!prefixed || !state || !stateIds.includes(state))
37
+ return { kind: "other", detail: problem };
38
+ const detail = prefixed[2] ?? "";
39
+ if (detail === "not scanned")
40
+ return { kind: "notScanned", state, detail };
41
+ if (detail === "no page could be visited")
42
+ return { kind: "noPages", state, detail };
43
+ if (/ran out of time/.test(detail))
44
+ return { kind: "outOfTime", state, detail };
45
+ return { kind: "pagesFailed", state, detail };
46
+ }
47
+ /**
48
+ * Roughly how long a running scan has left, from the pace so far; `undefined` until a page is
49
+ * done, when there is no pace to go by.
50
+ */
51
+ export function estimateLeft(elapsedMs, stage) {
52
+ const finished = finishedPages(stage);
53
+ if (finished < 1 || elapsedMs <= 0)
54
+ return undefined;
55
+ return (elapsedMs / finished) * Math.max(0, stage.total - finished);
56
+ }
57
+ /** `/about?x=1` for a page on the scanned site: the address without its origin. */
58
+ export function pagePath(url) {
59
+ try {
60
+ const { pathname, search } = new URL(url);
61
+ return `${pathname}${search}`;
62
+ }
63
+ catch {
64
+ return url;
65
+ }
66
+ }
package/dist/global.js CHANGED
@@ -186,6 +186,14 @@ export function consentGlobal(options, { usersSlug, schedule }) {
186
186
  sv: "Skannar den publicerade webbplatsen som ny besökare, efter avvisa och efter godkänn, och jämför det som hittas med Cookietjänsterna.",
187
187
  },
188
188
  fields: [
189
+ // The scan first: its settings follow.
190
+ {
191
+ name: "scanPanel",
192
+ type: "ui",
193
+ admin: {
194
+ components: { Field: "@simmalugnt-se/payload-consent/admin#ScanPanel" },
195
+ },
196
+ },
189
197
  {
190
198
  name: "scanUrl",
191
199
  type: "text",
@@ -223,20 +231,6 @@ export function consentGlobal(options, { usersSlug, schedule }) {
223
231
  },
224
232
  },
225
233
  },
226
- {
227
- name: "scanPanel",
228
- type: "ui",
229
- admin: {
230
- components: { Field: "@simmalugnt-se/payload-consent/admin#ScanPanel" },
231
- },
232
- },
233
- {
234
- name: "scanLinks",
235
- type: "ui",
236
- admin: {
237
- components: { Field: "@simmalugnt-se/payload-consent/admin#ScanLinks" },
238
- },
239
- },
240
234
  ],
241
235
  },
242
236
  ...(options.records === false
package/dist/scans.d.ts CHANGED
@@ -24,6 +24,20 @@ type Started = {
24
24
  error: string;
25
25
  status: number;
26
26
  };
27
+ /**
28
+ * Where a running scan is, from the scanner: the state (`stateNumber` of `states`), the page it is
29
+ * on in that state (`page` of `pages`, 0 before the first), and pages begun in all states
30
+ * (`visited` of `total`).
31
+ */
32
+ export type ScanStage = {
33
+ state: string;
34
+ stateNumber: number;
35
+ states: number;
36
+ page: number;
37
+ pages: number;
38
+ visited: number;
39
+ total: number;
40
+ };
27
41
  /**
28
42
  * Asks the scanner to scan the site in every consent state and records the scan as queued. The
29
43
  * address is the one given (the Scan tab's field, saved or not), then the saved one, then the
package/dist/scans.js CHANGED
@@ -377,6 +377,8 @@ function endpoints(options) {
377
377
  status: live.status,
378
378
  position: live.position,
379
379
  progress: live.progress,
380
+ stage: live.stage,
381
+ startedAt: live.startedAt,
380
382
  });
381
383
  },
382
384
  },
@@ -10,13 +10,118 @@
10
10
  align-items: center;
11
11
  gap: calc(var(--base) * 0.75);
12
12
  }
13
- .consent-scan__status,
14
- .consent-scan__summary {
13
+ .consent-scan__card {
14
+ display: grid;
15
+ gap: calc(var(--base) * 0.75);
16
+ padding: calc(var(--base) * 1.25);
17
+ border: 1px solid var(--theme-elevation-150);
18
+ border-radius: var(--style-radius-m);
19
+ background: var(--theme-elevation-0);
20
+ }
21
+ .consent-scan__card--error {
22
+ border-color: var(--theme-error-500);
23
+ }
24
+ .consent-scan__card--warning {
25
+ border-color: var(--theme-warning-500);
26
+ }
27
+ .consent-scan__head {
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: space-between;
31
+ gap: var(--base);
32
+ }
33
+ .consent-scan__pills {
34
+ display: flex;
35
+ flex-wrap: wrap;
36
+ gap: calc(var(--base) * 0.25);
37
+ }
38
+ .consent-scan__body {
39
+ display: grid;
40
+ gap: calc(var(--base) * 0.25);
41
+ }
42
+ .consent-scan__title {
43
+ margin: 0;
44
+ }
45
+ .consent-scan__body p {
46
+ margin: 0;
15
47
  color: var(--theme-elevation-800);
16
48
  }
17
- .consent-scan__summary {
49
+ .consent-scan__meta {
18
50
  margin: 0;
51
+ color: var(--theme-elevation-500);
52
+ }
53
+ .consent-scan__progress {
54
+ width: 100%;
55
+ height: calc(var(--base) * 0.4);
56
+ appearance: none;
57
+ border: 0;
58
+ border-radius: var(--style-radius-s);
59
+ background: var(--theme-elevation-100);
60
+ overflow: hidden;
61
+ }
62
+ .consent-scan__progress::-webkit-progress-bar {
63
+ background: var(--theme-elevation-100);
64
+ }
65
+ .consent-scan__progress::-webkit-progress-value {
66
+ background: var(--theme-success-500);
67
+ transition: width 0.4s ease;
68
+ }
69
+ .consent-scan__progress::-moz-progress-bar {
70
+ background: var(--theme-success-500);
71
+ }
72
+ .consent-scan__problems {
73
+ display: grid;
74
+ gap: calc(var(--base) * 0.25);
75
+ margin: 0;
76
+ padding-left: var(--base);
77
+ }
78
+ .consent-scan__detail {
79
+ display: block;
80
+ color: var(--theme-elevation-500);
81
+ font-size: 0.9em;
82
+ word-break: break-word;
83
+ }
84
+ .consent-scan__stats {
85
+ display: grid;
86
+ grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
87
+ gap: calc(var(--base) * 0.5);
88
+ margin: 0;
89
+ padding-block: calc(var(--base) * 0.75);
90
+ border-block: 1px solid var(--theme-elevation-100);
91
+ }
92
+ .consent-scan__stats div {
93
+ display: flex;
94
+ flex-direction: column-reverse;
95
+ }
96
+ .consent-scan__stats dd {
97
+ margin: 0;
98
+ font-size: 1.5rem;
19
99
  font-weight: 600;
100
+ line-height: 1.2;
101
+ }
102
+ .consent-scan__stats dt {
103
+ color: var(--theme-elevation-500);
104
+ }
105
+ .consent-scan__foot {
106
+ display: grid;
107
+ gap: calc(var(--base) * 0.5);
108
+ }
109
+ .consent-scan__meta a {
110
+ color: inherit;
111
+ }
112
+ .consent-scan__pages {
113
+ margin: 0;
114
+ }
115
+ .consent-scan__pages ul {
116
+ display: grid;
117
+ gap: calc(var(--base) * 0.25);
118
+ margin: 0;
119
+ padding: 0;
120
+ list-style: none;
121
+ }
122
+ .consent-scan__pages a {
123
+ color: var(--theme-elevation-800);
124
+ word-break: break-all;
20
125
  }
21
126
  .consent-scan__note {
22
127
  margin: 0;
@@ -26,75 +131,99 @@
26
131
  margin: 0;
27
132
  color: var(--theme-error-500);
28
133
  }
134
+ /* A group of findings: Payload's Collapsible, its count in the card's pill colours. */
29
135
  .consent-scan__group {
30
- border-top: 1px solid var(--theme-elevation-100);
31
- padding-top: calc(var(--base) * 0.75);
136
+ margin: 0;
32
137
  }
33
- .consent-scan__group h4 {
34
- margin: 0 0 calc(var(--base) * 0.25);
35
- display: inline;
138
+ .consent-scan__group-head {
139
+ display: flex;
140
+ align-items: center;
141
+ gap: calc(var(--base) * 0.5);
142
+ color: var(--theme-text);
36
143
  }
37
- .consent-scan__group--action h4 {
38
- color: var(--theme-error-500);
144
+ .consent-scan__group-title {
145
+ font-weight: 600;
39
146
  }
40
- .consent-scan__group summary {
41
- cursor: pointer;
147
+ .consent-scan__group .collapsible__content {
148
+ display: grid;
149
+ gap: calc(var(--base) * 0.5);
42
150
  }
43
151
  .consent-scan__list {
44
- list-style: none;
45
- margin: calc(var(--base) * 0.5) 0 0;
46
- padding: 0;
47
152
  display: grid;
48
- gap: calc(var(--base) * 0.5);
153
+ margin: 0;
154
+ padding: 0;
155
+ list-style: none;
49
156
  }
50
157
  .consent-scan__row {
51
158
  display: grid;
52
- gap: 4px;
53
- padding: calc(var(--base) * 0.5);
54
- border: 1px solid var(--theme-elevation-100);
55
- border-radius: var(--style-radius-s);
159
+ gap: calc(var(--base) * 0.5);
160
+ padding-block: calc(var(--base) * 0.75);
161
+ border-top: 1px solid var(--theme-elevation-100);
56
162
  }
57
- .consent-scan__name {
163
+ .consent-scan__row:last-child {
164
+ padding-bottom: 0;
165
+ }
166
+ .consent-scan__row-head {
58
167
  display: flex;
59
168
  flex-wrap: wrap;
60
169
  align-items: center;
61
- gap: 8px;
170
+ justify-content: space-between;
171
+ gap: calc(var(--base) * 0.5);
62
172
  }
63
- .consent-scan__kind {
64
- color: var(--theme-elevation-500);
65
- font-size: 0.85em;
173
+ /* A finding leads with its service in plain words; its raw name and domain follow, quieter. */
174
+ .consent-scan__name {
175
+ margin: 0;
176
+ font-size: 1.15rem;
177
+ line-height: 1.3;
178
+ font-weight: 600;
179
+ overflow-wrap: anywhere;
66
180
  }
67
- .consent-scan__where {
68
- color: var(--theme-elevation-500);
181
+ .consent-scan__name code {
182
+ font-size: 0.95rem;
69
183
  }
70
- .consent-scan__detail {
184
+ .consent-scan__seen {
71
185
  margin: 0;
72
- color: var(--theme-elevation-600);
73
- font-size: 0.9em;
74
- overflow-wrap: anywhere;
75
186
  }
76
- .consent-scan__classify {
187
+ .consent-scan__seen strong {
188
+ font-weight: 500;
189
+ color: var(--theme-error-500);
190
+ }
191
+ .consent-scan__details {
77
192
  display: flex;
78
193
  flex-wrap: wrap;
79
- align-items: flex-end;
80
- gap: 8px;
81
- margin-top: 4px;
194
+ gap: 0 calc(var(--base) * 0.5);
195
+ margin: 0;
196
+ color: var(--theme-elevation-500);
197
+ font-size: 0.85rem;
198
+ overflow-wrap: anywhere;
199
+ }
200
+ .consent-scan__details span:not(:last-child)::after {
201
+ content: "·";
202
+ margin-left: calc(var(--base) * 0.5);
82
203
  }
83
- .consent-scan__classify label {
204
+ .consent-scan__details a {
205
+ color: inherit;
206
+ text-decoration: underline;
207
+ text-underline-offset: 2px;
208
+ }
209
+ /* Service and Category side by side, with Add to service on their inputs' line. */
210
+ .consent-scan__classify {
84
211
  display: grid;
85
- gap: 2px;
86
- font-size: 0.85em;
87
- color: var(--theme-elevation-600);
212
+ grid-template-columns: minmax(10rem, 22rem) minmax(10rem, 14rem) auto;
213
+ justify-content: start;
214
+ align-items: end;
215
+ gap: calc(var(--base) * 0.5);
88
216
  }
89
- .consent-scan__classify input,
90
- .consent-scan__classify select {
91
- font: inherit;
92
- color: var(--theme-text);
93
- background: var(--theme-input-bg);
94
- border: 1px solid var(--theme-elevation-150);
95
- border-radius: var(--style-radius-s);
96
- padding: 6px 8px;
97
- min-height: 32px;
217
+ .consent-scan__classify .field-type {
218
+ margin: 0;
219
+ }
220
+ .consent-scan__classify .consent-scan__error {
221
+ grid-column: 1 / -1;
222
+ }
223
+ @media (max-width: 768px) {
224
+ .consent-scan__classify {
225
+ grid-template-columns: 1fr;
226
+ }
98
227
  }
99
228
 
100
229
  /* The dashboard widget, laid out like Payload's collection cards and content health's widget. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simmalugnt-se/payload-consent",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Cookie consent for Payload sites: banner texts, services and scans in Admin",
5
5
  "keywords": [
6
6
  "payload",