@sensinum/strapi-plugin-xecp 5.0.1 → 5.1.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 (29) hide show
  1. package/README.md +22 -19
  2. package/dist/admin/{App-ts9vnxkd.mjs → App-DnN-IvA2.mjs} +485 -466
  3. package/dist/admin/App-fzbS9IJs.js +30 -0
  4. package/dist/admin/TruncatedTypography-BIh1V9g2.mjs +49 -0
  5. package/dist/admin/TruncatedTypography-IG2-4h8c.js +12 -0
  6. package/dist/admin/{de-C25k5cq2.mjs → de-CXusi8Qg.mjs} +8 -1
  7. package/dist/admin/{de-bbLKG0Z0.js → de-DB2gq7qr.js} +1 -1
  8. package/dist/admin/{en-CN9XhSjy.js → en-BuzP59R9.js} +1 -1
  9. package/dist/admin/{en-B08MBp2G.mjs → en-Dw6HZo7C.mjs} +8 -1
  10. package/dist/admin/{fr-C0XfkZIq.mjs → fr-CyBDGDh1.mjs} +8 -1
  11. package/dist/admin/{fr-CrIyMsIk.js → fr-ISZXcmX2.js} +1 -1
  12. package/dist/admin/index-BPA-rtqa.js +1 -0
  13. package/dist/admin/{index-Ce11CAq4.mjs → index-CUUBtl-O.mjs} +5 -5
  14. package/dist/admin/{index-EJNj4rvX.js → index-CzhrALSL.js} +1 -1
  15. package/dist/admin/index-DDj2bCYO.mjs +653 -0
  16. package/dist/admin/{index-G1uJfkFG.js → index-DGBlS60G.js} +1 -1
  17. package/dist/admin/{index-C5AltFek.mjs → index-Dr164lAs.mjs} +1 -1
  18. package/dist/admin/index.js +1 -1
  19. package/dist/admin/index.mjs +1 -1
  20. package/dist/admin/{pl-DFGTrhGA.js → pl-Ds5SR76s.js} +1 -1
  21. package/dist/admin/{pl-CPolzlPI.mjs → pl-mwGoOpdR.mjs} +8 -1
  22. package/dist/server/index.js +7 -8
  23. package/dist/server/index.mjs +8046 -6773
  24. package/package.json +2 -1
  25. package/dist/admin/App-DRQbwTbi.js +0 -30
  26. package/dist/admin/TruncatedTypography-72wp11m4.js +0 -12
  27. package/dist/admin/TruncatedTypography-Df3hMZdB.mjs +0 -34
  28. package/dist/admin/index-79Ue9nfe.js +0 -1
  29. package/dist/admin/index-DVZWw0UF.mjs +0 -599
@@ -1,599 +0,0 @@
1
- import { jsx as t, Fragment as $, jsxs as u } from "react/jsx-runtime";
2
- import { useFetchClient as D, useForm as re, useNotification as se, Layouts as O, useRBAC as oe, Page as K, Form as ae } from "@strapi/strapi/admin";
3
- import { U, g as a, P as H } from "./index-Ce11CAq4.mjs";
4
- import { S as P, P as le, Q as de } from "./queryKeys-rUHP1d6p.mjs";
5
- import { useEffect as ce, useRef as pe, useMemo as ue } from "react";
6
- import { useIntl as f } from "react-intl";
7
- import ge, { z as g } from "zod";
8
- import { useQuery as V, queryOptions as me, useQueryClient as he, useMutation as W } from "@tanstack/react-query";
9
- import { Box as b, Field as h, SingleSelect as ye, SingleSelectOption as Te, Typography as C, Table as fe, Thead as Ce, Tr as _, Th as L, Tbody as be, Td as I, MultiSelect as ve, MultiSelectOption as Ee, Flex as G, Tooltip as Se, Grid as A, NumberInput as Ae, TextInput as j, Button as z, Loader as we } from "@strapi/design-system";
10
- import { Information as Re, Check as X } from "@strapi/icons";
11
- import { isEqual as De } from "lodash";
12
- import { T as Q, A as Z } from "./TruncatedTypography-Df3hMZdB.mjs";
13
- const Ue = 3, w = g.enum(["Related", "Promotable"]);
14
- g.object({
15
- targetEnvApiKey: g.string().optional(),
16
- targetEnvApiUrl: g.url().optional(),
17
- comparisonDepth: g.number().positive().optional(),
18
- contentTypes: g.array(g.object({ uid: g.string(), key: g.string(), kind: w })).optional()
19
- });
20
- const Fe = () => {
21
- const { get: e } = D();
22
- return V({
23
- queryKey: [P],
24
- queryFn: async () => {
25
- const { data: n } = await e(`/${U}/settings`);
26
- return n;
27
- }
28
- });
29
- }, Ke = [
30
- P,
31
- "content-type-options"
32
- ], Pe = () => {
33
- const { get: e } = D();
34
- return V({
35
- queryKey: Ke,
36
- queryFn: async () => {
37
- const { data: n } = await e(
38
- `/${U}/settings/content-type-options`
39
- );
40
- return n;
41
- }
42
- });
43
- }, ke = (e) => [P, "related-content-types", e], qe = (e, n) => me({
44
- queryKey: ke(n),
45
- queryFn: async () => {
46
- const { data: r } = await e(
47
- `/${U}/settings/related-content-types`,
48
- {
49
- params: {
50
- allowed: n.join(",")
51
- }
52
- }
53
- );
54
- return r;
55
- }
56
- }), N = (e) => {
57
- const { get: n } = D();
58
- return V({
59
- ...qe(n, e),
60
- enabled: e.length > 0
61
- });
62
- }, Le = () => {
63
- const { put: e } = D(), n = he();
64
- return W({
65
- mutationFn: async (r) => e(`/${U}/settings`, r),
66
- onSuccess: async () => {
67
- await Promise.all([
68
- n.invalidateQueries({ queryKey: [P] }),
69
- n.invalidateQueries({ queryKey: [le] })
70
- ]);
71
- }
72
- });
73
- }, Ie = (e, n) => Object.entries(n).reduce((r, [s, i]) => De(i, e[s]) ? r : {
74
- ...r,
75
- [s]: i
76
- }, {}), J = g.object({
77
- allowedContentTypes: g.array(g.string()).min(1, { message: "settings.form.error.minimalArrayLength" }),
78
- contentTypeSettings: g.record(
79
- g.string(),
80
- g.object({
81
- key: g.string({ message: "settings.form.error.required" }).min(1, { message: "settings.form.error.required" }).optional()
82
- }).optional()
83
- ),
84
- targetEnvApiKey: g.string({ message: "settings.form.error.required" }).min(1, { message: "settings.form.error.required" }),
85
- targetEnvApiUrl: g.url({ message: "settings.form.error.validURL" }),
86
- comparisonDepth: g.number({ message: "settings.form.error.required" }).positive({ message: "settings.form.error.positive" })
87
- }), Me = J.extend({
88
- relatedContentTypes: g.string().array()
89
- }), Ve = Me.refine(
90
- (e) => [
91
- ...e.allowedContentTypes,
92
- ...e.relatedContentTypes
93
- ].every(
94
- (r) => !!e.contentTypeSettings[r]?.key
95
- ),
96
- {
97
- path: ["allowedContentTypes"],
98
- message: "settings.form.error.uniqueKeyRequired",
99
- when(e) {
100
- return J.pick({ contentTypeSettings: !0 }).safeParse(e.value).success;
101
- }
102
- }
103
- ), Ne = (e, n) => {
104
- const r = [...e.allowedContentTypes, ...n];
105
- return {
106
- ...e,
107
- contentTypeSettings: Object.fromEntries(
108
- r.map((s) => [
109
- s,
110
- e.contentTypeSettings[s]
111
- ])
112
- )
113
- };
114
- }, ee = (e) => e.replace(".", ":"), M = (e) => e.replace(/:(?!.*:)/, "."), xe = (e, n) => {
115
- const s = {
116
- ...Ne(n, e),
117
- relatedContentTypes: e
118
- }, i = Ve.parse(s);
119
- return {
120
- contentTypes: [
121
- ...i.allowedContentTypes,
122
- ...i.relatedContentTypes
123
- ].map((p) => ({
124
- uid: M(p),
125
- key: i.contentTypeSettings[p]?.key,
126
- kind: i.allowedContentTypes.includes(p) ? w.enum.Promotable : w.enum.Related
127
- })),
128
- targetEnvApiKey: i.targetEnvApiKey,
129
- targetEnvApiUrl: i.targetEnvApiUrl,
130
- comparisonDepth: i.comparisonDepth
131
- };
132
- }, Oe = {
133
- background: "neutral0",
134
- hasRadius: !0,
135
- shadow: "filterShadow",
136
- padding: 6,
137
- width: "100%"
138
- }, x = ({ children: e, marginTop: n }) => /* @__PURE__ */ t(b, { ...Oe, marginTop: n, children: e }), _e = ({ onChange: e, attributes: n, value: r, name: s, error: i, disabled: d = !1 }) => {
139
- const { formatMessage: p } = f(), m = Object.entries(n).filter(
140
- ([c, o]) => o.type === "uid" || o.unique === !0
141
- );
142
- return ce(() => {
143
- !r && m.length > 0 && e("");
144
- }, []), /* @__PURE__ */ t($, { children: m.length > 0 ? /* @__PURE__ */ u(h.Root, { error: i && p({ id: a(i) }), children: [
145
- /* @__PURE__ */ t(ye, { name: s, value: r, onChange: e, required: !0, disabled: d, children: m.map(([c, o]) => /* @__PURE__ */ t(Te, { value: c, children: c }, c)) }),
146
- /* @__PURE__ */ t(h.Error, {})
147
- ] }) : /* @__PURE__ */ t(
148
- h.Root,
149
- {
150
- error: p({ id: a("settings.table.uniqueKeyRequiredWarning") }),
151
- children: /* @__PURE__ */ t(h.Error, {})
152
- }
153
- ) });
154
- }, B = ({
155
- label: e,
156
- contentTypes: n,
157
- setFormValue: r,
158
- errors: s,
159
- contentTypeSettings: i,
160
- shouldShowRequiredBy: d,
161
- isReadOnly: p
162
- }) => {
163
- const { formatMessage: m } = f();
164
- return /* @__PURE__ */ u(b, { marginTop: 4, width: "100%", paddingTop: 4, children: [
165
- /* @__PURE__ */ t(b, { marginBottom: 1, children: /* @__PURE__ */ t(C, { variant: "pi", textColor: "neutral800", fontWeight: "bold", children: e }) }),
166
- /* @__PURE__ */ u(fe, { width: "100%", rowCount: n.length, colCount: d ? 3 : 2, children: [
167
- /* @__PURE__ */ t(Ce, { children: /* @__PURE__ */ u(_, { children: [
168
- /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(C, { variant: "sigma", children: m({ id: a("settings.table.contentType") }) }) }),
169
- d && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(C, { variant: "sigma", children: m({ id: a("settings.table.requiredBy") }) }) }),
170
- /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(C, { variant: "sigma", children: m({ id: a("settings.table.uniqueKey") }) }) })
171
- ] }) }),
172
- /* @__PURE__ */ t(be, { children: n.map((c) => {
173
- const o = `contentTypeSettings.${c.uid}.key`;
174
- return /* @__PURE__ */ u(_, { children: [
175
- /* @__PURE__ */ t(I, { width: d ? "25%" : "50%", children: /* @__PURE__ */ t(
176
- Q,
177
- {
178
- maxCharacters: 55,
179
- text: c.schema.displayName,
180
- textColor: "neutral800"
181
- }
182
- ) }),
183
- d && /* @__PURE__ */ t(I, { width: "25%", children: /* @__PURE__ */ t(
184
- Q,
185
- {
186
- maxCharacters: 55,
187
- text: c.requiredBy,
188
- textColor: "neutral800"
189
- }
190
- ) }),
191
- /* @__PURE__ */ t(I, { width: "50%", children: /* @__PURE__ */ t(
192
- _e,
193
- {
194
- onChange: (l) => {
195
- r(o, l);
196
- },
197
- value: i[c.uid]?.key,
198
- attributes: c.schema.attributes,
199
- name: o,
200
- error: s[o],
201
- disabled: p
202
- }
203
- ) })
204
- ] }, c.uid);
205
- }) })
206
- ] })
207
- ] });
208
- }, je = ({
209
- allowedContentTypes: e,
210
- contentTypeSettings: n,
211
- setFormValue: r,
212
- promotableContentTypes: s,
213
- errors: i,
214
- isReadOnly: d
215
- }) => {
216
- const { formatMessage: p } = f(), m = e.map(
217
- (l) => s?.find((T) => T.uid === l)
218
- ), { data: c, isLoading: o } = N(e);
219
- return o ? null : /* @__PURE__ */ u(x, { children: [
220
- /* @__PURE__ */ t(C, { variant: "delta", children: p({ id: a("settings.allowedContentTypes") }) }),
221
- /* @__PURE__ */ t(b, { marginTop: 4, width: "100%", children: /* @__PURE__ */ u(
222
- h.Root,
223
- {
224
- width: "100%",
225
- error: i.allowedContentTypes && p({ id: a(i.allowedContentTypes) }),
226
- children: [
227
- /* @__PURE__ */ t(h.Label, { children: p({ id: a("settings.allowedContentTypes.label") }) }),
228
- /* @__PURE__ */ t(
229
- ve,
230
- {
231
- withTags: !0,
232
- name: "allowedContentTypes",
233
- value: e,
234
- onChange: (l) => {
235
- r("allowedContentTypes", l);
236
- },
237
- hasError: !!i.allowedContentTypes,
238
- disabled: d,
239
- children: s?.map((l) => /* @__PURE__ */ t(Ee, { value: l.uid, children: l.schema.displayName }, l.uid))
240
- }
241
- ),
242
- /* @__PURE__ */ t(h.Error, {})
243
- ]
244
- }
245
- ) }),
246
- e?.length > 0 && /* @__PURE__ */ t(
247
- B,
248
- {
249
- label: p({
250
- id: a("settings.table.keyForEligibleContentTypes")
251
- }),
252
- contentTypes: m,
253
- setFormValue: r,
254
- errors: i,
255
- contentTypeSettings: n,
256
- isReadOnly: d
257
- }
258
- ),
259
- (c?.length ?? 0) > 0 && /* @__PURE__ */ t(
260
- B,
261
- {
262
- label: p({
263
- id: a("settings.table.keyForRelatedContentTypes")
264
- }),
265
- contentTypes: c ?? [],
266
- setFormValue: r,
267
- errors: i,
268
- contentTypeSettings: n,
269
- shouldShowRequiredBy: !0,
270
- isReadOnly: d
271
- }
272
- )
273
- ] });
274
- }, Qe = () => {
275
- const { formatMessage: e } = f();
276
- return /* @__PURE__ */ t(b, { marginTop: 4, children: /* @__PURE__ */ t(
277
- Z,
278
- {
279
- title: e({ id: a("settings.alert.comparisonDepthHigh.title") }),
280
- variant: "warning",
281
- description: e({
282
- id: a("settings.alert.comparisonDepthHigh.description")
283
- })
284
- }
285
- ) });
286
- }, Be = ({ comparisonDepth: e, setFormValue: n, errors: r, isReadOnly: s }) => {
287
- const { formatMessage: i } = f();
288
- return /* @__PURE__ */ u(x, { marginTop: 4, children: [
289
- /* @__PURE__ */ u(G, { marginBottom: 4, gap: 1, children: [
290
- /* @__PURE__ */ t(C, { variant: "delta", children: i({ id: a("settings.comparisonDepth") }) }),
291
- /* @__PURE__ */ t(Se, { label: i({ id: a("settings.comparisonDepth.tooltip") }), children: /* @__PURE__ */ t(Re, {}) })
292
- ] }),
293
- /* @__PURE__ */ t(A.Root, { gap: 4, children: /* @__PURE__ */ t(A.Item, { col: 6, alignItems: "start", children: /* @__PURE__ */ u(
294
- h.Root,
295
- {
296
- error: r.comparisonDepth && i({ id: a(r.comparisonDepth) }),
297
- width: "100%",
298
- children: [
299
- /* @__PURE__ */ t(h.Label, { children: i({ id: a("settings.comparisonDepth.label") }) }),
300
- /* @__PURE__ */ t(
301
- Ae,
302
- {
303
- value: e,
304
- onValueChange: (d) => n("comparisonDepth", d),
305
- name: "comparisonDepth",
306
- disabled: s
307
- }
308
- ),
309
- /* @__PURE__ */ t(h.Error, {})
310
- ]
311
- }
312
- ) }) }),
313
- e > 5 && /* @__PURE__ */ t(Qe, {})
314
- ] });
315
- }, Ye = ({ staleValueMessages: e }) => {
316
- const { formatMessage: n } = f();
317
- return /* @__PURE__ */ t(b, { marginBottom: 4, children: /* @__PURE__ */ u(
318
- Z,
319
- {
320
- title: n({ id: a("settings.alert.staleValuesRemoved.title") }),
321
- variant: "danger",
322
- children: [
323
- n({ id: a("settings.alert.staleValuesRemoved.description") }),
324
- e.map((r, s) => /* @__PURE__ */ u("span", { children: [
325
- /* @__PURE__ */ t("br", {}),
326
- s + 1,
327
- ".",
328
- " ",
329
- n(
330
- {
331
- id: a(r.message)
332
- },
333
- r.variables
334
- )
335
- ] }, s))
336
- ]
337
- }
338
- ) });
339
- }, $e = () => {
340
- const { post: e } = D();
341
- return W({
342
- mutationFn: async (n) => {
343
- const { data: r } = await e(
344
- `/${U}/settings/testConnection`,
345
- n
346
- );
347
- return r;
348
- }
349
- });
350
- }, He = (e) => {
351
- if (e.isUrlCorrect)
352
- return e.isApiKeyCorrect ? e.arePermissionsCorrect ? void 0 : "settings.form.error.badKeyPermissions" : "settings.form.error.badApiKey";
353
- }, We = ({
354
- targetEnvApiKey: e,
355
- targetEnvApiUrl: n,
356
- setFormValue: r,
357
- errors: s,
358
- isReadOnly: i
359
- }) => {
360
- const { formatMessage: d } = f(), p = $e(), { setErrors: m } = re("TargetEnvConfigurationSection", (l) => l), c = async () => {
361
- const l = await p.mutateAsync({ targetEnvApiKey: e, targetEnvApiUrl: n });
362
- m({
363
- ...s,
364
- targetEnvApiUrl: l.isUrlCorrect ? void 0 : "settings.form.error.badApiUrl",
365
- targetEnvApiKey: He(l)
366
- });
367
- }, o = p.isSuccess && !s.targetEnvApiKey && !s.targetEnvApiUrl;
368
- return /* @__PURE__ */ u(x, { marginTop: 4, children: [
369
- /* @__PURE__ */ t(b, { marginBottom: 4, children: /* @__PURE__ */ t(C, { variant: "delta", children: d({ id: a("settings.targetEnvConfiguration") }) }) }),
370
- /* @__PURE__ */ u(A.Root, { gap: 4, children: [
371
- /* @__PURE__ */ t(A.Item, { col: 6, alignItems: "start", children: /* @__PURE__ */ u(
372
- h.Root,
373
- {
374
- error: s.targetEnvApiUrl && d({ id: a(s.targetEnvApiUrl) }),
375
- width: "100%",
376
- children: [
377
- /* @__PURE__ */ t(h.Label, { children: d({ id: a("settings.targetEnvApiUrl.label") }) }),
378
- /* @__PURE__ */ t(
379
- j,
380
- {
381
- name: "targetEnvApiUrl",
382
- value: n,
383
- onChange: r,
384
- disabled: i
385
- }
386
- ),
387
- /* @__PURE__ */ t(h.Error, {})
388
- ]
389
- }
390
- ) }),
391
- /* @__PURE__ */ t(A.Item, { col: 6, alignItems: "start", children: /* @__PURE__ */ u(
392
- h.Root,
393
- {
394
- error: s.targetEnvApiKey && d({ id: a(s.targetEnvApiKey) }),
395
- width: "100%",
396
- children: [
397
- /* @__PURE__ */ t(h.Label, { children: d({ id: a("settings.targetEnvApiKey.label") }) }),
398
- /* @__PURE__ */ t(
399
- j,
400
- {
401
- name: "targetEnvApiKey",
402
- value: e,
403
- onChange: r,
404
- disabled: i
405
- }
406
- ),
407
- /* @__PURE__ */ t(h.Error, {})
408
- ]
409
- }
410
- ) }),
411
- /* @__PURE__ */ u(A.Item, { col: 6, children: [
412
- i ? null : /* @__PURE__ */ t(z, { onClick: c, disabled: p.isPending, children: d({ id: a("settings.form.testConnection") }) }),
413
- /* @__PURE__ */ u(G, { marginLeft: 1, alignItems: "center", children: [
414
- p.isPending && /* @__PURE__ */ t(we, { small: !0 }),
415
- o && /* @__PURE__ */ t(X, { color: "#5cb176" })
416
- ] })
417
- ] })
418
- ] })
419
- ] });
420
- }, Ge = ({
421
- values: e,
422
- onChange: n,
423
- errors: r,
424
- setErrors: s,
425
- modified: i,
426
- settings: d,
427
- promotableContentTypes: p,
428
- staleValuesMessages: m,
429
- isReadOnly: c
430
- }) => {
431
- const { formatMessage: o } = f(), { toggleNotification: l } = se(), T = Le(), { data: v = [], isFetching: F } = N(e.allowedContentTypes), k = async () => {
432
- try {
433
- const E = v.map((S) => S.uid), R = xe(E, e), y = Ie(d, R);
434
- await T.mutateAsync(y, {
435
- onSuccess: () => {
436
- s({}), l({
437
- type: "success",
438
- message: o({ id: a("settings.form.savedSuccessfully") })
439
- });
440
- }
441
- });
442
- } catch (E) {
443
- if (E instanceof ge.ZodError) {
444
- const R = E.issues.reduce((y, S) => (y[S.path.join(".")] = S.message, y), {});
445
- s(R), l({
446
- type: "warning",
447
- message: o({ id: a("settings.form.error.validationMessage") })
448
- });
449
- } else
450
- l({
451
- type: "warning",
452
- message: o({ id: a("settings.form.error.other") })
453
- });
454
- }
455
- }, q = c || !i && m.length === 0 || F || T.isPending;
456
- return /* @__PURE__ */ u($, { children: [
457
- /* @__PURE__ */ t(
458
- O.Header,
459
- {
460
- title: o({ id: a("settings.title") }),
461
- subtitle: o({ id: a("settings.subtitle") }),
462
- primaryAction: c ? null : /* @__PURE__ */ t(
463
- z,
464
- {
465
- type: "submit",
466
- startIcon: /* @__PURE__ */ t(X, {}),
467
- onClick: k,
468
- disabled: q,
469
- children: o({
470
- id: a("settings.form.submit")
471
- })
472
- }
473
- )
474
- }
475
- ),
476
- /* @__PURE__ */ u(O.Content, { children: [
477
- m.length > 0 && /* @__PURE__ */ t(Ye, { staleValueMessages: m }),
478
- /* @__PURE__ */ t(
479
- je,
480
- {
481
- allowedContentTypes: e.allowedContentTypes,
482
- contentTypeSettings: e.contentTypeSettings,
483
- setFormValue: n,
484
- promotableContentTypes: p,
485
- errors: r,
486
- isReadOnly: c
487
- }
488
- ),
489
- /* @__PURE__ */ t(
490
- Be,
491
- {
492
- setFormValue: n,
493
- errors: r,
494
- comparisonDepth: e.comparisonDepth,
495
- isReadOnly: c
496
- }
497
- ),
498
- /* @__PURE__ */ t(
499
- We,
500
- {
501
- targetEnvApiKey: e.targetEnvApiKey,
502
- targetEnvApiUrl: e.targetEnvApiUrl,
503
- setFormValue: n,
504
- errors: r,
505
- isReadOnly: c
506
- }
507
- )
508
- ] })
509
- ] });
510
- }, Y = (e) => {
511
- const n = e.contentTypes ?? [], r = n.filter((i) => i.kind === w.enum.Promotable).map((i) => i.uid), s = Object.fromEntries(
512
- n.map((i) => [i.uid, { key: i.key }])
513
- );
514
- return {
515
- allowedContentTypes: r,
516
- contentTypeSettings: s,
517
- targetEnvApiKey: e?.targetEnvApiKey ?? "",
518
- targetEnvApiUrl: e?.targetEnvApiUrl ?? "",
519
- comparisonDepth: e?.comparisonDepth ?? Ue
520
- };
521
- }, ze = (e, n, r) => {
522
- if (!e.contentTypes)
523
- return [Y(e), []];
524
- const s = [], i = e.contentTypes.map((o) => ({
525
- ...o,
526
- uid: ee(o.uid)
527
- })), d = n.map((o) => o.uid), m = i.filter(
528
- (o) => {
529
- const l = !d.includes(o.uid);
530
- return l && s.push({
531
- message: "settings.alert.staleValuesRemoved.contentTypeDeleted",
532
- variables: { uid: M(o.uid) }
533
- }), !l;
534
- }
535
- ).filter((o) => {
536
- const l = !r.includes(o.uid) && o.kind === w.enum.Related;
537
- return l && s.push({
538
- message: "settings.alert.staleValuesRemoved.relationDeleted",
539
- variables: { uid: M(o.uid) }
540
- }), !l;
541
- }).map((o) => {
542
- const l = n.find(
543
- (F) => F.uid === o.uid
544
- ), T = l?.schema.attributes[o.key], v = T?.type === "uid" || T?.unique === !0;
545
- return v || s.push({
546
- message: "settings.alert.staleValuesRemoved.keyDeleted",
547
- variables: {
548
- key: o.key,
549
- schemaDisplayName: l?.schema.displayName
550
- }
551
- }), {
552
- ...o,
553
- key: v ? o.key : void 0
554
- };
555
- });
556
- return [Y({
557
- ...e,
558
- contentTypes: m
559
- }), s];
560
- }, Xe = () => {
561
- const { formatMessage: e } = f(), n = pe(null), {
562
- isLoading: r,
563
- allowedActions: { canUpdate: s }
564
- } = oe([...H.settingsUpdate]), { data: i, isLoading: d } = Fe(), { data: p, isLoading: m } = Pe(), c = ue(
565
- () => (i?.contentTypes ?? []).filter((y) => y.kind === w.enum.Promotable).map((y) => ee(y.uid)),
566
- [i?.contentTypes]
567
- ), {
568
- data: o = [],
569
- isLoading: l,
570
- isFetched: T
571
- } = N(c), v = c.length === 0 || T;
572
- if (r || d || m || l || !v || !i || !p)
573
- return /* @__PURE__ */ t(K.Loading, {});
574
- const { promotableContentTypes: k, relationLookupContentTypes: q } = p, [E, R] = ze(
575
- i,
576
- q,
577
- o.map((y) => y.uid)
578
- );
579
- return /* @__PURE__ */ u(K.Main, { children: [
580
- /* @__PURE__ */ t(K.Title, { children: e({ id: a("settings.metadata.title") }) }),
581
- /* @__PURE__ */ t(ae, { width: "100%", height: "100%", ref: n, method: "PUT", initialValues: E, children: ({ values: y, onChange: S, errors: te, setErrors: ne, modified: ie }) => /* @__PURE__ */ t(
582
- Ge,
583
- {
584
- values: y,
585
- onChange: S,
586
- errors: te,
587
- setErrors: ne,
588
- modified: ie,
589
- settings: i,
590
- promotableContentTypes: k,
591
- staleValuesMessages: R,
592
- isReadOnly: !s
593
- }
594
- ) })
595
- ] });
596
- }, ct = () => /* @__PURE__ */ t(K.Protect, { permissions: [...H.settingsRead], children: /* @__PURE__ */ t(de, { children: /* @__PURE__ */ t(Xe, {}) }) });
597
- export {
598
- ct as default
599
- };