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