@simmalugnt-se/payload-content-health 0.5.1 → 0.5.2

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,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.2
4
+
5
+ - Work-list filters use Payload's ReactSelect with its standard menu and focus styling.
6
+ Filters, Clear filters and individual and batch assistant buttons share one control height.
7
+ The filter row fills the available width, with Clear filters aligned to the batch action below.
8
+ - The workspace dev app now includes content health alongside the editor assistant and visual
9
+ editing, with alt text, SEO, heading, thin content and translation checks on its seed data.
10
+ - Source builds typecheck with the host app's generated collection and locale types.
11
+
3
12
  ## 0.5.1
4
13
 
5
14
  - The assistant's button now shows in the header of the work list. The view did not pass Admin's
package/dist/scan.js CHANGED
@@ -31,7 +31,7 @@ export async function scanContentHealth({ payload, user, checks }) {
31
31
  ? payload.config.localization.localeCodes
32
32
  : [undefined];
33
33
  for (const [slug, collectionOptions] of Object.entries(options.collections)) {
34
- const collection = payload.collections[slug]?.config;
34
+ const collection = payload.config.collections.find((collection) => collection.slug === slug);
35
35
  if (!collection) {
36
36
  result.problems.push(`Collection "${slug}" does not exist.`);
37
37
  continue;
@@ -95,7 +95,7 @@ export async function scanContentHealth({ payload, user, checks }) {
95
95
  depth: 0,
96
96
  draft: drafts,
97
97
  fallbackLocale: false,
98
- ...(locale ? { locale } : {}),
98
+ ...(locale ? { locale: locale } : {}),
99
99
  overrideAccess: false,
100
100
  pagination: false,
101
101
  select: select,
@@ -159,7 +159,7 @@ async function scanTranslations(input) {
159
159
  depth: 0,
160
160
  draft: input.drafts,
161
161
  fallbackLocale: false,
162
- locale,
162
+ locale: locale,
163
163
  overrideAccess: false,
164
164
  pagination: false,
165
165
  user: input.user,
@@ -1,6 +1,7 @@
1
1
  /* The work list. Colors come from Payload's theme; the accent is the blue the widget uses. */
2
2
  .content-health-list {
3
3
  --content-health-accent: #2563eb;
4
+ --content-health-control-height: calc(var(--base) * 1.6);
4
5
  padding-bottom: calc(var(--base) * 2);
5
6
  }
6
7
 
@@ -31,21 +32,39 @@ html[data-theme="dark"] .content-health-list {
31
32
 
32
33
  .content-health-list__filter {
33
34
  display: flex;
35
+ flex: 1 1 10rem;
36
+ min-width: 0;
34
37
  flex-direction: column;
35
38
  gap: calc(var(--base) * 0.25);
36
39
  font-size: 0.9em;
40
+ color: var(--theme-text);
41
+ }
42
+
43
+ .content-health-list__filter > label {
37
44
  color: var(--theme-elevation-600);
38
45
  }
39
46
 
40
- .content-health-list__filter select {
41
- min-width: 12rem;
42
- height: calc(var(--base) * 1.6);
47
+ .content-health-list__filter .rs__control {
48
+ box-sizing: border-box;
49
+ min-height: var(--content-health-control-height);
50
+ height: var(--content-health-control-height);
43
51
  padding: 0 calc(var(--base) * 0.5);
44
- border: 1px solid var(--theme-elevation-150);
45
- border-radius: var(--style-radius-s);
46
- background: var(--theme-input-bg, var(--theme-elevation-0));
47
- color: var(--theme-text);
48
- font: inherit;
52
+ }
53
+
54
+ .content-health-list__filters .btn,
55
+ .content-health-list__summary .btn,
56
+ .content-health-list__actions .btn {
57
+ display: inline-flex;
58
+ align-items: center;
59
+ justify-content: center;
60
+ box-sizing: border-box;
61
+ min-height: var(--content-health-control-height);
62
+ padding-inline: calc(var(--base) * 0.6);
63
+ }
64
+
65
+ .content-health-list__clear {
66
+ flex-shrink: 0;
67
+ margin-inline-start: auto;
49
68
  }
50
69
 
51
70
  .content-health-list__summary {
@@ -55,7 +74,7 @@ html[data-theme="dark"] .content-health-list {
55
74
  align-items: center;
56
75
  justify-content: space-between;
57
76
  min-height: 1.5em;
58
- margin: var(--base) 0 calc(var(--base) * 0.5);
77
+ margin: var(--base) 0 calc(var(--base) * 0.75);
59
78
  color: var(--theme-elevation-600);
60
79
  }
61
80
 
@@ -61,7 +61,7 @@ export async function ContentHealthView({ initPageResult, params, searchParams,
61
61
  }));
62
62
  const collections = Object.keys(result.documents).map((slug) => ({
63
63
  value: slug,
64
- label: label(req.payload.collections[slug]?.config.labels?.plural, language) ?? slug,
64
+ label: label(config.collections.find((collection) => collection.slug === slug)?.labels?.plural, language) ?? slug,
65
65
  }));
66
66
  const locales = config.localization
67
67
  ? config.localization.locales.map((locale) => ({
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Button, Link } from "@payloadcms/ui";
4
- import { useMemo, useState } from "react";
3
+ import { Button, Link, ReactSelect } from "@payloadcms/ui";
4
+ import { useId, useMemo, useState } from "react";
5
5
  import { LIST_COPY } from "../copy.js";
6
6
  import { BATCH_CHECKS, batchURL, filterQuery, MAX_BATCH_TARGETS, matchesFilters, } from "../links.js";
7
7
  /**
@@ -23,8 +23,14 @@ export function WorkList({ adminRoute, batchAsk, checks, collections, initialFil
23
23
  const query = filterQuery(next);
24
24
  window.history.replaceState(window.history.state, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
25
25
  };
26
- return (_jsxs("div", { className: "content-health-list__body", children: [_jsxs("div", { className: "content-health-list__filters", children: [_jsx(Filter, { label: copy.check, all: copy.all, onChange: (check) => update({ ...filters, check: check }), options: checks, value: filters.check }), collections.length > 1 ? (_jsx(Filter, { label: copy.collection, all: copy.all, onChange: (collection) => update({ ...filters, collection }), options: collections, value: filters.collection })) : null, locales.length > 1 ? (_jsx(Filter, { label: copy.locale, all: copy.all, onChange: (locale) => update({ ...filters, locale }), options: locales, value: filters.locale })) : null, filtered ? (_jsx(Button, { buttonStyle: "subtle", margin: false, onClick: () => update({}), size: "small", children: copy.clear })) : null] }), _jsxs("div", { className: "content-health-list__summary", children: [_jsx("p", { "aria-live": "polite", children: shown.length ? copy.summary(shown.length, documents) : null }), batchHref ? (_jsx(Button, { buttonStyle: "primary", el: "link", margin: false, size: "small", url: batchHref, children: copy.fixMany(Math.min(batch.length, MAX_BATCH_TARGETS), batch.length) })) : null] }), shown.length ? (_jsx("ul", { className: "content-health-list__rows", children: shown.map((row) => (_jsxs("li", { className: "content-health-list__row", children: [_jsxs("div", { className: "content-health-list__what", children: [_jsx("span", { className: "content-health-list__check", children: row.checkLabel }), row.detail ? (_jsx("span", { className: "content-health-list__detail", children: row.detail })) : null] }), _jsxs("div", { className: "content-health-list__document", children: [_jsx(Link, { href: row.href, prefetch: false, children: row.title }), row.locale ? (_jsx("span", { className: "content-health-list__pill", children: row.locale })) : null, row.draft ? (_jsx("span", { className: "content-health-list__pill content-health-list__pill--draft", children: copy.draft })) : null] }), _jsx("div", { className: "content-health-list__actions", children: row.askHref ? (_jsx(Button, { buttonStyle: "secondary", el: "link", margin: false, size: "small", url: row.askHref, children: copy.fix })) : null })] }, row.key))) })) : (_jsx("p", { className: "content-health-list__empty", children: filtered ? copy.noneFiltered : copy.none }))] }));
26
+ return (_jsxs("div", { className: "content-health-list__body", children: [_jsxs("div", { className: "content-health-list__filters", children: [_jsx(Filter, { label: copy.check, all: copy.all, onChange: (check) => update({ ...filters, check: check }), options: checks, value: filters.check }), collections.length > 1 ? (_jsx(Filter, { label: copy.collection, all: copy.all, onChange: (collection) => update({ ...filters, collection }), options: collections, value: filters.collection })) : null, locales.length > 1 ? (_jsx(Filter, { label: copy.locale, all: copy.all, onChange: (locale) => update({ ...filters, locale }), options: locales, value: filters.locale })) : null, filtered ? (_jsx(Button, { buttonStyle: "subtle", className: "content-health-list__clear", margin: false, onClick: () => update({}), size: "small", children: copy.clear })) : null] }), _jsxs("div", { className: "content-health-list__summary", children: [_jsx("p", { "aria-live": "polite", children: shown.length ? copy.summary(shown.length, documents) : null }), batchHref ? (_jsx(Button, { buttonStyle: "primary", el: "link", margin: false, size: "small", url: batchHref, children: copy.fixMany(Math.min(batch.length, MAX_BATCH_TARGETS), batch.length) })) : null] }), shown.length ? (_jsx("ul", { className: "content-health-list__rows", children: shown.map((row) => (_jsxs("li", { className: "content-health-list__row", children: [_jsxs("div", { className: "content-health-list__what", children: [_jsx("span", { className: "content-health-list__check", children: row.checkLabel }), row.detail ? (_jsx("span", { className: "content-health-list__detail", children: row.detail })) : null] }), _jsxs("div", { className: "content-health-list__document", children: [_jsx(Link, { href: row.href, prefetch: false, children: row.title }), row.locale ? (_jsx("span", { className: "content-health-list__pill", children: row.locale })) : null, row.draft ? (_jsx("span", { className: "content-health-list__pill content-health-list__pill--draft", children: copy.draft })) : null] }), _jsx("div", { className: "content-health-list__actions", children: row.askHref ? (_jsx(Button, { buttonStyle: "secondary", el: "link", margin: false, size: "small", url: row.askHref, children: copy.fix })) : null })] }, row.key))) })) : (_jsx("p", { className: "content-health-list__empty", children: filtered ? copy.noneFiltered : copy.none }))] }));
27
27
  }
28
28
  function Filter({ all, label, onChange, options, value, }) {
29
- return (_jsxs("label", { className: "content-health-list__filter", children: [_jsx("span", { children: label }), _jsxs("select", { onChange: (event) => onChange(event.target.value || undefined), value: value ?? "", children: [_jsx("option", { value: "", children: all }), options.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value)))] })] }));
29
+ const inputId = useId();
30
+ const choices = [{ label: all, value: "" }, ...options];
31
+ return (_jsxs("div", { className: "content-health-list__filter", children: [_jsx("label", { htmlFor: inputId, children: label }), _jsx(ReactSelect, { inputId: inputId, isClearable: false, isSearchable: options.length > 6, onChange: (option) => {
32
+ if (!Array.isArray(option)) {
33
+ onChange(typeof option?.value === "string" && option.value ? option.value : undefined);
34
+ }
35
+ }, options: choices, value: choices.find((option) => option.value === (value ?? "")) ?? choices[0] })] }));
30
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simmalugnt-se/payload-content-health",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Content health checks and dashboard widgets for Payload Admin: alt texts, SEO fields and more",
5
5
  "keywords": [
6
6
  "payload",