@mattisvensson/strapi-plugin-webatlas 0.3.1 → 0.4.2

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 (56) hide show
  1. package/dist/_chunks/{EmptyBox-7D4LrvdH.mjs → EmptyBox-BM4IscSk.mjs} +2 -6
  2. package/dist/_chunks/{EmptyBox-DT6D5gcf.js → EmptyBox-T8t29l25.js} +1 -5
  3. package/dist/_chunks/FullLoader-Cmsf8xS6.js +11 -0
  4. package/dist/_chunks/FullLoader-CrPED_dY.mjs +12 -0
  5. package/dist/_chunks/{de-C8PE3n3B.mjs → de-Dn24NwJf.mjs} +11 -1
  6. package/dist/_chunks/{de-4tL_cJTC.js → de-RiCps8UH.js} +11 -1
  7. package/dist/_chunks/{en-CR1YZvJo.mjs → en-D9Lxaugc.mjs} +11 -1
  8. package/dist/_chunks/{en-Bg4z3fR7.js → en-JLW5S3ZC.js} +11 -1
  9. package/dist/_chunks/index-9db80XRS.mjs +126 -0
  10. package/dist/_chunks/{index-CwHhwtOU.mjs → index-B4pe6Yuh.mjs} +1375 -357
  11. package/dist/_chunks/{index-CKoxbSC0.js → index-CSYue_D0.js} +42 -60
  12. package/dist/_chunks/index-CVj7qbwh.mjs +281 -0
  13. package/dist/_chunks/index-CiY-8z8F.js +126 -0
  14. package/dist/_chunks/{index-BAqGJ3TM.js → index-Clikpy91.js} +1381 -363
  15. package/dist/_chunks/{index-BBL_eQ0G.mjs → index-CtJ_9-RB.mjs} +42 -60
  16. package/dist/_chunks/index-IHvD3566.js +281 -0
  17. package/dist/admin/index.js +1 -1
  18. package/dist/admin/index.mjs +1 -1
  19. package/dist/admin/src/components/UI/FullLoader.d.ts +3 -0
  20. package/dist/admin/src/components/UI/index.d.ts +2 -1
  21. package/dist/admin/src/components/modals/Delete.d.ts +3 -3
  22. package/dist/admin/src/components/modals/NavEdit.d.ts +2 -2
  23. package/dist/admin/src/components/modals/externalItem/index.d.ts +10 -4
  24. package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +1 -1
  25. package/dist/admin/src/components/modals/wrapperItem/index.d.ts +11 -5
  26. package/dist/admin/src/hooks/useApi.d.ts +6 -5
  27. package/dist/admin/src/hooks/useNavigations.d.ts +2 -0
  28. package/dist/admin/src/hooks/usePluginConfig.d.ts +3 -3
  29. package/dist/admin/src/pages/Navigation/PageWrapper.d.ts +7 -0
  30. package/dist/admin/src/pages/Navigation/index.d.ts +1 -1
  31. package/dist/admin/src/pages/Routes/PageWrapper.d.ts +4 -0
  32. package/dist/admin/src/pages/Routes/TableHeader.d.ts +1 -0
  33. package/dist/admin/src/pages/Routes/TableRow.d.ts +4 -0
  34. package/dist/admin/src/pages/Settings/ContentTypeAccordion.d.ts +7 -0
  35. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +8 -0
  36. package/dist/admin/src/utils/createTempNavItemObject.d.ts +25 -0
  37. package/dist/admin/src/utils/index.d.ts +2 -1
  38. package/dist/server/index.js +225 -176
  39. package/dist/server/index.mjs +225 -176
  40. package/dist/server/src/controllers/admin.d.ts +1 -4
  41. package/dist/server/src/controllers/index.d.ts +1 -4
  42. package/dist/server/src/index.d.ts +2 -8
  43. package/dist/server/src/services/admin.d.ts +2 -5
  44. package/dist/server/src/services/index.d.ts +1 -4
  45. package/dist/server/src/utils/navItemHandler.d.ts +5 -0
  46. package/dist/server/src/utils/routeHandler.d.ts +3 -0
  47. package/package.json +1 -1
  48. package/dist/_chunks/_baseConvert-B84_vf8X.js +0 -864
  49. package/dist/_chunks/_baseConvert-C2SW1VHq.mjs +0 -865
  50. package/dist/_chunks/index-BOq-WidK.mjs +0 -17176
  51. package/dist/_chunks/index-C4ou6MTp.js +0 -17195
  52. package/dist/_chunks/index-DZmhgSeq.mjs +0 -92
  53. package/dist/_chunks/index-DsTyLL2l.js +0 -92
  54. package/dist/admin/src/pages/Navigation/Header.d.ts +0 -6
  55. package/dist/server/index.js.map +0 -1
  56. package/dist/server/index.mjs.map +0 -1
@@ -3,13 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const icons = require("@strapi/icons");
5
5
  const designSystem = require("@strapi/design-system");
6
- const admin = require("@strapi/strapi/admin");
7
6
  const React = require("react");
8
7
  const ReactDOM = require("react-dom");
9
- const index = require("./index-CKoxbSC0.js");
10
8
  const reactIntl = require("react-intl");
11
- const EmptyBox = require("./EmptyBox-DT6D5gcf.js");
12
- const _baseConvert = require("./_baseConvert-B84_vf8X.js");
9
+ const index = require("./index-CSYue_D0.js");
10
+ const admin = require("@strapi/strapi/admin");
11
+ const FullLoader = require("./FullLoader-Cmsf8xS6.js");
12
+ const EmptyBox = require("./EmptyBox-T8t29l25.js");
13
13
  const core = require("@dnd-kit/core");
14
14
  const sortable = require("@dnd-kit/sortable");
15
15
  const utilities = require("@dnd-kit/utilities");
@@ -33,36 +33,74 @@ const useAllEntities = () => {
33
33
  }, []);
34
34
  return { entities, loading, error };
35
35
  };
36
- function useNavigations() {
37
- const { get } = admin.useFetchClient();
38
- const [navigations, setNavigations] = React.useState([]);
39
- const fetchNavigations = async () => {
40
- const { data } = await get("/webatlas/navigation");
41
- setNavigations(data || []);
36
+ function createTempNavItemObject({
37
+ parentId,
38
+ entityRoute,
39
+ selectedNavigation,
40
+ navItemState,
41
+ selectedEntity,
42
+ selectedContentType,
43
+ path,
44
+ wrapper = false,
45
+ internal = true
46
+ }) {
47
+ const tempNavItem = {
48
+ id: Math.floor(Math.random() * -1e6),
49
+ // Temporary negative ID
50
+ documentId: `temp-${Date.now()}`,
51
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
52
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
53
+ depth: 0,
54
+ status: null,
55
+ order: 0,
56
+ parent: parentId ? { documentId: parentId } : null,
57
+ items: [],
58
+ isNew: {
59
+ route: entityRoute?.documentId ?? null,
60
+ parent: parentId ?? null,
61
+ navigation: selectedNavigation?.documentId ?? null
62
+ },
63
+ route: {
64
+ active: navItemState.active || false,
65
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
66
+ documentId: "",
67
+ documentIdPath: selectedEntity ? selectedEntity.documentId : "",
68
+ fullPath: path?.value || "",
69
+ id: 0,
70
+ internal,
71
+ isOverride: navItemState.isOverride || false,
72
+ relatedContentType: selectedContentType ? JSON.stringify(selectedContentType.contentType) : "",
73
+ relatedDocumentId: selectedEntity ? selectedEntity.documentId : "",
74
+ relatedId: selectedEntity ? selectedEntity.id : 0,
75
+ slug: path?.value || "",
76
+ title: navItemState.title || "",
77
+ uidPath: path?.uidPath || "",
78
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
79
+ wrapper,
80
+ navitem: null
81
+ }
42
82
  };
43
- React.useEffect(() => {
44
- fetchNavigations();
45
- }, []);
46
- return { navigations, fetchNavigations };
83
+ return tempNavItem;
47
84
  }
48
85
  const ModalContext = React.createContext({ modalType: "", setModalType: () => {
49
86
  } });
50
87
  const SelectedNavigationContext = React.createContext({ selectedNavigation: void 0, setSelectedNavigation: () => {
51
88
  } });
52
- function Delete({ variant, item, fetchNavigations }) {
53
- const { deleteNavigation, deleteNavItem } = index.useApi();
89
+ function Delete({ variant, item, onDelete }) {
54
90
  const itemName = React.useRef(variant === "NavDelete" ? item.name : item.route.title);
55
91
  const closeModalState = React.useRef(variant === "NavDelete" ? "NavOverview" : "");
56
92
  const { setModalType } = React.useContext(ModalContext);
57
93
  const { formatMessage } = reactIntl.useIntl();
58
94
  const handleDelete = async () => {
59
95
  try {
60
- if (variant === "NavDelete") await deleteNavigation(item.documentId);
61
- else await deleteNavItem(item.documentId);
96
+ if (variant === "NavDelete") {
97
+ } else if (variant === "ItemDelete") {
98
+ const editedItem = { ...item, deleted: true };
99
+ onDelete(editedItem);
100
+ }
62
101
  } catch (err) {
63
102
  console.log(err);
64
103
  }
65
- fetchNavigations();
66
104
  setModalType(closeModalState.current);
67
105
  };
68
106
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { defaultOpen: true, onClose: () => setModalType(closeModalState.current), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
@@ -218,7 +256,7 @@ function NavCreate() {
218
256
  }
219
257
  );
220
258
  }
221
- function NavEdit({ item, fetchNavigations }) {
259
+ function NavEdit({ item, onEdit }) {
222
260
  const { setModalType } = React.useContext(ModalContext);
223
261
  const [name, setName] = React.useState(item.name);
224
262
  const [visible, setVisible] = React.useState(item.visible);
@@ -229,8 +267,8 @@ function NavEdit({ item, fetchNavigations }) {
229
267
  setLoading(true);
230
268
  try {
231
269
  await updateNavigation(item.documentId, { name, visible });
232
- fetchNavigations();
233
270
  setModalType("NavOverview");
271
+ onEdit();
234
272
  } catch (err) {
235
273
  console.log(err);
236
274
  } finally {
@@ -368,13 +406,14 @@ function NavOverview({ navigations, setActionItem }) {
368
406
  children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {})
369
407
  }
370
408
  )
371
- ] }, nav.id)) : /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.Center, { height: 100, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: formatMessage({
409
+ ] }, nav.id)) : /* @__PURE__ */ jsxRuntime.jsx(FullLoader.Center, { height: 100, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: formatMessage({
372
410
  id: index.getTranslation("navigation.page.emptyNavigation"),
373
411
  defaultMessage: "You have no navigations yet..."
374
412
  }) }) })
375
413
  }
376
414
  );
377
415
  }
416
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
378
417
  var lodash_min = { exports: {} };
379
418
  /**
380
419
  * @license
@@ -818,7 +857,7 @@ lodash_min.exports;
818
857
  "œ": "oe",
819
858
  "ʼn": "'n",
820
859
  "ſ": "s"
821
- }, Hr = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, Jr = { "&amp;": "&", "&lt;": "<", "&gt;": ">", "&quot;": '"', "&#39;": "'" }, Yr = { "\\": "\\", "'": "'", "\n": "n", "\r": "r", "\u2028": "u2028", "\u2029": "u2029" }, Qr = parseFloat, Xr = parseInt, ne = "object" == typeof _baseConvert.commonjsGlobal && _baseConvert.commonjsGlobal && _baseConvert.commonjsGlobal.Object === Object && _baseConvert.commonjsGlobal, te = "object" == typeof self && self && self.Object === Object && self, re = ne || te || Function("return this")(), ee = exports2 && !exports2.nodeType && exports2, ue = ee && true && module2 && !module2.nodeType && module2, ie = ue && ue.exports === ee, oe = ie && ne.process, fe = function() {
860
+ }, Hr = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, Jr = { "&amp;": "&", "&lt;": "<", "&gt;": ">", "&quot;": '"', "&#39;": "'" }, Yr = { "\\": "\\", "'": "'", "\n": "n", "\r": "r", "\u2028": "u2028", "\u2029": "u2029" }, Qr = parseFloat, Xr = parseInt, ne = "object" == typeof commonjsGlobal && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal, te = "object" == typeof self && self && self.Object === Object && self, re = ne || te || Function("return this")(), ee = exports2 && !exports2.nodeType && exports2, ue = ee && true && module2 && !module2.nodeType && module2, ie = ue && ue.exports === ee, oe = ie && ne.process, fe = function() {
822
861
  try {
823
862
  var n2 = ue && ue.require && ue.require("util").types;
824
863
  return n2 ? n2 : oe && oe.binding && oe.binding("util");
@@ -3487,11 +3526,834 @@ lodash_min.exports;
3487
3526
  }), fs[Qu(X, vn).name] = [{ name: "wrapper", func: X }], Ct2.prototype.clone = $t2, Ct2.prototype.reverse = Yt2, Ct2.prototype.value = Qt2, Z2.prototype.at = Qs, Z2.prototype.chain = tf, Z2.prototype.commit = rf, Z2.prototype.next = ef, Z2.prototype.plant = of, Z2.prototype.reverse = ff, Z2.prototype.toJSON = Z2.prototype.valueOf = Z2.prototype.value = cf, Z2.prototype.first = Z2.prototype.head, Ul && (Z2.prototype[Ul] = uf), Z2;
3488
3527
  }, be = de();
3489
3528
  ue ? ((ue.exports = be)._ = be, ee._ = be) : re._ = be;
3490
- }).call(_baseConvert.commonjsGlobal);
3529
+ }).call(commonjsGlobal);
3491
3530
  })(lodash_min, lodash_min.exports);
3492
3531
  var lodash_minExports = lodash_min.exports;
3532
+ var _mapping = {};
3533
+ (function(exports2) {
3534
+ exports2.aliasToReal = {
3535
+ // Lodash aliases.
3536
+ "each": "forEach",
3537
+ "eachRight": "forEachRight",
3538
+ "entries": "toPairs",
3539
+ "entriesIn": "toPairsIn",
3540
+ "extend": "assignIn",
3541
+ "extendAll": "assignInAll",
3542
+ "extendAllWith": "assignInAllWith",
3543
+ "extendWith": "assignInWith",
3544
+ "first": "head",
3545
+ // Methods that are curried variants of others.
3546
+ "conforms": "conformsTo",
3547
+ "matches": "isMatch",
3548
+ "property": "get",
3549
+ // Ramda aliases.
3550
+ "__": "placeholder",
3551
+ "F": "stubFalse",
3552
+ "T": "stubTrue",
3553
+ "all": "every",
3554
+ "allPass": "overEvery",
3555
+ "always": "constant",
3556
+ "any": "some",
3557
+ "anyPass": "overSome",
3558
+ "apply": "spread",
3559
+ "assoc": "set",
3560
+ "assocPath": "set",
3561
+ "complement": "negate",
3562
+ "compose": "flowRight",
3563
+ "contains": "includes",
3564
+ "dissoc": "unset",
3565
+ "dissocPath": "unset",
3566
+ "dropLast": "dropRight",
3567
+ "dropLastWhile": "dropRightWhile",
3568
+ "equals": "isEqual",
3569
+ "identical": "eq",
3570
+ "indexBy": "keyBy",
3571
+ "init": "initial",
3572
+ "invertObj": "invert",
3573
+ "juxt": "over",
3574
+ "omitAll": "omit",
3575
+ "nAry": "ary",
3576
+ "path": "get",
3577
+ "pathEq": "matchesProperty",
3578
+ "pathOr": "getOr",
3579
+ "paths": "at",
3580
+ "pickAll": "pick",
3581
+ "pipe": "flow",
3582
+ "pluck": "map",
3583
+ "prop": "get",
3584
+ "propEq": "matchesProperty",
3585
+ "propOr": "getOr",
3586
+ "props": "at",
3587
+ "symmetricDifference": "xor",
3588
+ "symmetricDifferenceBy": "xorBy",
3589
+ "symmetricDifferenceWith": "xorWith",
3590
+ "takeLast": "takeRight",
3591
+ "takeLastWhile": "takeRightWhile",
3592
+ "unapply": "rest",
3593
+ "unnest": "flatten",
3594
+ "useWith": "overArgs",
3595
+ "where": "conformsTo",
3596
+ "whereEq": "isMatch",
3597
+ "zipObj": "zipObject"
3598
+ };
3599
+ exports2.aryMethod = {
3600
+ "1": [
3601
+ "assignAll",
3602
+ "assignInAll",
3603
+ "attempt",
3604
+ "castArray",
3605
+ "ceil",
3606
+ "create",
3607
+ "curry",
3608
+ "curryRight",
3609
+ "defaultsAll",
3610
+ "defaultsDeepAll",
3611
+ "floor",
3612
+ "flow",
3613
+ "flowRight",
3614
+ "fromPairs",
3615
+ "invert",
3616
+ "iteratee",
3617
+ "memoize",
3618
+ "method",
3619
+ "mergeAll",
3620
+ "methodOf",
3621
+ "mixin",
3622
+ "nthArg",
3623
+ "over",
3624
+ "overEvery",
3625
+ "overSome",
3626
+ "rest",
3627
+ "reverse",
3628
+ "round",
3629
+ "runInContext",
3630
+ "spread",
3631
+ "template",
3632
+ "trim",
3633
+ "trimEnd",
3634
+ "trimStart",
3635
+ "uniqueId",
3636
+ "words",
3637
+ "zipAll"
3638
+ ],
3639
+ "2": [
3640
+ "add",
3641
+ "after",
3642
+ "ary",
3643
+ "assign",
3644
+ "assignAllWith",
3645
+ "assignIn",
3646
+ "assignInAllWith",
3647
+ "at",
3648
+ "before",
3649
+ "bind",
3650
+ "bindAll",
3651
+ "bindKey",
3652
+ "chunk",
3653
+ "cloneDeepWith",
3654
+ "cloneWith",
3655
+ "concat",
3656
+ "conformsTo",
3657
+ "countBy",
3658
+ "curryN",
3659
+ "curryRightN",
3660
+ "debounce",
3661
+ "defaults",
3662
+ "defaultsDeep",
3663
+ "defaultTo",
3664
+ "delay",
3665
+ "difference",
3666
+ "divide",
3667
+ "drop",
3668
+ "dropRight",
3669
+ "dropRightWhile",
3670
+ "dropWhile",
3671
+ "endsWith",
3672
+ "eq",
3673
+ "every",
3674
+ "filter",
3675
+ "find",
3676
+ "findIndex",
3677
+ "findKey",
3678
+ "findLast",
3679
+ "findLastIndex",
3680
+ "findLastKey",
3681
+ "flatMap",
3682
+ "flatMapDeep",
3683
+ "flattenDepth",
3684
+ "forEach",
3685
+ "forEachRight",
3686
+ "forIn",
3687
+ "forInRight",
3688
+ "forOwn",
3689
+ "forOwnRight",
3690
+ "get",
3691
+ "groupBy",
3692
+ "gt",
3693
+ "gte",
3694
+ "has",
3695
+ "hasIn",
3696
+ "includes",
3697
+ "indexOf",
3698
+ "intersection",
3699
+ "invertBy",
3700
+ "invoke",
3701
+ "invokeMap",
3702
+ "isEqual",
3703
+ "isMatch",
3704
+ "join",
3705
+ "keyBy",
3706
+ "lastIndexOf",
3707
+ "lt",
3708
+ "lte",
3709
+ "map",
3710
+ "mapKeys",
3711
+ "mapValues",
3712
+ "matchesProperty",
3713
+ "maxBy",
3714
+ "meanBy",
3715
+ "merge",
3716
+ "mergeAllWith",
3717
+ "minBy",
3718
+ "multiply",
3719
+ "nth",
3720
+ "omit",
3721
+ "omitBy",
3722
+ "overArgs",
3723
+ "pad",
3724
+ "padEnd",
3725
+ "padStart",
3726
+ "parseInt",
3727
+ "partial",
3728
+ "partialRight",
3729
+ "partition",
3730
+ "pick",
3731
+ "pickBy",
3732
+ "propertyOf",
3733
+ "pull",
3734
+ "pullAll",
3735
+ "pullAt",
3736
+ "random",
3737
+ "range",
3738
+ "rangeRight",
3739
+ "rearg",
3740
+ "reject",
3741
+ "remove",
3742
+ "repeat",
3743
+ "restFrom",
3744
+ "result",
3745
+ "sampleSize",
3746
+ "some",
3747
+ "sortBy",
3748
+ "sortedIndex",
3749
+ "sortedIndexOf",
3750
+ "sortedLastIndex",
3751
+ "sortedLastIndexOf",
3752
+ "sortedUniqBy",
3753
+ "split",
3754
+ "spreadFrom",
3755
+ "startsWith",
3756
+ "subtract",
3757
+ "sumBy",
3758
+ "take",
3759
+ "takeRight",
3760
+ "takeRightWhile",
3761
+ "takeWhile",
3762
+ "tap",
3763
+ "throttle",
3764
+ "thru",
3765
+ "times",
3766
+ "trimChars",
3767
+ "trimCharsEnd",
3768
+ "trimCharsStart",
3769
+ "truncate",
3770
+ "union",
3771
+ "uniqBy",
3772
+ "uniqWith",
3773
+ "unset",
3774
+ "unzipWith",
3775
+ "without",
3776
+ "wrap",
3777
+ "xor",
3778
+ "zip",
3779
+ "zipObject",
3780
+ "zipObjectDeep"
3781
+ ],
3782
+ "3": [
3783
+ "assignInWith",
3784
+ "assignWith",
3785
+ "clamp",
3786
+ "differenceBy",
3787
+ "differenceWith",
3788
+ "findFrom",
3789
+ "findIndexFrom",
3790
+ "findLastFrom",
3791
+ "findLastIndexFrom",
3792
+ "getOr",
3793
+ "includesFrom",
3794
+ "indexOfFrom",
3795
+ "inRange",
3796
+ "intersectionBy",
3797
+ "intersectionWith",
3798
+ "invokeArgs",
3799
+ "invokeArgsMap",
3800
+ "isEqualWith",
3801
+ "isMatchWith",
3802
+ "flatMapDepth",
3803
+ "lastIndexOfFrom",
3804
+ "mergeWith",
3805
+ "orderBy",
3806
+ "padChars",
3807
+ "padCharsEnd",
3808
+ "padCharsStart",
3809
+ "pullAllBy",
3810
+ "pullAllWith",
3811
+ "rangeStep",
3812
+ "rangeStepRight",
3813
+ "reduce",
3814
+ "reduceRight",
3815
+ "replace",
3816
+ "set",
3817
+ "slice",
3818
+ "sortedIndexBy",
3819
+ "sortedLastIndexBy",
3820
+ "transform",
3821
+ "unionBy",
3822
+ "unionWith",
3823
+ "update",
3824
+ "xorBy",
3825
+ "xorWith",
3826
+ "zipWith"
3827
+ ],
3828
+ "4": [
3829
+ "fill",
3830
+ "setWith",
3831
+ "updateWith"
3832
+ ]
3833
+ };
3834
+ exports2.aryRearg = {
3835
+ "2": [1, 0],
3836
+ "3": [2, 0, 1],
3837
+ "4": [3, 2, 0, 1]
3838
+ };
3839
+ exports2.iterateeAry = {
3840
+ "dropRightWhile": 1,
3841
+ "dropWhile": 1,
3842
+ "every": 1,
3843
+ "filter": 1,
3844
+ "find": 1,
3845
+ "findFrom": 1,
3846
+ "findIndex": 1,
3847
+ "findIndexFrom": 1,
3848
+ "findKey": 1,
3849
+ "findLast": 1,
3850
+ "findLastFrom": 1,
3851
+ "findLastIndex": 1,
3852
+ "findLastIndexFrom": 1,
3853
+ "findLastKey": 1,
3854
+ "flatMap": 1,
3855
+ "flatMapDeep": 1,
3856
+ "flatMapDepth": 1,
3857
+ "forEach": 1,
3858
+ "forEachRight": 1,
3859
+ "forIn": 1,
3860
+ "forInRight": 1,
3861
+ "forOwn": 1,
3862
+ "forOwnRight": 1,
3863
+ "map": 1,
3864
+ "mapKeys": 1,
3865
+ "mapValues": 1,
3866
+ "partition": 1,
3867
+ "reduce": 2,
3868
+ "reduceRight": 2,
3869
+ "reject": 1,
3870
+ "remove": 1,
3871
+ "some": 1,
3872
+ "takeRightWhile": 1,
3873
+ "takeWhile": 1,
3874
+ "times": 1,
3875
+ "transform": 2
3876
+ };
3877
+ exports2.iterateeRearg = {
3878
+ "mapKeys": [1],
3879
+ "reduceRight": [1, 0]
3880
+ };
3881
+ exports2.methodRearg = {
3882
+ "assignInAllWith": [1, 0],
3883
+ "assignInWith": [1, 2, 0],
3884
+ "assignAllWith": [1, 0],
3885
+ "assignWith": [1, 2, 0],
3886
+ "differenceBy": [1, 2, 0],
3887
+ "differenceWith": [1, 2, 0],
3888
+ "getOr": [2, 1, 0],
3889
+ "intersectionBy": [1, 2, 0],
3890
+ "intersectionWith": [1, 2, 0],
3891
+ "isEqualWith": [1, 2, 0],
3892
+ "isMatchWith": [2, 1, 0],
3893
+ "mergeAllWith": [1, 0],
3894
+ "mergeWith": [1, 2, 0],
3895
+ "padChars": [2, 1, 0],
3896
+ "padCharsEnd": [2, 1, 0],
3897
+ "padCharsStart": [2, 1, 0],
3898
+ "pullAllBy": [2, 1, 0],
3899
+ "pullAllWith": [2, 1, 0],
3900
+ "rangeStep": [1, 2, 0],
3901
+ "rangeStepRight": [1, 2, 0],
3902
+ "setWith": [3, 1, 2, 0],
3903
+ "sortedIndexBy": [2, 1, 0],
3904
+ "sortedLastIndexBy": [2, 1, 0],
3905
+ "unionBy": [1, 2, 0],
3906
+ "unionWith": [1, 2, 0],
3907
+ "updateWith": [3, 1, 2, 0],
3908
+ "xorBy": [1, 2, 0],
3909
+ "xorWith": [1, 2, 0],
3910
+ "zipWith": [1, 2, 0]
3911
+ };
3912
+ exports2.methodSpread = {
3913
+ "assignAll": { "start": 0 },
3914
+ "assignAllWith": { "start": 0 },
3915
+ "assignInAll": { "start": 0 },
3916
+ "assignInAllWith": { "start": 0 },
3917
+ "defaultsAll": { "start": 0 },
3918
+ "defaultsDeepAll": { "start": 0 },
3919
+ "invokeArgs": { "start": 2 },
3920
+ "invokeArgsMap": { "start": 2 },
3921
+ "mergeAll": { "start": 0 },
3922
+ "mergeAllWith": { "start": 0 },
3923
+ "partial": { "start": 1 },
3924
+ "partialRight": { "start": 1 },
3925
+ "without": { "start": 1 },
3926
+ "zipAll": { "start": 0 }
3927
+ };
3928
+ exports2.mutate = {
3929
+ "array": {
3930
+ "fill": true,
3931
+ "pull": true,
3932
+ "pullAll": true,
3933
+ "pullAllBy": true,
3934
+ "pullAllWith": true,
3935
+ "pullAt": true,
3936
+ "remove": true,
3937
+ "reverse": true
3938
+ },
3939
+ "object": {
3940
+ "assign": true,
3941
+ "assignAll": true,
3942
+ "assignAllWith": true,
3943
+ "assignIn": true,
3944
+ "assignInAll": true,
3945
+ "assignInAllWith": true,
3946
+ "assignInWith": true,
3947
+ "assignWith": true,
3948
+ "defaults": true,
3949
+ "defaultsAll": true,
3950
+ "defaultsDeep": true,
3951
+ "defaultsDeepAll": true,
3952
+ "merge": true,
3953
+ "mergeAll": true,
3954
+ "mergeAllWith": true,
3955
+ "mergeWith": true
3956
+ },
3957
+ "set": {
3958
+ "set": true,
3959
+ "setWith": true,
3960
+ "unset": true,
3961
+ "update": true,
3962
+ "updateWith": true
3963
+ }
3964
+ };
3965
+ exports2.realToAlias = function() {
3966
+ var hasOwnProperty = Object.prototype.hasOwnProperty, object = exports2.aliasToReal, result = {};
3967
+ for (var key in object) {
3968
+ var value = object[key];
3969
+ if (hasOwnProperty.call(result, value)) {
3970
+ result[value].push(key);
3971
+ } else {
3972
+ result[value] = [key];
3973
+ }
3974
+ }
3975
+ return result;
3976
+ }();
3977
+ exports2.remap = {
3978
+ "assignAll": "assign",
3979
+ "assignAllWith": "assignWith",
3980
+ "assignInAll": "assignIn",
3981
+ "assignInAllWith": "assignInWith",
3982
+ "curryN": "curry",
3983
+ "curryRightN": "curryRight",
3984
+ "defaultsAll": "defaults",
3985
+ "defaultsDeepAll": "defaultsDeep",
3986
+ "findFrom": "find",
3987
+ "findIndexFrom": "findIndex",
3988
+ "findLastFrom": "findLast",
3989
+ "findLastIndexFrom": "findLastIndex",
3990
+ "getOr": "get",
3991
+ "includesFrom": "includes",
3992
+ "indexOfFrom": "indexOf",
3993
+ "invokeArgs": "invoke",
3994
+ "invokeArgsMap": "invokeMap",
3995
+ "lastIndexOfFrom": "lastIndexOf",
3996
+ "mergeAll": "merge",
3997
+ "mergeAllWith": "mergeWith",
3998
+ "padChars": "pad",
3999
+ "padCharsEnd": "padEnd",
4000
+ "padCharsStart": "padStart",
4001
+ "propertyOf": "get",
4002
+ "rangeStep": "range",
4003
+ "rangeStepRight": "rangeRight",
4004
+ "restFrom": "rest",
4005
+ "spreadFrom": "spread",
4006
+ "trimChars": "trim",
4007
+ "trimCharsEnd": "trimEnd",
4008
+ "trimCharsStart": "trimStart",
4009
+ "zipAll": "zip"
4010
+ };
4011
+ exports2.skipFixed = {
4012
+ "castArray": true,
4013
+ "flow": true,
4014
+ "flowRight": true,
4015
+ "iteratee": true,
4016
+ "mixin": true,
4017
+ "rearg": true,
4018
+ "runInContext": true
4019
+ };
4020
+ exports2.skipRearg = {
4021
+ "add": true,
4022
+ "assign": true,
4023
+ "assignIn": true,
4024
+ "bind": true,
4025
+ "bindKey": true,
4026
+ "concat": true,
4027
+ "difference": true,
4028
+ "divide": true,
4029
+ "eq": true,
4030
+ "gt": true,
4031
+ "gte": true,
4032
+ "isEqual": true,
4033
+ "lt": true,
4034
+ "lte": true,
4035
+ "matchesProperty": true,
4036
+ "merge": true,
4037
+ "multiply": true,
4038
+ "overArgs": true,
4039
+ "partial": true,
4040
+ "partialRight": true,
4041
+ "propertyOf": true,
4042
+ "random": true,
4043
+ "range": true,
4044
+ "rangeRight": true,
4045
+ "subtract": true,
4046
+ "zip": true,
4047
+ "zipObject": true,
4048
+ "zipObjectDeep": true
4049
+ };
4050
+ })(_mapping);
4051
+ var placeholder = {};
4052
+ var mapping = _mapping, fallbackHolder = placeholder;
4053
+ var push = Array.prototype.push;
4054
+ function baseArity(func, n) {
4055
+ return n == 2 ? function(a, b) {
4056
+ return func.apply(void 0, arguments);
4057
+ } : function(a) {
4058
+ return func.apply(void 0, arguments);
4059
+ };
4060
+ }
4061
+ function baseAry(func, n) {
4062
+ return n == 2 ? function(a, b) {
4063
+ return func(a, b);
4064
+ } : function(a) {
4065
+ return func(a);
4066
+ };
4067
+ }
4068
+ function cloneArray(array) {
4069
+ var length = array ? array.length : 0, result = Array(length);
4070
+ while (length--) {
4071
+ result[length] = array[length];
4072
+ }
4073
+ return result;
4074
+ }
4075
+ function createCloner(func) {
4076
+ return function(object) {
4077
+ return func({}, object);
4078
+ };
4079
+ }
4080
+ function flatSpread(func, start) {
4081
+ return function() {
4082
+ var length = arguments.length, lastIndex = length - 1, args = Array(length);
4083
+ while (length--) {
4084
+ args[length] = arguments[length];
4085
+ }
4086
+ var array = args[start], otherArgs = args.slice(0, start);
4087
+ if (array) {
4088
+ push.apply(otherArgs, array);
4089
+ }
4090
+ if (start != lastIndex) {
4091
+ push.apply(otherArgs, args.slice(start + 1));
4092
+ }
4093
+ return func.apply(this, otherArgs);
4094
+ };
4095
+ }
4096
+ function wrapImmutable(func, cloner) {
4097
+ return function() {
4098
+ var length = arguments.length;
4099
+ if (!length) {
4100
+ return;
4101
+ }
4102
+ var args = Array(length);
4103
+ while (length--) {
4104
+ args[length] = arguments[length];
4105
+ }
4106
+ var result = args[0] = cloner.apply(void 0, args);
4107
+ func.apply(void 0, args);
4108
+ return result;
4109
+ };
4110
+ }
4111
+ function baseConvert(util, name, func, options) {
4112
+ var isLib = typeof name == "function", isObj = name === Object(name);
4113
+ if (isObj) {
4114
+ options = func;
4115
+ func = name;
4116
+ name = void 0;
4117
+ }
4118
+ if (func == null) {
4119
+ throw new TypeError();
4120
+ }
4121
+ options || (options = {});
4122
+ var config = {
4123
+ "cap": "cap" in options ? options.cap : true,
4124
+ "curry": "curry" in options ? options.curry : true,
4125
+ "fixed": "fixed" in options ? options.fixed : true,
4126
+ "immutable": "immutable" in options ? options.immutable : true,
4127
+ "rearg": "rearg" in options ? options.rearg : true
4128
+ };
4129
+ var defaultHolder = isLib ? func : fallbackHolder, forceCurry = "curry" in options && options.curry, forceFixed = "fixed" in options && options.fixed, forceRearg = "rearg" in options && options.rearg, pristine = isLib ? func.runInContext() : void 0;
4130
+ var helpers = isLib ? func : {
4131
+ "ary": util.ary,
4132
+ "assign": util.assign,
4133
+ "clone": util.clone,
4134
+ "curry": util.curry,
4135
+ "forEach": util.forEach,
4136
+ "isArray": util.isArray,
4137
+ "isError": util.isError,
4138
+ "isFunction": util.isFunction,
4139
+ "isWeakMap": util.isWeakMap,
4140
+ "iteratee": util.iteratee,
4141
+ "keys": util.keys,
4142
+ "rearg": util.rearg,
4143
+ "toInteger": util.toInteger,
4144
+ "toPath": util.toPath
4145
+ };
4146
+ var ary = helpers.ary, assign = helpers.assign, clone = helpers.clone, curry = helpers.curry, each = helpers.forEach, isArray = helpers.isArray, isError = helpers.isError, isFunction = helpers.isFunction, isWeakMap = helpers.isWeakMap, keys = helpers.keys, rearg = helpers.rearg, toInteger = helpers.toInteger, toPath = helpers.toPath;
4147
+ var aryMethodKeys = keys(mapping.aryMethod);
4148
+ var wrappers = {
4149
+ "castArray": function(castArray) {
4150
+ return function() {
4151
+ var value = arguments[0];
4152
+ return isArray(value) ? castArray(cloneArray(value)) : castArray.apply(void 0, arguments);
4153
+ };
4154
+ },
4155
+ "iteratee": function(iteratee) {
4156
+ return function() {
4157
+ var func2 = arguments[0], arity = arguments[1], result = iteratee(func2, arity), length = result.length;
4158
+ if (config.cap && typeof arity == "number") {
4159
+ arity = arity > 2 ? arity - 2 : 1;
4160
+ return length && length <= arity ? result : baseAry(result, arity);
4161
+ }
4162
+ return result;
4163
+ };
4164
+ },
4165
+ "mixin": function(mixin) {
4166
+ return function(source) {
4167
+ var func2 = this;
4168
+ if (!isFunction(func2)) {
4169
+ return mixin(func2, Object(source));
4170
+ }
4171
+ var pairs2 = [];
4172
+ each(keys(source), function(key) {
4173
+ if (isFunction(source[key])) {
4174
+ pairs2.push([key, func2.prototype[key]]);
4175
+ }
4176
+ });
4177
+ mixin(func2, Object(source));
4178
+ each(pairs2, function(pair) {
4179
+ var value = pair[1];
4180
+ if (isFunction(value)) {
4181
+ func2.prototype[pair[0]] = value;
4182
+ } else {
4183
+ delete func2.prototype[pair[0]];
4184
+ }
4185
+ });
4186
+ return func2;
4187
+ };
4188
+ },
4189
+ "nthArg": function(nthArg) {
4190
+ return function(n) {
4191
+ var arity = n < 0 ? 1 : toInteger(n) + 1;
4192
+ return curry(nthArg(n), arity);
4193
+ };
4194
+ },
4195
+ "rearg": function(rearg2) {
4196
+ return function(func2, indexes) {
4197
+ var arity = indexes ? indexes.length : 0;
4198
+ return curry(rearg2(func2, indexes), arity);
4199
+ };
4200
+ },
4201
+ "runInContext": function(runInContext) {
4202
+ return function(context) {
4203
+ return baseConvert(util, runInContext(context), options);
4204
+ };
4205
+ }
4206
+ };
4207
+ function castCap(name2, func2) {
4208
+ if (config.cap) {
4209
+ var indexes = mapping.iterateeRearg[name2];
4210
+ if (indexes) {
4211
+ return iterateeRearg(func2, indexes);
4212
+ }
4213
+ var n = !isLib && mapping.iterateeAry[name2];
4214
+ if (n) {
4215
+ return iterateeAry(func2, n);
4216
+ }
4217
+ }
4218
+ return func2;
4219
+ }
4220
+ function castCurry(name2, func2, n) {
4221
+ return forceCurry || config.curry && n > 1 ? curry(func2, n) : func2;
4222
+ }
4223
+ function castFixed(name2, func2, n) {
4224
+ if (config.fixed && (forceFixed || !mapping.skipFixed[name2])) {
4225
+ var data = mapping.methodSpread[name2], start = data && data.start;
4226
+ return start === void 0 ? ary(func2, n) : flatSpread(func2, start);
4227
+ }
4228
+ return func2;
4229
+ }
4230
+ function castRearg(name2, func2, n) {
4231
+ return config.rearg && n > 1 && (forceRearg || !mapping.skipRearg[name2]) ? rearg(func2, mapping.methodRearg[name2] || mapping.aryRearg[n]) : func2;
4232
+ }
4233
+ function cloneByPath(object, path) {
4234
+ path = toPath(path);
4235
+ var index2 = -1, length = path.length, lastIndex = length - 1, result = clone(Object(object)), nested = result;
4236
+ while (nested != null && ++index2 < length) {
4237
+ var key = path[index2], value = nested[key];
4238
+ if (value != null && !(isFunction(value) || isError(value) || isWeakMap(value))) {
4239
+ nested[key] = clone(index2 == lastIndex ? value : Object(value));
4240
+ }
4241
+ nested = nested[key];
4242
+ }
4243
+ return result;
4244
+ }
4245
+ function convertLib(options2) {
4246
+ return _2.runInContext.convert(options2)(void 0);
4247
+ }
4248
+ function createConverter(name2, func2) {
4249
+ var realName = mapping.aliasToReal[name2] || name2, methodName = mapping.remap[realName] || realName, oldOptions = options;
4250
+ return function(options2) {
4251
+ var newUtil = isLib ? pristine : helpers, newFunc = isLib ? pristine[methodName] : func2, newOptions = assign(assign({}, oldOptions), options2);
4252
+ return baseConvert(newUtil, realName, newFunc, newOptions);
4253
+ };
4254
+ }
4255
+ function iterateeAry(func2, n) {
4256
+ return overArg(func2, function(func3) {
4257
+ return typeof func3 == "function" ? baseAry(func3, n) : func3;
4258
+ });
4259
+ }
4260
+ function iterateeRearg(func2, indexes) {
4261
+ return overArg(func2, function(func3) {
4262
+ var n = indexes.length;
4263
+ return baseArity(rearg(baseAry(func3, n), indexes), n);
4264
+ });
4265
+ }
4266
+ function overArg(func2, transform) {
4267
+ return function() {
4268
+ var length = arguments.length;
4269
+ if (!length) {
4270
+ return func2();
4271
+ }
4272
+ var args = Array(length);
4273
+ while (length--) {
4274
+ args[length] = arguments[length];
4275
+ }
4276
+ var index2 = config.rearg ? 0 : length - 1;
4277
+ args[index2] = transform(args[index2]);
4278
+ return func2.apply(void 0, args);
4279
+ };
4280
+ }
4281
+ function wrap(name2, func2, placeholder2) {
4282
+ var result, realName = mapping.aliasToReal[name2] || name2, wrapped = func2, wrapper = wrappers[realName];
4283
+ if (wrapper) {
4284
+ wrapped = wrapper(func2);
4285
+ } else if (config.immutable) {
4286
+ if (mapping.mutate.array[realName]) {
4287
+ wrapped = wrapImmutable(func2, cloneArray);
4288
+ } else if (mapping.mutate.object[realName]) {
4289
+ wrapped = wrapImmutable(func2, createCloner(func2));
4290
+ } else if (mapping.mutate.set[realName]) {
4291
+ wrapped = wrapImmutable(func2, cloneByPath);
4292
+ }
4293
+ }
4294
+ each(aryMethodKeys, function(aryKey) {
4295
+ each(mapping.aryMethod[aryKey], function(otherName) {
4296
+ if (realName == otherName) {
4297
+ var data = mapping.methodSpread[realName], afterRearg = data && data.afterRearg;
4298
+ result = afterRearg ? castFixed(realName, castRearg(realName, wrapped, aryKey), aryKey) : castRearg(realName, castFixed(realName, wrapped, aryKey), aryKey);
4299
+ result = castCap(realName, result);
4300
+ result = castCurry(realName, result, aryKey);
4301
+ return false;
4302
+ }
4303
+ });
4304
+ return !result;
4305
+ });
4306
+ result || (result = wrapped);
4307
+ if (result == func2) {
4308
+ result = forceCurry ? curry(result, 1) : function() {
4309
+ return func2.apply(this, arguments);
4310
+ };
4311
+ }
4312
+ result.convert = createConverter(realName, func2);
4313
+ result.placeholder = func2.placeholder = placeholder2;
4314
+ return result;
4315
+ }
4316
+ if (!isObj) {
4317
+ return wrap(name, func, defaultHolder);
4318
+ }
4319
+ var _2 = func;
4320
+ var pairs = [];
4321
+ each(aryMethodKeys, function(aryKey) {
4322
+ each(mapping.aryMethod[aryKey], function(key) {
4323
+ var func2 = _2[mapping.remap[key] || key];
4324
+ if (func2) {
4325
+ pairs.push([key, wrap(key, func2, _2)]);
4326
+ }
4327
+ });
4328
+ });
4329
+ each(keys(_2), function(key) {
4330
+ var func2 = _2[key];
4331
+ if (typeof func2 == "function") {
4332
+ var length = pairs.length;
4333
+ while (length--) {
4334
+ if (pairs[length][0] == key) {
4335
+ return;
4336
+ }
4337
+ }
4338
+ func2.convert = createConverter(key, func2);
4339
+ pairs.push([key, func2]);
4340
+ }
4341
+ });
4342
+ each(pairs, function(pair) {
4343
+ _2[pair[0]] = pair[1];
4344
+ });
4345
+ _2.convert = convertLib;
4346
+ _2.placeholder = _2;
4347
+ each(keys(_2), function(key) {
4348
+ each(mapping.realToAlias[key] || [], function(alias) {
4349
+ _2[alias] = _2[key];
4350
+ });
4351
+ });
4352
+ return _2;
4353
+ }
4354
+ var _baseConvert = baseConvert;
3493
4355
  var _ = lodash_minExports.runInContext();
3494
- _baseConvert._baseConvert(_, _);
4356
+ _baseConvert(_, _);
3495
4357
  function itemStateReducer(navItemState, action) {
3496
4358
  switch (action.type) {
3497
4359
  case "SET_TITLE":
@@ -3549,7 +4411,7 @@ function useModalSharedLogic() {
3549
4411
  const [replacement, setReplacement] = React.useState("");
3550
4412
  const [validationState, setValidationState] = React.useState("initial");
3551
4413
  const { entities } = useAllEntities();
3552
- const { createNavItem, updateRoute, getRelatedRoute, createExternalRoute } = index.useApi();
4414
+ const { updateRoute, getRelatedRoute } = index.useApi();
3553
4415
  const initialState = React.useRef({
3554
4416
  title: "",
3555
4417
  slug: "",
@@ -3587,8 +4449,6 @@ function useModalSharedLogic() {
3587
4449
  entityRoute,
3588
4450
  setEntityRoute,
3589
4451
  entities,
3590
- createNavItem,
3591
- createExternalRoute,
3592
4452
  updateRoute,
3593
4453
  getRelatedRoute,
3594
4454
  replacement,
@@ -3613,47 +4473,58 @@ function withModalSharedLogic(Component) {
3613
4473
  return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...props, ...sharedLogic });
3614
4474
  };
3615
4475
  }
3616
- function ExternalItemComponent({
3617
- variant,
3618
- item,
3619
- createNavItem,
3620
- navItemState,
3621
- dispatchItemState,
3622
- createExternalRoute,
3623
- updateRoute,
3624
- path,
3625
- dispatchPath,
3626
- setModalType,
3627
- selectedNavigation,
3628
- parentDocumentId
3629
- }) {
4476
+ function isExternalEditProps(props) {
4477
+ return props.variant === "ExternalEdit";
4478
+ }
4479
+ function isExternalCreateProps(props) {
4480
+ return props.variant === "ExternalCreate";
4481
+ }
4482
+ function ExternalItemComponent(props) {
4483
+ const {
4484
+ variant,
4485
+ navItemState,
4486
+ dispatchItemState,
4487
+ path,
4488
+ dispatchPath,
4489
+ setModalType,
4490
+ selectedNavigation
4491
+ } = props;
4492
+ const parentId = isExternalCreateProps(props) ? props.parentId : void 0;
4493
+ const onCreate = isExternalCreateProps(props) ? props.onCreate : void 0;
4494
+ const onSave = isExternalEditProps(props) ? props.onSave : void 0;
4495
+ const item = isExternalEditProps(props) ? props.item : void 0;
3630
4496
  const { formatMessage } = reactIntl.useIntl();
3631
4497
  React.useEffect(() => {
3632
4498
  if (variant !== "ExternalEdit" || !item) return;
3633
4499
  dispatchItemState({ type: "SET_TITLE", payload: item.route.title });
3634
4500
  dispatchItemState({ type: "SET_ACTIVE", payload: item.route.active });
3635
4501
  dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: item.route.fullPath });
3636
- }, []);
3637
- const addItem = async () => {
4502
+ }, [variant, item, dispatchItemState, dispatchPath]);
4503
+ const handleConfirm = async () => {
3638
4504
  try {
3639
4505
  if (!path || !navItemState.title || !selectedNavigation) return;
3640
- const data = {
3641
- title: navItemState.title,
3642
- fullPath: path.value,
3643
- active: navItemState.active,
3644
- internal: false
3645
- };
3646
- if (variant === "ExternalEdit" && item) {
3647
- await updateRoute(data, item.route.documentId);
3648
- } else {
3649
- const route = await createExternalRoute(data);
3650
- if (!route) return;
3651
- const settings = {
3652
- route: route.documentId,
3653
- parent: parentDocumentId ?? null,
3654
- navigation: selectedNavigation.documentId
3655
- };
3656
- await createNavItem(settings);
4506
+ if (variant === "ExternalEdit" && item && onSave) {
4507
+ onSave({
4508
+ ...item,
4509
+ update: {
4510
+ title: navItemState.title,
4511
+ fullPath: path.value
4512
+ // internal: false,
4513
+ // active: navItemState.active,
4514
+ }
4515
+ });
4516
+ } else if (onCreate) {
4517
+ const newItem = createTempNavItemObject({
4518
+ parentId,
4519
+ entityRoute: null,
4520
+ selectedNavigation,
4521
+ navItemState,
4522
+ selectedEntity: null,
4523
+ selectedContentType: null,
4524
+ path,
4525
+ internal: false
4526
+ });
4527
+ onCreate(newItem);
3657
4528
  }
3658
4529
  setModalType("");
3659
4530
  } catch (err) {
@@ -3667,7 +4538,7 @@ function ExternalItemComponent({
3667
4538
  closeText: formatMessage({ id: index.getTranslation("cancel"), defaultMessage: "Cancel" }),
3668
4539
  titleText: variant === "ExternalCreate" ? formatMessage({ id: index.getTranslation("modal.externalItem.titleText.create"), defaultMessage: "Create new external item" }) : formatMessage({ id: index.getTranslation("modal.externalItem.titleText.edit"), defaultMessage: `Edit external route "${navItemState.title}"` }),
3669
4540
  loadingText: variant === "ExternalCreate" ? formatMessage({ id: index.getTranslation("modal.externalItem.loadingText.create"), defaultMessage: "Adding" }) : formatMessage({ id: index.getTranslation("modal.externalItem.loadingText.edit"), defaultMessage: "Saving" }),
3670
- onConfirm: addItem,
4541
+ onConfirm: handleConfirm,
3671
4542
  modalToOpen: "",
3672
4543
  currentModalType: "ExternalCreate",
3673
4544
  currentModalMode: variant === "ExternalCreate" ? "create" : "edit",
@@ -3725,8 +4596,6 @@ function ItemCreateComponent({
3725
4596
  entityRoute,
3726
4597
  setEntityRoute,
3727
4598
  entities,
3728
- createNavItem,
3729
- updateRoute,
3730
4599
  getRelatedRoute,
3731
4600
  replacement,
3732
4601
  validationState,
@@ -3738,7 +4607,8 @@ function ItemCreateComponent({
3738
4607
  debouncedCheckUrl,
3739
4608
  setModalType,
3740
4609
  selectedNavigation,
3741
- parentId
4610
+ parentId,
4611
+ onCreate
3742
4612
  }) {
3743
4613
  const [loading, setLoading] = React.useState(false);
3744
4614
  const { formatMessage } = reactIntl.useIntl();
@@ -3785,16 +4655,16 @@ function ItemCreateComponent({
3785
4655
  try {
3786
4656
  setLoading(true);
3787
4657
  if (!entityRoute || !selectedNavigation) return;
3788
- const settings = {
3789
- route: entityRoute.documentId ?? null,
3790
- parent: parentId ?? null,
3791
- navigation: selectedNavigation.documentId ?? null
3792
- };
3793
- if (path.value !== path.initialPath) {
3794
- if (navItemState.slug !== entityRoute.fullPath) navItemState.isOverride = true;
3795
- await updateRoute({ fullPath: path.value }, entityRoute.documentId);
3796
- }
3797
- await createNavItem(settings);
4658
+ const newItem = createTempNavItemObject({
4659
+ parentId,
4660
+ entityRoute,
4661
+ selectedNavigation,
4662
+ navItemState,
4663
+ selectedEntity,
4664
+ selectedContentType,
4665
+ path
4666
+ });
4667
+ onCreate(newItem);
3798
4668
  setModalType("");
3799
4669
  } catch (err) {
3800
4670
  console.log(err);
@@ -4260,7 +5130,7 @@ lodash.exports;
4260
5130
  "\u2029": "u2029"
4261
5131
  };
4262
5132
  var freeParseFloat = parseFloat, freeParseInt = parseInt;
4263
- var freeGlobal = typeof _baseConvert.commonjsGlobal == "object" && _baseConvert.commonjsGlobal && _baseConvert.commonjsGlobal.Object === Object && _baseConvert.commonjsGlobal;
5133
+ var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
4264
5134
  var freeSelf = typeof self == "object" && self && self.Object === Object && self;
4265
5135
  var root = freeGlobal || freeSelf || Function("return this")();
4266
5136
  var freeExports = exports2 && !exports2.nodeType && exports2;
@@ -4511,10 +5381,10 @@ lodash.exports;
4511
5381
  }
4512
5382
  return index2;
4513
5383
  }
4514
- function countHolders(array, placeholder) {
5384
+ function countHolders(array, placeholder2) {
4515
5385
  var length = array.length, result = 0;
4516
5386
  while (length--) {
4517
- if (array[length] === placeholder) {
5387
+ if (array[length] === placeholder2) {
4518
5388
  ++result;
4519
5389
  }
4520
5390
  }
@@ -4553,11 +5423,11 @@ lodash.exports;
4553
5423
  return func(transform(arg));
4554
5424
  };
4555
5425
  }
4556
- function replaceHolders(array, placeholder) {
5426
+ function replaceHolders(array, placeholder2) {
4557
5427
  var index2 = -1, length = array.length, resIndex = 0, result = [];
4558
5428
  while (++index2 < length) {
4559
5429
  var value = array[index2];
4560
- if (value === placeholder || value === PLACEHOLDER) {
5430
+ if (value === placeholder2 || value === PLACEHOLDER) {
4561
5431
  array[index2] = PLACEHOLDER;
4562
5432
  result[resIndex++] = index2;
4563
5433
  }
@@ -4624,7 +5494,7 @@ lodash.exports;
4624
5494
  }
4625
5495
  var runInContext = function runInContext2(context) {
4626
5496
  context = context == null ? root : _2.defaults(root.Object(), context, _2.pick(root, contextProps));
4627
- var Array2 = context.Array, Date = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String = context.String, TypeError = context.TypeError;
5497
+ var Array2 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String = context.String, TypeError2 = context.TypeError;
4628
5498
  var arrayProto = Array2.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
4629
5499
  var coreJsData = context["__core-js_shared__"];
4630
5500
  var funcToString = funcProto.toString;
@@ -4649,8 +5519,8 @@ lodash.exports;
4649
5519
  } catch (e) {
4650
5520
  }
4651
5521
  }();
4652
- var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date && Date.now !== root.Date.now && Date.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
4653
- var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
5522
+ var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
5523
+ var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
4654
5524
  var DataView = getNative(context, "DataView"), Map = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set = getNative(context, "Set"), WeakMap = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
4655
5525
  var metaMap = WeakMap && new WeakMap();
4656
5526
  var realNames = {};
@@ -5147,7 +6017,7 @@ lodash.exports;
5147
6017
  }
5148
6018
  function baseDelay(func, wait, args) {
5149
6019
  if (typeof func != "function") {
5150
- throw new TypeError(FUNC_ERROR_TEXT);
6020
+ throw new TypeError2(FUNC_ERROR_TEXT);
5151
6021
  }
5152
6022
  return setTimeout(function() {
5153
6023
  func.apply(undefined$1, args);
@@ -6154,11 +7024,11 @@ lodash.exports;
6154
7024
  function createCurry(func, bitmask, arity) {
6155
7025
  var Ctor = createCtor(func);
6156
7026
  function wrapper() {
6157
- var length = arguments.length, args = Array2(length), index2 = length, placeholder = getHolder(wrapper);
7027
+ var length = arguments.length, args = Array2(length), index2 = length, placeholder2 = getHolder(wrapper);
6158
7028
  while (index2--) {
6159
7029
  args[index2] = arguments[index2];
6160
7030
  }
6161
- var holders = length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder ? [] : replaceHolders(args, placeholder);
7031
+ var holders = length < 3 && args[0] !== placeholder2 && args[length - 1] !== placeholder2 ? [] : replaceHolders(args, placeholder2);
6162
7032
  length -= holders.length;
6163
7033
  if (length < arity) {
6164
7034
  return createRecurry(
@@ -6202,7 +7072,7 @@ lodash.exports;
6202
7072
  while (index2--) {
6203
7073
  var func = funcs[index2];
6204
7074
  if (typeof func != "function") {
6205
- throw new TypeError(FUNC_ERROR_TEXT);
7075
+ throw new TypeError2(FUNC_ERROR_TEXT);
6206
7076
  }
6207
7077
  if (prereq && !wrapper && getFuncName(func) == "wrapper") {
6208
7078
  var wrapper = new LodashWrapper([], true);
@@ -6239,7 +7109,7 @@ lodash.exports;
6239
7109
  args[index2] = arguments[index2];
6240
7110
  }
6241
7111
  if (isCurried) {
6242
- var placeholder = getHolder(wrapper), holdersCount = countHolders(args, placeholder);
7112
+ var placeholder2 = getHolder(wrapper), holdersCount = countHolders(args, placeholder2);
6243
7113
  }
6244
7114
  if (partials) {
6245
7115
  args = composeArgs(args, partials, holders, isCurried);
@@ -6249,7 +7119,7 @@ lodash.exports;
6249
7119
  }
6250
7120
  length -= holdersCount;
6251
7121
  if (isCurried && length < arity) {
6252
- var newHolders = replaceHolders(args, placeholder);
7122
+ var newHolders = replaceHolders(args, placeholder2);
6253
7123
  return createRecurry(
6254
7124
  func,
6255
7125
  bitmask,
@@ -6369,7 +7239,7 @@ lodash.exports;
6369
7239
  return operator(value, other);
6370
7240
  };
6371
7241
  }
6372
- function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary2, arity) {
7242
+ function createRecurry(func, bitmask, wrapFunc, placeholder2, thisArg, partials, holders, argPos, ary2, arity) {
6373
7243
  var isCurry = bitmask & WRAP_CURRY_FLAG, newHolders = isCurry ? holders : undefined$1, newHoldersRight = isCurry ? undefined$1 : holders, newPartials = isCurry ? partials : undefined$1, newPartialsRight = isCurry ? undefined$1 : partials;
6374
7244
  bitmask |= isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG;
6375
7245
  bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
@@ -6392,7 +7262,7 @@ lodash.exports;
6392
7262
  if (isLaziable(func)) {
6393
7263
  setData(result2, newData);
6394
7264
  }
6395
- result2.placeholder = placeholder;
7265
+ result2.placeholder = placeholder2;
6396
7266
  return setWrapToString(result2, func, bitmask);
6397
7267
  }
6398
7268
  function createRound(methodName) {
@@ -6426,7 +7296,7 @@ lodash.exports;
6426
7296
  function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary2, arity) {
6427
7297
  var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
6428
7298
  if (!isBindKey && typeof func != "function") {
6429
- throw new TypeError(FUNC_ERROR_TEXT);
7299
+ throw new TypeError2(FUNC_ERROR_TEXT);
6430
7300
  }
6431
7301
  var length = partials ? partials.length : 0;
6432
7302
  if (!length) {
@@ -7693,7 +8563,7 @@ lodash.exports;
7693
8563
  };
7694
8564
  function after(n, func) {
7695
8565
  if (typeof func != "function") {
7696
- throw new TypeError(FUNC_ERROR_TEXT);
8566
+ throw new TypeError2(FUNC_ERROR_TEXT);
7697
8567
  }
7698
8568
  n = toInteger(n);
7699
8569
  return function() {
@@ -7710,7 +8580,7 @@ lodash.exports;
7710
8580
  function before(n, func) {
7711
8581
  var result2;
7712
8582
  if (typeof func != "function") {
7713
- throw new TypeError(FUNC_ERROR_TEXT);
8583
+ throw new TypeError2(FUNC_ERROR_TEXT);
7714
8584
  }
7715
8585
  n = toInteger(n);
7716
8586
  return function() {
@@ -7754,7 +8624,7 @@ lodash.exports;
7754
8624
  function debounce(func, wait, options) {
7755
8625
  var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
7756
8626
  if (typeof func != "function") {
7757
- throw new TypeError(FUNC_ERROR_TEXT);
8627
+ throw new TypeError2(FUNC_ERROR_TEXT);
7758
8628
  }
7759
8629
  wait = toNumber(wait) || 0;
7760
8630
  if (isObject(options)) {
@@ -7843,7 +8713,7 @@ lodash.exports;
7843
8713
  }
7844
8714
  function memoize(func, resolver) {
7845
8715
  if (typeof func != "function" || resolver != null && typeof resolver != "function") {
7846
- throw new TypeError(FUNC_ERROR_TEXT);
8716
+ throw new TypeError2(FUNC_ERROR_TEXT);
7847
8717
  }
7848
8718
  var memoized = function() {
7849
8719
  var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
@@ -7860,7 +8730,7 @@ lodash.exports;
7860
8730
  memoize.Cache = MapCache;
7861
8731
  function negate(predicate) {
7862
8732
  if (typeof predicate != "function") {
7863
- throw new TypeError(FUNC_ERROR_TEXT);
8733
+ throw new TypeError2(FUNC_ERROR_TEXT);
7864
8734
  }
7865
8735
  return function() {
7866
8736
  var args = arguments;
@@ -7904,14 +8774,14 @@ lodash.exports;
7904
8774
  });
7905
8775
  function rest(func, start) {
7906
8776
  if (typeof func != "function") {
7907
- throw new TypeError(FUNC_ERROR_TEXT);
8777
+ throw new TypeError2(FUNC_ERROR_TEXT);
7908
8778
  }
7909
8779
  start = start === undefined$1 ? start : toInteger(start);
7910
8780
  return baseRest(func, start);
7911
8781
  }
7912
8782
  function spread(func, start) {
7913
8783
  if (typeof func != "function") {
7914
- throw new TypeError(FUNC_ERROR_TEXT);
8784
+ throw new TypeError2(FUNC_ERROR_TEXT);
7915
8785
  }
7916
8786
  start = start == null ? 0 : nativeMax(toInteger(start), 0);
7917
8787
  return baseRest(function(args) {
@@ -7925,7 +8795,7 @@ lodash.exports;
7925
8795
  function throttle(func, wait, options) {
7926
8796
  var leading = true, trailing = true;
7927
8797
  if (typeof func != "function") {
7928
- throw new TypeError(FUNC_ERROR_TEXT);
8798
+ throw new TypeError2(FUNC_ERROR_TEXT);
7929
8799
  }
7930
8800
  if (isObject(options)) {
7931
8801
  leading = "leading" in options ? !!options.leading : leading;
@@ -8741,7 +9611,7 @@ lodash.exports;
8741
9611
  var length = pairs == null ? 0 : pairs.length, toIteratee = getIteratee();
8742
9612
  pairs = !length ? [] : arrayMap(pairs, function(pair) {
8743
9613
  if (typeof pair[1] != "function") {
8744
- throw new TypeError(FUNC_ERROR_TEXT);
9614
+ throw new TypeError2(FUNC_ERROR_TEXT);
8745
9615
  }
8746
9616
  return [toIteratee(pair[0]), pair[1]];
8747
9617
  });
@@ -9404,7 +10274,7 @@ lodash.exports;
9404
10274
  } else {
9405
10275
  root._ = _2;
9406
10276
  }
9407
- }).call(_baseConvert.commonjsGlobal);
10277
+ }).call(commonjsGlobal);
9408
10278
  })(lodash, lodash.exports);
9409
10279
  var lodashExports = lodash.exports;
9410
10280
  function ItemEditComponent({
@@ -9412,7 +10282,6 @@ function ItemEditComponent({
9412
10282
  selectedContentType,
9413
10283
  setSelectedContentType,
9414
10284
  entities,
9415
- updateRoute,
9416
10285
  replacement,
9417
10286
  validationState,
9418
10287
  initialState,
@@ -9421,7 +10290,8 @@ function ItemEditComponent({
9421
10290
  path,
9422
10291
  dispatchPath,
9423
10292
  debouncedCheckUrl,
9424
- setModalType
10293
+ setModalType,
10294
+ onEdit
9425
10295
  }) {
9426
10296
  const { formatMessage } = reactIntl.useIntl();
9427
10297
  React.useEffect(() => {
@@ -9467,12 +10337,15 @@ function ItemEditComponent({
9467
10337
  try {
9468
10338
  if (lodashExports.isEqual(navItemState, initialState.current) && path.value === path.initialPath) return;
9469
10339
  const isOverride = path.value !== item.route.fullPath ? true : navItemState.isOverride;
9470
- await updateRoute({
9471
- ...navItemState,
9472
- slug: path.value,
9473
- fullPath: path.value,
9474
- isOverride
9475
- }, item.route.documentId);
10340
+ onEdit({
10341
+ ...item,
10342
+ update: {
10343
+ title: navItemState.title,
10344
+ slug: navItemState.slug,
10345
+ fullPath: path.value,
10346
+ isOverride
10347
+ }
10348
+ });
9476
10349
  setModalType("");
9477
10350
  } catch (err) {
9478
10351
  console.log(err);
@@ -9571,19 +10444,25 @@ function ItemEditComponent({
9571
10444
  );
9572
10445
  }
9573
10446
  const ItemEdit = withModalSharedLogic(ItemEditComponent);
9574
- function WrapperItemComponent({
9575
- variant,
9576
- item,
9577
- createNavItem,
9578
- navItemState,
9579
- dispatchItemState,
9580
- createExternalRoute,
9581
- updateRoute,
9582
- dispatchPath,
9583
- setModalType,
9584
- selectedNavigation,
9585
- parentDocumentId
9586
- }) {
10447
+ function isWrapperEditProps(props) {
10448
+ return props.variant === "WrapperEdit";
10449
+ }
10450
+ function isWrapperCreateProps(props) {
10451
+ return props.variant === "WrapperCreate";
10452
+ }
10453
+ function WrapperItemComponent(props) {
10454
+ const {
10455
+ variant,
10456
+ navItemState,
10457
+ dispatchItemState,
10458
+ dispatchPath,
10459
+ setModalType,
10460
+ selectedNavigation
10461
+ } = props;
10462
+ const parentId = isWrapperCreateProps(props) ? props.parentId : void 0;
10463
+ const onCreate = isWrapperCreateProps(props) ? props.onCreate : void 0;
10464
+ const onSave = isWrapperEditProps(props) ? props.onSave : void 0;
10465
+ const item = isWrapperEditProps(props) ? props.item : void 0;
9587
10466
  const { formatMessage } = reactIntl.useIntl();
9588
10467
  React.useEffect(() => {
9589
10468
  if (variant !== "WrapperEdit" || !item) return;
@@ -9591,7 +10470,7 @@ function WrapperItemComponent({
9591
10470
  dispatchItemState({ type: "SET_ACTIVE", payload: item.route.active });
9592
10471
  dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: item.route.fullPath });
9593
10472
  }, []);
9594
- const addItem = async () => {
10473
+ const onConfirm = async () => {
9595
10474
  try {
9596
10475
  if (!navItemState.title || !selectedNavigation) return;
9597
10476
  const data = {
@@ -9600,17 +10479,24 @@ function WrapperItemComponent({
9600
10479
  internal: false,
9601
10480
  wrapper: true
9602
10481
  };
9603
- if (variant === "WrapperEdit" && item) {
9604
- await updateRoute(data, item.route.documentId);
9605
- } else {
9606
- const route = await createExternalRoute(data);
9607
- if (!route) return;
9608
- const settings = {
9609
- route: route.documentId,
9610
- parent: parentDocumentId ?? null,
9611
- navigation: selectedNavigation.documentId
9612
- };
9613
- await createNavItem(settings);
10482
+ if (variant === "WrapperEdit" && item && onSave) {
10483
+ onSave({
10484
+ ...item,
10485
+ update: {
10486
+ ...data
10487
+ }
10488
+ });
10489
+ } else if (onCreate) {
10490
+ const newItem = createTempNavItemObject({
10491
+ parentId,
10492
+ entityRoute: null,
10493
+ selectedNavigation,
10494
+ navItemState,
10495
+ selectedEntity: null,
10496
+ selectedContentType: null,
10497
+ wrapper: true
10498
+ });
10499
+ onCreate(newItem);
9614
10500
  }
9615
10501
  setModalType("");
9616
10502
  } catch (err) {
@@ -9624,7 +10510,7 @@ function WrapperItemComponent({
9624
10510
  closeText: formatMessage({ id: index.getTranslation("cancel"), defaultMessage: "Cancel" }),
9625
10511
  titleText: variant === "WrapperCreate" ? formatMessage({ id: index.getTranslation("modal.wrapperItem.titleText.create"), defaultMessage: "Create new wrapper item" }) : formatMessage({ id: index.getTranslation("modal.wrapperItem.titleText.edit"), defaultMessage: "Edit wrapper item:" }) + ` "${navItemState.title}"`,
9626
10512
  loadingText: variant === "WrapperCreate" ? formatMessage({ id: index.getTranslation("modal.wrapperItem.loadingText.create"), defaultMessage: "Adding" }) : formatMessage({ id: index.getTranslation("modal.wrapperItem.loadingText.edit"), defaultMessage: "Saving" }),
9627
- onConfirm: addItem,
10513
+ onConfirm,
9628
10514
  modalToOpen: "",
9629
10515
  currentModalType: "WrapperCreate",
9630
10516
  currentModalMode: variant === "WrapperCreate" ? "create" : "edit",
@@ -9651,35 +10537,6 @@ function WrapperItemComponent({
9651
10537
  );
9652
10538
  }
9653
10539
  const WrapperItem = withModalSharedLogic(WrapperItemComponent);
9654
- function Header({ navigations }) {
9655
- const { setModalType } = React.useContext(ModalContext);
9656
- const { selectedNavigation, setSelectedNavigation } = React.useContext(SelectedNavigationContext);
9657
- const { formatMessage } = reactIntl.useIntl();
9658
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, children: [
9659
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: () => setModalType("NavOverview"), children: formatMessage({
9660
- id: index.getTranslation("manage"),
9661
- defaultMessage: "Manage"
9662
- }) }),
9663
- /* @__PURE__ */ jsxRuntime.jsx(
9664
- designSystem.SingleSelect,
9665
- {
9666
- value: selectedNavigation ? selectedNavigation.slug : "",
9667
- placeholder: formatMessage({
9668
- id: index.getTranslation("navigation.page.selectNavigation"),
9669
- defaultMessage: "Select Navigation"
9670
- }),
9671
- onChange: (value) => {
9672
- const navItem = navigations.find((nav) => nav.slug === value);
9673
- if (navItem) {
9674
- setSelectedNavigation(navItem);
9675
- }
9676
- },
9677
- disabled: navigations.length === 0,
9678
- children: navigations.map((nav) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: nav.slug, children: nav.name }, nav.id))
9679
- }
9680
- )
9681
- ] });
9682
- }
9683
10540
  const measuring = {
9684
10541
  droppable: {
9685
10542
  strategy: core.MeasuringStrategy.Always
@@ -9736,13 +10593,30 @@ function RouteIcon({ type, color = "neutral800" }) {
9736
10593
  const RouteItem = React.forwardRef(({ item, setParentId, setActionItem, ghost, depth, style, wrapperRef, handleProps }, ref) => {
9737
10594
  if (!item || !item.route) return null;
9738
10595
  const { setModalType } = React.useContext(ModalContext);
9739
- const { get } = admin.useFetchClient();
9740
10596
  const { formatMessage } = reactIntl.useIntl();
9741
- const [itemStatus, setItemStatus] = React.useState({
9742
- status: "published",
9743
- variant: "primary",
9744
- textColor: "primary700"
9745
- });
10597
+ const itemStatusOptions = {
10598
+ published: {
10599
+ status: formatMessage({
10600
+ id: index.getTranslation("published"),
10601
+ defaultMessage: "Published"
10602
+ }),
10603
+ variant: "primary"
10604
+ },
10605
+ draft: {
10606
+ status: formatMessage({
10607
+ id: index.getTranslation("draft"),
10608
+ defaultMessage: "Draft"
10609
+ }),
10610
+ variant: "secondary"
10611
+ },
10612
+ modified: {
10613
+ status: formatMessage({
10614
+ id: index.getTranslation("modified"),
10615
+ defaultMessage: "Modified"
10616
+ }),
10617
+ variant: "alternative"
10618
+ }
10619
+ };
9746
10620
  const [type, setType] = React.useState();
9747
10621
  React.useEffect(() => {
9748
10622
  if (!item.route.internal && !item.route.wrapper) {
@@ -9753,41 +10627,6 @@ const RouteItem = React.forwardRef(({ item, setParentId, setActionItem, ghost, d
9753
10627
  setType("internal");
9754
10628
  }
9755
10629
  }, [item]);
9756
- React.useEffect(() => {
9757
- const ct = item.route.relatedContentType;
9758
- const id = item.route.relatedDocumentId;
9759
- if (!ct || !id) return;
9760
- async function fetchRelated() {
9761
- try {
9762
- const { data } = await get(`/content-manager/collection-types/${ct}/${id}`);
9763
- switch (data.data.status) {
9764
- case "modified":
9765
- setItemStatus({
9766
- status: "Modified",
9767
- variant: "alternative",
9768
- textColor: "alternative700"
9769
- });
9770
- break;
9771
- case "draft":
9772
- setItemStatus({
9773
- status: "Draft",
9774
- variant: "secondary",
9775
- textColor: "secondary700"
9776
- });
9777
- break;
9778
- default:
9779
- setItemStatus({
9780
- status: "Published",
9781
- variant: "primary",
9782
- textColor: "primary700"
9783
- });
9784
- }
9785
- } catch (err) {
9786
- console.log(err);
9787
- }
9788
- }
9789
- fetchRelated();
9790
- }, []);
9791
10630
  const handleAddChildren = () => {
9792
10631
  setParentId(item.documentId);
9793
10632
  setModalType("ItemCreate");
@@ -9805,7 +10644,7 @@ const RouteItem = React.forwardRef(({ item, setParentId, setActionItem, ghost, d
9805
10644
  };
9806
10645
  const elStyle = {
9807
10646
  marginLeft: depth !== void 0 ? depth * 48 : 0,
9808
- opacity: ghost ? 0.5 : 1,
10647
+ opacity: ghost || item.deleted ? 0.5 : 1,
9809
10648
  ...style
9810
10649
  };
9811
10650
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -9826,29 +10665,39 @@ const RouteItem = React.forwardRef(({ item, setParentId, setActionItem, ghost, d
9826
10665
  shadow: "tableShadow",
9827
10666
  ref,
9828
10667
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
9829
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
10668
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, children: [
9830
10669
  /* @__PURE__ */ jsxRuntime.jsx(icons.Drag, { color: "neutral800", ...handleProps }),
9831
10670
  /* @__PURE__ */ jsxRuntime.jsx(
9832
10671
  designSystem.Box,
9833
10672
  {
9834
- marginLeft: 4,
9835
- marginRight: 4,
9836
10673
  width: "1px",
9837
10674
  height: "32px",
9838
10675
  background: "neutral150"
9839
10676
  }
9840
10677
  ),
9841
10678
  /* @__PURE__ */ jsxRuntime.jsx(RouteIcon, { type }),
9842
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, marginLeft: 4, children: [
9843
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: item.route.title }),
10679
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
10680
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: item.update?.title ? item.update.title : item.route.title }),
9844
10681
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { textColor: "neutral400", children: [
9845
10682
  type === "internal" && "/",
9846
- item.route.fullPath
10683
+ item.update?.fullPath ? item.update.fullPath : item.route.fullPath
9847
10684
  ] })
9848
- ] })
10685
+ ] }),
10686
+ item.isNew && !item.deleted && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { variant: "alternative", size: "S", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: formatMessage({
10687
+ id: index.getTranslation("new"),
10688
+ defaultMessage: "New"
10689
+ }) }) }),
10690
+ item.update && !item.deleted && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { variant: "alternative", size: "S", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: formatMessage({
10691
+ id: index.getTranslation("updated"),
10692
+ defaultMessage: "Updated"
10693
+ }) }) }),
10694
+ item.deleted && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { size: "S", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "danger500", children: formatMessage({
10695
+ id: index.getTranslation("deleted"),
10696
+ defaultMessage: "Deleted"
10697
+ }) }) })
9849
10698
  ] }),
9850
10699
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "row", gap: 4, children: [
9851
- type === "internal" && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { variant: itemStatus.variant, size: "S", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: itemStatus.textColor, children: itemStatus.status }) }),
10700
+ type === "internal" && item.status && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { variant: itemStatusOptions[item.status].variant, size: "S", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: itemStatusOptions[item.status].status }) }),
9852
10701
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SimpleMenu, { label: "Notifications", tag: designSystem.IconButton, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.More, {}), children: [
9853
10702
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onClick: () => handleEdit(), children: formatMessage({
9854
10703
  id: index.getTranslation("edit"),
@@ -9902,50 +10751,176 @@ function SortableRouteItem({ item, depth, ...props }) {
9902
10751
  }
9903
10752
  );
9904
10753
  }
10754
+ function PageWrapper({ navigations, loading = false, children }) {
10755
+ const { formatMessage } = reactIntl.useIntl();
10756
+ const { selectedNavigation, setSelectedNavigation } = React.useContext(SelectedNavigationContext);
10757
+ const { setModalType } = React.useContext(ModalContext);
10758
+ return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
10759
+ /* @__PURE__ */ jsxRuntime.jsx(
10760
+ admin.Layouts.Header,
10761
+ {
10762
+ title: formatMessage({
10763
+ id: index.getTranslation("navigation.page.title"),
10764
+ defaultMessage: "Navigation"
10765
+ }) + (selectedNavigation ? `: ${selectedNavigation.name}` : ""),
10766
+ subtitle: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral500", children: selectedNavigation ? `ID: ${selectedNavigation.id} | DocumentID : ${selectedNavigation.documentId}` : formatMessage({
10767
+ id: index.getTranslation("navigation.page.subtitle.noNavigationSelected"),
10768
+ defaultMessage: "No navigation selected"
10769
+ }) }),
10770
+ primaryAction: !loading && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, children: [
10771
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: () => setModalType("NavOverview"), children: formatMessage({
10772
+ id: index.getTranslation("manage"),
10773
+ defaultMessage: "Manage"
10774
+ }) }),
10775
+ /* @__PURE__ */ jsxRuntime.jsx(
10776
+ designSystem.SingleSelect,
10777
+ {
10778
+ value: selectedNavigation ? selectedNavigation.slug : "",
10779
+ placeholder: formatMessage({
10780
+ id: index.getTranslation("navigation.page.selectNavigation"),
10781
+ defaultMessage: "Select Navigation"
10782
+ }),
10783
+ onChange: (value) => {
10784
+ const navItem = navigations.find((nav) => nav.slug === value);
10785
+ console.log("switched navigation to: ", navItem);
10786
+ if (navItem) {
10787
+ setSelectedNavigation(navItem);
10788
+ }
10789
+ },
10790
+ disabled: navigations.length === 0,
10791
+ children: navigations.map((nav) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: nav.slug, children: nav.name }, nav.id))
10792
+ }
10793
+ )
10794
+ ] })
10795
+ }
10796
+ ),
10797
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children }) })
10798
+ ] });
10799
+ }
9905
10800
  const Navigation = () => {
9906
- const { navigations, fetchNavigations } = useNavigations();
10801
+ const [navigations, setNavigations] = React.useState([]);
9907
10802
  const [modalType, setModalType] = React.useState("");
9908
10803
  const [selectedNavigation, setSelectedNavigation] = React.useState();
9909
10804
  const [navigationItems, setNavigationItems] = React.useState();
9910
10805
  const [initialNavigationItems, setInitialNavigationItems] = React.useState();
9911
10806
  const [actionItem, setActionItem] = React.useState();
9912
10807
  const [parentId, setParentId] = React.useState();
9913
- const { getStructuredNavigation, updateNavItem } = index.useApi();
10808
+ const { getNavigation, updateNavigationItemStructure } = index.useApi();
10809
+ const [isSavingNavigation, setIsSavingNavigation] = React.useState(false);
10810
+ const [loading, setLoading] = React.useState(false);
9914
10811
  const [projected, setProjected] = React.useState(null);
9915
10812
  const [activeItem, setActiveItem] = React.useState();
9916
10813
  const [activeId, setActiveId] = React.useState(null);
9917
10814
  const [overId, setOverId] = React.useState(null);
9918
10815
  const [offsetLeft, setOffsetLeft] = React.useState(0);
9919
10816
  const { formatMessage } = reactIntl.useIntl();
9920
- if (!navigations) return null;
10817
+ const { toggleNotification } = admin.useNotification();
10818
+ const { get } = admin.useFetchClient();
10819
+ async function loadNavigations() {
10820
+ try {
10821
+ const data = await getNavigation({ variant: "flat" });
10822
+ const updatedNavigations = await Promise.all(
10823
+ data.map(async (nav) => {
10824
+ const updatedItems = await Promise.all(
10825
+ nav.items.map(async (item) => {
10826
+ const ct = item.route?.relatedContentType;
10827
+ const id = item.route?.relatedDocumentId;
10828
+ if (!ct || !id) return item;
10829
+ try {
10830
+ const { data: data2 } = await get(`/content-manager/collection-types/${ct}/${id}`);
10831
+ return { ...item, status: data2.data.status };
10832
+ } catch (err) {
10833
+ console.error(err);
10834
+ return item;
10835
+ }
10836
+ })
10837
+ );
10838
+ return { ...nav, items: updatedItems };
10839
+ })
10840
+ );
10841
+ setNavigations(updatedNavigations);
10842
+ setSelectedNavigation(updatedNavigations[0]);
10843
+ } catch (error) {
10844
+ console.error("Error fetching navigations: ", error);
10845
+ toggleNotification({
10846
+ type: "danger",
10847
+ message: formatMessage({
10848
+ id: index.getTranslation("notification.navigation.fetchFailed"),
10849
+ defaultMessage: "Failed to fetch navigations"
10850
+ })
10851
+ });
10852
+ }
10853
+ }
10854
+ React.useEffect(() => {
10855
+ async function fetchNavigations() {
10856
+ setLoading(true);
10857
+ await loadNavigations();
10858
+ setLoading(false);
10859
+ }
10860
+ fetchNavigations();
10861
+ }, []);
9921
10862
  React.useEffect(() => {
9922
10863
  if (modalType === "NavOverview" || modalType === "") {
9923
10864
  setActionItem(void 0);
9924
10865
  setParentId(void 0);
9925
- fetchNavigations();
9926
10866
  }
9927
10867
  }, [modalType]);
9928
10868
  React.useEffect(() => {
9929
- async function fetchNestedNavigation() {
9930
- if (!selectedNavigation && (!navigations || navigations.length === 0)) return;
9931
- const documentId = selectedNavigation?.documentId ?? navigations?.[0]?.documentId;
9932
- if (!documentId) return;
9933
- const { items } = await getStructuredNavigation(documentId, "flat");
9934
- setNavigationItems(items);
9935
- }
9936
- if (Array.isArray(navigations) && navigations?.length > 0)
9937
- fetchNestedNavigation();
9938
- }, [navigations, selectedNavigation]);
9939
- React.useEffect(() => {
9940
- if (navigations.length > 0 && (!selectedNavigation || !navigations.find((nav) => nav.id === selectedNavigation.id))) {
9941
- setSelectedNavigation(navigations[0]);
9942
- }
9943
- }, [navigations]);
10869
+ setNavigationItems(selectedNavigation?.items || []);
10870
+ }, [selectedNavigation]);
9944
10871
  React.useEffect(() => {
9945
- if (navigationItems && !initialNavigationItems) {
10872
+ if (selectedNavigation?.items && !initialNavigationItems) {
9946
10873
  setInitialNavigationItems(navigationItems);
9947
10874
  }
9948
10875
  }, [navigationItems]);
10876
+ React.useEffect(() => {
10877
+ if (!activeId || !navigationItems) return;
10878
+ const item = navigationItems.find(({ id }) => id === activeId);
10879
+ setActiveItem(item);
10880
+ }, [navigationItems, activeId]);
10881
+ function handleSoftAddedItem(newItem) {
10882
+ if (newItem.isNew?.parent) {
10883
+ const parentIndex = navigationItems?.findIndex((item) => item.documentId === newItem.isNew?.parent);
10884
+ if (parentIndex !== void 0 && parentIndex >= 0) {
10885
+ const parentDepth = navigationItems ? navigationItems[parentIndex].depth || 0 : 0;
10886
+ newItem.depth = parentDepth + 1;
10887
+ const updatedItems = navigationItems ? [
10888
+ ...navigationItems.slice(0, parentIndex + 1),
10889
+ newItem,
10890
+ ...navigationItems.slice(parentIndex + 1)
10891
+ ] : [newItem];
10892
+ setNavigationItems(updatedItems);
10893
+ return;
10894
+ }
10895
+ }
10896
+ setNavigationItems((items) => items ? [...items, newItem] : [newItem]);
10897
+ }
10898
+ async function saveNavigation() {
10899
+ if (!navigationItems || !selectedNavigation) return;
10900
+ setIsSavingNavigation(true);
10901
+ try {
10902
+ await updateNavigationItemStructure(selectedNavigation.documentId, navigationItems);
10903
+ toggleNotification({
10904
+ type: "success",
10905
+ message: formatMessage({
10906
+ id: index.getTranslation("notification.navigation.navigationSaved"),
10907
+ defaultMessage: "Navigation updated successfully"
10908
+ })
10909
+ });
10910
+ } catch (e) {
10911
+ console.error(e);
10912
+ toggleNotification({
10913
+ type: "danger",
10914
+ message: formatMessage({
10915
+ id: index.getTranslation("notification.navigation.saveNavigationFailed"),
10916
+ defaultMessage: "Error updating navigation item"
10917
+ })
10918
+ });
10919
+ } finally {
10920
+ loadNavigations();
10921
+ setIsSavingNavigation(false);
10922
+ }
10923
+ }
9949
10924
  function handleDragStart({ active: { id: activeId2 } }) {
9950
10925
  if (!navigationItems) return;
9951
10926
  setActiveId(activeId2);
@@ -9980,41 +10955,6 @@ const Navigation = () => {
9980
10955
  setOffsetLeft(0);
9981
10956
  document.body.style.setProperty("cursor", "");
9982
10957
  }
9983
- function saveOrder() {
9984
- if (!navigationItems || !selectedNavigation) return;
9985
- let groupIndices = [0];
9986
- let parentIds = [];
9987
- navigationItems.forEach((item, index2) => {
9988
- const previousItem = navigationItems[index2 - 1];
9989
- if (typeof item.depth !== "number") return;
9990
- if (item.depth === 0) {
9991
- groupIndices[0] = (groupIndices[0] || 0) + 1;
9992
- parentIds = [];
9993
- } else if (typeof previousItem.depth === "number" && item.depth === previousItem.depth + 1) {
9994
- parentIds.push(previousItem.documentId);
9995
- groupIndices[item.depth] = 0;
9996
- } else if (typeof previousItem.depth === "number" && item.depth <= previousItem.depth) {
9997
- const diff = previousItem.depth - item.depth;
9998
- for (let i = 0; i < diff; i++) {
9999
- parentIds.pop();
10000
- groupIndices.pop();
10001
- }
10002
- groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
10003
- }
10004
- updateNavItem(item.documentId, {
10005
- order: groupIndices[item.depth],
10006
- parent: parentIds.at(-1) || "",
10007
- route: item?.route?.documentId || "",
10008
- navigation: selectedNavigation?.documentId || ""
10009
- });
10010
- });
10011
- setInitialNavigationItems(navigationItems);
10012
- }
10013
- React.useEffect(() => {
10014
- if (!activeId || !navigationItems) return;
10015
- const item = navigationItems.find(({ id }) => id === activeId);
10016
- setActiveItem(item);
10017
- }, [navigationItems, activeId]);
10018
10958
  React.useEffect(() => {
10019
10959
  const projection = activeId && overId ? getProjection(
10020
10960
  navigationItems,
@@ -10024,107 +10964,185 @@ const Navigation = () => {
10024
10964
  ) : null;
10025
10965
  setProjected(projection);
10026
10966
  }, [activeId, overId, offsetLeft, navigationItems]);
10967
+ if (loading) {
10968
+ return /* @__PURE__ */ jsxRuntime.jsx(PageWrapper, { navigations, loading, children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, {}) });
10969
+ }
10027
10970
  return /* @__PURE__ */ jsxRuntime.jsx(ModalContext.Provider, { value: { modalType, setModalType }, children: /* @__PURE__ */ jsxRuntime.jsxs(SelectedNavigationContext.Provider, { value: { selectedNavigation, setSelectedNavigation }, children: [
10028
- /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10029
- /* @__PURE__ */ jsxRuntime.jsx(
10030
- admin.Layouts.Header,
10031
- {
10032
- title: formatMessage({
10033
- id: index.getTranslation("navigation.page.title"),
10034
- defaultMessage: "Navigation"
10035
- }) + (selectedNavigation ? `: ${selectedNavigation.name}` : ""),
10036
- subtitle: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral500", children: selectedNavigation ? `ID: ${selectedNavigation.id} | DocumentID : ${selectedNavigation.documentId}` : formatMessage({
10037
- id: index.getTranslation("navigation.page.subtitle.noNavigationSelected"),
10038
- defaultMessage: "No navigation selected"
10039
- }) }),
10040
- primaryAction: /* @__PURE__ */ jsxRuntime.jsx(Header, { navigations })
10041
- }
10042
- ),
10043
- /* @__PURE__ */ jsxRuntime.jsxs(admin.Layouts.Content, { children: [
10044
- selectedNavigation && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, paddingBottom: 6, justifyContent: "flex-end", children: [
10045
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}), onClick: () => setModalType("ItemCreate"), children: formatMessage({
10046
- id: index.getTranslation("navigation.page.newItemButton"),
10047
- defaultMessage: "New Item"
10048
- }) }),
10049
- /* @__PURE__ */ jsxRuntime.jsx(
10050
- designSystem.Button,
10051
- {
10052
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
10053
- onClick: () => saveOrder(),
10054
- disabled: JSON.stringify(navigationItems) === JSON.stringify(initialNavigationItems),
10055
- children: formatMessage({
10056
- id: index.getTranslation("save"),
10057
- defaultMessage: "Save"
10058
- })
10059
- }
10060
- )
10061
- ] }),
10062
- navigationItems && navigationItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
10063
- core.DndContext,
10971
+ /* @__PURE__ */ jsxRuntime.jsxs(PageWrapper, { navigations, children: [
10972
+ selectedNavigation && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, paddingBottom: 6, justifyContent: "flex-end", children: [
10973
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}), onClick: () => setModalType("ItemCreate"), children: formatMessage({
10974
+ id: index.getTranslation("navigation.page.newItemButton"),
10975
+ defaultMessage: "New Item"
10976
+ }) }),
10977
+ /* @__PURE__ */ jsxRuntime.jsx(
10978
+ designSystem.Button,
10064
10979
  {
10065
- collisionDetection: (e) => core.closestCenter(e),
10066
- onDragStart: (e) => handleDragStart(e),
10067
- onDragMove: (e) => handleDragMove(e),
10068
- onDragOver: (e) => handleDragOver(e),
10069
- onDragEnd: (e) => handleDragEnd(e),
10070
- onDragCancel: () => handleDragCancel(),
10071
- measuring,
10072
- children: /* @__PURE__ */ jsxRuntime.jsxs(sortable.SortableContext, { items: navigationItems, strategy: sortable.verticalListSortingStrategy, children: [
10073
- navigationItems.map((item, index2) => /* @__PURE__ */ jsxRuntime.jsx(
10980
+ onClick: () => saveNavigation(),
10981
+ loading: isSavingNavigation,
10982
+ variant: "primary",
10983
+ children: formatMessage({
10984
+ id: index.getTranslation("save"),
10985
+ defaultMessage: "Save"
10986
+ })
10987
+ }
10988
+ )
10989
+ ] }),
10990
+ selectedNavigation && navigationItems && navigationItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
10991
+ core.DndContext,
10992
+ {
10993
+ collisionDetection: (e) => core.closestCenter(e),
10994
+ onDragStart: (e) => handleDragStart(e),
10995
+ onDragMove: (e) => handleDragMove(e),
10996
+ onDragOver: (e) => handleDragOver(e),
10997
+ onDragEnd: (e) => handleDragEnd(e),
10998
+ onDragCancel: () => handleDragCancel(),
10999
+ measuring,
11000
+ children: /* @__PURE__ */ jsxRuntime.jsxs(sortable.SortableContext, { items: navigationItems, strategy: sortable.verticalListSortingStrategy, children: [
11001
+ navigationItems.map((item, index2) => /* @__PURE__ */ jsxRuntime.jsx(
11002
+ SortableRouteItem,
11003
+ {
11004
+ item,
11005
+ setParentId,
11006
+ setActionItem,
11007
+ indentationWidth,
11008
+ depth: item.id === activeId && projected ? projected.depth : item.depth
11009
+ },
11010
+ item.documentId || index2
11011
+ )),
11012
+ ReactDOM.createPortal(
11013
+ /* @__PURE__ */ jsxRuntime.jsx(core.DragOverlay, { children: activeId && activeItem ? /* @__PURE__ */ jsxRuntime.jsx(
10074
11014
  SortableRouteItem,
10075
11015
  {
10076
- item,
11016
+ item: activeItem,
10077
11017
  setParentId,
10078
- setActionItem,
10079
- indentationWidth,
10080
- depth: item.id === activeId && projected ? projected.depth : item.depth
10081
- },
10082
- index2
10083
- )),
10084
- ReactDOM.createPortal(
10085
- /* @__PURE__ */ jsxRuntime.jsx(core.DragOverlay, { children: activeId && activeItem ? /* @__PURE__ */ jsxRuntime.jsx(
10086
- SortableRouteItem,
10087
- {
10088
- item: activeItem,
10089
- setParentId,
10090
- setActionItem
10091
- }
10092
- ) : null }),
10093
- document.body
10094
- )
10095
- ] })
10096
- }
10097
- ) }),
10098
- navigations?.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(EmptyBox.Center, { height: 400, children: [
10099
- /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.EmptyBox, { msg: formatMessage({
10100
- id: index.getTranslation("navigation.page.emptyNavigation"),
10101
- defaultMessage: "You have no navigations yet..."
10102
- }) }),
10103
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "primary", onClick: () => setModalType("NavCreate"), children: formatMessage({
10104
- id: index.getTranslation("navigation.page.createNewNavigation"),
10105
- defaultMessage: "Create new navigation"
10106
- }) })
10107
- ] }),
10108
- navigationItems?.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(EmptyBox.Center, { height: 400, children: [
10109
- /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.EmptyBox, { msg: "Your navigation is empty..." }),
10110
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "primary", onClick: () => setModalType("ItemCreate"), children: formatMessage({
10111
- id: index.getTranslation("navigation.page.createNewItem"),
10112
- defaultMessage: "Create new item"
10113
- }) })
10114
- ] })
11018
+ setActionItem
11019
+ }
11020
+ ) : null }),
11021
+ document.body
11022
+ )
11023
+ ] })
11024
+ }
11025
+ ) }),
11026
+ navigations?.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(FullLoader.Center, { height: 400, children: [
11027
+ /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.EmptyBox, { msg: formatMessage({
11028
+ id: index.getTranslation("navigation.page.emptyNavigation"),
11029
+ defaultMessage: "You have no navigations yet..."
11030
+ }) }),
11031
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "primary", onClick: () => setModalType("NavCreate"), children: formatMessage({
11032
+ id: index.getTranslation("navigation.page.createNewNavigation"),
11033
+ defaultMessage: "Create new navigation"
11034
+ }) })
11035
+ ] }),
11036
+ navigationItems?.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(FullLoader.Center, { height: 400, children: [
11037
+ /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.EmptyBox, { msg: "Your navigation is empty..." }),
11038
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "primary", onClick: () => setModalType("ItemCreate"), children: formatMessage({
11039
+ id: index.getTranslation("navigation.page.createNewItem"),
11040
+ defaultMessage: "Create new item"
11041
+ }) })
10115
11042
  ] })
10116
11043
  ] }),
10117
- modalType === "NavOverview" && /* @__PURE__ */ jsxRuntime.jsx(NavOverview, { navigations, setActionItem }),
11044
+ modalType === "NavOverview" && /* @__PURE__ */ jsxRuntime.jsx(
11045
+ NavOverview,
11046
+ {
11047
+ navigations,
11048
+ setActionItem
11049
+ }
11050
+ ),
10118
11051
  modalType === "NavCreate" && /* @__PURE__ */ jsxRuntime.jsx(NavCreate, {}),
10119
- modalType === "NavDelete" && /* @__PURE__ */ jsxRuntime.jsx(Delete, { variant: "NavDelete", item: actionItem, fetchNavigations }),
10120
- modalType === "NavEdit" && /* @__PURE__ */ jsxRuntime.jsx(NavEdit, { item: actionItem, fetchNavigations }),
10121
- modalType === "ItemCreate" && /* @__PURE__ */ jsxRuntime.jsx(ItemCreate, { parentId }),
10122
- modalType === "ItemDelete" && /* @__PURE__ */ jsxRuntime.jsx(Delete, { variant: "ItemDelete", item: actionItem, fetchNavigations }),
10123
- modalType === "ItemEdit" && /* @__PURE__ */ jsxRuntime.jsx(ItemEdit, { item: actionItem }),
10124
- modalType === "ExternalCreate" && /* @__PURE__ */ jsxRuntime.jsx(ExternalItem, { variant: modalType, parentDocumentId: parentId }),
10125
- modalType === "ExternalEdit" && /* @__PURE__ */ jsxRuntime.jsx(ExternalItem, { variant: modalType, item: actionItem }),
10126
- modalType === "WrapperCreate" && /* @__PURE__ */ jsxRuntime.jsx(WrapperItem, { variant: modalType, parentDocumentId: parentId }),
10127
- modalType === "WrapperEdit" && /* @__PURE__ */ jsxRuntime.jsx(WrapperItem, { variant: modalType, item: actionItem })
11052
+ modalType === "NavDelete" && /* @__PURE__ */ jsxRuntime.jsx(
11053
+ Delete,
11054
+ {
11055
+ variant: "NavDelete",
11056
+ item: actionItem,
11057
+ onDelete: () => {
11058
+ }
11059
+ }
11060
+ ),
11061
+ modalType === "NavEdit" && /* @__PURE__ */ jsxRuntime.jsx(
11062
+ NavEdit,
11063
+ {
11064
+ item: actionItem,
11065
+ onEdit: () => {
11066
+ }
11067
+ }
11068
+ ),
11069
+ modalType === "ItemCreate" && /* @__PURE__ */ jsxRuntime.jsx(
11070
+ ItemCreate,
11071
+ {
11072
+ parentId,
11073
+ onCreate: (newItem) => {
11074
+ handleSoftAddedItem(newItem);
11075
+ }
11076
+ }
11077
+ ),
11078
+ modalType === "ItemDelete" && /* @__PURE__ */ jsxRuntime.jsx(
11079
+ Delete,
11080
+ {
11081
+ variant: "ItemDelete",
11082
+ item: actionItem,
11083
+ onDelete: (editedItem) => {
11084
+ setNavigationItems(
11085
+ (items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
11086
+ );
11087
+ }
11088
+ }
11089
+ ),
11090
+ modalType === "ItemEdit" && /* @__PURE__ */ jsxRuntime.jsx(
11091
+ ItemEdit,
11092
+ {
11093
+ item: actionItem,
11094
+ onEdit: (editedItem) => {
11095
+ console.log(editedItem);
11096
+ setNavigationItems(
11097
+ (items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
11098
+ );
11099
+ }
11100
+ }
11101
+ ),
11102
+ modalType === "ExternalCreate" && /* @__PURE__ */ jsxRuntime.jsx(
11103
+ ExternalItem,
11104
+ {
11105
+ variant: modalType,
11106
+ parentId,
11107
+ onCreate: (newItem) => {
11108
+ handleSoftAddedItem(newItem);
11109
+ }
11110
+ }
11111
+ ),
11112
+ modalType === "ExternalEdit" && /* @__PURE__ */ jsxRuntime.jsx(
11113
+ ExternalItem,
11114
+ {
11115
+ variant: modalType,
11116
+ item: actionItem,
11117
+ onSave: (editedItem) => {
11118
+ setNavigationItems(
11119
+ (items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
11120
+ );
11121
+ }
11122
+ }
11123
+ ),
11124
+ modalType === "WrapperCreate" && /* @__PURE__ */ jsxRuntime.jsx(
11125
+ WrapperItem,
11126
+ {
11127
+ variant: modalType,
11128
+ parentId,
11129
+ onCreate: (newItem) => {
11130
+ handleSoftAddedItem(newItem);
11131
+ }
11132
+ }
11133
+ ),
11134
+ modalType === "WrapperEdit" && /* @__PURE__ */ jsxRuntime.jsx(
11135
+ WrapperItem,
11136
+ {
11137
+ variant: modalType,
11138
+ item: actionItem,
11139
+ onSave: (editedItem) => {
11140
+ setNavigationItems(
11141
+ (items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
11142
+ );
11143
+ }
11144
+ }
11145
+ )
10128
11146
  ] }) });
10129
11147
  };
10130
11148
  exports.default = Navigation;