@sensinum/strapi-plugin-xecp 5.1.0 → 5.3.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 (42) hide show
  1. package/README.md +14 -3
  2. package/dist/admin/App-BbgV5mHU.mjs +2809 -0
  3. package/dist/admin/App-OXf6qXjU.js +74 -0
  4. package/dist/admin/TruncatedTypography-B8iYkeNP.js +12 -0
  5. package/dist/admin/{TruncatedTypography-BIh1V9g2.mjs → TruncatedTypography-BA_MhPw6.mjs} +4 -4
  6. package/dist/admin/de-9eabZie2.mjs +288 -0
  7. package/dist/admin/de-BN51VcbT.js +1 -0
  8. package/dist/admin/en-DI1XKd0e.js +1 -0
  9. package/dist/admin/en-tFIwzuCy.mjs +288 -0
  10. package/dist/admin/fr-BRWFIMrf.mjs +288 -0
  11. package/dist/admin/fr-lAhQzMjM.js +1 -0
  12. package/dist/admin/index-BU_gTHIE.mjs +110 -0
  13. package/dist/admin/index-C5CJ1Sy4.js +1 -0
  14. package/dist/admin/index-CT94KSzm.mjs +656 -0
  15. package/dist/admin/index-CmLDGvPV.js +1 -0
  16. package/dist/admin/{index-Dr164lAs.mjs → index-SQ5frWDn.mjs} +96 -90
  17. package/dist/admin/{index-CzhrALSL.js → index-ghS-FZ_7.js} +8 -8
  18. package/dist/admin/index.js +1 -1
  19. package/dist/admin/index.mjs +3 -2
  20. package/dist/admin/pl-CSVwN6jF.js +1 -0
  21. package/dist/admin/pl-DLMBD4Lc.mjs +288 -0
  22. package/dist/admin/{queryKeys-rUHP1d6p.mjs → queryKeys-LazhiKSv.mjs} +5 -4
  23. package/dist/admin/queryKeys-Y6_AOyGq.js +1 -0
  24. package/dist/server/index.js +7 -7
  25. package/dist/server/index.mjs +8776 -8080
  26. package/package.json +48 -22
  27. package/dist/admin/App-DnN-IvA2.mjs +0 -1947
  28. package/dist/admin/App-fzbS9IJs.js +0 -30
  29. package/dist/admin/TruncatedTypography-IG2-4h8c.js +0 -12
  30. package/dist/admin/de-CXusi8Qg.mjs +0 -203
  31. package/dist/admin/de-DB2gq7qr.js +0 -1
  32. package/dist/admin/en-BuzP59R9.js +0 -1
  33. package/dist/admin/en-Dw6HZo7C.mjs +0 -203
  34. package/dist/admin/fr-CyBDGDh1.mjs +0 -203
  35. package/dist/admin/fr-ISZXcmX2.js +0 -1
  36. package/dist/admin/index-BPA-rtqa.js +0 -1
  37. package/dist/admin/index-CUUBtl-O.mjs +0 -113
  38. package/dist/admin/index-DDj2bCYO.mjs +0 -653
  39. package/dist/admin/index-DGBlS60G.js +0 -1
  40. package/dist/admin/pl-Ds5SR76s.js +0 -1
  41. package/dist/admin/pl-mwGoOpdR.mjs +0 -203
  42. package/dist/admin/queryKeys-B_GC_f73.js +0 -1
@@ -1,1947 +0,0 @@
1
- import { jsx as n, jsxs as u, Fragment as A } from "react/jsx-runtime";
2
- import { useFetchClient as k, useRBAC as Pt, useQueryParams as St, Page as Z, Layouts as Qe, Pagination as Ee } from "@strapi/strapi/admin";
3
- import { Link as Re, Routes as Ct, Route as He } from "react-router-dom";
4
- import { U as _, g as a, P as ke } from "./index-CUUBtl-O.mjs";
5
- import { L as bt, S as It, P as wt, Q as Et } from "./queryKeys-rUHP1d6p.mjs";
6
- import { Combobox as Tt, ComboboxOption as vt, Modal as N, Button as E, Flex as f, Typography as h, Link as Me, EmptyStateLayout as W, Tooltip as qe, Checkbox as Le, Badge as z, Table as _e, Thead as Ke, Tr as H, Th as F, Tbody as De, Td as T, Accordion as q, Divider as kt, Box as xt, ProgressBar as Rt, Loader as Te } from "@strapi/design-system";
7
- import { WarningCircle as Ae, Information as Mt } from "@strapi/icons";
8
- import { useState as L, useEffect as ne, Fragment as qt, useMemo as Je, useRef as Ze, useCallback as Ve } from "react";
9
- import { useIntl as b } from "react-intl";
10
- import ae from "zod";
11
- import { f as ue, A as w, T as V, a as Lt } from "./TruncatedTypography-BIh1V9g2.mjs";
12
- import { useQuery as U, useQueryClient as oe, useMutation as me } from "@tanstack/react-query";
13
- import Be from "styled-components";
14
- const _t = 120 * 1e3, Kt = () => {
15
- const { get: e } = k();
16
- return U({
17
- queryKey: [bt, "status"],
18
- staleTime: _t,
19
- queryFn: async () => {
20
- const { data: t } = await e(`/${_}/license/status`);
21
- return t;
22
- }
23
- });
24
- }, Ye = (e, t) => t ? e.find((o) => o.value === t)?.label ?? "" : "", Dt = ({ name: e, onClear: t, onChange: o, options: r, value: i, placeholder: s, disabled: l }) => {
25
- const [c, d] = L(() => Ye(r, i));
26
- return ne(() => {
27
- d(Ye(r, i));
28
- }, [i, r]), /* @__PURE__ */ n(
29
- Tt,
30
- {
31
- name: e,
32
- autocomplete: "list",
33
- onClear: t,
34
- onChange: o,
35
- placeholder: s,
36
- onTextValueChange: d,
37
- value: i,
38
- textValue: c,
39
- disabled: l,
40
- width: "100%",
41
- children: r.map(({ key: m, label: p, value: y }) => /* @__PURE__ */ n(vt, { value: y, children: p }, m))
42
- }
43
- );
44
- }, At = "90vh", ge = ({
45
- open: e,
46
- onClose: t,
47
- title: o,
48
- children: r,
49
- isConfirmButtonLoading: i = !1,
50
- confirmButtonText: s,
51
- isConfirmButtonDisabled: l = !1,
52
- onSubmit: c,
53
- cancelButtonText: d,
54
- showConfirmButton: m = !0,
55
- fillMaxHeight: p = !1
56
- }) => {
57
- const { formatMessage: y } = b();
58
- return /* @__PURE__ */ n(N.Root, { open: e, onOpenChange: () => t(), children: /* @__PURE__ */ u(N.Content, { style: p ? { height: At } : void 0, children: [
59
- /* @__PURE__ */ n(N.Header, { children: /* @__PURE__ */ n(N.Title, { children: o }) }),
60
- /* @__PURE__ */ n(N.Body, { children: r }),
61
- /* @__PURE__ */ n(N.Footer, { style: m ? void 0 : { justifyContent: "flex-end" }, children: m ? /* @__PURE__ */ u(A, { children: [
62
- /* @__PURE__ */ n(N.Close, { children: /* @__PURE__ */ n(E, { variant: "tertiary", onClick: t, children: d || y({ id: a("common.button.close") }) }) }),
63
- /* @__PURE__ */ n(
64
- E,
65
- {
66
- loading: i,
67
- disabled: l,
68
- onClick: c,
69
- children: s || y({ id: a("common.button.submit") })
70
- }
71
- )
72
- ] }) : /* @__PURE__ */ n(N.Close, { children: /* @__PURE__ */ n(E, { variant: "tertiary", onClick: t, children: d || y({ id: a("common.button.close") }) }) }) })
73
- ] }) });
74
- }, ee = {
75
- all: ["sync"],
76
- lists: () => [...ee.all, "list"],
77
- list: (e) => [...ee.lists(), { uid: e }]
78
- }, We = "entities-comparison", Bt = ({
79
- uid: e,
80
- page: t = 1,
81
- pageSize: o = 10,
82
- enabled: r = !0
83
- }) => {
84
- const { get: i } = k();
85
- return U({
86
- queryKey: [We, { uid: e, page: t, pageSize: o }],
87
- queryFn: async () => {
88
- const { data: s } = await i(
89
- `/${_}/entity-comparison/${e}?page=${t}&pageSize=${o}`
90
- );
91
- return s;
92
- },
93
- enabled: !!e && r
94
- });
95
- }, ze = (e) => {
96
- e.invalidateQueries({ queryKey: [We] });
97
- }, he = (e, t) => {
98
- e.invalidateQueries({ queryKey: t ? ee.list(t) : ee.lists() }), ze(e);
99
- }, Nt = () => {
100
- const { post: e } = k(), t = oe();
101
- return me({
102
- mutationFn: async (o) => await e(`/${_}/snapshot/${o}/sync`),
103
- onSuccess: (o, r) => {
104
- he(t, r);
105
- }
106
- });
107
- }, et = ({ open: e, onClose: t, contentTypeUid: o }) => {
108
- const { formatMessage: r } = b(), {
109
- mutate: i,
110
- isPending: s,
111
- error: l,
112
- reset: c
113
- } = Nt();
114
- return /* @__PURE__ */ n(
115
- ge,
116
- {
117
- open: e,
118
- onClose: () => {
119
- t(), c();
120
- },
121
- onSubmit: () => {
122
- i(o, {
123
- onSuccess: t
124
- });
125
- },
126
- title: r({
127
- id: a("homePage.modal.getNewSnapshot.title")
128
- }),
129
- confirmButtonText: r({
130
- id: a("homePage.modal.getNewSnapshot.confirmButtonText")
131
- }),
132
- isConfirmButtonDisabled: s || !o,
133
- isConfirmButtonLoading: s,
134
- children: /* @__PURE__ */ u(f, { direction: "column", gap: 4, alignItems: "stretch", children: [
135
- /* @__PURE__ */ n(h, { variant: "omega", children: r({
136
- id: a("homePage.modal.getNewSnapshot.description")
137
- }) }),
138
- l && /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: ue(l, r) })
139
- ] })
140
- }
141
- );
142
- }, Ft = ({
143
- contentTypeUid: e,
144
- selectedPromotionsLength: t,
145
- syncedAt: o,
146
- isGetSnapshotDisabled: r = !1,
147
- hasSnapshot: i,
148
- clearSelectedPromotions: s,
149
- canExecute: l
150
- }) => {
151
- const { formatMessage: c } = b(), [d, m] = L(!1);
152
- return /* @__PURE__ */ u(
153
- f,
154
- {
155
- direction: "row",
156
- justifyContent: "space-between",
157
- alignItems: "center",
158
- marginBottom: 1,
159
- marginTop: 1,
160
- children: [
161
- e && i ? /* @__PURE__ */ u(f, { direction: "row", gap: 3, alignItems: "center", children: [
162
- /* @__PURE__ */ n(h, { variant: "omega", children: c(
163
- { id: a("homePage.selectedEntities") },
164
- { count: t }
165
- ) }),
166
- t > 0 && l ? /* @__PURE__ */ n(E, { variant: "secondary", onClick: s, children: c({ id: a("homePage.clearSelectedEntities") }) }) : null
167
- ] }) : null,
168
- o ? /* @__PURE__ */ u(f, { direction: "row", gap: 3, alignItems: "center", children: [
169
- /* @__PURE__ */ n(h, { variant: "omega", textColor: "neutral600", children: c(
170
- { id: a("homePage.lastSync") },
171
- {
172
- lastSync: new Date(o).toLocaleString()
173
- }
174
- ) }),
175
- l ? /* @__PURE__ */ n(
176
- E,
177
- {
178
- variant: "secondary",
179
- onClick: () => m(!0),
180
- disabled: r,
181
- children: c({
182
- id: a("homePage.getNewSnapshot")
183
- })
184
- }
185
- ) : null
186
- ] }) : null,
187
- l ? /* @__PURE__ */ n(
188
- et,
189
- {
190
- open: d,
191
- onClose: () => m(!1),
192
- contentTypeUid: e
193
- }
194
- ) : null
195
- ]
196
- }
197
- );
198
- }, Ot = ({ canReadSettings: e }) => {
199
- const { formatMessage: t } = b();
200
- return /* @__PURE__ */ n(
201
- w,
202
- {
203
- title: t({ id: a("homePage.alert.invalidLicense.title") }),
204
- variant: "danger",
205
- description: t({
206
- id: a(
207
- e ? "homePage.alert.invalidLicense.description" : "homePage.alert.invalidLicense.readOnlyDescription"
208
- )
209
- }),
210
- action: e ? /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n(Me, { tag: Re, to: "/settings/xecp/about", children: t({ id: a("homePage.alert.invalidLicense.linkText") }) }) }) : void 0
211
- }
212
- );
213
- }, Ut = ({ compareSchemasData: e, errorCompareSchemas: t }) => {
214
- const { formatMessage: o } = b(), r = e && !e?.isMatch, i = () => o(r ? { id: a("homePage.alert.schemaMismatch.title") } : { id: a("homePage.error") }), s = () => {
215
- switch (!0) {
216
- case r:
217
- return o({ id: a("homePage.alert.schemaMismatch.description") });
218
- case !!t:
219
- return t;
220
- default:
221
- return o({ id: a("homePage.somethingWentWrong") });
222
- }
223
- };
224
- return /* @__PURE__ */ n(w, { title: i(), variant: "danger", children: s() });
225
- }, $t = ({
226
- contentTypeUid: e,
227
- hasExistingSnapshot: t,
228
- unconfiguredRelationsError: o,
229
- isGetSnapshotDisabled: r = !1,
230
- canExecute: i,
231
- canReadSettings: s
232
- }) => {
233
- const { formatMessage: l } = b(), [c, d] = L(!1);
234
- return !t && !o ? /* @__PURE__ */ u(A, { children: [
235
- /* @__PURE__ */ n(
236
- W,
237
- {
238
- content: l({
239
- id: a(
240
- i ? "homePage.alert.noSync.description" : "homePage.alert.noSync.readOnlyDescription"
241
- )
242
- }),
243
- action: i ? /* @__PURE__ */ n(
244
- E,
245
- {
246
- onClick: () => d(!0),
247
- disabled: r,
248
- children: l({ id: a("homePage.alert.noSync.linkText") })
249
- }
250
- ) : void 0
251
- }
252
- ),
253
- i ? /* @__PURE__ */ n(
254
- et,
255
- {
256
- open: c,
257
- onClose: () => d(!1),
258
- contentTypeUid: e
259
- }
260
- ) : null
261
- ] }) : /* @__PURE__ */ u(A, { children: [
262
- o ? /* @__PURE__ */ n(
263
- w,
264
- {
265
- title: l({
266
- id: a("homePage.alert.unconfiguredRelations.title")
267
- }),
268
- variant: "danger",
269
- action: s ? /* @__PURE__ */ n(Me, { tag: Re, to: "/settings/xecp/configuration", children: l({
270
- id: a("homePage.alert.unconfiguredRelations.linkText")
271
- }) }) : void 0,
272
- description: l(
273
- {
274
- id: a(
275
- s ? "homePage.alert.unconfiguredRelations.description" : "homePage.alert.unconfiguredRelations.readOnlyDescription"
276
- )
277
- },
278
- { relations: o.unconfiguredRelations.join(", ") }
279
- )
280
- }
281
- ) : null,
282
- /* @__PURE__ */ n(W, { content: l({ id: a("homePage.emptyState") }) })
283
- ] });
284
- }, Ne = (e) => [
285
- e,
286
- ...e.localizations ?? []
287
- ], tt = (e) => (e ?? []).flatMap(Ne), Gt = (e, t) => {
288
- const o = t?.find((r) => r.documentId === e);
289
- return o ? Ne(o) : [];
290
- }, Qt = (e) => {
291
- const t = e[0];
292
- return t ? {
293
- ...t,
294
- localizations: e.slice(1)
295
- } : null;
296
- }, pe = (e, t) => {
297
- if (!t) return e.uniqueKeyValue;
298
- const o = e?.[t];
299
- return typeof o == "string" || typeof o == "number" ? String(o) : e.uniqueKeyValue;
300
- }, se = (e) => ({
301
- documentId: e.documentId,
302
- locale: e.locale ?? "default"
303
- }), te = (e, t) => e.documentId === t.documentId && e.locale === t.locale, ce = (e, t) => t.some((o) => te(o, se(e))), Ht = (e) => [...new Set(e.map((t) => t.documentId))], Vt = (e, t) => {
304
- if (e.length === 0)
305
- return !1;
306
- const o = e.filter((r) => t.has(r)).length;
307
- return o === 0 ? !1 : o === e.length ? !0 : "indeterminate";
308
- }, Yt = (e, t) => {
309
- const o = new Set(t);
310
- return new Set([...e].filter((r) => o.has(r)));
311
- }, jt = "homePage.missingUniqueKey", le = {
312
- single: "homePage.hint.missingUniqueKey.single",
313
- allLocales: "homePage.hint.missingUniqueKey.allLocales",
314
- someLocales: "homePage.hint.missingUniqueKey.someLocales"
315
- }, Y = (e, t) => e !== "up_to_date" && t !== "missing_unique_key", Xt = (e) => {
316
- switch (!0) {
317
- case e.every((t) => t.warning === "missing_unique_key"):
318
- return "allLocales";
319
- case e.some((t) => t.warning === "missing_unique_key"):
320
- return "someLocales";
321
- default:
322
- return null;
323
- }
324
- }, nt = (e, t, o) => {
325
- if (!e)
326
- return "homePage.tooltip.noExecutePermission";
327
- switch (!0) {
328
- case t === "up_to_date":
329
- return "homePage.tooltip.upToDate";
330
- case o === "missing_unique_key":
331
- return le.single;
332
- default:
333
- return null;
334
- }
335
- }, ot = (e, t) => {
336
- if (!e)
337
- return "homePage.tooltip.noExecutePermission";
338
- switch (!0) {
339
- case t.some((o) => Y(o.status, o.warning)):
340
- return null;
341
- case t.every((o) => o.status === "up_to_date"):
342
- return "homePage.tooltip.allEntitiesUpToDate";
343
- case t.every((o) => o.warning === "missing_unique_key"):
344
- return le.allLocales;
345
- default:
346
- return le.someLocales;
347
- }
348
- }, xe = ({
349
- checked: e,
350
- onCheckedChange: t,
351
- disable: o = !1,
352
- tooltipLabel: r = ""
353
- }) => /* @__PURE__ */ n("div", { onClick: (i) => i.stopPropagation(), children: /* @__PURE__ */ n(qe, { label: o ? r : "", align: "start", children: /* @__PURE__ */ n(Le, { checked: e, onCheckedChange: t, disabled: o }) }) }), ye = ({ locale: e }) => {
354
- const { formatMessage: t } = b();
355
- return e === "default" ? /* @__PURE__ */ n(z, { variant: "neutral", children: t({ id: a("homePage.promotionResults.locale.nonLocalized") }) }) : /* @__PURE__ */ n(z, { variant: "neutral", children: e });
356
- }, Jt = (e) => {
357
- switch (e) {
358
- case "new":
359
- return "homePage.table.status.new";
360
- case "changed":
361
- return "homePage.table.status.changed";
362
- case "up_to_date":
363
- return "homePage.table.status.upToDate";
364
- default:
365
- return "homePage.table.status.new";
366
- }
367
- }, Zt = (e) => {
368
- switch (e) {
369
- case "new":
370
- return "success";
371
- case "changed":
372
- return "danger";
373
- case "up_to_date":
374
- return "neutral";
375
- default:
376
- return "success";
377
- }
378
- }, rt = ({ status: e }) => {
379
- const { formatMessage: t } = b();
380
- return /* @__PURE__ */ n(z, { variant: Zt(e), children: t({
381
- id: a(Jt(e))
382
- }) });
383
- }, Wt = ({ shouldShow: e, message: t, tooltipLabel: o }) => e ? /* @__PURE__ */ n(qe, { label: o, align: "start", children: /* @__PURE__ */ u(f, { direction: "row", gap: 1, alignItems: "center", children: [
384
- /* @__PURE__ */ n(Ae, { fill: "warning500", width: 20, height: 20 }),
385
- /* @__PURE__ */ n(h, { variant: "pi", textColor: "warning500", children: t })
386
- ] }) }) : null, fe = ({ uniqueKey: e, missingUniqueKeyScope: t, maxCharacters: o = 40 }) => {
387
- const { formatMessage: r } = b();
388
- if (!t)
389
- return /* @__PURE__ */ n(
390
- V,
391
- {
392
- maxCharacters: o,
393
- text: e || "N/A",
394
- variant: "pi",
395
- textColor: "neutral600"
396
- }
397
- );
398
- const i = r({
399
- id: a(jt)
400
- }), s = r({
401
- id: a(le[t])
402
- }), l = /* @__PURE__ */ n(Wt, { shouldShow: !0, tooltipLabel: s, message: i });
403
- return t === "someLocales" && e ? /* @__PURE__ */ u(f, { direction: "row", gap: 2, alignItems: "center", children: [
404
- /* @__PURE__ */ n(
405
- V,
406
- {
407
- maxCharacters: o,
408
- text: e,
409
- variant: "pi",
410
- textColor: "neutral600"
411
- }
412
- ),
413
- l
414
- ] }) : l;
415
- }, it = ({
416
- entryTitle: e,
417
- uniqueKey: t,
418
- missingUniqueKeyScope: o,
419
- locale: r,
420
- titleMaxCharacters: i = 60,
421
- checked: s,
422
- onCheckedChange: l,
423
- checkboxDisabled: c = !1,
424
- checkboxTooltipLabel: d,
425
- status: m
426
- }) => {
427
- const p = /* @__PURE__ */ n(
428
- V,
429
- {
430
- maxCharacters: i,
431
- text: e,
432
- variant: "omega",
433
- fontWeight: "semiBold"
434
- }
435
- );
436
- return /* @__PURE__ */ u(A, { children: [
437
- /* @__PURE__ */ u(f, { direction: "row", gap: 4, alignItems: "center", children: [
438
- /* @__PURE__ */ n(
439
- xe,
440
- {
441
- checked: s,
442
- onCheckedChange: l,
443
- disable: c,
444
- tooltipLabel: d
445
- }
446
- ),
447
- r ? /* @__PURE__ */ u(f, { direction: "row", gap: 2, alignItems: "center", children: [
448
- /* @__PURE__ */ n(ye, { locale: r }),
449
- p
450
- ] }) : p,
451
- /* @__PURE__ */ n(fe, { uniqueKey: t, missingUniqueKeyScope: o })
452
- ] }),
453
- /* @__PURE__ */ n(rt, { status: m })
454
- ] });
455
- }, zt = ({
456
- entryTitle: e,
457
- uniqueKey: t,
458
- status: o,
459
- warning: r,
460
- locale: i,
461
- isChecked: s,
462
- onCheckItemChange: l,
463
- canExecute: c
464
- }) => {
465
- const { formatMessage: d } = b(), m = !c || !Y(o, r), p = nt(c, o, r);
466
- return /* @__PURE__ */ n(
467
- f,
468
- {
469
- direction: "row",
470
- justifyContent: "space-between",
471
- alignItems: "center",
472
- background: "neutral0",
473
- style: {
474
- width: "100%",
475
- padding: "24px"
476
- },
477
- grow: 1,
478
- gap: 4,
479
- children: /* @__PURE__ */ n(
480
- it,
481
- {
482
- entryTitle: e,
483
- uniqueKey: t,
484
- missingUniqueKeyScope: r === "missing_unique_key" ? "single" : null,
485
- locale: i,
486
- checked: s,
487
- onCheckedChange: l,
488
- checkboxDisabled: m,
489
- checkboxTooltipLabel: p ? d({ id: a(p) }) : void 0,
490
- status: o
491
- }
492
- )
493
- }
494
- );
495
- }, en = ({
496
- isAllCheckedInEntity: e,
497
- onCheckAllInEntity: t,
498
- entityWithLocalizations: o,
499
- selectedPromotions: r,
500
- onCheckItemChange: i,
501
- isIndeterminate: s,
502
- contentTypeMainField: l,
503
- canExecute: c
504
- }) => {
505
- const { formatMessage: d } = b(), m = [
506
- {
507
- key: "checkbox"
508
- },
509
- {
510
- key: "locale",
511
- label: d({ id: a("homePage.table.locale") })
512
- },
513
- {
514
- key: "entryTitle",
515
- label: d({ id: a("homePage.table.entryTitle") })
516
- },
517
- {
518
- key: "key",
519
- label: d({ id: a("homePage.table.key") })
520
- },
521
- {
522
- key: "status",
523
- label: d({ id: a("homePage.table.status") })
524
- }
525
- ], p = !o?.some(
526
- (g) => Y(g.status, g.warning)
527
- ), y = ot(
528
- c,
529
- o ?? []
530
- );
531
- return /* @__PURE__ */ u(_e, { colCount: m.length, rowCount: o?.length ?? 0, children: [
532
- /* @__PURE__ */ n(Ke, { children: /* @__PURE__ */ n(H, { children: m.map((g) => /* @__PURE__ */ n(F, { children: g.key === "checkbox" ? /* @__PURE__ */ n(
533
- xe,
534
- {
535
- checked: s ? "indeterminate" : e,
536
- onCheckedChange: t,
537
- disable: p || !c,
538
- tooltipLabel: y ? d({ id: a(y) }) : ""
539
- }
540
- ) : /* @__PURE__ */ n(h, { variant: "sigma", children: g.label }) }, g.key)) }) }),
541
- /* @__PURE__ */ n(De, { children: o?.map((g) => {
542
- const P = !c || !Y(g.status, g.warning), C = nt(
543
- c,
544
- g.status,
545
- g.warning
546
- );
547
- return /* @__PURE__ */ u(H, { children: [
548
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(
549
- xe,
550
- {
551
- checked: ce(g, r),
552
- onCheckedChange: i(g),
553
- disable: P,
554
- tooltipLabel: C ? d({ id: a(C) }) : ""
555
- }
556
- ) }),
557
- /* @__PURE__ */ n(T, { children: g?.locale ? /* @__PURE__ */ n(ye, { locale: g.locale }) : null }),
558
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(
559
- V,
560
- {
561
- maxCharacters: 50,
562
- text: pe(g, l) || ""
563
- }
564
- ) }),
565
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(
566
- fe,
567
- {
568
- uniqueKey: g?.uniqueKeyValue,
569
- missingUniqueKeyScope: g?.warning === "missing_unique_key" ? "single" : null
570
- }
571
- ) }),
572
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(rt, { status: g?.status }) })
573
- ] }, `${g.documentId}-${g.locale}`);
574
- }) })
575
- ] });
576
- }, tn = Be(q.Trigger)`
577
- width: 100%;
578
- & > span:first-child {
579
- width: 100%;
580
- display: flex;
581
- justify-content: space-between;
582
- & > span {
583
- width: 100%;
584
- }
585
- }
586
- `, nn = ({
587
- uniqueKey: e,
588
- entityWithLocalizations: t,
589
- entryTitle: o,
590
- selectedPromotions: r,
591
- setSelectedPromotions: i,
592
- onCheckItemChange: s,
593
- contentTypeMainField: l,
594
- onRememberEntityGroup: c,
595
- canExecute: d
596
- }) => {
597
- const { formatMessage: m } = b(), p = t.filter(
598
- (S) => Y(S.status, S.warning)
599
- ), y = (S) => {
600
- i((G) => {
601
- const Q = p.map(
602
- (R) => se(R)
603
- ), K = (R) => t.some(
604
- (M) => te(R, se(M))
605
- );
606
- return S ? (c?.(t), [...G.filter((M) => !K(M)), ...Q]) : G.filter((R) => !K(R));
607
- });
608
- }, g = t?.some(
609
- (S) => ce(S, r)
610
- ), P = p.length > 0 && p.every(
611
- (S) => ce(S, r)
612
- ), C = p.length === 0, v = ot(
613
- d,
614
- t
615
- ), $ = Xt(t), x = (() => {
616
- switch (!0) {
617
- case t?.some((S) => S?.status === "new"):
618
- return "new";
619
- case t?.some((S) => S?.status === "changed"):
620
- return "changed";
621
- default:
622
- return "up_to_date";
623
- }
624
- })(), O = g && !P;
625
- return /* @__PURE__ */ n(q.Root, { style: { width: "100%" }, size: "M", children: /* @__PURE__ */ u(q.Item, { value: `${o}-${e}`, children: [
626
- /* @__PURE__ */ n(q.Header, { children: /* @__PURE__ */ n(tn, { caretPosition: "right", children: /* @__PURE__ */ n(
627
- f,
628
- {
629
- direction: "row",
630
- justifyContent: "space-between",
631
- alignItems: "center",
632
- style: { width: "100%" },
633
- grow: 1,
634
- gap: 4,
635
- children: /* @__PURE__ */ n(
636
- it,
637
- {
638
- entryTitle: o,
639
- uniqueKey: e,
640
- missingUniqueKeyScope: $,
641
- checked: O ? "indeterminate" : P,
642
- onCheckedChange: y,
643
- checkboxDisabled: C || !d,
644
- checkboxTooltipLabel: v ? m({ id: a(v) }) : void 0,
645
- status: x
646
- }
647
- )
648
- }
649
- ) }) }),
650
- /* @__PURE__ */ n(q.Content, { children: /* @__PURE__ */ n(
651
- en,
652
- {
653
- isAllCheckedInEntity: P,
654
- onCheckAllInEntity: y,
655
- entityWithLocalizations: t,
656
- selectedPromotions: r,
657
- onCheckItemChange: s,
658
- isIndeterminate: O,
659
- contentTypeMainField: l,
660
- canExecute: d
661
- }
662
- ) })
663
- ] }) });
664
- }, on = ({
665
- entities: e,
666
- contentTypeMainField: t,
667
- selectedPromotions: o,
668
- setSelectedPromotions: r,
669
- onRememberEntityGroup: i,
670
- canExecute: s
671
- }) => {
672
- const l = (d) => (m) => (p) => {
673
- const y = se(m);
674
- r((g) => p ? g.some((P) => te(P, y)) ? g : (i?.(d), [...g, y]) : g.filter((P) => !te(P, y)));
675
- }, c = (d, m) => {
676
- const p = pe(d, t), y = d?.uniqueKeyValue || "";
677
- return m.length > 1 ? /* @__PURE__ */ n(
678
- nn,
679
- {
680
- uniqueKey: y,
681
- contentTypeMainField: t,
682
- entityWithLocalizations: m,
683
- entryTitle: p || "",
684
- selectedPromotions: o,
685
- setSelectedPromotions: r,
686
- onCheckItemChange: l(m),
687
- onRememberEntityGroup: i,
688
- canExecute: s
689
- }
690
- ) : /* @__PURE__ */ n(
691
- zt,
692
- {
693
- entryTitle: p || "",
694
- uniqueKey: y,
695
- status: d?.status,
696
- warning: d?.warning,
697
- locale: d?.locale,
698
- isChecked: ce(d, o),
699
- onCheckItemChange: l(m)(d),
700
- canExecute: s
701
- }
702
- );
703
- };
704
- return /* @__PURE__ */ n("div", { children: e?.map((d, m) => {
705
- const p = Ne(d);
706
- return /* @__PURE__ */ u(qt, { children: [
707
- c(d, p),
708
- e?.length - 1 > m && /* @__PURE__ */ n(kt, {})
709
- ] }, d?.documentId);
710
- }) });
711
- }, rn = () => {
712
- const { get: e } = k();
713
- return U({
714
- queryKey: ["content-types"],
715
- queryFn: async () => {
716
- const { data: t } = await e("/content-type-builder/content-types");
717
- return t.data;
718
- }
719
- });
720
- }, an = (e, t) => {
721
- const { get: o } = k();
722
- return U({
723
- queryKey: [It, "related-content-types", e],
724
- queryFn: async () => {
725
- const { data: r } = await o(
726
- `/${_}/promotion/related-content-types`,
727
- {
728
- params: {
729
- contentTypeUid: e
730
- }
731
- }
732
- );
733
- return r;
734
- },
735
- enabled: !!e && t
736
- });
737
- }, sn = () => {
738
- const { post: e } = k(), t = oe();
739
- return me({
740
- mutationFn: async (o) => {
741
- const { data: r } = await e(
742
- `/${_}/promotion`,
743
- o
744
- );
745
- return r;
746
- },
747
- onSuccess: () => {
748
- ze(t);
749
- }
750
- });
751
- }, cn = (e, t) => e.includes(t) ? [t, ...e.filter((o) => o !== t).sort()] : e.sort(), ln = (e) => e.filter((t) => Y(t.status, t.warning)).map((t) => t.locale ?? "default"), dn = (e, t) => e.length > 0 && e.every((o) => t.includes(o)), un = (e, t, o) => {
752
- const r = /* @__PURE__ */ new Map();
753
- for (const c of t ?? [])
754
- r.set(c.documentId, c);
755
- const i = tt(t), s = /* @__PURE__ */ new Map();
756
- for (const c of e) {
757
- const d = s.get(c.documentId) ?? [];
758
- d.push(c), s.set(c.documentId, d);
759
- }
760
- return [...new Set(e.map((c) => c.documentId))].map((c) => {
761
- const d = s.get(c) ?? [], m = r.get(c) ?? i.find((C) => C.documentId === c), p = m?.locale ?? "default", y = m ?? i.find(
762
- (C) => d.some(
763
- (v) => te(v, {
764
- documentId: C.documentId,
765
- locale: C.locale ?? "default"
766
- })
767
- )
768
- ), g = cn(
769
- d.map((C) => C.locale),
770
- p
771
- ), P = ln(
772
- Gt(c, t)
773
- );
774
- return {
775
- documentId: c,
776
- title: y ? pe(y, o) ?? c : c,
777
- locales: g,
778
- allLocalesSelected: dn(P, g),
779
- uniqueKey: y?.uniqueKeyValue ?? null
780
- };
781
- });
782
- }, de = (e, t) => t?.find((o) => o.uid === e)?.schema.displayName ?? e, mn = (e) => {
783
- const t = [
784
- e.summary,
785
- ...e.dependencyResults.map((i) => i.summary)
786
- ], o = t.reduce((i, s) => i + s.failed, 0), r = t.reduce((i, s) => i + s.total, 0);
787
- return o === 0 ? "success" : o >= r ? "failure" : "partial";
788
- }, gn = ["en", "default"], hn = (e) => {
789
- for (const t of gn) {
790
- const o = e.find((r) => r.locale === t);
791
- if (o?.uniqueKey != null && o.uniqueKey.length > 0)
792
- return o.uniqueKey;
793
- }
794
- return e.find((t) => t.uniqueKey != null && t.uniqueKey.length > 0)?.uniqueKey ?? null;
795
- }, pn = (e, t, o) => {
796
- if (e.uniqueKey != null && e.uniqueKey.length > 0)
797
- return e.uniqueKey;
798
- const r = e.documentId ?? e.documentKey, i = tt(t).find(
799
- (s) => s.documentId === r
800
- );
801
- if (i) {
802
- const s = pe(i, o);
803
- if (s != null && String(s).length > 0)
804
- return String(s);
805
- }
806
- return r;
807
- }, yn = (e) => {
808
- if (e.documentId != null && e.documentId.length > 0)
809
- return e.documentId;
810
- const t = e.steps.find(
811
- (r) => r.push.remoteDocumentId != null && r.push.remoteDocumentId.length > 0
812
- )?.push.remoteDocumentId;
813
- if (t != null && t.length > 0)
814
- return t;
815
- if (e.uniqueKey != null && e.uniqueKey.length > 0)
816
- return e.uniqueKey;
817
- const o = e.groupKey.lastIndexOf("::");
818
- return o === -1 ? e.groupKey : e.groupKey.slice(0, o);
819
- }, fn = {
820
- create: "created",
821
- update: "updated"
822
- }, at = (e) => e.push.ok ? e.push.skipped || e.action === "skip" ? "skipped" : fn[e.action] : "failed", Pn = (e) => {
823
- const t = e[0];
824
- return t ? at(t) : "skipped";
825
- }, Sn = (e) => {
826
- switch (e) {
827
- case "failed":
828
- return "danger";
829
- case "skipped":
830
- return "neutral";
831
- case "updated":
832
- return "secondary";
833
- case "created":
834
- return "success";
835
- default:
836
- return "success";
837
- }
838
- }, re = (e) => {
839
- const t = /* @__PURE__ */ new Map();
840
- for (const o of e) {
841
- const r = o.snapshotKey, i = t.get(r) ?? [];
842
- i.push(o), t.set(r, i);
843
- }
844
- return Array.from(t.entries()).map(([o, r]) => {
845
- const i = r.some((l) => !l.push.ok), s = r[r.length - 1];
846
- return {
847
- groupKey: o,
848
- documentId: s.documentId,
849
- locale: s.locale,
850
- uniqueKey: s.uniqueKey,
851
- outcome: i ? "failed" : Pn(r),
852
- steps: r,
853
- hasFailure: i
854
- };
855
- });
856
- }, st = (e) => {
857
- const t = re(e), o = /* @__PURE__ */ new Map();
858
- for (const r of t) {
859
- const i = yn(r), s = o.get(i) ?? [];
860
- s.push(r), o.set(i, s);
861
- }
862
- return Array.from(o.entries()).map(([r, i]) => {
863
- const s = i.sort(
864
- (l, c) => l.locale.localeCompare(c.locale)
865
- );
866
- return {
867
- documentKey: r,
868
- documentId: s[0]?.documentId,
869
- uniqueKey: hn(s),
870
- localeEntries: s
871
- };
872
- });
873
- }, Cn = (e, t) => st(e).map((o) => ({
874
- id: o.documentKey,
875
- title: pn(
876
- o,
877
- t?.comparedEntities,
878
- t?.contentTypeMainField
879
- ),
880
- entries: o.localeEntries.flatMap((r) => r.steps)
881
- })), je = (e) => {
882
- const t = re(e);
883
- return {
884
- entityCount: t.length,
885
- created: t.filter((o) => o.outcome === "created").length,
886
- updated: t.filter((o) => o.outcome === "updated").length,
887
- skipped: t.filter((o) => o.outcome === "skipped").length,
888
- failed: t.filter((o) => o.outcome === "failed").length,
889
- locales: [...new Set(t.map((o) => o.locale))].sort()
890
- };
891
- }, bn = (e) => {
892
- const t = {
893
- total: 0,
894
- created: 0,
895
- updated: 0,
896
- skipped: 0,
897
- failed: 0
898
- }, o = re(e);
899
- for (const r of o) {
900
- const i = r.steps[0];
901
- i && (t.total += 1, t[at(i)] += 1);
902
- }
903
- return t;
904
- }, In = (e) => re(e).filter(
905
- (t) => t.steps.some((o) => o.hasUnlinkedRelations)
906
- ).length, wn = (e, t) => {
907
- const o = st(e.entries), r = je(e.entries), i = [
908
- ...new Set(e.selections.map((d) => d.locale))
909
- ].sort(), s = e.dependencyResults.map((d) => {
910
- const m = je(d.entries);
911
- return {
912
- contentTypeUid: d.contentTypeUid,
913
- displayName: de(d.contentTypeUid, t),
914
- ...m
915
- };
916
- }), l = r.entityCount + s.reduce((d, m) => d + m.entityCount, 0), c = r.failed + s.reduce((d, m) => d + m.failed, 0);
917
- return {
918
- outcome: mn(e),
919
- primaryDisplayName: de(e.contentTypeUid, t),
920
- primaryEntityCount: o.length,
921
- dependencySummaries: s,
922
- totalEntityCount: l,
923
- totalFailed: c,
924
- selectionLocales: i,
925
- dependencyContentTypeCount: e.dependencyResults.length,
926
- mediaSummary: e.mediaSummary
927
- };
928
- }, ct = ({ entries: e, showFailuresOnly: t = !1 }) => {
929
- const { formatMessage: o } = b(), r = Je(() => {
930
- const i = re(e);
931
- return t ? i.filter((s) => s.hasFailure) : i;
932
- }, [e, t]);
933
- return r.length === 0 ? /* @__PURE__ */ n(h, { variant: "omega", textColor: "neutral600", children: o({
934
- id: a(
935
- t ? "homePage.promotionResults.noFailures" : "homePage.promotionResults.noEntries"
936
- )
937
- }) }) : /* @__PURE__ */ u(_e, { colCount: 3, rowCount: r.length, children: [
938
- /* @__PURE__ */ n(Ke, { children: /* @__PURE__ */ u(H, { children: [
939
- /* @__PURE__ */ n(F, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: o({ id: a("homePage.table.locale") }) }) }),
940
- /* @__PURE__ */ n(F, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: o({ id: a("homePage.table.key") }) }) }),
941
- /* @__PURE__ */ n(F, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: o({
942
- id: a("homePage.promotionResults.table.outcome")
943
- }) }) })
944
- ] }) }),
945
- /* @__PURE__ */ n(De, { children: r.map((i) => /* @__PURE__ */ u(H, { children: [
946
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(ye, { locale: i.locale }) }),
947
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(fe, { uniqueKey: i.uniqueKey, maxCharacters: 35 }) }),
948
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(z, { variant: Sn(i.outcome), children: o({
949
- id: a(`homePage.promotionResults.outcome.${i.outcome}`)
950
- }) }) })
951
- ] }, i.groupKey)) })
952
- ] });
953
- }, En = ({ summary: e, unlinkedRelationCount: t = 0 }) => {
954
- const { formatMessage: o } = b(), r = [
955
- {
956
- key: "created",
957
- label: o({ id: a("homePage.promotionResults.summary.created") }),
958
- value: e.created,
959
- variant: "success"
960
- },
961
- {
962
- key: "updated",
963
- label: o({ id: a("homePage.promotionResults.summary.updated") }),
964
- value: e.updated,
965
- variant: "secondary"
966
- },
967
- ...e.skipped > 0 ? [
968
- {
969
- key: "skipped",
970
- label: o({
971
- id: a("homePage.promotionResults.summary.skipped")
972
- }),
973
- value: e.skipped,
974
- variant: "neutral"
975
- }
976
- ] : [],
977
- ...e.failed > 0 ? [
978
- {
979
- key: "failed",
980
- label: o({
981
- id: a("homePage.promotionResults.summary.failed")
982
- }),
983
- value: e.failed,
984
- variant: "danger"
985
- }
986
- ] : [],
987
- ...t > 0 ? [
988
- {
989
- key: "unlinkedRelations",
990
- label: o({
991
- id: a("homePage.promotionResults.summary.unlinkedRelations")
992
- }),
993
- value: t,
994
- variant: "warning"
995
- }
996
- ] : []
997
- ];
998
- return /* @__PURE__ */ n(f, { gap: 2, wrap: "wrap", children: r.map((i) => /* @__PURE__ */ u(z, { variant: i.variant, children: [
999
- i.label,
1000
- ": ",
1001
- i.value
1002
- ] }, i.key)) });
1003
- }, Tn = Be(q.Trigger)`
1004
- width: 100%;
1005
- font-weight: ${({ theme: e }) => e.fontWeights.regular};
1006
-
1007
- & > span:first-child {
1008
- width: 100%;
1009
- display: flex;
1010
- justify-content: space-between;
1011
- font-weight: inherit;
1012
- & > span {
1013
- width: 100%;
1014
- font-weight: inherit;
1015
- }
1016
- }
1017
- `, Xe = ({ items: e }) => /* @__PURE__ */ n(q.Root, { style: { width: "100%" }, size: "S", children: e.map((t) => /* @__PURE__ */ u(q.Item, { value: t.id, children: [
1018
- /* @__PURE__ */ n(q.Header, { children: /* @__PURE__ */ n(Tn, { caretPosition: "right", children: /* @__PURE__ */ u(f, { justifyContent: "space-between", alignItems: "center", width: "100%", gap: 2, children: [
1019
- /* @__PURE__ */ n(V, { maxCharacters: 40, text: t.title, fontWeight: "regular" }),
1020
- /* @__PURE__ */ n(xt, { style: { flexShrink: 0 }, children: /* @__PURE__ */ n(
1021
- En,
1022
- {
1023
- summary: bn(t.entries),
1024
- unlinkedRelationCount: In(t.entries)
1025
- }
1026
- ) })
1027
- ] }) }) }),
1028
- /* @__PURE__ */ n(q.Content, { children: /* @__PURE__ */ n(ct, { entries: t.entries }) })
1029
- ] }, t.id)) }), vn = ({ overview: e }) => {
1030
- const { formatMessage: t } = b(), o = e.dependencySummaries.map((r) => r.displayName);
1031
- return /* @__PURE__ */ u(f, { direction: "column", alignItems: "stretch", gap: 2, children: [
1032
- /* @__PURE__ */ n(h, { variant: "omega", children: t(
1033
- { id: a("homePage.promotionResults.header.summary") },
1034
- {
1035
- primaryCount: e.primaryEntityCount,
1036
- dependencyCount: e.dependencyContentTypeCount,
1037
- entityCount: e.totalEntityCount,
1038
- failedCount: e.totalFailed
1039
- }
1040
- ) }),
1041
- o.length > 0 && /* @__PURE__ */ n(h, { variant: "pi", textColor: "neutral600", children: t(
1042
- { id: a("homePage.promotionResults.header.dependencies") },
1043
- { contentTypes: o.join(", ") }
1044
- ) }),
1045
- e.mediaSummary && /* @__PURE__ */ n(h, { variant: "pi", textColor: "neutral600", children: t(
1046
- { id: a("homePage.promotionResults.media.summary") },
1047
- {
1048
- uploaded: e.mediaSummary.uploaded,
1049
- replaced: e.mediaSummary.replaced,
1050
- failed: e.mediaSummary.failed
1051
- }
1052
- ) })
1053
- ] });
1054
- }, kn = ({
1055
- result: e,
1056
- contentTypes: t,
1057
- comparedEntities: o,
1058
- contentTypeMainField: r
1059
- }) => {
1060
- const { formatMessage: i } = b(), s = wn(e, t), l = s.outcome, c = [
1061
- ...e.entries,
1062
- ...e.dependencyResults.flatMap((C) => C.entries)
1063
- ], d = de(e.contentTypeUid, t), m = s.totalFailed > 0, p = e.dependencyResults.length > 0, y = Cn(e.entries, {
1064
- comparedEntities: o,
1065
- contentTypeMainField: r
1066
- }), g = e.dependencyResults.map((C) => ({
1067
- id: C.contentTypeUid,
1068
- title: de(C.contentTypeUid, t),
1069
- entries: C.entries
1070
- }));
1071
- return /* @__PURE__ */ u(f, { direction: "column", alignItems: "stretch", gap: 4, children: [
1072
- (() => {
1073
- switch (l) {
1074
- case "success":
1075
- return /* @__PURE__ */ n(
1076
- w,
1077
- {
1078
- variant: "success",
1079
- title: i({
1080
- id: a("homePage.promotionResults.success.title")
1081
- }),
1082
- description: i(
1083
- { id: a("homePage.promotionResults.success.description") },
1084
- {
1085
- primaryCount: s.primaryEntityCount
1086
- }
1087
- )
1088
- }
1089
- );
1090
- case "partial":
1091
- return /* @__PURE__ */ n(
1092
- w,
1093
- {
1094
- variant: "warning",
1095
- title: i({
1096
- id: a("homePage.promotionResults.partialFailure.title")
1097
- }),
1098
- description: i({
1099
- id: a("homePage.promotionResults.partialFailure.description")
1100
- })
1101
- }
1102
- );
1103
- case "failure":
1104
- return /* @__PURE__ */ n(
1105
- w,
1106
- {
1107
- variant: "danger",
1108
- title: i({
1109
- id: a("homePage.promotionResults.failure.title")
1110
- }),
1111
- description: i({
1112
- id: a("homePage.promotionResults.failure.description")
1113
- })
1114
- }
1115
- );
1116
- }
1117
- })(),
1118
- e.hasUnlinkedRelations && /* @__PURE__ */ n(
1119
- w,
1120
- {
1121
- variant: "warning",
1122
- title: i({
1123
- id: a("homePage.promotionResults.unlinkedRelations.title")
1124
- }),
1125
- description: i({
1126
- id: a("homePage.promotionResults.unlinkedRelations.description")
1127
- })
1128
- }
1129
- ),
1130
- /* @__PURE__ */ n(vn, { overview: s }),
1131
- m && /* @__PURE__ */ u(f, { direction: "column", alignItems: "stretch", gap: 2, children: [
1132
- /* @__PURE__ */ n(h, { variant: "delta", children: i({
1133
- id: a("homePage.promotionResults.failures.title")
1134
- }) }),
1135
- /* @__PURE__ */ n(ct, { entries: c, showFailuresOnly: !0 })
1136
- ] }),
1137
- /* @__PURE__ */ u(f, { direction: "column", alignItems: "stretch", gap: 2, children: [
1138
- /* @__PURE__ */ u(h, { variant: "delta", children: [
1139
- d,
1140
- ":"
1141
- ] }),
1142
- /* @__PURE__ */ n(Xe, { items: y })
1143
- ] }),
1144
- p && /* @__PURE__ */ u(f, { direction: "column", alignItems: "stretch", gap: 2, children: [
1145
- /* @__PURE__ */ n(h, { variant: "delta", children: i({
1146
- id: a("homePage.promotionResults.dependencies.title")
1147
- }) }),
1148
- /* @__PURE__ */ n(Xe, { items: g })
1149
- ] })
1150
- ] });
1151
- }, xn = ({
1152
- previews: e,
1153
- mediaDocumentIds: t,
1154
- onToggleMediaDocument: o
1155
- }) => {
1156
- const { formatMessage: r } = b();
1157
- return e.length === 0 ? null : /* @__PURE__ */ u(_e, { colCount: 4, rowCount: e.length, children: [
1158
- /* @__PURE__ */ n(Ke, { children: /* @__PURE__ */ u(H, { children: [
1159
- /* @__PURE__ */ u(F, { children: [
1160
- /* @__PURE__ */ n(h, { variant: "sigma", children: r({
1161
- id: a("homePage.modal.confirmPromotion.includeMedia")
1162
- }) }),
1163
- /* @__PURE__ */ n(
1164
- qe,
1165
- {
1166
- label: r({
1167
- id: a("homePage.modal.confirmPromotion.tooltip")
1168
- }),
1169
- children: /* @__PURE__ */ n(Mt, { style: { marginLeft: "4px" } })
1170
- }
1171
- )
1172
- ] }),
1173
- /* @__PURE__ */ n(F, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: r({ id: a("homePage.table.entryTitle") }) }) }),
1174
- /* @__PURE__ */ n(F, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: r({ id: a("homePage.table.locale") }) }) }),
1175
- /* @__PURE__ */ n(F, { children: /* @__PURE__ */ n(h, { variant: "sigma", children: r({ id: a("homePage.table.key") }) }) })
1176
- ] }) }),
1177
- /* @__PURE__ */ n(De, { children: e.map((i) => /* @__PURE__ */ u(H, { children: [
1178
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(
1179
- Le,
1180
- {
1181
- checked: t.has(i.documentId),
1182
- onCheckedChange: (s) => o(i.documentId, s === !0),
1183
- "aria-label": r(
1184
- {
1185
- id: a("homePage.modal.confirmPromotion.includeMediaForDocument")
1186
- },
1187
- { title: i.title }
1188
- )
1189
- }
1190
- ) }),
1191
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(V, { maxCharacters: 50, text: i.title }) }),
1192
- /* @__PURE__ */ n(T, { children: i.allLocalesSelected ? /* @__PURE__ */ n(h, { variant: "pi", children: r({
1193
- id: a("homePage.modal.confirmPromotion.allLocalesSelected")
1194
- }) }) : /* @__PURE__ */ n(f, { gap: 2, wrap: "wrap", children: i.locales.map((s) => /* @__PURE__ */ n(ye, { locale: s }, `${i.documentId}-${s}`)) }) }),
1195
- /* @__PURE__ */ n(T, { children: /* @__PURE__ */ n(fe, { uniqueKey: i.uniqueKey, maxCharacters: 35 }) })
1196
- ] }, i.documentId)) })
1197
- ] });
1198
- }, Rn = ({
1199
- open: e,
1200
- onClose: t,
1201
- selectedPromotions: o,
1202
- contentTypeUid: r,
1203
- contentTypeMainField: i,
1204
- comparedEntities: s,
1205
- onPromoteComplete: l
1206
- }) => {
1207
- const { formatMessage: c } = b(), { data: d } = rn(), { data: m } = an(
1208
- r,
1209
- e
1210
- ), [p, y] = L(null), [g, P] = L(() => /* @__PURE__ */ new Set()), C = Ht(o), v = Vt(C, g), $ = g.size > 0, {
1211
- mutate: j,
1212
- isPending: x,
1213
- error: O,
1214
- reset: S
1215
- } = sn(), G = () => {
1216
- y(null), P(/* @__PURE__ */ new Set()), S();
1217
- };
1218
- ne(() => {
1219
- P((I) => Yt(I, C));
1220
- }, [C]);
1221
- const Q = m?.contentTypes.map((I) => I.displayName) ?? [], K = un(
1222
- o,
1223
- s,
1224
- i
1225
- ), R = () => {
1226
- G(), t();
1227
- }, M = (I) => {
1228
- P(I ? new Set(C) : /* @__PURE__ */ new Set());
1229
- }, Pe = (I, Ce) => {
1230
- P((J) => {
1231
- const D = new Set(J);
1232
- return Ce ? D.add(I) : D.delete(I), D;
1233
- });
1234
- }, Se = () => {
1235
- j(
1236
- {
1237
- selections: o,
1238
- contentTypeUid: r,
1239
- mediaDocumentIds: [...g]
1240
- },
1241
- {
1242
- onSuccess: (I) => {
1243
- y(I), l?.(I);
1244
- }
1245
- }
1246
- );
1247
- }, X = p != null;
1248
- return /* @__PURE__ */ n(
1249
- ge,
1250
- {
1251
- open: e,
1252
- onClose: R,
1253
- onSubmit: Se,
1254
- title: c({
1255
- id: a(
1256
- X ? "homePage.modal.promotionResults.title" : "homePage.modal.confirmPromotion.title"
1257
- )
1258
- }),
1259
- confirmButtonText: c({
1260
- id: a("homePage.modal.confirmPromotion.confirmButtonText")
1261
- }),
1262
- isConfirmButtonDisabled: x || !r || o.length === 0,
1263
- isConfirmButtonLoading: x,
1264
- showConfirmButton: !X,
1265
- fillMaxHeight: !0,
1266
- children: X ? /* @__PURE__ */ n(
1267
- kn,
1268
- {
1269
- result: p,
1270
- contentTypes: d,
1271
- comparedEntities: s,
1272
- contentTypeMainField: i
1273
- }
1274
- ) : /* @__PURE__ */ u(f, { direction: "column", gap: 4, alignItems: "stretch", children: [
1275
- /* @__PURE__ */ n(h, { variant: "omega", children: c(
1276
- {
1277
- id: a("homePage.modal.confirmPromotion.description")
1278
- },
1279
- { count: o.length }
1280
- ) }),
1281
- /* @__PURE__ */ n(
1282
- Le,
1283
- {
1284
- checked: v,
1285
- onCheckedChange: (I) => M(I === !0),
1286
- children: c({
1287
- id: a("homePage.modal.confirmPromotion.includeMediaAll")
1288
- })
1289
- }
1290
- ),
1291
- /* @__PURE__ */ n(
1292
- xn,
1293
- {
1294
- previews: K,
1295
- mediaDocumentIds: g,
1296
- onToggleMediaDocument: Pe
1297
- }
1298
- ),
1299
- /* @__PURE__ */ n(
1300
- w,
1301
- {
1302
- variant: "default",
1303
- title: c({
1304
- id: a("homePage.promotionResults.scope.title")
1305
- }),
1306
- description: c({
1307
- id: a("homePage.modal.confirmPromotion.localeScopeHint")
1308
- })
1309
- }
1310
- ),
1311
- $ && /* @__PURE__ */ n(
1312
- w,
1313
- {
1314
- variant: "default",
1315
- title: c({
1316
- id: a("homePage.modal.confirmPromotion.mediaScopeHint.title")
1317
- }),
1318
- description: c({
1319
- id: a("homePage.modal.confirmPromotion.mediaScopeHint.description")
1320
- })
1321
- }
1322
- ),
1323
- Q.length > 0 && /* @__PURE__ */ n(
1324
- w,
1325
- {
1326
- variant: "warning",
1327
- title: c({
1328
- id: a("homePage.modal.confirmPromotion.relatedWarning.title")
1329
- }),
1330
- description: c(
1331
- {
1332
- id: a("homePage.modal.confirmPromotion.relatedWarning.description")
1333
- },
1334
- { contentTypes: Q.join(", ") }
1335
- )
1336
- }
1337
- ),
1338
- O && /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: ue(O, c) })
1339
- ] })
1340
- }
1341
- );
1342
- }, Mn = 2500, qn = 5e3, Ln = (e) => e === "running" ? Mn : e === "queued" ? qn : !1, lt = (e, t = !0) => {
1343
- const { get: o } = k(), r = oe(), i = Ze(void 0), s = U({
1344
- queryKey: ee.list(e),
1345
- queryFn: async () => {
1346
- const { data: l } = await o(
1347
- `/${_}/snapshot/sync/${e}/status`
1348
- );
1349
- return l;
1350
- },
1351
- enabled: !!e && t,
1352
- refetchInterval: (l) => Ln(l.state.data?.status),
1353
- refetchOnWindowFocus: !0
1354
- });
1355
- return ne(() => {
1356
- if (!e)
1357
- return;
1358
- const l = i.current, c = s.data?.status;
1359
- (l === "running" && c !== "running" || l === "queued" && c === "running") && he(r, e), i.current = c;
1360
- }, [s.data?.status, e, r]), s;
1361
- }, _n = ({
1362
- syncStatus: e,
1363
- isSyncInProgressFromComparison: t
1364
- }) => {
1365
- const o = e?.status;
1366
- switch (!0) {
1367
- case (o === "running" || t):
1368
- return "in_progress";
1369
- case o === "queued":
1370
- return "queued";
1371
- case o === "cancelled":
1372
- return "cancelled";
1373
- case o === "failed":
1374
- return "failed";
1375
- default:
1376
- return "none";
1377
- }
1378
- }, Kn = Be(Rt)`
1379
- background-color: ${({ theme: e }) => e.colors.neutral600};
1380
- & > div {
1381
- background-color: ${({ theme: e }) => e.colors.neutral150};
1382
- }
1383
- `, ve = ({ lastProcessedPage: e, totalPages: t }) => {
1384
- const { formatMessage: o } = b(), r = (i, s) => Math.round(Number(i) / Number(s) * 100);
1385
- return /* @__PURE__ */ u(f, { direction: "row", gap: 2, alignItems: "center", children: [
1386
- /* @__PURE__ */ n(h, { variant: "omega", children: o(
1387
- {
1388
- id: a("homePage.alert.syncInProgress.progress")
1389
- },
1390
- {
1391
- currentPage: e,
1392
- totalPages: t
1393
- }
1394
- ) }),
1395
- /* @__PURE__ */ n(Kn, { value: r(e, t) })
1396
- ] });
1397
- }, Dn = ({
1398
- view: e,
1399
- syncStatus: t,
1400
- onRefresh: o,
1401
- onCancel: r,
1402
- onResume: i,
1403
- canExecute: s
1404
- }) => {
1405
- const { formatMessage: l } = b();
1406
- if (e === "none")
1407
- return null;
1408
- const c = Lt(t?.error, l), m = (() => {
1409
- switch (e) {
1410
- case "queued":
1411
- return {
1412
- title: l({
1413
- id: a("homePage.alert.syncQueued.title")
1414
- }),
1415
- description: /* @__PURE__ */ u(f, { direction: "column", gap: 2, alignItems: "flex-start", children: [
1416
- /* @__PURE__ */ n(h, { variant: "omega", children: l({
1417
- id: a("homePage.alert.syncQueued.description")
1418
- }) }),
1419
- t?.queuePosition != null ? /* @__PURE__ */ n(h, { variant: "omega", textColor: "neutral600", children: l(
1420
- { id: a("homePage.alert.syncQueued.position") },
1421
- { position: t.queuePosition }
1422
- ) }) : null,
1423
- t?.queuedAt ? /* @__PURE__ */ n(h, { variant: "omega", textColor: "neutral600", children: l(
1424
- { id: a("homePage.alert.syncQueued.queuedAt") },
1425
- { queuedAt: new Date(t.queuedAt).toLocaleString() }
1426
- ) }) : null
1427
- ] }),
1428
- action: /* @__PURE__ */ n(E, { onClick: o, variant: "secondary", children: l({
1429
- id: a("homePage.alert.syncQueued.linkText")
1430
- }) }),
1431
- variant: "default"
1432
- };
1433
- case "in_progress":
1434
- return {
1435
- title: l({
1436
- id: a("homePage.alert.syncInProgress.title")
1437
- }),
1438
- description: /* @__PURE__ */ u(f, { direction: "column", gap: 2, alignItems: "flex-start", children: [
1439
- /* @__PURE__ */ n(h, { variant: "omega", children: l({
1440
- id: a("homePage.alert.syncInProgress.description")
1441
- }) }),
1442
- /* @__PURE__ */ n(
1443
- ve,
1444
- {
1445
- lastProcessedPage: t?.lastProcessedPage ?? 0,
1446
- totalPages: t?.totalPages ?? 1
1447
- }
1448
- )
1449
- ] }),
1450
- action: /* @__PURE__ */ u(f, { direction: "row", gap: 2, alignItems: "center", children: [
1451
- /* @__PURE__ */ n(E, { onClick: o, variant: "secondary", children: l({
1452
- id: a("homePage.alert.syncInProgress.linkText")
1453
- }) }),
1454
- s ? /* @__PURE__ */ n(E, { variant: "danger-light", onClick: r, children: l({
1455
- id: a("common.button.cancel")
1456
- }) }) : null
1457
- ] }),
1458
- variant: "default"
1459
- };
1460
- case "cancelled":
1461
- return {
1462
- title: l({
1463
- id: a("homePage.alert.resumeSync.title")
1464
- }),
1465
- description: /* @__PURE__ */ u(f, { direction: "column", gap: 2, alignItems: "flex-start", children: [
1466
- /* @__PURE__ */ n(h, { variant: "omega", children: l({
1467
- id: a("homePage.alert.resumeSync.description")
1468
- }) }),
1469
- /* @__PURE__ */ n(
1470
- ve,
1471
- {
1472
- lastProcessedPage: t?.lastProcessedPage ?? 0,
1473
- totalPages: t?.totalPages ?? 1
1474
- }
1475
- )
1476
- ] }),
1477
- action: s ? /* @__PURE__ */ n(E, { onClick: i, variant: "secondary", children: l({
1478
- id: a("homePage.alert.resumeSync.linkText")
1479
- }) }) : void 0,
1480
- variant: "warning"
1481
- };
1482
- case "failed":
1483
- return {
1484
- title: l({
1485
- id: a("homePage.alert.syncFailed.title")
1486
- }),
1487
- description: /* @__PURE__ */ u(f, { direction: "column", gap: 2, alignItems: "flex-start", children: [
1488
- /* @__PURE__ */ n(h, { variant: "omega", children: l({
1489
- id: a("homePage.alert.syncFailed.description")
1490
- }) }),
1491
- c ? /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: c }) : null,
1492
- /* @__PURE__ */ n(
1493
- ve,
1494
- {
1495
- lastProcessedPage: t?.lastProcessedPage ?? 0,
1496
- totalPages: t?.totalPages ?? 1
1497
- }
1498
- )
1499
- ] }),
1500
- action: s ? /* @__PURE__ */ n(E, { onClick: i, variant: "secondary", children: l({
1501
- id: a("homePage.alert.syncFailed.linkText")
1502
- }) }) : void 0,
1503
- variant: "danger"
1504
- };
1505
- default:
1506
- return e;
1507
- }
1508
- })();
1509
- return /* @__PURE__ */ n(
1510
- w,
1511
- {
1512
- title: m?.title,
1513
- description: m?.description,
1514
- action: m?.action,
1515
- variant: m?.variant
1516
- }
1517
- );
1518
- }, An = () => {
1519
- const { post: e } = k(), t = oe();
1520
- return me({
1521
- mutationFn: async () => await e(`/${_}/snapshot/sync/cancel`),
1522
- onSuccess: () => {
1523
- he(t);
1524
- }
1525
- });
1526
- }, Bn = ({ open: e, onClose: t }) => {
1527
- const { formatMessage: o } = b(), {
1528
- mutate: r,
1529
- isPending: i,
1530
- error: s,
1531
- reset: l
1532
- } = An(), c = () => {
1533
- t(), l();
1534
- };
1535
- return /* @__PURE__ */ n(
1536
- ge,
1537
- {
1538
- open: e,
1539
- onClose: c,
1540
- onSubmit: () => r(void 0, { onSuccess: c }),
1541
- title: /* @__PURE__ */ u(f, { direction: "row", gap: 2, alignItems: "center", children: [
1542
- /* @__PURE__ */ n(Ae, { fill: "danger500", width: 20, height: 20 }),
1543
- o({
1544
- id: a("homePage.modal.cancelSync.title")
1545
- })
1546
- ] }),
1547
- confirmButtonText: o({
1548
- id: a("homePage.modal.cancelSync.confirmButtonText")
1549
- }),
1550
- isConfirmButtonLoading: i,
1551
- children: /* @__PURE__ */ u(f, { direction: "column", gap: 4, alignItems: "stretch", children: [
1552
- /* @__PURE__ */ n(h, { variant: "omega", children: o({
1553
- id: a("homePage.modal.cancelSync.description")
1554
- }) }),
1555
- s && /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: ue(s, o) })
1556
- ] })
1557
- }
1558
- );
1559
- }, Nn = () => {
1560
- const { post: e } = k(), t = oe();
1561
- return me({
1562
- mutationFn: async (o) => await e(`/${_}/snapshot/sync/${o}/resume`),
1563
- onSuccess: () => {
1564
- he(t);
1565
- }
1566
- });
1567
- }, Fn = ({ open: e, onClose: t, jobDocumentId: o }) => {
1568
- const { formatMessage: r } = b(), {
1569
- mutate: i,
1570
- isPending: s,
1571
- error: l,
1572
- reset: c
1573
- } = Nn(), d = () => {
1574
- t(), c();
1575
- };
1576
- return /* @__PURE__ */ n(
1577
- ge,
1578
- {
1579
- open: e,
1580
- onClose: d,
1581
- onSubmit: () => i(o, { onSuccess: d }),
1582
- title: r({
1583
- id: a("homePage.modal.resumeSync.title")
1584
- }),
1585
- confirmButtonText: r({
1586
- id: a("homePage.modal.resumeSync.confirmButtonText")
1587
- }),
1588
- isConfirmButtonDisabled: !o,
1589
- isConfirmButtonLoading: s,
1590
- children: /* @__PURE__ */ u(f, { direction: "column", gap: 4, alignItems: "stretch", children: [
1591
- /* @__PURE__ */ n(h, { variant: "omega", children: r({
1592
- id: a("homePage.modal.resumeSync.description")
1593
- }) }),
1594
- l && /* @__PURE__ */ n(h, { variant: "omega", textColor: "danger500", children: ue(l, r) })
1595
- ] })
1596
- }
1597
- );
1598
- }, On = ({
1599
- contentTypeUid: e,
1600
- isSyncInProgressFromComparison: t,
1601
- canExecute: o,
1602
- enabled: r = !0
1603
- }) => {
1604
- const [i, s] = L(!1), [l, c] = L(!1), { data: d, refetch: m } = lt(
1605
- e,
1606
- r
1607
- ), p = _n({
1608
- syncStatus: d,
1609
- isSyncInProgressFromComparison: t
1610
- }), y = d?.jobDocumentId ?? "";
1611
- return /* @__PURE__ */ u(A, { children: [
1612
- /* @__PURE__ */ n(
1613
- Dn,
1614
- {
1615
- view: p,
1616
- syncStatus: d,
1617
- onRefresh: () => m(),
1618
- onCancel: () => s(!0),
1619
- onResume: () => c(!0),
1620
- canExecute: o
1621
- }
1622
- ),
1623
- o ? /* @__PURE__ */ u(A, { children: [
1624
- /* @__PURE__ */ n(Bn, { open: i, onClose: () => s(!1) }),
1625
- /* @__PURE__ */ n(
1626
- Fn,
1627
- {
1628
- open: l,
1629
- onClose: () => c(!1),
1630
- jobDocumentId: y
1631
- }
1632
- )
1633
- ] }) : null
1634
- ] });
1635
- }, Un = (e) => {
1636
- const { get: t } = k();
1637
- return U({
1638
- queryKey: ["compare-schemas"],
1639
- queryFn: async () => {
1640
- const { data: o } = await t(`/${_}/compare-schemas`);
1641
- return o;
1642
- },
1643
- enabled: e
1644
- });
1645
- }, $n = (e = !0) => {
1646
- const { get: t } = k();
1647
- return U({
1648
- queryKey: [wt],
1649
- enabled: e,
1650
- queryFn: async () => {
1651
- const { data: o } = await t(
1652
- `/${_}/promotion/promotable-content-types`
1653
- );
1654
- return o.contentTypes;
1655
- }
1656
- });
1657
- }, Gn = (e, t) => {
1658
- const o = new Set((e ?? []).map((i) => i.documentId)), r = [...t.entries()].filter(([i]) => !o.has(i)).map(([, i]) => Qt(i)).filter((i) => i != null);
1659
- return [...e ?? [], ...r];
1660
- }, Qn = (e, t) => {
1661
- const o = new Set(t.map((i) => i.documentId)), r = /* @__PURE__ */ new Map();
1662
- for (const [i, s] of e)
1663
- o.has(i) && r.set(i, s);
1664
- return r;
1665
- }, Hn = (e, t) => {
1666
- const o = t[0]?.documentId;
1667
- if (!o)
1668
- return e;
1669
- const r = new Map(e);
1670
- return r.set(o, t), r;
1671
- }, Vn = (e) => {
1672
- const [t, o] = L([]), [r, i] = L(() => /* @__PURE__ */ new Map()), s = Ve(() => {
1673
- o([]), i(/* @__PURE__ */ new Map());
1674
- }, []);
1675
- ne(() => {
1676
- i(
1677
- (d) => Qn(d, t)
1678
- );
1679
- }, [t]);
1680
- const l = Ve((d) => {
1681
- i(
1682
- (m) => Hn(m, d)
1683
- );
1684
- }, []), c = Je(
1685
- () => Gn(e, r),
1686
- [e, r]
1687
- );
1688
- return {
1689
- selectedPromotions: t,
1690
- setSelectedPromotions: o,
1691
- clear: s,
1692
- rememberEntityGroup: l,
1693
- entitiesForPreview: c
1694
- };
1695
- }, Yn = () => {
1696
- const { formatMessage: e } = b(), {
1697
- isLoading: t,
1698
- allowedActions: { canExecute: o = !1, canRead: r = !1 }
1699
- } = Pt([...ke.promotionExecute, ...ke.settingsRead]), [{ query: i }, s] = St(), l = Ze(!1), c = ae.object({
1700
- page: ae.coerce.number().optional().default(1),
1701
- pageSize: ae.coerce.number().optional().default(10),
1702
- uid: ae.string().optional()
1703
- }).parse(i), [d, m] = L(!1), { data: p, isLoading: y } = Kt(), g = p?.active === !0, P = !y && p?.active === !1, { data: C } = lt(c.uid ?? "", g), {
1704
- data: v,
1705
- isSuccess: $,
1706
- isLoading: j
1707
- } = $n(g), x = $ && (v?.length ?? 0) > 0, O = v?.map((B) => ({
1708
- key: B.uid,
1709
- value: B.uid,
1710
- label: B.displayName
1711
- })) ?? [], {
1712
- data: S,
1713
- isLoading: G,
1714
- error: Q
1715
- } = Bt({
1716
- uid: c.uid,
1717
- page: c.page,
1718
- pageSize: c.pageSize,
1719
- enabled: g
1720
- }), {
1721
- selectedPromotions: K,
1722
- setSelectedPromotions: R,
1723
- clear: M,
1724
- rememberEntityGroup: Pe,
1725
- entitiesForPreview: Se
1726
- } = Vn(S?.results), X = (B) => {
1727
- l.current = !1, s({
1728
- ...i,
1729
- page: 1,
1730
- pageSize: 10,
1731
- uid: B
1732
- }), M();
1733
- }, I = () => {
1734
- l.current = !0, s({
1735
- ...i,
1736
- page: 1,
1737
- pageSize: 10,
1738
- uid: void 0
1739
- }), M();
1740
- }, Ce = () => {
1741
- m(!1), M();
1742
- }, {
1743
- data: J,
1744
- isLoading: D,
1745
- error: Fe
1746
- } = Un(g && x), Oe = S?.mainField, dt = S?.maxDepthReached, be = S?.errors, ut = be?.type === "unconfigured_relations" ? be : void 0, Ie = be?.type === "sync_in_progress", we = Ie || C?.status === "running", ie = !P && !D && (!!Fe || !!J && !J?.isMatch), Ue = !o || y || P || D || ie || Ie || C?.status === "running" || C?.status === "queued", mt = !!c.uid && G, gt = () => {
1747
- switch (!0) {
1748
- case (j || mt):
1749
- return /* @__PURE__ */ n(Te, {});
1750
- case ($ && !x):
1751
- return /* @__PURE__ */ n(
1752
- w,
1753
- {
1754
- title: e({
1755
- id: a("homePage.alert.configurationNeeded.title")
1756
- }),
1757
- description: e({
1758
- id: a(
1759
- r ? "homePage.alert.configurationNeeded.description" : "homePage.alert.configurationNeeded.readOnlyDescription"
1760
- )
1761
- }),
1762
- action: r ? /* @__PURE__ */ n(Me, { tag: Re, to: "/settings/xecp/configuration", children: e({
1763
- id: a("homePage.alert.configurationNeeded.linkText")
1764
- }) }) : void 0,
1765
- variant: "danger"
1766
- }
1767
- );
1768
- case we:
1769
- return /* @__PURE__ */ n(
1770
- W,
1771
- {
1772
- content: e({
1773
- id: a("homePage.alert.syncInProgress.contentUnavailable")
1774
- })
1775
- }
1776
- );
1777
- case (S?.results && S?.results?.length > 0):
1778
- return /* @__PURE__ */ u(A, { children: [
1779
- dt && /* @__PURE__ */ n(
1780
- w,
1781
- {
1782
- title: e({
1783
- id: a("homePage.alert.maxDepthExceeded.title")
1784
- }),
1785
- variant: "warning",
1786
- description: e({
1787
- id: a("homePage.alert.maxDepthExceeded.description")
1788
- })
1789
- }
1790
- ),
1791
- /* @__PURE__ */ n(
1792
- on,
1793
- {
1794
- entities: S?.results,
1795
- contentTypeMainField: Oe,
1796
- selectedPromotions: K,
1797
- setSelectedPromotions: R,
1798
- onRememberEntityGroup: Pe,
1799
- canExecute: o && !P
1800
- }
1801
- )
1802
- ] });
1803
- case !!Q:
1804
- return /* @__PURE__ */ n(
1805
- W,
1806
- {
1807
- icon: /* @__PURE__ */ n(Ae, { width: 24, height: 24 }),
1808
- content: e({ id: a("homePage.errorLoadingEntities") })
1809
- }
1810
- );
1811
- case (S?.results && S?.results?.length === 0):
1812
- return /* @__PURE__ */ n(
1813
- $t,
1814
- {
1815
- contentTypeUid: c.uid ?? "",
1816
- hasExistingSnapshot: S?.snapshot?.exists ?? !1,
1817
- unconfiguredRelationsError: ut,
1818
- isGetSnapshotDisabled: Ue,
1819
- canExecute: o && !P,
1820
- canReadSettings: r
1821
- }
1822
- );
1823
- default:
1824
- return /* @__PURE__ */ n(
1825
- W,
1826
- {
1827
- content: e({
1828
- id: a("homePage.youNeedToSelectAContentTypeToSeeTheEntities")
1829
- })
1830
- }
1831
- );
1832
- }
1833
- }, $e = S?.snapshot?.exists ?? !1, ht = !we && $e && S?.pagination && S?.pagination?.pageCount > 0, pt = !o || y || P || D || !x || ie || !c.uid || K.length === 0 || we, yt = j || y || D || P || ie || !x, ft = () => {
1834
- switch (!0) {
1835
- case y:
1836
- return /* @__PURE__ */ u(f, { gap: 2, alignItems: "center", children: [
1837
- /* @__PURE__ */ n(Te, { small: !0 }),
1838
- /* @__PURE__ */ n(h, { variant: "omega", children: e({ id: a("homePage.verifyingLicense") }) })
1839
- ] });
1840
- case P:
1841
- return /* @__PURE__ */ n(Ot, { canReadSettings: r });
1842
- case D:
1843
- return /* @__PURE__ */ u(f, { gap: 2, alignItems: "center", children: [
1844
- /* @__PURE__ */ n(Te, { small: !0 }),
1845
- /* @__PURE__ */ n(h, { variant: "omega", children: e({ id: a("homePage.verifyingSchemas") }) })
1846
- ] });
1847
- case ie:
1848
- return /* @__PURE__ */ n(
1849
- Ut,
1850
- {
1851
- compareSchemasData: J,
1852
- errorCompareSchemas: Fe?.message
1853
- }
1854
- );
1855
- default:
1856
- return null;
1857
- }
1858
- }, Ge = l.current || !!c.uid || !x;
1859
- return ne(() => {
1860
- if (Ge) return;
1861
- const B = v?.[0]?.uid;
1862
- B && s({
1863
- ...i,
1864
- uid: B,
1865
- page: 1,
1866
- pageSize: 10
1867
- });
1868
- }, [Ge, v, i, s]), t ? /* @__PURE__ */ n(Z.Loading, {}) : /* @__PURE__ */ u(A, { children: [
1869
- /* @__PURE__ */ n(Z.Title, { children: e({ id: a("homePage.title") }) }),
1870
- /* @__PURE__ */ u(Z.Main, { children: [
1871
- /* @__PURE__ */ n(
1872
- Qe.Header,
1873
- {
1874
- title: e({ id: a("homePage.title") }),
1875
- primaryAction: o ? /* @__PURE__ */ n(E, { disabled: pt, onClick: () => m(!0), children: e({ id: a("homePage.promoteContent") }) }) : null
1876
- }
1877
- ),
1878
- /* @__PURE__ */ n(Qe.Content, { children: /* @__PURE__ */ u(f, { direction: "column", alignItems: "stretch", gap: 4, children: [
1879
- ft(),
1880
- /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n(
1881
- Dt,
1882
- {
1883
- name: "contentType",
1884
- placeholder: e({ id: a("homePage.selectContentType") }),
1885
- onClear: I,
1886
- onChange: X,
1887
- options: O,
1888
- value: c.uid,
1889
- disabled: yt
1890
- }
1891
- ) }),
1892
- c?.uid && !P ? /* @__PURE__ */ u(A, { children: [
1893
- /* @__PURE__ */ n(
1894
- On,
1895
- {
1896
- contentTypeUid: c.uid,
1897
- isSyncInProgressFromComparison: Ie,
1898
- canExecute: o && !P,
1899
- enabled: g
1900
- }
1901
- ),
1902
- /* @__PURE__ */ n(
1903
- Ft,
1904
- {
1905
- contentTypeUid: c.uid,
1906
- selectedPromotionsLength: K.length,
1907
- syncedAt: S?.snapshot?.syncedAt ?? null,
1908
- isGetSnapshotDisabled: Ue,
1909
- hasSnapshot: $e,
1910
- clearSelectedPromotions: M,
1911
- canExecute: o && !P
1912
- }
1913
- )
1914
- ] }) : null,
1915
- P ? null : gt(),
1916
- ht && !P ? /* @__PURE__ */ u(
1917
- Ee.Root,
1918
- {
1919
- total: S?.pagination?.total || 0,
1920
- pageCount: S?.pagination?.pageCount || 0,
1921
- children: [
1922
- /* @__PURE__ */ n(Ee.PageSize, {}),
1923
- /* @__PURE__ */ n(Ee.Links, {})
1924
- ]
1925
- }
1926
- ) : null
1927
- ] }) })
1928
- ] }),
1929
- o && !P && d ? /* @__PURE__ */ n(
1930
- Rn,
1931
- {
1932
- open: d,
1933
- onClose: Ce,
1934
- selectedPromotions: K,
1935
- contentTypeUid: c.uid ?? "",
1936
- contentTypeMainField: Oe,
1937
- comparedEntities: Se
1938
- }
1939
- ) : null
1940
- ] });
1941
- }, jn = () => /* @__PURE__ */ n(Z.Protect, { permissions: [...ke.promotionRead], children: /* @__PURE__ */ n(Yn, {}) }), co = () => /* @__PURE__ */ n(Et, { children: /* @__PURE__ */ u(Ct, { children: [
1942
- /* @__PURE__ */ n(He, { index: !0, element: /* @__PURE__ */ n(jn, {}) }),
1943
- /* @__PURE__ */ n(He, { path: "*", element: /* @__PURE__ */ n(Z.Error, {}) })
1944
- ] }) });
1945
- export {
1946
- co as default
1947
- };