magic-editor-x 2.3.1 → 2.4.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.
- package/CHANGELOG.md +74 -0
- package/README.md +299 -142
- package/dist/admin/AuditPage-C2u6z4aN.js +381 -0
- package/dist/admin/AuditPage-guB0SiGS.mjs +381 -0
- package/dist/admin/{ConfigurationPage-CFP3lp9p.js → ConfigurationPage-D6uya-J1.js} +228 -13
- package/dist/admin/{ConfigurationPage-CYGDLjM7.mjs → ConfigurationPage-DiEpF1Rr.mjs} +222 -7
- package/dist/admin/ConfirmAction-CUhpngYU.js +71 -0
- package/dist/admin/ConfirmAction-CZjpduc3.mjs +72 -0
- package/dist/admin/{CustomBlocksPage-B5Q33N-s.mjs → CustomBlocksPage-Byt10-6c.mjs} +6 -4
- package/dist/admin/{CustomBlocksPage-DzPOSpfn.js → CustomBlocksPage-DP3h_wNd.js} +21 -19
- package/dist/admin/MentionsWidget-C2OCAmqq.js +227 -0
- package/dist/admin/MentionsWidget-sMkM9mHX.mjs +225 -0
- package/dist/admin/{TemplatesPage-BVkgafCK.js → TemplatesPage-DrSJdteI.js} +313 -17
- package/dist/admin/{TemplatesPage-4A8JNO_Z.mjs → TemplatesPage-Yp4OqFE2.mjs} +305 -9
- package/dist/admin/{ConfirmAction-DuQwvRYi.mjs → api-2ZRpHM3d.mjs} +19 -70
- package/dist/admin/{ConfirmAction-zLuIFj8t.js → api-bix9RLLI.js} +19 -70
- package/dist/admin/auditText-DIIYVR6k.mjs +110 -0
- package/dist/admin/auditText-DUhWu2Nx.js +109 -0
- package/dist/admin/comments-C7P41lan.js +86 -0
- package/dist/admin/comments-hfIbLQNO.mjs +87 -0
- package/dist/admin/{de-BMY2LBaa.mjs → de-BNPIGqhs.mjs} +41 -2
- package/dist/admin/{de-2Ie5jy7j.js → de-BhhGss1l.js} +41 -2
- package/dist/admin/{de-DOiGaTNX.mjs → de-CKz6CG3V.mjs} +191 -5
- package/dist/admin/{de-C3AsGauQ.js → de-CbBDnXeT.js} +140 -1
- package/dist/admin/{de-BUS1hUw0.mjs → de-DiCZrmH8.mjs} +140 -1
- package/dist/admin/{de-B1X46JJZ.js → de-zcV8D7nt.js} +191 -5
- package/dist/admin/{en-Ah-Cw0Wd.js → en-B9ApE1y1.js} +41 -2
- package/dist/admin/{en-CDg_18Bt.js → en-BMWhILnj.js} +191 -5
- package/dist/admin/{en-BkEjpC3i.js → en-CpehF0Kv.js} +140 -1
- package/dist/admin/{en-GCzgS9Aw.mjs → en-DCPMqFIa.mjs} +140 -1
- package/dist/admin/{en-CU6UzV4g.mjs → en-cYzqbASF.mjs} +191 -5
- package/dist/admin/{en-CvFiqti2.mjs → en-gFLeK9Ng.mjs} +41 -2
- package/dist/admin/{es-DbKHZz5l.mjs → es-BmwBgEgz.mjs} +41 -2
- package/dist/admin/{es-Cr8JH85N.js → es-C0W31rl8.js} +41 -2
- package/dist/admin/{es-BCpJmUEM.js → es-CQPh8PXw.js} +191 -5
- package/dist/admin/{es-C4pEnDRv.js → es-CawpzwyC.js} +140 -1
- package/dist/admin/{es-DHBBZKl2.mjs → es-Chs37IBR.mjs} +140 -1
- package/dist/admin/{es-BmfffNM2.mjs → es-DCamt1ek.mjs} +191 -5
- package/dist/admin/{fr-DQJ_7aq5.mjs → fr-CMWBNE5D.mjs} +41 -2
- package/dist/admin/{fr-C2aLSwEu.js → fr-COOsqexl.js} +140 -1
- package/dist/admin/{fr-Dvq4xk2e.mjs → fr-Dp5-XP29.mjs} +140 -1
- package/dist/admin/{fr-ZcN0yM_2.js → fr-DpC44Ol8.js} +191 -5
- package/dist/admin/{fr-OJ4VW1kh.js → fr-iGeIfEcU.js} +41 -2
- package/dist/admin/{fr-DZd2XJP6.mjs → fr-oW0t8bT5.mjs} +191 -5
- package/dist/admin/{index-DQVE0ymw.js → index-64wc26Bl.js} +17467 -10369
- package/dist/admin/{index-k8_a5o1A.mjs → index-BVjf1gVC.mjs} +13786 -6687
- package/dist/admin/{index-DR8sHkTk.js → index-D6Z7i8ba.js} +1003 -53
- package/dist/admin/{index-My6FjjHB.mjs → index-D_Fv8Non.mjs} +1032 -82
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.mjs +3 -2
- package/dist/admin/math-CIQ4Z_mY.mjs +47 -0
- package/dist/admin/math-vsK_06ZR.js +49 -0
- package/dist/admin/{pt-D0I0_JYs.js → pt-BHmXk2d9.js} +41 -2
- package/dist/admin/{pt-CImqDnLB.js → pt-Bo0Pm_Pt.js} +191 -5
- package/dist/admin/{pt-CilDggGF.mjs → pt-DALDvfBn.mjs} +140 -1
- package/dist/admin/{pt-BSLzA17U.mjs → pt-DFNgZ5_k.mjs} +41 -2
- package/dist/admin/{pt-DX0OAIoL.js → pt-DXy7G1x7.js} +140 -1
- package/dist/admin/{pt-C3UdeIpd.mjs → pt-uGpfRQLC.mjs} +191 -5
- package/dist/admin/{useT-DNphiBQR.js → useT-BXJLIPN4.js} +1 -1
- package/dist/admin/{useT-Cmg1jwwG.mjs → useT-CLPhBmBC.mjs} +1 -1
- package/dist/blocks/index.d.mts +2 -0
- package/dist/blocks/index.d.ts +2 -0
- package/dist/blocks/index.js +13 -2
- package/dist/blocks/index.mjs +13 -2
- package/dist/math/index.d.mts +27 -0
- package/dist/math/index.d.ts +27 -0
- package/dist/math/index.js +164 -0
- package/dist/math/index.mjs +134 -0
- package/dist/react/index.js +673 -91
- package/dist/react/index.mjs +673 -91
- package/dist/render/index.d.mts +26 -0
- package/dist/render/index.d.ts +26 -0
- package/dist/render/index.js +779 -106
- package/dist/render/index.mjs +779 -106
- package/dist/server/index.js +10419 -4103
- package/dist/server/index.mjs +10419 -4103
- package/dist/vue/index.js +673 -91
- package/dist/vue/index.mjs +673 -91
- package/package.json +8 -2
- package/schema/magic-editor-x.schema.json +127 -2
- package/types/blocks.d.ts +2 -0
- package/types/index.d.ts +42 -0
- package/types/math.d.ts +27 -0
- package/types/render.d.ts +26 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { Flex, Typography, Button, Loader, EmptyStateLayout, Box, Badge, Table, Thead, Tr, Th, Tbody, Td, Alert, Grid, Field, SingleSelect, SingleSelectOption, TextInput } from "@strapi/design-system";
|
|
5
|
+
import { ArrowClockwise, Filter } from "@strapi/icons";
|
|
6
|
+
import { useFetchClient, useRBAC, useQueryParams, Page, Pagination } from "@strapi/strapi/admin";
|
|
7
|
+
import { P as PERMISSIONS } from "./index-D_Fv8Non.mjs";
|
|
8
|
+
import { A as API } from "./api-2ZRpHM3d.mjs";
|
|
9
|
+
import { u as useT, P as PageShell, S as SectionCard } from "./useT-CLPhBmBC.mjs";
|
|
10
|
+
import { u as useBreakpoint } from "./useBreakpoint-DCfn6pDG.mjs";
|
|
11
|
+
import { c as changeSummary, e as eventLabel, a as actorLabel, E as EVENT_LABELS } from "./auditText-DIIYVR6k.mjs";
|
|
12
|
+
const ALL = "__all__";
|
|
13
|
+
const UID_PATTERN = /^(api|plugin)::[a-z0-9-]{1,60}\.[a-z0-9-]{1,60}$/;
|
|
14
|
+
const DOCUMENT_ID_PATTERN = /^[a-z0-9]{1,64}$/;
|
|
15
|
+
const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
16
|
+
const FILTER_KEYS = ["event", "actor", "uid", "documentId", "from", "to"];
|
|
17
|
+
const readFilters = (query) => {
|
|
18
|
+
const text = (key) => typeof query[key] === "string" ? query[key] : "";
|
|
19
|
+
return {
|
|
20
|
+
event: text("event"),
|
|
21
|
+
actor: /^\d{1,10}$/.test(text("actor")) ? text("actor") : "",
|
|
22
|
+
uid: text("uid"),
|
|
23
|
+
documentId: text("documentId"),
|
|
24
|
+
from: DATE_PATTERN.test(text("from")) ? text("from") : "",
|
|
25
|
+
to: DATE_PATTERN.test(text("to")) ? text("to") : ""
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const AuditFilters = ({ t, applied, actors, active, onApply, onReset }) => {
|
|
29
|
+
const [draft, setDraft] = useState(applied);
|
|
30
|
+
const uidInvalid = draft.uid !== "" && !UID_PATTERN.test(draft.uid);
|
|
31
|
+
const documentInvalid = draft.documentId !== "" && !DOCUMENT_ID_PATTERN.test(draft.documentId);
|
|
32
|
+
const documentWithoutUid = draft.documentId !== "" && draft.uid === "";
|
|
33
|
+
const rangeInvalid = Boolean(draft.from && draft.to && draft.from > draft.to);
|
|
34
|
+
const canApply = !uidInvalid && !documentInvalid && !documentWithoutUid && !rangeInvalid;
|
|
35
|
+
const apply = (event) => {
|
|
36
|
+
if (event) event.preventDefault();
|
|
37
|
+
if (canApply) onApply(draft);
|
|
38
|
+
};
|
|
39
|
+
const reset = onReset;
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
SectionCard,
|
|
42
|
+
{
|
|
43
|
+
title: t("settings.audit.filters", "Filters"),
|
|
44
|
+
action: active ? /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: reset, children: t("settings.audit.reset", "Reset filters") }) : null,
|
|
45
|
+
children: /* @__PURE__ */ jsxs(Box, { tag: "form", onSubmit: apply, noValidate: true, children: [
|
|
46
|
+
/* @__PURE__ */ jsxs(Grid.Root, { gap: { initial: 4, medium: 6 }, children: [
|
|
47
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 6, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(Field.Root, { name: "event", children: [
|
|
48
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("settings.audit.filter.event", "Event") }),
|
|
49
|
+
/* @__PURE__ */ jsxs(
|
|
50
|
+
SingleSelect,
|
|
51
|
+
{
|
|
52
|
+
value: draft.event || ALL,
|
|
53
|
+
onChange: (value) => setDraft({ ...draft, event: value === ALL ? "" : String(value) }),
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: ALL, children: t("settings.audit.filter.allEvents", "All events") }),
|
|
56
|
+
Object.keys(EVENT_LABELS).map((event) => /* @__PURE__ */ jsx(SingleSelectOption, { value: event, children: eventLabel(t, event) }, event))
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] }) }),
|
|
61
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 6, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(Field.Root, { name: "actor", children: [
|
|
62
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("settings.audit.filter.actor", "Changed by") }),
|
|
63
|
+
/* @__PURE__ */ jsxs(
|
|
64
|
+
SingleSelect,
|
|
65
|
+
{
|
|
66
|
+
value: draft.actor || ALL,
|
|
67
|
+
onChange: (value) => setDraft({ ...draft, actor: value === ALL ? "" : String(value) }),
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: ALL, children: t("settings.audit.filter.allActors", "Everyone") }),
|
|
70
|
+
actors.map((actor) => /* @__PURE__ */ jsx(SingleSelectOption, { value: String(actor.id), children: actor.name || t("settings.audit.actor.unnamed", "Admin without a name") }, actor.id))
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] }) }),
|
|
75
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 6, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(
|
|
76
|
+
Field.Root,
|
|
77
|
+
{
|
|
78
|
+
name: "uid",
|
|
79
|
+
error: uidInvalid ? t("settings.audit.filter.uidInvalid", "Use a uid such as api::article.article.") : void 0,
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("settings.audit.filter.uid", "Content type") }),
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
83
|
+
TextInput,
|
|
84
|
+
{
|
|
85
|
+
value: draft.uid,
|
|
86
|
+
placeholder: "api::article.article",
|
|
87
|
+
onChange: (event) => setDraft({ ...draft, uid: event.target.value.trim() })
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
) }),
|
|
94
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 6, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(
|
|
95
|
+
Field.Root,
|
|
96
|
+
{
|
|
97
|
+
name: "documentId",
|
|
98
|
+
hint: t("settings.audit.filter.documentHint", "Needs a content type."),
|
|
99
|
+
error: documentInvalid ? t("settings.audit.filter.documentInvalid", "Use lowercase letters and digits only.") : documentWithoutUid ? t("settings.audit.filter.documentHint", "Needs a content type.") : void 0,
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("settings.audit.filter.document", "Document id") }),
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
103
|
+
TextInput,
|
|
104
|
+
{
|
|
105
|
+
value: draft.documentId,
|
|
106
|
+
onChange: (event) => setDraft({ ...draft, documentId: event.target.value.trim() })
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
110
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
) }),
|
|
114
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 6, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(Field.Root, { name: "from", children: [
|
|
115
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("settings.audit.filter.from", "From") }),
|
|
116
|
+
/* @__PURE__ */ jsx(
|
|
117
|
+
TextInput,
|
|
118
|
+
{
|
|
119
|
+
type: "date",
|
|
120
|
+
value: draft.from,
|
|
121
|
+
onChange: (event) => setDraft({ ...draft, from: event.target.value })
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
] }) }),
|
|
125
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 6, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(
|
|
126
|
+
Field.Root,
|
|
127
|
+
{
|
|
128
|
+
name: "to",
|
|
129
|
+
error: rangeInvalid ? t("settings.audit.filter.rangeInvalid", "The end is before the start.") : void 0,
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ jsx(Field.Label, { children: t("settings.audit.filter.to", "To") }),
|
|
132
|
+
/* @__PURE__ */ jsx(
|
|
133
|
+
TextInput,
|
|
134
|
+
{
|
|
135
|
+
type: "date",
|
|
136
|
+
value: draft.to,
|
|
137
|
+
onChange: (event) => setDraft({ ...draft, to: event.target.value })
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
) })
|
|
144
|
+
] }),
|
|
145
|
+
/* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", paddingTop: 6, children: /* @__PURE__ */ jsx(Button, { type: "submit", startIcon: /* @__PURE__ */ jsx(Filter, {}), disabled: !canApply, children: t("settings.audit.apply", "Apply filters") }) })
|
|
146
|
+
] })
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
const AuditPage = () => {
|
|
151
|
+
const t = useT();
|
|
152
|
+
const { formatDate } = useIntl();
|
|
153
|
+
const { get } = useFetchClient();
|
|
154
|
+
const { isBelowLarge } = useBreakpoint();
|
|
155
|
+
const audit = useRBAC(PERMISSIONS.auditRead);
|
|
156
|
+
const settings = useRBAC(PERMISSIONS.settingsRead);
|
|
157
|
+
const [{ query }, setQuery] = useQueryParams();
|
|
158
|
+
const applied = readFilters(query);
|
|
159
|
+
const page = Math.max(1, Number(query.page) || 1);
|
|
160
|
+
const pageSize = [10, 25, 50, 100].includes(Number(query.pageSize)) ? Number(query.pageSize) : 25;
|
|
161
|
+
const [result, setResult] = useState({
|
|
162
|
+
key: null,
|
|
163
|
+
failed: false,
|
|
164
|
+
items: [],
|
|
165
|
+
pagination: null,
|
|
166
|
+
enabled: true
|
|
167
|
+
});
|
|
168
|
+
const [nonce, setNonce] = useState(0);
|
|
169
|
+
const [actors, setActors] = useState([]);
|
|
170
|
+
const allowed = audit.allowedActions.canRead && settings.allowedActions.canRead;
|
|
171
|
+
const appliedKey = JSON.stringify(applied);
|
|
172
|
+
const requestKey = `${appliedKey}|${page}|${pageSize}|${nonce}`;
|
|
173
|
+
const title = t("settings.audit.title", "Audit trail");
|
|
174
|
+
const state = {
|
|
175
|
+
...result,
|
|
176
|
+
status: result.key !== requestKey ? "loading" : result.failed ? "error" : "ready"
|
|
177
|
+
};
|
|
178
|
+
const params = { page, pageSize };
|
|
179
|
+
if (applied.event) params.event = applied.event;
|
|
180
|
+
if (applied.actor) params.actor = applied.actor;
|
|
181
|
+
if (UID_PATTERN.test(applied.uid)) params.uid = applied.uid;
|
|
182
|
+
if (params.uid && DOCUMENT_ID_PATTERN.test(applied.documentId)) params.documentId = applied.documentId;
|
|
183
|
+
if (applied.from) params.from = `${applied.from}T00:00:00`;
|
|
184
|
+
if (applied.to) params.to = `${applied.to}T23:59:59`;
|
|
185
|
+
const paramsKey = JSON.stringify(params);
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
if (!allowed) return void 0;
|
|
188
|
+
let active2 = true;
|
|
189
|
+
get(API.audit, { params: JSON.parse(paramsKey) }).then(
|
|
190
|
+
({ data }) => {
|
|
191
|
+
if (!active2) return;
|
|
192
|
+
setResult({
|
|
193
|
+
key: requestKey,
|
|
194
|
+
failed: false,
|
|
195
|
+
items: data.data || [],
|
|
196
|
+
pagination: data.meta && data.meta.pagination || null,
|
|
197
|
+
enabled: !(data.meta && data.meta.enabled === false)
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
() => {
|
|
201
|
+
if (active2) setResult((current) => ({ ...current, key: requestKey, failed: true }));
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
return () => {
|
|
205
|
+
active2 = false;
|
|
206
|
+
};
|
|
207
|
+
}, [allowed, get, paramsKey, requestKey]);
|
|
208
|
+
const load = () => setNonce((value) => value + 1);
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
if (!allowed) return;
|
|
211
|
+
get(API.auditActors).then(
|
|
212
|
+
({ data }) => setActors(data.data || []),
|
|
213
|
+
() => setActors([])
|
|
214
|
+
);
|
|
215
|
+
}, [allowed, get]);
|
|
216
|
+
if (audit.isLoading || settings.isLoading) {
|
|
217
|
+
return /* @__PURE__ */ jsxs(Page.Main, { children: [
|
|
218
|
+
/* @__PURE__ */ jsx(Page.Title, { children: title }),
|
|
219
|
+
/* @__PURE__ */ jsx(Page.Loading, {})
|
|
220
|
+
] });
|
|
221
|
+
}
|
|
222
|
+
if (!allowed) {
|
|
223
|
+
return /* @__PURE__ */ jsxs(Page.Main, { children: [
|
|
224
|
+
/* @__PURE__ */ jsx(Page.Title, { children: title }),
|
|
225
|
+
/* @__PURE__ */ jsx(Page.NoPermissions, {})
|
|
226
|
+
] });
|
|
227
|
+
}
|
|
228
|
+
const apply = (draft) => {
|
|
229
|
+
const next = { page: 1, pageSize };
|
|
230
|
+
for (const key of FILTER_KEYS) next[key] = draft[key] || void 0;
|
|
231
|
+
setQuery(next);
|
|
232
|
+
};
|
|
233
|
+
const reset = () => {
|
|
234
|
+
const cleared = Object.fromEntries(FILTER_KEYS.map((key) => [key, void 0]));
|
|
235
|
+
setQuery({ ...cleared, page: 1, pageSize });
|
|
236
|
+
};
|
|
237
|
+
const active = FILTER_KEYS.some((key) => applied[key]);
|
|
238
|
+
const when = (value) => formatDate(new Date(value), { dateStyle: "medium", timeStyle: "short" });
|
|
239
|
+
const targetText = (item) => {
|
|
240
|
+
const target = item.target || {};
|
|
241
|
+
if (!target.uid) return t("settings.audit.target.none", "Plugin settings");
|
|
242
|
+
const parts = [target.uid];
|
|
243
|
+
if (target.documentId) parts.push(target.documentId);
|
|
244
|
+
if (target.locale) parts.push(target.locale);
|
|
245
|
+
if (target.field) parts.push(target.field);
|
|
246
|
+
return parts.join(" · ");
|
|
247
|
+
};
|
|
248
|
+
const filters = /* @__PURE__ */ jsx(
|
|
249
|
+
AuditFilters,
|
|
250
|
+
{
|
|
251
|
+
t,
|
|
252
|
+
applied,
|
|
253
|
+
actors,
|
|
254
|
+
active,
|
|
255
|
+
onApply: apply,
|
|
256
|
+
onReset: reset
|
|
257
|
+
},
|
|
258
|
+
appliedKey
|
|
259
|
+
);
|
|
260
|
+
let results;
|
|
261
|
+
if (state.status === "error") {
|
|
262
|
+
results = /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
|
|
263
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: t("settings.audit.error", "The audit trail could not be loaded.") }),
|
|
264
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", startIcon: /* @__PURE__ */ jsx(ArrowClockwise, {}), onClick: load, children: t("settings.retry", "Try again") })
|
|
265
|
+
] });
|
|
266
|
+
} else if (state.status === "loading" && state.items.length === 0) {
|
|
267
|
+
results = /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 6, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("settings.audit.loading", "Loading the audit trail") }) });
|
|
268
|
+
} else if (state.items.length === 0) {
|
|
269
|
+
results = /* @__PURE__ */ jsx(
|
|
270
|
+
EmptyStateLayout,
|
|
271
|
+
{
|
|
272
|
+
content: active ? t("settings.audit.emptyFiltered", "No events match these filters.") : t("settings.audit.empty", "No events recorded yet.")
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
} else if (isBelowLarge) {
|
|
276
|
+
results = /* @__PURE__ */ jsx(Flex, { tag: "ul", direction: "column", alignItems: "stretch", gap: 3, "aria-label": title, children: state.items.map((item) => {
|
|
277
|
+
const summary = changeSummary(t, item);
|
|
278
|
+
return /* @__PURE__ */ jsx(
|
|
279
|
+
Box,
|
|
280
|
+
{
|
|
281
|
+
tag: "li",
|
|
282
|
+
padding: 4,
|
|
283
|
+
hasRadius: true,
|
|
284
|
+
borderColor: "neutral200",
|
|
285
|
+
background: "neutral0",
|
|
286
|
+
minWidth: 0,
|
|
287
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
|
|
288
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", children: [
|
|
289
|
+
/* @__PURE__ */ jsx(Badge, { children: eventLabel(t, item.event) }),
|
|
290
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: when(item.createdAt) })
|
|
291
|
+
] }),
|
|
292
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: actorLabel(t, item.actor) }),
|
|
293
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: targetText(item) }),
|
|
294
|
+
summary ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral800", style: { overflowWrap: "anywhere" }, children: summary }) : null
|
|
295
|
+
] })
|
|
296
|
+
},
|
|
297
|
+
item.id
|
|
298
|
+
);
|
|
299
|
+
}) });
|
|
300
|
+
} else {
|
|
301
|
+
results = /* @__PURE__ */ jsxs(Table, { colCount: 5, rowCount: state.items.length + 1, children: [
|
|
302
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
303
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("settings.audit.col.time", "Time") }) }),
|
|
304
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("settings.audit.col.event", "Event") }) }),
|
|
305
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("settings.audit.col.actor", "Changed by") }) }),
|
|
306
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("settings.audit.col.target", "Where") }) }),
|
|
307
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: t("settings.audit.col.changes", "Changes") }) })
|
|
308
|
+
] }) }),
|
|
309
|
+
/* @__PURE__ */ jsx(Tbody, { children: state.items.map((item) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
310
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: when(item.createdAt) }) }),
|
|
311
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Badge, { children: eventLabel(t, item.event) }) }),
|
|
312
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: actorLabel(t, item.actor) }) }),
|
|
313
|
+
/* @__PURE__ */ jsx(Td, { style: { whiteSpace: "normal" }, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", style: { overflowWrap: "anywhere" }, children: targetText(item) }) }),
|
|
314
|
+
/* @__PURE__ */ jsx(Td, { style: { whiteSpace: "normal" }, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", style: { overflowWrap: "anywhere" }, children: changeSummary(t, item) }) })
|
|
315
|
+
] }, item.id)) })
|
|
316
|
+
] });
|
|
317
|
+
}
|
|
318
|
+
return /* @__PURE__ */ jsxs(
|
|
319
|
+
PageShell,
|
|
320
|
+
{
|
|
321
|
+
title,
|
|
322
|
+
subtitle: t(
|
|
323
|
+
"settings.audit.subtitle",
|
|
324
|
+
"Who changed what and when in editor fields, templates, synced blocks, comments, AI actions and settings. Only counts and block ids are kept, never the content."
|
|
325
|
+
),
|
|
326
|
+
primaryAction: /* @__PURE__ */ jsx(
|
|
327
|
+
Button,
|
|
328
|
+
{
|
|
329
|
+
variant: "secondary",
|
|
330
|
+
startIcon: /* @__PURE__ */ jsx(ArrowClockwise, {}),
|
|
331
|
+
onClick: load,
|
|
332
|
+
loading: state.status === "loading",
|
|
333
|
+
children: t("settings.audit.refresh", "Refresh")
|
|
334
|
+
}
|
|
335
|
+
),
|
|
336
|
+
children: [
|
|
337
|
+
!state.enabled ? /* @__PURE__ */ jsx(
|
|
338
|
+
Alert,
|
|
339
|
+
{
|
|
340
|
+
variant: "warning",
|
|
341
|
+
closeLabel: t("settings.close", "Close"),
|
|
342
|
+
title: t("settings.audit.offTitle", "Recording is off"),
|
|
343
|
+
children: t(
|
|
344
|
+
"settings.audit.off",
|
|
345
|
+
"The audit trail is turned off in config/plugins.js (audit.enabled). Earlier events are still shown."
|
|
346
|
+
)
|
|
347
|
+
}
|
|
348
|
+
) : null,
|
|
349
|
+
filters,
|
|
350
|
+
/* @__PURE__ */ jsxs(
|
|
351
|
+
SectionCard,
|
|
352
|
+
{
|
|
353
|
+
title: t("settings.audit.results", "Events"),
|
|
354
|
+
subtitle: state.pagination ? t("settings.audit.total", "{total, plural, one {# event} other {# events}}", {
|
|
355
|
+
total: state.pagination.total
|
|
356
|
+
}) : void 0,
|
|
357
|
+
children: [
|
|
358
|
+
/* @__PURE__ */ jsx(Box, { "aria-busy": state.status === "loading", "data-mex-audit-results": true, minWidth: 0, children: results }),
|
|
359
|
+
state.pagination && state.pagination.total > 0 ? /* @__PURE__ */ jsxs(
|
|
360
|
+
Pagination.Root,
|
|
361
|
+
{
|
|
362
|
+
pageCount: state.pagination.pageCount,
|
|
363
|
+
total: state.pagination.total,
|
|
364
|
+
defaultPageSize: 25,
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ jsx(Pagination.PageSize, { options: ["10", "25", "50", "100"] }),
|
|
367
|
+
/* @__PURE__ */ jsx(Pagination.Links, {})
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
) : null
|
|
371
|
+
]
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
);
|
|
377
|
+
};
|
|
378
|
+
export {
|
|
379
|
+
AuditPage,
|
|
380
|
+
AuditPage as default
|
|
381
|
+
};
|