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