@simmalugnt-se/payload-consent 0.6.4 → 0.6.5

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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.5
4
+
5
+ - The Scan tab shows the card's shape with Payload's shimmer while the latest scan loads. Before,
6
+ it said "The site has not been scanned yet" for a moment on every load of a scanned site.
7
+
3
8
  ## 0.6.4
4
9
 
5
10
  - The Scan tab's time left counts down. It grew while a page took its time, since it was worked
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { Button, Collapsible, Pill, SelectInput, TextInput, useConfig, useFormFields, useLocale, useTranslation, } from "@payloadcms/ui";
3
+ import { Button, Collapsible, Pill, SelectInput, ShimmerEffect, TextInput, useConfig, useFormFields, useLocale, useTranslation, } from "@payloadcms/ui";
4
4
  import { useCallback, useEffect, useRef, useState, } from "react";
5
5
  import { CATEGORIES } from "../defaults.js";
6
6
  import { CONSENT_SCANS } from "../types.js";
@@ -11,6 +11,7 @@ const COPY = {
11
11
  noScanner: "No scanner is set up. Give the plugin `scanner: { url, token }` (see the README), then scan from here.",
12
12
  scan: "Scan now",
13
13
  starting: "Starting…",
14
+ loading: "Loading the latest scan",
14
15
  card: {
15
16
  pills: {
16
17
  none: "Not scanned",
@@ -129,6 +130,7 @@ const COPY = {
129
130
  noScanner: "Ingen skanner är inställd. Ge pluginet `scanner: { url, token }` (se README), och skanna sedan härifrån.",
130
131
  scan: "Skanna nu",
131
132
  starting: "Startar…",
133
+ loading: "Hämtar den senaste skanningen",
132
134
  card: {
133
135
  pills: {
134
136
  none: "Inte skannad",
@@ -361,6 +363,13 @@ function ScanCard({ active, busy, copy, current, error, finishingSince, fresh, l
361
363
  ? ` · ${card.states(stateIds.length, statesLabel(copy, stateIds, language))}`
362
364
  : "", " · ", _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] }));
363
365
  }
366
+ /**
367
+ * The card's shape while the latest scan loads, so a scanned site never shows "not scanned yet"
368
+ * first; Payload's shimmer, as Admin shows while it loads.
369
+ */
370
+ function LoadingCard({ label }) {
371
+ return (_jsxs("section", { "aria-busy": "true", "aria-label": label, className: "consent-scan__card", children: [_jsx(ShimmerEffect, { height: 20, width: 80 }), _jsx(ShimmerEffect, { height: 24, width: "40%" }), _jsx(ShimmerEffect, { height: 16, width: "70%" }), _jsx(ShimmerEffect, { height: 44 }), _jsx(ShimmerEffect, { height: 16, width: "55%" })] }));
372
+ }
364
373
  function capitalize(value) {
365
374
  return value ? `${value[0]?.toUpperCase()}${value.slice(1)}` : value;
366
375
  }
@@ -467,7 +476,7 @@ export function ScanPanel() {
467
476
  if (!hasScanner)
468
477
  return _jsx("p", { className: "consent-scan__note", children: copy.noScanner });
469
478
  const findings = scan?.findings ?? [];
470
- return (_jsxs("div", { className: "consent-scan", children: [_jsx(ScanCard, { active: active, busy: busy, copy: copy, current: current, error: error, finishingSince: finishingSince, fresh: Boolean(scan) && watched.current === scan?.id, language: language, live: live, now: now, onStart: start, pace: pace.id === scan?.id ? pace.marks : [], scan: scan ?? null, scansUrl: `${config.routes.admin}/collections/${CONSENT_SCANS}` }), scan?.status === "done"
479
+ return (_jsxs("div", { className: "consent-scan", children: [scan === undefined ? (_jsx(LoadingCard, { label: copy.loading })) : (_jsx(ScanCard, { active: active, busy: busy, copy: copy, current: current, error: error, finishingSince: finishingSince, fresh: Boolean(scan) && watched.current === scan?.id, language: language, live: live, now: now, onStart: start, pace: pace.id === scan?.id ? pace.marks : [], scan: scan, scansUrl: `${config.routes.admin}/collections/${CONSENT_SCANS}` })), scan?.status === "done"
471
480
  ? ["action", "unknown", "ok"].map((status) => {
472
481
  const rows = findings.filter((finding) => finding.status === status);
473
482
  if (!rows.length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simmalugnt-se/payload-consent",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Cookie consent for Payload sites: banner texts, services and scans in Admin",
5
5
  "keywords": [
6
6
  "payload",