@simmalugnt-se/payload-content-health 0.5.0 → 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 +15 -0
- package/dist/scan.js +3 -3
- package/dist/styles/view.css +28 -9
- package/dist/view/ContentHealthView.js +2 -2
- package/dist/view/WorkList.js +10 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
|
|
12
|
+
## 0.5.1
|
|
13
|
+
|
|
14
|
+
- The assistant's button now shows in the header of the work list. The view did not pass Admin's
|
|
15
|
+
header actions to its template, so the button was missing there, and an editor who closed the
|
|
16
|
+
panel could not open it again.
|
|
17
|
+
|
|
3
18
|
## 0.5.0
|
|
4
19
|
|
|
5
20
|
- "Fix N with the assistant" on the work list, when it is filtered to missing alt texts, meta titles
|
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
|
|
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,
|
package/dist/styles/view.css
CHANGED
|
@@ -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
|
|
41
|
-
|
|
42
|
-
height:
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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.
|
|
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(
|
|
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) => ({
|
|
@@ -70,7 +70,7 @@ export async function ContentHealthView({ initPageResult, params, searchParams,
|
|
|
70
70
|
}))
|
|
71
71
|
: [];
|
|
72
72
|
// Payload wraps only its own views in the Admin shell; a custom view brings nav and header itself.
|
|
73
|
-
return (_jsx(DefaultTemplate, { i18n: req.i18n, locale: locale, params: params, payload: req.payload, permissions: permissions, req: req, searchParams: searchParams, user: req.user ?? undefined, visibleEntities: visibleEntities, children: _jsxs(Gutter, { className: "content-health-list", children: [_jsx(SetStepNav, { nav: [{ label: copy.title }] }), _jsxs("header", { className: "content-health-list__header", children: [_jsx("h1", { children: copy.title }), _jsx("p", { className: "content-health-list__intro", children: copy.intro })] }), _jsx(WorkList, { adminRoute: adminRoute, batchAsk: batchAsk, checks: checks, collections: collections, initialFilters: readFilters(searchParams), language: language, locales: locales, rows: rows }), result.problems.length ? (_jsx("ul", { className: "content-health-list__problems", children: result.problems.map((problem) => (_jsx("li", { children: problem }, problem))) })) : null] }) }));
|
|
73
|
+
return (_jsx(DefaultTemplate, { i18n: req.i18n, locale: locale, params: params, payload: req.payload, permissions: permissions, req: req, searchParams: searchParams, user: req.user ?? undefined, viewActions: req.payload.config.admin?.components?.actions, visibleEntities: visibleEntities, children: _jsxs(Gutter, { className: "content-health-list", children: [_jsx(SetStepNav, { nav: [{ label: copy.title }] }), _jsxs("header", { className: "content-health-list__header", children: [_jsx("h1", { children: copy.title }), _jsx("p", { className: "content-health-list__intro", children: copy.intro })] }), _jsx(WorkList, { adminRoute: adminRoute, batchAsk: batchAsk, checks: checks, collections: collections, initialFilters: readFilters(searchParams), language: language, locales: locales, rows: rows }), result.problems.length ? (_jsx("ul", { className: "content-health-list__problems", children: result.problems.map((problem) => (_jsx("li", { children: problem }, problem))) })) : null] }) }));
|
|
74
74
|
}
|
|
75
75
|
/** By check, then document, then locale, so a document's locales sit together. */
|
|
76
76
|
function sortFindings(findings) {
|
package/dist/view/WorkList.js
CHANGED
|
@@ -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
|
-
|
|
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