@micelio/strapi-plugin-core 0.1.0 → 0.2.0

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.
Files changed (54) hide show
  1. package/README.md +5 -3
  2. package/dist/admin/MicelioLayout-Bmu5xCw9.js +1023 -0
  3. package/dist/admin/MicelioLayout-DMMsKnMo.mjs +1021 -0
  4. package/dist/admin/PreviewHeaderAction-BaduMvYy.mjs +61 -0
  5. package/dist/admin/PreviewHeaderAction-CGHycv4I.js +61 -0
  6. package/dist/admin/{en-D-T8z3qh.js → en-BDVuq0fN.js} +37 -1
  7. package/dist/admin/{en-C2O-S2ym.mjs → en-Bahc6y6N.mjs} +37 -1
  8. package/dist/admin/{es-RV0vkOHh.js → es-DStBGkm7.js} +37 -1
  9. package/dist/admin/{es-CQ2tv9N8.mjs → es-nUHBIoZG.mjs} +37 -1
  10. package/dist/admin/{index-D3TGbaQ7.js → index-D_Dbvo2F.js} +8 -2
  11. package/dist/admin/{index-CiSujTES.mjs → index-Dwr15ZsB.mjs} +8 -2
  12. package/dist/admin/index.js +1 -1
  13. package/dist/admin/index.mjs +1 -1
  14. package/dist/admin/permissions-BAI0qDr9.js +24 -0
  15. package/dist/admin/permissions-CYirM30e.mjs +25 -0
  16. package/dist/admin/src/components/EyeIcon.d.ts +8 -0
  17. package/dist/admin/src/components/PreviewFrame.d.ts +47 -0
  18. package/dist/admin/src/components/PreviewHeaderAction.d.ts +28 -0
  19. package/dist/admin/src/hooks/useEntry.d.ts +31 -0
  20. package/dist/admin/src/hooks/usePreviewSource.d.ts +31 -0
  21. package/dist/admin/src/pages/MicelioLayout.d.ts +2 -1
  22. package/dist/admin/src/pages/PreviewPage.d.ts +2 -0
  23. package/dist/admin/src/permissions.d.ts +5 -0
  24. package/dist/admin/src/translations/en.json.d.ts +37 -1
  25. package/dist/admin/src/utils/fetchError.d.ts +2 -0
  26. package/dist/admin/src/utils/previewAction.d.ts +22 -0
  27. package/dist/admin/src/utils/previewPane.d.ts +59 -0
  28. package/dist/server/index.js +796 -105
  29. package/dist/server/index.mjs +796 -105
  30. package/dist/server/src/constants/preview.d.ts +2 -0
  31. package/dist/server/src/constants/taxonomy.d.ts +13 -0
  32. package/dist/server/src/content-types/category/schema.json.d.ts +78 -0
  33. package/dist/server/src/content-types/index.d.ts +125 -2
  34. package/dist/server/src/content-types/preview-credential/schema.json.d.ts +7 -6
  35. package/dist/server/src/content-types/tag/schema.json.d.ts +46 -0
  36. package/dist/server/src/controllers/index.d.ts +6 -0
  37. package/dist/server/src/editorial/transitions.d.ts +5 -2
  38. package/dist/server/src/index.d.ts +140 -2
  39. package/dist/server/src/migrations/rename-legacy-uids.d.ts +26 -0
  40. package/dist/server/src/migrations/site-backfill.d.ts +13 -0
  41. package/dist/server/src/preview/credentials.d.ts +7 -5
  42. package/dist/server/src/preview/draft-query.d.ts +62 -0
  43. package/dist/server/src/preview/revocation.d.ts +9 -1
  44. package/dist/server/src/preview/shortcut.d.ts +24 -0
  45. package/dist/server/src/routes/index.d.ts +2 -0
  46. package/dist/server/src/routes/taxonomy.d.ts +12 -0
  47. package/dist/server/src/services/index.d.ts +6 -0
  48. package/dist/server/src/services/preview.d.ts +25 -6
  49. package/dist/server/src/site-scope/documents.d.ts +13 -3
  50. package/dist/server/src/types/hooks.d.ts +5 -4
  51. package/dist/server/src/types/preview.d.ts +35 -10
  52. package/package.json +4 -3
  53. package/dist/admin/MicelioLayout-3sKGPS_0.mjs +0 -443
  54. package/dist/admin/MicelioLayout-DXzRS4l3.js +0 -443
@@ -1,443 +0,0 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { Typography, Flex, Button, Box, useNotifyAT, Table, Thead, Tr, Th, Tbody, Td, Badge } from "@strapi/design-system";
3
- import { useFetchClient, Page, Layouts, useAuth, SubNav } from "@strapi/strapi/admin";
4
- import { useRef, useState, useEffect, useCallback, useMemo, lazy, Suspense } from "react";
5
- import { useIntl } from "react-intl";
6
- import { Routes, Route, Navigate, useParams } from "react-router-dom";
7
- import en from "./en-C2O-S2ym.mjs";
8
- import { g as getTranslation, P as PLUGIN_ID, p as pageLoaderOf } from "./index-CiSujTES.mjs";
9
- function useAdminPages() {
10
- const client = useFetchClient();
11
- const clientRef = useRef(client);
12
- clientRef.current = client;
13
- const [state, setState] = useState({ pages: [], hasFailed: false, isLoading: true });
14
- useEffect(() => {
15
- let isCurrent = true;
16
- void (async () => {
17
- try {
18
- const response = await clientRef.current.get(
19
- "/micelio/admin-pages"
20
- );
21
- if (isCurrent) setState({ pages: response.data.data, hasFailed: false, isLoading: false });
22
- } catch {
23
- if (isCurrent) setState({ pages: [], hasFailed: true, isLoading: false });
24
- }
25
- })();
26
- return () => {
27
- isCurrent = false;
28
- };
29
- }, []);
30
- return state;
31
- }
32
- function hasMessage(id) {
33
- return Object.hasOwn(en, id);
34
- }
35
- function useMessages() {
36
- const { formatMessage, formatDate } = useIntl();
37
- return {
38
- t: (id, values) => formatMessage(
39
- { id: getTranslation(id), defaultMessage: en[id] ?? id },
40
- values
41
- ),
42
- // Seconds included: a run again within the same minute must read as new.
43
- date: (iso) => formatDate(iso, { dateStyle: "medium", timeStyle: "medium" })
44
- };
45
- }
46
- const STATUS_READ_PERMISSION = { action: "plugin::micelio.status.read", subject: null };
47
- const NAV_GROUPS = ["overview", "content", "site", "about"];
48
- const CORE_NAV_ITEMS = [
49
- { id: "status", group: "overview", to: "", permission: STATUS_READ_PERMISSION },
50
- { id: "about", group: "about", to: "about" }
51
- ];
52
- function visibleNavItems(items, permissions) {
53
- return items.filter(
54
- (item) => !item.permission || permissions.some(({ action }) => action === item.permission?.action)
55
- );
56
- }
57
- function localised(text, locale) {
58
- const language = locale.split("-")[0] ?? "en";
59
- const found = language === "es" ? text.es : void 0;
60
- return found && found.trim() !== "" ? found : text.en;
61
- }
62
- function AboutPage() {
63
- const { t } = useMessages();
64
- return /* @__PURE__ */ jsxs(Page.Main, { children: [
65
- /* @__PURE__ */ jsx(Page.Title, { children: t("about.title") }),
66
- /* @__PURE__ */ jsx(Layouts.Header, { title: t("about.title"), subtitle: t("about.subtitle") }),
67
- /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(Typography, { children: t("about.body") }) })
68
- ] });
69
- }
70
- function useHostCheckRun(initial) {
71
- const client = useFetchClient();
72
- const clientRef = useRef(client);
73
- clientRef.current = client;
74
- const [report, setReport] = useState(initial);
75
- const [isRunning, setIsRunning] = useState(false);
76
- const [hasFailed, setHasFailed] = useState(false);
77
- const run = useCallback(async () => {
78
- setIsRunning(true);
79
- setHasFailed(false);
80
- try {
81
- const response = await clientRef.current.post(
82
- "/micelio/status/host-check"
83
- );
84
- setReport(response.data.data);
85
- return response.data.data;
86
- } catch {
87
- setHasFailed(true);
88
- return null;
89
- } finally {
90
- setIsRunning(false);
91
- }
92
- }, []);
93
- return { report, isRunning, hasFailed, run };
94
- }
95
- function useStatus() {
96
- const client = useFetchClient();
97
- const clientRef = useRef(client);
98
- clientRef.current = client;
99
- const [resource, setResource] = useState({ kind: "loading" });
100
- const [count, setCount] = useState(0);
101
- useEffect(() => {
102
- let isCurrent = true;
103
- void (async () => {
104
- try {
105
- const response = await clientRef.current.get("/micelio/status");
106
- if (isCurrent) setResource({ kind: "ready", data: response.data.data });
107
- } catch {
108
- if (isCurrent) setResource({ kind: "error" });
109
- }
110
- })();
111
- return () => {
112
- isCurrent = false;
113
- };
114
- }, [count]);
115
- const reload = useCallback(() => {
116
- setResource({ kind: "loading" });
117
- setCount((value) => value + 1);
118
- }, []);
119
- const refresh = useCallback(async () => {
120
- try {
121
- const response = await clientRef.current.get("/micelio/status");
122
- setResource({ kind: "ready", data: response.data.data });
123
- } catch {
124
- }
125
- }, []);
126
- return { resource, reload, refresh };
127
- }
128
- function checkText(result, part, isKnown) {
129
- const fallback = part === "title" ? result.title : result.fix;
130
- if (fallback === void 0) return null;
131
- const messageId = `status.hostCheck.check.${result.id}.${part}`;
132
- return isKnown(messageId) ? { messageId } : { text: fallback };
133
- }
134
- function diagnosticsText(report) {
135
- const lines = [`Micelio ${report.plugin.version} (core release line ${report.plugin.coreLine})`];
136
- if (report.hostCheck) {
137
- const failed = report.hostCheck.results.filter(({ status }) => status === "fail").length;
138
- lines.push(`Host check: ${report.hostCheck.ok ? "ok" : "fails"} (${failed} failed)`);
139
- } else {
140
- lines.push("Host check: not run");
141
- }
142
- for (const [id, result] of Object.entries(report.plugins)) lines.push(pluginLine(id, result));
143
- return lines.join("\n");
144
- }
145
- function pluginLine(id, result) {
146
- if (result.ranAt === null) return `${id}: checks not run`;
147
- const count = (status) => result.checks.filter((check) => check.status === status).length;
148
- return `${id}: ${count("ok")} ok, ${count("warn")} warn, ${count("fail")} fail`;
149
- }
150
- const TONES = {
151
- success: { backgroundColor: "success100", textColor: "success700" },
152
- danger: { backgroundColor: "danger100", textColor: "danger700" },
153
- // warning700 on warning100 is 4.0:1, below the 4.5:1 of WCAG AA.
154
- warning: { backgroundColor: "warning100", textColor: "neutral800" },
155
- neutral: { backgroundColor: "neutral150", textColor: "neutral700" }
156
- };
157
- const CHECK_TONES = {
158
- pass: "success",
159
- fail: "danger",
160
- skip: "neutral"
161
- };
162
- function StatusPage() {
163
- const { t } = useMessages();
164
- return /* @__PURE__ */ jsx(Page.Protect, { permissions: [STATUS_READ_PERMISSION], children: /* @__PURE__ */ jsxs(Page.Main, { children: [
165
- /* @__PURE__ */ jsx(Page.Title, { children: t("status.title") }),
166
- /* @__PURE__ */ jsx(Layouts.Header, { title: t("status.title"), subtitle: t("status.subtitle") }),
167
- /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(StatusContent, {}) })
168
- ] }) });
169
- }
170
- function StatusContent() {
171
- const { t } = useMessages();
172
- const { resource, reload, refresh } = useStatus();
173
- if (resource.kind === "loading") return /* @__PURE__ */ jsx(Page.Loading, { children: t("status.loading") });
174
- if (resource.kind === "error") {
175
- return /* @__PURE__ */ jsx(Section, { title: t("status.error.title"), children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
176
- /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: t("status.error") }),
177
- /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "S", onClick: reload, children: t("status.retry") })
178
- ] }) });
179
- }
180
- const report = resource.data;
181
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
182
- /* @__PURE__ */ jsx(PluginSection, { report }),
183
- /* @__PURE__ */ jsx(HostCheckSection, { initial: report.hostCheck, onRan: refresh }),
184
- /* @__PURE__ */ jsx(PluginChecksSections, { report }),
185
- /* @__PURE__ */ jsx(FrontendsSection, { frontends: report.frontends }),
186
- /* @__PURE__ */ jsx(SitesSection, { sites: report.sites }),
187
- /* @__PURE__ */ jsx(DiagnosticsButton, { report })
188
- ] });
189
- }
190
- function Section({ title, children }) {
191
- return /* @__PURE__ */ jsx(Box, { tag: "section", background: "neutral0", hasRadius: true, shadow: "filterShadow", padding: 6, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
192
- /* @__PURE__ */ jsx(Typography, { variant: "delta", tag: "h2", children: title }),
193
- children
194
- ] }) });
195
- }
196
- function StatusBadge({ tone, children }) {
197
- return /* @__PURE__ */ jsx(Badge, { ...TONES[tone], children });
198
- }
199
- function Fact({ label, value }) {
200
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
201
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", tag: "dt", children: label }),
202
- /* @__PURE__ */ jsx(Typography, { tag: "dd", children: value })
203
- ] });
204
- }
205
- function PluginSection({ report }) {
206
- const { t } = useMessages();
207
- return /* @__PURE__ */ jsx(Section, { title: t("status.plugin.title"), children: /* @__PURE__ */ jsxs(Flex, { tag: "dl", gap: 8, wrap: "wrap", alignItems: "flex-start", children: [
208
- /* @__PURE__ */ jsx(Fact, { label: t("status.plugin.version"), value: report.plugin.version }),
209
- /* @__PURE__ */ jsx(Fact, { label: t("status.plugin.coreLine"), value: report.plugin.coreLine }),
210
- /* @__PURE__ */ jsx(Fact, { label: t("status.blocks.count"), value: report.blocks.count }),
211
- /* @__PURE__ */ jsx(Fact, { label: t("status.sites.count"), value: report.sites.length })
212
- ] }) });
213
- }
214
- function HostCheckSection({
215
- initial,
216
- onRan
217
- }) {
218
- const { t, date } = useMessages();
219
- const { notifyStatus, notifyAlert } = useNotifyAT();
220
- const { report, isRunning, hasFailed, run } = useHostCheckRun(initial);
221
- const say = (text) => "messageId" in text ? t(text.messageId) : text.text;
222
- const verdict = (current) => `${t(current.ok ? "status.hostCheck.ok" : "status.hostCheck.failed")} ${t(
223
- "status.hostCheck.checkedAt",
224
- { date: date(current.checkedAt), environment: current.environment }
225
- )}`;
226
- const runAgain = async () => {
227
- const answer = await run();
228
- if (answer) await onRan();
229
- if (answer) notifyStatus(verdict(answer));
230
- else notifyAlert(t("status.hostCheck.runFailed"));
231
- };
232
- const header = /* @__PURE__ */ jsxs(Flex, { gap: 4, wrap: "wrap", justifyContent: "space-between", alignItems: "center", children: [
233
- /* @__PURE__ */ jsx(Typography, { textColor: report ? void 0 : "neutral600", children: report ? verdict(report) : t("status.hostCheck.notRun") }),
234
- /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "S", loading: isRunning, onClick: runAgain, children: t(isRunning ? "status.hostCheck.running" : "status.hostCheck.runAgain") })
235
- ] });
236
- const failure = hasFailed ? /* @__PURE__ */ jsx(Typography, { textColor: "danger700", children: t("status.hostCheck.runFailed") }) : null;
237
- if (!report) {
238
- return /* @__PURE__ */ jsxs(Section, { title: t("status.hostCheck.title"), children: [
239
- header,
240
- failure
241
- ] });
242
- }
243
- return /* @__PURE__ */ jsxs(Section, { title: t("status.hostCheck.title"), children: [
244
- header,
245
- failure,
246
- /* @__PURE__ */ jsxs(Table, { colCount: 3, rowCount: report.results.length + 1, children: [
247
- /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
248
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.hostCheck.column.check") }) }),
249
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.hostCheck.column.status") }) }),
250
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.hostCheck.column.found") }) })
251
- ] }) }),
252
- /* @__PURE__ */ jsx(Tbody, { children: report.results.map((result) => {
253
- const title = checkText(result, "title", hasMessage);
254
- const fix = result.status === "fail" ? checkText(result, "fix", hasMessage) : null;
255
- return /* @__PURE__ */ jsxs(Tr, { children: [
256
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
257
- /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: title ? say(title) : result.id }),
258
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(
259
- result.required ? "status.hostCheck.required" : "status.hostCheck.optional"
260
- ) })
261
- ] }) }),
262
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(StatusBadge, { tone: CHECK_TONES[result.status], children: t(`status.hostCheck.status.${result.status}`) }) }),
263
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
264
- /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: result.detail }),
265
- fix ? /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral800", children: [
266
- /* @__PURE__ */ jsxs("strong", { children: [
267
- t("status.hostCheck.fix"),
268
- ":"
269
- ] }),
270
- " ",
271
- say(fix)
272
- ] }) : null
273
- ] }) })
274
- ] }, result.id);
275
- }) })
276
- ] }),
277
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("status.hostCheck.rerun") })
278
- ] });
279
- }
280
- function FrontendsSection({ frontends }) {
281
- const { t } = useMessages();
282
- if (frontends.length === 0) {
283
- return /* @__PURE__ */ jsx(Section, { title: t("status.frontends.title"), children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: t("status.frontends.none") }) });
284
- }
285
- return /* @__PURE__ */ jsx(Section, { title: t("status.frontends.title"), children: /* @__PURE__ */ jsxs(Table, { colCount: 4, rowCount: frontends.length + 1, children: [
286
- /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
287
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.frontends.column.origin") }) }),
288
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.frontends.column.sites") }) }),
289
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.frontends.column.health") }) }),
290
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.frontends.column.version") }) })
291
- ] }) }),
292
- /* @__PURE__ */ jsx(Tbody, { children: frontends.map((frontend) => /* @__PURE__ */ jsxs(Tr, { children: [
293
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { children: frontend.origin }) }),
294
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { children: frontend.sites.join(", ") }) }),
295
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
296
- /* @__PURE__ */ jsx(StatusBadge, { tone: frontend.health === "reachable" ? "success" : "neutral", children: t(`status.frontends.health.${frontend.health}`) }),
297
- frontend.health === "unavailable" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("status.frontends.unavailable") }) : null
298
- ] }) }),
299
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { children: frontend.version ?? t("status.frontends.noVersion") }) })
300
- ] }, frontend.origin)) })
301
- ] }) });
302
- }
303
- function SitesSection({ sites }) {
304
- const { t } = useMessages();
305
- return /* @__PURE__ */ jsx(Section, { title: t("status.sites.title"), children: /* @__PURE__ */ jsxs(Table, { colCount: 4, rowCount: sites.length + 1, children: [
306
- /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
307
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.sites.column.name") }) }),
308
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.sites.column.slug") }) }),
309
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.sites.column.hosts") }) }),
310
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.sites.column.url") }) })
311
- ] }) }),
312
- /* @__PURE__ */ jsx(Tbody, { children: sites.map((site) => /* @__PURE__ */ jsxs(Tr, { children: [
313
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
314
- /* @__PURE__ */ jsx(Typography, { children: site.name }),
315
- site.isDefault ? /* @__PURE__ */ jsx(Badge, { children: t("status.sites.default") }) : null
316
- ] }) }),
317
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { children: site.slug }) }),
318
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { children: site.hosts.length > 0 ? site.hosts.join(", ") : t("status.sites.noHosts") }) }),
319
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { children: site.origin ?? t("status.sites.noUrl") }) })
320
- ] }, site.documentId)) })
321
- ] }) });
322
- }
323
- const PLUGIN_TONES = {
324
- ok: "success",
325
- warn: "warning",
326
- fail: "danger"
327
- };
328
- function PluginChecksSections({ report }) {
329
- return /* @__PURE__ */ jsx(Fragment, { children: Object.entries(report.plugins).map(([id, result]) => /* @__PURE__ */ jsx(PluginChecksCard, { result, sites: report.sites }, id)) });
330
- }
331
- function PluginChecksCard({ result, sites }) {
332
- const { t, date } = useMessages();
333
- const { locale } = useIntl();
334
- const slugOf = (documentId) => sites.find((site) => site.documentId === documentId)?.slug ?? documentId;
335
- return /* @__PURE__ */ jsxs(Section, { title: localised(result.label, locale), children: [
336
- /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: result.ranAt === null ? t("status.plugins.notRun") : t("status.plugins.ranAt", { date: date(result.ranAt) }) }),
337
- result.ranAt !== null && result.checks.length === 0 ? /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: t("status.plugins.empty") }) : null,
338
- result.checks.length > 0 ? /* @__PURE__ */ jsxs(Table, { colCount: 4, rowCount: result.checks.length + 1, children: [
339
- /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
340
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.plugins.column.site") }) }),
341
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.plugins.column.check") }) }),
342
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.plugins.column.status") }) }),
343
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("status.plugins.column.found") }) })
344
- ] }) }),
345
- /* @__PURE__ */ jsx(Tbody, { children: result.checks.map((check) => /* @__PURE__ */ jsxs(Tr, { children: [
346
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { children: slugOf(check.site) }) }),
347
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: localised(check.title, locale) }) }),
348
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(StatusBadge, { tone: PLUGIN_TONES[check.status], children: t(`status.plugins.status.${check.status}`) }) }),
349
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
350
- check.detail ? /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: localised(check.detail, locale) }) : null,
351
- check.fix ? /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral800", children: [
352
- /* @__PURE__ */ jsxs("strong", { children: [
353
- t("status.plugins.fix"),
354
- ":"
355
- ] }),
356
- " ",
357
- localised(check.fix, locale)
358
- ] }) : null
359
- ] }) })
360
- ] }, `${check.site}:${check.id}`)) })
361
- ] }) : null
362
- ] });
363
- }
364
- function DiagnosticsButton({ report }) {
365
- const { t } = useMessages();
366
- const { notifyStatus, notifyAlert } = useNotifyAT();
367
- const copy = async () => {
368
- try {
369
- await navigator.clipboard.writeText(diagnosticsText(report));
370
- notifyStatus(t("status.diagnostics.copied"));
371
- } catch {
372
- notifyAlert(t("status.diagnostics.failed"));
373
- }
374
- };
375
- return /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", size: "S", onClick: copy, children: t("status.diagnostics.copy") }) });
376
- }
377
- function MicelioLayout() {
378
- const { t } = useMessages();
379
- const { locale } = useIntl();
380
- const { pages, hasFailed, isLoading } = useAdminPages();
381
- const isLoadingPermissions = useAuth("MicelioLayout", (state) => state.isLoading);
382
- const permissions = useAuth("MicelioLayout", (state) => state.permissions);
383
- const canReadStatus = permissions.some(({ action }) => action === STATUS_READ_PERMISSION.action);
384
- const coreItems = visibleNavItems(CORE_NAV_ITEMS, permissions);
385
- const linksOf = (group) => [
386
- ...coreItems.filter((item) => item.group === group).map((item) => /* @__PURE__ */ jsx(
387
- SubNav.Link,
388
- {
389
- to: item.to ? `/plugins/${PLUGIN_ID}/${item.to}` : `/plugins/${PLUGIN_ID}`,
390
- end: !item.to,
391
- label: t(`nav.${item.id}`)
392
- },
393
- item.id
394
- )),
395
- ...pages.filter((page) => page.group === group).map((page) => /* @__PURE__ */ jsx(
396
- SubNav.Link,
397
- {
398
- to: `/plugins/${PLUGIN_ID}/${page.to}`,
399
- label: localised(page.label, locale)
400
- },
401
- page.id
402
- ))
403
- ];
404
- if (isLoadingPermissions) return /* @__PURE__ */ jsx(Page.Loading, {});
405
- return /* @__PURE__ */ jsx(
406
- Layouts.Root,
407
- {
408
- sideNav: /* @__PURE__ */ jsxs(SubNav.Main, { "aria-label": t("nav.label"), children: [
409
- /* @__PURE__ */ jsx(SubNav.Header, { label: t("nav.title") }),
410
- /* @__PURE__ */ jsxs(SubNav.Sections, { children: [
411
- NAV_GROUPS.map((group) => ({ group, links: linksOf(group) })).filter(({ links }) => links.length > 0).map(({ group, links }) => /* @__PURE__ */ jsx(SubNav.Section, { label: t(`nav.group.${group}`), children: links }, group)),
412
- hasFailed ? /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: t("nav.error") }) : null
413
- ] })
414
- ] }),
415
- children: /* @__PURE__ */ jsxs(Routes, { children: [
416
- /* @__PURE__ */ jsx(Route, { index: true, element: canReadStatus ? /* @__PURE__ */ jsx(StatusPage, {}) : /* @__PURE__ */ jsx(Navigate, { to: "about", replace: true }) }),
417
- /* @__PURE__ */ jsx(Route, { path: "about", element: /* @__PURE__ */ jsx(AboutPage, {}) }),
418
- /* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(ExtensionPage, { pages, isLoading }) })
419
- ] })
420
- }
421
- );
422
- }
423
- function ExtensionPage({ pages, isLoading }) {
424
- const { t } = useMessages();
425
- const path = useParams()["*"] ?? "";
426
- const page = pages.find((candidate) => candidate.to === path);
427
- const Component = useMemo(() => {
428
- const loader = page ? pageLoaderOf(page.id) : void 0;
429
- return loader ? lazy(loader) : null;
430
- }, [page]);
431
- if (isLoading) return /* @__PURE__ */ jsx(Page.Loading, {});
432
- if (!Component) {
433
- return /* @__PURE__ */ jsxs(Page.Main, { children: [
434
- /* @__PURE__ */ jsx(Page.Title, { children: t("page.unavailable.title") }),
435
- /* @__PURE__ */ jsx(Layouts.Header, { title: t("page.unavailable.title") }),
436
- /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: t("page.unavailable") }) })
437
- ] });
438
- }
439
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Page.Loading, {}), children: /* @__PURE__ */ jsx(Component, {}) });
440
- }
441
- export {
442
- MicelioLayout as default
443
- };