@mattisvensson/strapi-plugin-webatlas 0.11.0 → 0.11.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.
- package/README.md +14 -8
- package/dist/admin/{FullLoader-CrPED_dY.mjs → FullLoader-Btjb2W2p.mjs} +4 -2
- package/dist/admin/{FullLoader-Cmsf8xS6.js → FullLoader-Da2n70bJ.js} +4 -2
- package/dist/admin/{SettingTitle-BjE_2u6R.js → SettingTitle-B0quw3f8.js} +5 -3
- package/dist/admin/{SettingTitle-B1IaU3qs.mjs → SettingTitle-HMfQOJnK.mjs} +5 -3
- package/dist/admin/de-B5pRvs13.mjs +0 -1
- package/dist/admin/de-CqU1FU8C.js +0 -1
- package/dist/admin/en-BE-zzIv8.mjs +0 -1
- package/dist/admin/en-C7I90FwV.js +0 -1
- package/dist/admin/{index-Cf9j0bn2.mjs → index-9_HhKDUC.mjs} +31 -59
- package/dist/admin/{index-DCYCtKrj.mjs → index-B79ELMEC.mjs} +220 -215
- package/dist/admin/{index-JLpXBQVL.js → index-BEVoxEAm.js} +31 -59
- package/dist/admin/index-Bmg-ERct.mjs +243 -0
- package/dist/admin/{index-AVI3QJ0R.js → index-C8YjuuOx.js} +496 -354
- package/dist/admin/{index-Yq-QR8t0.js → index-Cx_mktdk.js} +220 -215
- package/dist/admin/{index-BbnlyBrZ.mjs → index-Cz_k_jjp.mjs} +41 -31
- package/dist/admin/{index-D8bG0YFB.js → index-D2hB1vTw.js} +41 -31
- package/dist/admin/index-YdWxpvOH.js +243 -0
- package/dist/admin/{index-BIEUXWe7.mjs → index-oEJT_mvw.mjs} +496 -354
- package/dist/admin/index.js +1 -2
- package/dist/admin/index.mjs +1 -2
- package/dist/admin/src/index.d.ts +12 -0
- package/dist/server/index.js +174 -145
- package/dist/server/index.mjs +174 -145
- package/dist/server/src/index.d.ts +305 -0
- package/package.json +108 -108
- package/dist/admin/FullLoader-Cmsf8xS6.js.map +0 -1
- package/dist/admin/FullLoader-CrPED_dY.mjs.map +0 -1
- package/dist/admin/SettingTitle-B1IaU3qs.mjs.map +0 -1
- package/dist/admin/SettingTitle-BjE_2u6R.js.map +0 -1
- package/dist/admin/de-B5pRvs13.mjs.map +0 -1
- package/dist/admin/de-CqU1FU8C.js.map +0 -1
- package/dist/admin/en-BE-zzIv8.mjs.map +0 -1
- package/dist/admin/en-C7I90FwV.js.map +0 -1
- package/dist/admin/index-AVI3QJ0R.js.map +0 -1
- package/dist/admin/index-B90eSO4a.js +0 -219
- package/dist/admin/index-B90eSO4a.js.map +0 -1
- package/dist/admin/index-BIEUXWe7.mjs.map +0 -1
- package/dist/admin/index-BbnlyBrZ.mjs.map +0 -1
- package/dist/admin/index-Cf9j0bn2.mjs.map +0 -1
- package/dist/admin/index-D8bG0YFB.js.map +0 -1
- package/dist/admin/index-DCYCtKrj.mjs.map +0 -1
- package/dist/admin/index-JLpXBQVL.js.map +0 -1
- package/dist/admin/index-Y_PYIiRA.mjs +0 -219
- package/dist/admin/index-Y_PYIiRA.mjs.map +0 -1
- package/dist/admin/index-Yq-QR8t0.js.map +0 -1
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/index.mjs.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/server/index.mjs.map +0 -1
|
@@ -5,9 +5,9 @@ import { Box, Typography, Dialog, Button, Modal, Flex, SingleSelect, SingleSelec
|
|
|
5
5
|
import { useState, useEffect, createContext, useRef, useContext, useMemo, useReducer, useCallback, forwardRef } from "react";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
7
|
import { useIntl } from "react-intl";
|
|
8
|
-
import { u as useApi, g as getTranslation, P as PLUGIN_ID, d as debounce, a as duplicateCheck, T as Tooltip, b as PathInfo, c as usePluginConfig, p as pluginPermissions } from "./index-
|
|
8
|
+
import { u as useApi, g as getTranslation, P as PLUGIN_ID, d as debounce, a as duplicateCheck, T as Tooltip, b as PathInfo, c as usePluginConfig, p as pluginPermissions } from "./index-B79ELMEC.mjs";
|
|
9
9
|
import { useNotification, useFetchClient, Page, Layouts } from "@strapi/strapi/admin";
|
|
10
|
-
import { C as Center, F as FullLoader } from "./FullLoader-
|
|
10
|
+
import { C as Center, F as FullLoader } from "./FullLoader-Btjb2W2p.mjs";
|
|
11
11
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
12
12
|
import { MeasuringStrategy, DndContext, DragOverlay, closestCenter } from "@dnd-kit/core";
|
|
13
13
|
import { arrayMove, useSortable, SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
@@ -138,10 +138,16 @@ function EmptyBox({ msg }) {
|
|
|
138
138
|
/* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", textColor: "neutral600", children: msg }) })
|
|
139
139
|
] });
|
|
140
140
|
}
|
|
141
|
-
const ModalContext = createContext({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
141
|
+
const ModalContext = createContext({
|
|
142
|
+
modalType: "",
|
|
143
|
+
setModalType: () => {
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
const SelectedNavigationContext = createContext({
|
|
147
|
+
selectedNavigation: void 0,
|
|
148
|
+
setSelectedNavigation: () => {
|
|
149
|
+
}
|
|
150
|
+
});
|
|
145
151
|
function Delete({ variant, item, onDelete }) {
|
|
146
152
|
const itemName = useRef(variant === "NavDelete" ? item.name : item.route.title);
|
|
147
153
|
const closeModalState = useRef(variant === "NavDelete" ? "NavOverview" : "");
|
|
@@ -200,7 +206,15 @@ function Delete({ variant, item, onDelete }) {
|
|
|
200
206
|
defaultMessage: "navigation"
|
|
201
207
|
})
|
|
202
208
|
] }),
|
|
203
|
-
/* @__PURE__ */ jsx(
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
Typography,
|
|
211
|
+
{
|
|
212
|
+
textAlign: "center",
|
|
213
|
+
fontWeight: "bold",
|
|
214
|
+
style: { marginTop: 8, marginBottom: 8, fontSize: 20 },
|
|
215
|
+
children: itemName.current
|
|
216
|
+
}
|
|
217
|
+
),
|
|
204
218
|
/* @__PURE__ */ jsx(Typography, { textAlign: "center", children: formatMessage({
|
|
205
219
|
id: getTranslation("modal.delete.message.end"),
|
|
206
220
|
defaultMessage: "This can not be undone. Are you sure?"
|
|
@@ -325,10 +339,22 @@ function NavCreate() {
|
|
|
325
339
|
return /* @__PURE__ */ jsx(
|
|
326
340
|
NavModal,
|
|
327
341
|
{
|
|
328
|
-
confirmText: formatMessage({
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
342
|
+
confirmText: formatMessage({
|
|
343
|
+
id: getTranslation("modal.navCreate.confirmText"),
|
|
344
|
+
defaultMessage: "Create"
|
|
345
|
+
}),
|
|
346
|
+
closeText: formatMessage({
|
|
347
|
+
id: getTranslation("modal.navCreate.closeText"),
|
|
348
|
+
defaultMessage: "Cancel"
|
|
349
|
+
}),
|
|
350
|
+
titleText: formatMessage({
|
|
351
|
+
id: getTranslation("modal.navCreate.titleText"),
|
|
352
|
+
defaultMessage: "Create new navigation"
|
|
353
|
+
}),
|
|
354
|
+
loadingText: formatMessage({
|
|
355
|
+
id: getTranslation("modal.navCreate.loadingText"),
|
|
356
|
+
defaultMessage: "Creating"
|
|
357
|
+
}),
|
|
332
358
|
onConfirm,
|
|
333
359
|
loading,
|
|
334
360
|
disabled: name.trim() === "",
|
|
@@ -380,10 +406,22 @@ function NavEdit({ item, onEdit }) {
|
|
|
380
406
|
return /* @__PURE__ */ jsx(
|
|
381
407
|
NavModal,
|
|
382
408
|
{
|
|
383
|
-
confirmText: formatMessage({
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
409
|
+
confirmText: formatMessage({
|
|
410
|
+
id: getTranslation("modal.navEdit.confirmText"),
|
|
411
|
+
defaultMessage: "Create"
|
|
412
|
+
}),
|
|
413
|
+
closeText: formatMessage({
|
|
414
|
+
id: getTranslation("modal.navEdit.closeText"),
|
|
415
|
+
defaultMessage: "Cancel"
|
|
416
|
+
}),
|
|
417
|
+
titleText: formatMessage({
|
|
418
|
+
id: getTranslation("modal.navEdit.titleText"),
|
|
419
|
+
defaultMessage: "Edit navigation:"
|
|
420
|
+
}) + " " + item.name,
|
|
421
|
+
loadingText: formatMessage({
|
|
422
|
+
id: getTranslation("modal.navEdit.loadingText"),
|
|
423
|
+
defaultMessage: "Updating"
|
|
424
|
+
}),
|
|
387
425
|
onConfirm: updateNav,
|
|
388
426
|
loading,
|
|
389
427
|
disabled: name.trim() === "" || name === initialNavState.name && visible === initialNavState.visible,
|
|
@@ -468,10 +506,18 @@ function NavOverview({ navigations, setActionItem }) {
|
|
|
468
506
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
|
|
469
507
|
/* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: nav.name }),
|
|
470
508
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
471
|
-
/* @__PURE__ */ jsx(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
509
|
+
/* @__PURE__ */ jsx(
|
|
510
|
+
Button,
|
|
511
|
+
{
|
|
512
|
+
startIcon: /* @__PURE__ */ jsx(Trash, {}),
|
|
513
|
+
variant: "danger-light",
|
|
514
|
+
onClick: () => handleDelete(nav),
|
|
515
|
+
children: formatMessage({
|
|
516
|
+
id: getTranslation("delete"),
|
|
517
|
+
defaultMessage: "Delete"
|
|
518
|
+
})
|
|
519
|
+
}
|
|
520
|
+
),
|
|
475
521
|
/* @__PURE__ */ jsx(Button, { startIcon: /* @__PURE__ */ jsx(Pencil, {}), variant: "secondary", onClick: () => handleEdit(nav), children: formatMessage({
|
|
476
522
|
id: getTranslation("edit"),
|
|
477
523
|
defaultMessage: "Edit"
|
|
@@ -491,14 +537,7 @@ function NavOverview({ navigations, setActionItem }) {
|
|
|
491
537
|
)
|
|
492
538
|
] })
|
|
493
539
|
] }, `box-${nav.slug}`),
|
|
494
|
-
navigations.length - 1 !== index && /* @__PURE__ */ jsx(
|
|
495
|
-
Box,
|
|
496
|
-
{
|
|
497
|
-
paddingTop: 2,
|
|
498
|
-
paddingBottom: 2,
|
|
499
|
-
children: /* @__PURE__ */ jsx(Divider, {})
|
|
500
|
-
}
|
|
501
|
-
)
|
|
540
|
+
navigations.length - 1 !== index && /* @__PURE__ */ jsx(Box, { paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsx(Divider, {}) })
|
|
502
541
|
] }, nav.id)) : /* @__PURE__ */ jsx(Center, { height: 100, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
|
|
503
542
|
id: getTranslation("navigation.page.emptyNavigation"),
|
|
504
543
|
defaultMessage: "You have no navigations yet..."
|
|
@@ -596,7 +635,12 @@ function useModalSharedLogic() {
|
|
|
596
635
|
setValidationState("checking");
|
|
597
636
|
dispatchPath({ type: "SET_REPLACEMENT", payload: "" });
|
|
598
637
|
try {
|
|
599
|
-
const data = await duplicateCheck({
|
|
638
|
+
const data = await duplicateCheck({
|
|
639
|
+
fetchFunction: get,
|
|
640
|
+
path: url,
|
|
641
|
+
routeDocumentId,
|
|
642
|
+
withoutTransform
|
|
643
|
+
});
|
|
600
644
|
if (!data || data === url) return;
|
|
601
645
|
dispatchPath({ type: "NO_URL_CHECK", payload: data });
|
|
602
646
|
dispatchPath({ type: "SET_REPLACEMENT", payload: data });
|
|
@@ -660,7 +704,8 @@ function ExternalItemComponent(props) {
|
|
|
660
704
|
}, [variant, item, dispatchNavItemState, dispatchPath]);
|
|
661
705
|
const handleConfirm = async () => {
|
|
662
706
|
try {
|
|
663
|
-
if (!path || path.value?.trim() === "" || !navItemState.title || navItemState.title?.trim() === "" || !selectedNavigation)
|
|
707
|
+
if (!path || path.value?.trim() === "" || !navItemState.title || navItemState.title?.trim() === "" || !selectedNavigation)
|
|
708
|
+
return;
|
|
664
709
|
if (variant === "ExternalEdit" && item && onSave) {
|
|
665
710
|
onSave({
|
|
666
711
|
...item,
|
|
@@ -692,10 +737,28 @@ function ExternalItemComponent(props) {
|
|
|
692
737
|
return /* @__PURE__ */ jsx(
|
|
693
738
|
NavModal,
|
|
694
739
|
{
|
|
695
|
-
confirmText: variant === "ExternalCreate" ? formatMessage({ id: getTranslation("add"), defaultMessage: "Add" }) : formatMessage({
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
740
|
+
confirmText: variant === "ExternalCreate" ? formatMessage({ id: getTranslation("add"), defaultMessage: "Add" }) : formatMessage({
|
|
741
|
+
id: getTranslation("save"),
|
|
742
|
+
defaultMessage: "Save"
|
|
743
|
+
}),
|
|
744
|
+
closeText: formatMessage({
|
|
745
|
+
id: getTranslation("cancel"),
|
|
746
|
+
defaultMessage: "Cancel"
|
|
747
|
+
}),
|
|
748
|
+
titleText: variant === "ExternalCreate" ? formatMessage({
|
|
749
|
+
id: getTranslation("modal.externalItem.titleText.create"),
|
|
750
|
+
defaultMessage: "Create new external item"
|
|
751
|
+
}) : formatMessage({
|
|
752
|
+
id: getTranslation("modal.externalItem.titleText.edit"),
|
|
753
|
+
defaultMessage: `Edit external path "${navItemState.title}"`
|
|
754
|
+
}),
|
|
755
|
+
loadingText: variant === "ExternalCreate" ? formatMessage({
|
|
756
|
+
id: getTranslation("modal.externalItem.loadingText.create"),
|
|
757
|
+
defaultMessage: "Adding"
|
|
758
|
+
}) : formatMessage({
|
|
759
|
+
id: getTranslation("modal.externalItem.loadingText.edit"),
|
|
760
|
+
defaultMessage: "Saving"
|
|
761
|
+
}),
|
|
699
762
|
onConfirm: handleConfirm,
|
|
700
763
|
modalToOpen: "",
|
|
701
764
|
currentModalType: "ExternalCreate",
|
|
@@ -716,7 +779,10 @@ function ExternalItemComponent(props) {
|
|
|
716
779
|
}),
|
|
717
780
|
name: "title",
|
|
718
781
|
value: navItemState.title || "",
|
|
719
|
-
onChange: (e) => dispatchNavItemState({
|
|
782
|
+
onChange: (e) => dispatchNavItemState({
|
|
783
|
+
type: "SET_TITLE",
|
|
784
|
+
payload: e.target.value
|
|
785
|
+
}),
|
|
720
786
|
required: true
|
|
721
787
|
}
|
|
722
788
|
)
|
|
@@ -736,7 +802,10 @@ function ExternalItemComponent(props) {
|
|
|
736
802
|
}),
|
|
737
803
|
name: "slug",
|
|
738
804
|
value: path?.value || "",
|
|
739
|
-
onChange: (e) => dispatchPath({
|
|
805
|
+
onChange: (e) => dispatchPath({
|
|
806
|
+
type: "NO_TRANSFORM_AND_CHECK",
|
|
807
|
+
payload: e.target.value
|
|
808
|
+
})
|
|
740
809
|
}
|
|
741
810
|
)
|
|
742
811
|
] }) }) })
|
|
@@ -773,16 +842,28 @@ function ItemDetails({
|
|
|
773
842
|
if (!navigationItems) return null;
|
|
774
843
|
const targetItem = item || parentNavItem;
|
|
775
844
|
if (!targetItem || typeof targetItem.depth !== "number") return null;
|
|
776
|
-
return buildBreadcrumbString({
|
|
845
|
+
return buildBreadcrumbString({
|
|
846
|
+
navigationItems,
|
|
847
|
+
targetItem,
|
|
848
|
+
includeTarget: modalVariant === "create"
|
|
849
|
+
});
|
|
777
850
|
}, [parentNavItem, navigationItems, item, modalVariant]);
|
|
778
851
|
const navigationWhereRouteExists = useMemo(() => {
|
|
779
852
|
if (!navigations || !route) return false;
|
|
780
|
-
return navigations.find(
|
|
853
|
+
return navigations.find(
|
|
854
|
+
(nav) => nav.items.some(
|
|
855
|
+
(r) => r.route.documentId === route.documentId || r.route.relatedContentType === route.relatedContentType && r.route.relatedDocumentId === route.relatedDocumentId
|
|
856
|
+
)
|
|
857
|
+
);
|
|
781
858
|
}, [navigations, route, navigationItems]);
|
|
782
859
|
useEffect(() => {
|
|
783
860
|
if (path.needsUrlCheck && path.value) {
|
|
784
861
|
if (path.uidPath === path.value || path.initialPath === path.value) return;
|
|
785
|
-
debouncedCheckUrl({
|
|
862
|
+
debouncedCheckUrl({
|
|
863
|
+
url: path.value,
|
|
864
|
+
routeDocumentId: route.documentId,
|
|
865
|
+
withoutTransform: true
|
|
866
|
+
});
|
|
786
867
|
dispatchPath({ type: "RESET_URL_CHECK_FLAG" });
|
|
787
868
|
}
|
|
788
869
|
}, [path.needsUrlCheck, route.documentId]);
|
|
@@ -805,12 +886,15 @@ function ItemDetails({
|
|
|
805
886
|
navigationWhereRouteExists && /* @__PURE__ */ jsx(
|
|
806
887
|
Warning,
|
|
807
888
|
{
|
|
808
|
-
main: formatMessage(
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
889
|
+
main: formatMessage(
|
|
890
|
+
{
|
|
891
|
+
id: getTranslation("modal.item.routeAlreadyUsed"),
|
|
892
|
+
defaultMessage: 'Warning: This route is already used in the navigation "{navigationName}"'
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
navigationName: navigationWhereRouteExists.name
|
|
896
|
+
}
|
|
897
|
+
),
|
|
814
898
|
info: formatMessage({
|
|
815
899
|
id: getTranslation("modal.item.routeAlreadyUsed.info"),
|
|
816
900
|
defaultMessage: "Changing the path for this item will also update the path in the existing item."
|
|
@@ -827,7 +911,10 @@ function ItemDetails({
|
|
|
827
911
|
{
|
|
828
912
|
name: "title",
|
|
829
913
|
value: navItemState?.title || "",
|
|
830
|
-
onChange: (e) => dispatchNavItemState({
|
|
914
|
+
onChange: (e) => dispatchNavItemState({
|
|
915
|
+
type: "SET_TITLE",
|
|
916
|
+
payload: e.target.value
|
|
917
|
+
}),
|
|
831
918
|
required: true
|
|
832
919
|
}
|
|
833
920
|
)
|
|
@@ -838,19 +925,17 @@ function ItemDetails({
|
|
|
838
925
|
id: getTranslation("modal.item.canonicalPathField.label"),
|
|
839
926
|
defaultMessage: "Canonical Path"
|
|
840
927
|
}),
|
|
841
|
-
/* @__PURE__ */ jsx(
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
928
|
+
/* @__PURE__ */ jsx(
|
|
929
|
+
Tooltip,
|
|
930
|
+
{
|
|
931
|
+
description: formatMessage({
|
|
932
|
+
id: getTranslation("modal.item.canonicalPathField.tooltip"),
|
|
933
|
+
defaultMessage: "Based on content hierarchy"
|
|
934
|
+
})
|
|
935
|
+
}
|
|
936
|
+
)
|
|
845
937
|
] }),
|
|
846
|
-
/* @__PURE__ */ jsx(
|
|
847
|
-
Field.Input,
|
|
848
|
-
{
|
|
849
|
-
name: "canonicalPath",
|
|
850
|
-
value: route.canonicalPath || "",
|
|
851
|
-
disabled: true
|
|
852
|
-
}
|
|
853
|
-
),
|
|
938
|
+
/* @__PURE__ */ jsx(Field.Input, { name: "canonicalPath", value: route.canonicalPath || "", disabled: true }),
|
|
854
939
|
/* @__PURE__ */ jsx(Field.Hint, {})
|
|
855
940
|
] }) }) }),
|
|
856
941
|
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, alignItems: "baseline", children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Field.Root, { required: true, children: [
|
|
@@ -875,14 +960,7 @@ function ItemDetails({
|
|
|
875
960
|
id: getTranslation("modal.item.navigationPosition.label"),
|
|
876
961
|
defaultMessage: "Navigation Position"
|
|
877
962
|
}) }),
|
|
878
|
-
/* @__PURE__ */ jsx(
|
|
879
|
-
Field.Input,
|
|
880
|
-
{
|
|
881
|
-
name: "navigationPosition",
|
|
882
|
-
value: breadcrumbString || "Root",
|
|
883
|
-
disabled: true
|
|
884
|
-
}
|
|
885
|
-
)
|
|
963
|
+
/* @__PURE__ */ jsx(Field.Input, { name: "navigationPosition", value: breadcrumbString || "Root", disabled: true })
|
|
886
964
|
] }) }) }),
|
|
887
965
|
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { width: "100%", children: [
|
|
888
966
|
/* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
@@ -890,14 +968,7 @@ function ItemDetails({
|
|
|
890
968
|
id: getTranslation("modal.item.pathField.label"),
|
|
891
969
|
defaultMessage: "Path"
|
|
892
970
|
}) }),
|
|
893
|
-
/* @__PURE__ */ jsx(
|
|
894
|
-
Field.Input,
|
|
895
|
-
{
|
|
896
|
-
name: "path",
|
|
897
|
-
value: path.value,
|
|
898
|
-
disabled: true
|
|
899
|
-
}
|
|
900
|
-
)
|
|
971
|
+
/* @__PURE__ */ jsx(Field.Input, { name: "path", value: path.value, disabled: true })
|
|
901
972
|
] }),
|
|
902
973
|
/* @__PURE__ */ jsx(PathInfo, { validationState, replacement: path.replacement })
|
|
903
974
|
] }) })
|
|
@@ -935,10 +1006,19 @@ function ItemCreateComponent({
|
|
|
935
1006
|
dispatchPath({ type: "NO_URL_CHECK", payload: relatedRoute.path });
|
|
936
1007
|
dispatchPath({ type: "SET_SLUG", payload: relatedRoute.slug });
|
|
937
1008
|
dispatchPath({ type: "SET_INITIALPATH", payload: relatedRoute.path });
|
|
938
|
-
dispatchPath({
|
|
1009
|
+
dispatchPath({
|
|
1010
|
+
type: "SET_CANONICALPATH",
|
|
1011
|
+
payload: relatedRoute.canonicalPath
|
|
1012
|
+
});
|
|
939
1013
|
dispatchNavItemState({ type: "SET_TITLE", payload: relatedRoute.title });
|
|
940
|
-
dispatchNavItemState({
|
|
941
|
-
|
|
1014
|
+
dispatchNavItemState({
|
|
1015
|
+
type: "SET_ACTIVE",
|
|
1016
|
+
payload: relatedRoute.active
|
|
1017
|
+
});
|
|
1018
|
+
dispatchNavItemState({
|
|
1019
|
+
type: "SET_OVERRIDE",
|
|
1020
|
+
payload: relatedRoute.isOverride
|
|
1021
|
+
});
|
|
942
1022
|
setRoute(relatedRoute);
|
|
943
1023
|
} catch (err) {
|
|
944
1024
|
strapi.log.error(err);
|
|
@@ -950,7 +1030,8 @@ function ItemCreateComponent({
|
|
|
950
1030
|
}, [entity]);
|
|
951
1031
|
const addItem = async () => {
|
|
952
1032
|
try {
|
|
953
|
-
if (!selectedContentType?.contentType || !entity?.documentId || !path || !path.value?.trim() || !navItemState.title || !navItemState.title?.trim() || !selectedNavigation || !route)
|
|
1033
|
+
if (!selectedContentType?.contentType || !entity?.documentId || !path || !path.value?.trim() || !navItemState.title || !navItemState.title?.trim() || !selectedNavigation || !route)
|
|
1034
|
+
return;
|
|
954
1035
|
const newItem = createTempNavItemObject({
|
|
955
1036
|
actionItemParentId: actionItemParent?.documentId,
|
|
956
1037
|
entityRoute: route,
|
|
@@ -970,9 +1051,18 @@ function ItemCreateComponent({
|
|
|
970
1051
|
return /* @__PURE__ */ jsx(
|
|
971
1052
|
NavModal,
|
|
972
1053
|
{
|
|
973
|
-
confirmText: formatMessage({
|
|
974
|
-
|
|
975
|
-
|
|
1054
|
+
confirmText: formatMessage({
|
|
1055
|
+
id: getTranslation("add"),
|
|
1056
|
+
defaultMessage: "Add"
|
|
1057
|
+
}),
|
|
1058
|
+
closeText: formatMessage({
|
|
1059
|
+
id: getTranslation("cancel"),
|
|
1060
|
+
defaultMessage: "Cancel"
|
|
1061
|
+
}),
|
|
1062
|
+
titleText: formatMessage({
|
|
1063
|
+
id: getTranslation("modal.internalItem.titleText.create"),
|
|
1064
|
+
defaultMessage: "Add new navigation item"
|
|
1065
|
+
}),
|
|
976
1066
|
footer: /* @__PURE__ */ jsx(Fragment, {}),
|
|
977
1067
|
children: /* @__PURE__ */ jsx(FullLoader, { height: 50 })
|
|
978
1068
|
}
|
|
@@ -981,10 +1071,22 @@ function ItemCreateComponent({
|
|
|
981
1071
|
return /* @__PURE__ */ jsxs(
|
|
982
1072
|
NavModal,
|
|
983
1073
|
{
|
|
984
|
-
confirmText: formatMessage({
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1074
|
+
confirmText: formatMessage({
|
|
1075
|
+
id: getTranslation("add"),
|
|
1076
|
+
defaultMessage: "Add"
|
|
1077
|
+
}),
|
|
1078
|
+
closeText: formatMessage({
|
|
1079
|
+
id: getTranslation("cancel"),
|
|
1080
|
+
defaultMessage: "Cancel"
|
|
1081
|
+
}),
|
|
1082
|
+
titleText: formatMessage({
|
|
1083
|
+
id: getTranslation("modal.internalItem.titleText.create"),
|
|
1084
|
+
defaultMessage: "Add new navigation item"
|
|
1085
|
+
}),
|
|
1086
|
+
loadingText: formatMessage({
|
|
1087
|
+
id: getTranslation("modal.internalItem.loadingText.create"),
|
|
1088
|
+
defaultMessage: "Creating"
|
|
1089
|
+
}),
|
|
988
1090
|
onConfirm: addItem,
|
|
989
1091
|
modalToOpen: "",
|
|
990
1092
|
currentModalType: "ItemCreate",
|
|
@@ -1006,7 +1108,9 @@ function ItemCreateComponent({
|
|
|
1006
1108
|
defaultMessage: "Select a content type"
|
|
1007
1109
|
}),
|
|
1008
1110
|
onChange: (value) => {
|
|
1009
|
-
const [contentType] = availableEntities.filter(
|
|
1111
|
+
const [contentType] = availableEntities.filter(
|
|
1112
|
+
(group) => group.contentType.label === value
|
|
1113
|
+
);
|
|
1010
1114
|
if (contentType) {
|
|
1011
1115
|
setSelectedContentType(contentType);
|
|
1012
1116
|
setEntity(null);
|
|
@@ -1031,14 +1135,16 @@ function ItemCreateComponent({
|
|
|
1031
1135
|
defaultMessage: "Select an entity"
|
|
1032
1136
|
}),
|
|
1033
1137
|
onChange: (value) => {
|
|
1034
|
-
const flatEntities = availableEntities.flatMap(
|
|
1035
|
-
|
|
1138
|
+
const flatEntities = availableEntities.flatMap(
|
|
1139
|
+
(group) => group.entities
|
|
1140
|
+
);
|
|
1141
|
+
const route2 = flatEntities.find(
|
|
1142
|
+
(route3) => route3.documentId === String(value)
|
|
1143
|
+
);
|
|
1036
1144
|
if (route2) setEntity(route2);
|
|
1037
1145
|
},
|
|
1038
1146
|
disabled: !selectedContentType || selectedContentType?.entities && selectedContentType?.entities.length === 0,
|
|
1039
|
-
children: selectedContentType && selectedContentType.entities?.map(
|
|
1040
|
-
(entity2) => /* @__PURE__ */ jsx(SingleSelectOption, { value: entity2.documentId, children: entity2[selectedContentType.contentType.default] }, entity2.id)
|
|
1041
|
-
)
|
|
1147
|
+
children: selectedContentType && selectedContentType.entities?.map((entity2) => /* @__PURE__ */ jsx(SingleSelectOption, { value: entity2.documentId, children: entity2[selectedContentType.contentType.default] }, entity2.id))
|
|
1042
1148
|
}
|
|
1043
1149
|
)
|
|
1044
1150
|
] }) }) })
|
|
@@ -6589,10 +6695,16 @@ function ItemEditComponent({
|
|
|
6589
6695
|
dispatchPath({ type: "DEFAULT", payload: initialPath });
|
|
6590
6696
|
dispatchPath({ type: "SET_SLUG", payload: item.route.slug });
|
|
6591
6697
|
dispatchPath({ type: "SET_INITIALPATH", payload: initialPath });
|
|
6592
|
-
dispatchPath({
|
|
6698
|
+
dispatchPath({
|
|
6699
|
+
type: "SET_CANONICALPATH",
|
|
6700
|
+
payload: item.route.canonicalPath
|
|
6701
|
+
});
|
|
6593
6702
|
dispatchNavItemState({ type: "SET_TITLE", payload: item.route.title });
|
|
6594
6703
|
dispatchNavItemState({ type: "SET_ACTIVE", payload: item.route.active });
|
|
6595
|
-
dispatchNavItemState({
|
|
6704
|
+
dispatchNavItemState({
|
|
6705
|
+
type: "SET_OVERRIDE",
|
|
6706
|
+
payload: item.route.isOverride
|
|
6707
|
+
});
|
|
6596
6708
|
const initialValues = {
|
|
6597
6709
|
title: item.route.title,
|
|
6598
6710
|
active: item.route.active,
|
|
@@ -6603,13 +6715,18 @@ function ItemEditComponent({
|
|
|
6603
6715
|
}, [navigationItems, item, parentNavItem]);
|
|
6604
6716
|
useEffect(() => {
|
|
6605
6717
|
if (!entities) return;
|
|
6606
|
-
const contentType = entities.find(
|
|
6718
|
+
const contentType = entities.find(
|
|
6719
|
+
(group) => group.contentType.uid === item.route.relatedContentType
|
|
6720
|
+
);
|
|
6607
6721
|
if (contentType) setSelectedContentType(contentType);
|
|
6608
6722
|
}, [entities]);
|
|
6609
6723
|
useEffect(() => {
|
|
6610
6724
|
if (path.needsUrlCheck && path.value) {
|
|
6611
6725
|
if (path.uidPath === path.value || path.initialPath === path.value) return;
|
|
6612
|
-
debouncedCheckUrl({
|
|
6726
|
+
debouncedCheckUrl({
|
|
6727
|
+
url: path.value,
|
|
6728
|
+
routeDocumentId: item.route.documentId
|
|
6729
|
+
});
|
|
6613
6730
|
dispatchPath({ type: "RESET_URL_CHECK_FLAG" });
|
|
6614
6731
|
}
|
|
6615
6732
|
}, [path.needsUrlCheck, item.route.documentId]);
|
|
@@ -6636,10 +6753,19 @@ function ItemEditComponent({
|
|
|
6636
6753
|
return /* @__PURE__ */ jsxs(
|
|
6637
6754
|
NavModal,
|
|
6638
6755
|
{
|
|
6639
|
-
confirmText: formatMessage({
|
|
6640
|
-
|
|
6756
|
+
confirmText: formatMessage({
|
|
6757
|
+
id: getTranslation("save"),
|
|
6758
|
+
defaultMessage: "Save"
|
|
6759
|
+
}),
|
|
6760
|
+
closeText: formatMessage({
|
|
6761
|
+
id: getTranslation("cancel"),
|
|
6762
|
+
defaultMessage: "Cancel"
|
|
6763
|
+
}),
|
|
6641
6764
|
titleText: `${formatMessage({ id: getTranslation("edit"), defaultMessage: "Edit" })} ${selectedContentType.contentType.label} "${item.route.title}"`,
|
|
6642
|
-
loadingText: formatMessage({
|
|
6765
|
+
loadingText: formatMessage({
|
|
6766
|
+
id: getTranslation("modal.internalItem.loadingText.edit"),
|
|
6767
|
+
defaultMessage: "Saving"
|
|
6768
|
+
}),
|
|
6643
6769
|
onConfirm: updateItem,
|
|
6644
6770
|
modalToOpen: "",
|
|
6645
6771
|
currentModalType: "ItemCreate",
|
|
@@ -6652,26 +6778,14 @@ function ItemEditComponent({
|
|
|
6652
6778
|
id: getTranslation("modal.internalItem.contentType.label"),
|
|
6653
6779
|
defaultMessage: "Content Type"
|
|
6654
6780
|
}) }),
|
|
6655
|
-
/* @__PURE__ */ jsx(
|
|
6656
|
-
Field.Input,
|
|
6657
|
-
{
|
|
6658
|
-
value: selectedContentType.contentType.label,
|
|
6659
|
-
disabled: true
|
|
6660
|
-
}
|
|
6661
|
-
)
|
|
6781
|
+
/* @__PURE__ */ jsx(Field.Input, { value: selectedContentType.contentType.label, disabled: true })
|
|
6662
6782
|
] }) }) }),
|
|
6663
6783
|
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
6664
6784
|
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
|
6665
6785
|
id: getTranslation("modal.internalItem.entity.label"),
|
|
6666
6786
|
defaultMessage: "Entity"
|
|
6667
6787
|
}) }),
|
|
6668
|
-
/* @__PURE__ */ jsx(
|
|
6669
|
-
Field.Input,
|
|
6670
|
-
{
|
|
6671
|
-
value: `${item.route.relatedId} - ${item.route.title}`,
|
|
6672
|
-
disabled: true
|
|
6673
|
-
}
|
|
6674
|
-
)
|
|
6788
|
+
/* @__PURE__ */ jsx(Field.Input, { value: `${item.route.relatedId} - ${item.route.title}`, disabled: true })
|
|
6675
6789
|
] }) }) })
|
|
6676
6790
|
] }),
|
|
6677
6791
|
item && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -6756,10 +6870,28 @@ function WrapperItemComponent(props) {
|
|
|
6756
6870
|
return /* @__PURE__ */ jsx(
|
|
6757
6871
|
NavModal,
|
|
6758
6872
|
{
|
|
6759
|
-
confirmText: variant === "WrapperCreate" ? formatMessage({ id: getTranslation("add"), defaultMessage: "Add" }) : formatMessage({
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6873
|
+
confirmText: variant === "WrapperCreate" ? formatMessage({ id: getTranslation("add"), defaultMessage: "Add" }) : formatMessage({
|
|
6874
|
+
id: getTranslation("save"),
|
|
6875
|
+
defaultMessage: "Save"
|
|
6876
|
+
}),
|
|
6877
|
+
closeText: formatMessage({
|
|
6878
|
+
id: getTranslation("cancel"),
|
|
6879
|
+
defaultMessage: "Cancel"
|
|
6880
|
+
}),
|
|
6881
|
+
titleText: variant === "WrapperCreate" ? formatMessage({
|
|
6882
|
+
id: getTranslation("modal.wrapperItem.titleText.create"),
|
|
6883
|
+
defaultMessage: "Create new wrapper item"
|
|
6884
|
+
}) : formatMessage({
|
|
6885
|
+
id: getTranslation("modal.wrapperItem.titleText.edit"),
|
|
6886
|
+
defaultMessage: "Edit wrapper item:"
|
|
6887
|
+
}) + ` "${navItemState.title}"`,
|
|
6888
|
+
loadingText: variant === "WrapperCreate" ? formatMessage({
|
|
6889
|
+
id: getTranslation("modal.wrapperItem.loadingText.create"),
|
|
6890
|
+
defaultMessage: "Adding"
|
|
6891
|
+
}) : formatMessage({
|
|
6892
|
+
id: getTranslation("modal.wrapperItem.loadingText.edit"),
|
|
6893
|
+
defaultMessage: "Saving"
|
|
6894
|
+
}),
|
|
6763
6895
|
onConfirm,
|
|
6764
6896
|
modalToOpen: "",
|
|
6765
6897
|
currentModalType: "WrapperCreate",
|
|
@@ -6779,7 +6911,10 @@ function WrapperItemComponent(props) {
|
|
|
6779
6911
|
}),
|
|
6780
6912
|
name: "title",
|
|
6781
6913
|
value: navItemState.title || "",
|
|
6782
|
-
onChange: (e) => dispatchNavItemState({
|
|
6914
|
+
onChange: (e) => dispatchNavItemState({
|
|
6915
|
+
type: "SET_TITLE",
|
|
6916
|
+
payload: e.target.value
|
|
6917
|
+
}),
|
|
6783
6918
|
required: true
|
|
6784
6919
|
}
|
|
6785
6920
|
)
|
|
@@ -6813,7 +6948,10 @@ function getProjection(items, activeId, overId, dragOffset, maxDepthValue) {
|
|
|
6813
6948
|
}
|
|
6814
6949
|
return { depth, maxDepth, minDepth };
|
|
6815
6950
|
}
|
|
6816
|
-
function getMaxDepth({
|
|
6951
|
+
function getMaxDepth({
|
|
6952
|
+
previousItem,
|
|
6953
|
+
maxDepthValue
|
|
6954
|
+
}) {
|
|
6817
6955
|
if (previousItem && typeof previousItem.depth === "number") {
|
|
6818
6956
|
return Math.min(previousItem.depth + 1, maxDepthValue);
|
|
6819
6957
|
}
|
|
@@ -6844,16 +6982,10 @@ function RouteItemMenu({
|
|
|
6844
6982
|
id: getTranslation("edit"),
|
|
6845
6983
|
defaultMessage: "Edit"
|
|
6846
6984
|
}) }),
|
|
6847
|
-
item.route.type === "internal" && viewEntityTo && /* @__PURE__ */ jsx(
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
children: /* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
|
6852
|
-
id: getTranslation("navigation.page.navItem.viewEntity"),
|
|
6853
|
-
defaultMessage: "View Entity"
|
|
6854
|
-
}) })
|
|
6855
|
-
}
|
|
6856
|
-
),
|
|
6985
|
+
item.route.type === "internal" && viewEntityTo && /* @__PURE__ */ jsx(MenuItem, { onClick: () => navigate(viewEntityTo), children: /* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
|
6986
|
+
id: getTranslation("navigation.page.navItem.viewEntity"),
|
|
6987
|
+
defaultMessage: "View Entity"
|
|
6988
|
+
}) }) }),
|
|
6857
6989
|
depth !== void 0 && depth < maxDepth && /* @__PURE__ */ jsx(MenuItem, { onClick: () => handleAddChildren(), children: formatMessage({
|
|
6858
6990
|
id: getTranslation("navigation.page.navItem.addChildren"),
|
|
6859
6991
|
defaultMessage: "Add children"
|
|
@@ -6872,47 +7004,26 @@ function RouteItemStatus({
|
|
|
6872
7004
|
if (!item) return null;
|
|
6873
7005
|
const { formatMessage } = useIntl();
|
|
6874
7006
|
if (item.clientModifications?.type === "create")
|
|
6875
|
-
return /* @__PURE__ */ jsx(
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
textColor: "success600",
|
|
6880
|
-
borderColor: "success200",
|
|
6881
|
-
children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
|
|
6882
|
-
id: getTranslation("new"),
|
|
6883
|
-
defaultMessage: "New"
|
|
6884
|
-
}) })
|
|
6885
|
-
}
|
|
6886
|
-
);
|
|
7007
|
+
return /* @__PURE__ */ jsx(Badge, { backgroundColor: "success100", textColor: "success600", borderColor: "success200", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
|
|
7008
|
+
id: getTranslation("new"),
|
|
7009
|
+
defaultMessage: "New"
|
|
7010
|
+
}) }) });
|
|
6887
7011
|
if (item.clientModifications?.type === "update" || isUpdated)
|
|
6888
|
-
return /* @__PURE__ */ jsx(
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
textColor: "warning600",
|
|
6893
|
-
borderColor: "warning200",
|
|
6894
|
-
children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
|
|
6895
|
-
id: getTranslation("updated"),
|
|
6896
|
-
defaultMessage: "Updated"
|
|
6897
|
-
}) })
|
|
6898
|
-
}
|
|
6899
|
-
);
|
|
7012
|
+
return /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning600", borderColor: "warning200", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
|
|
7013
|
+
id: getTranslation("updated"),
|
|
7014
|
+
defaultMessage: "Updated"
|
|
7015
|
+
}) }) });
|
|
6900
7016
|
if (item.clientModifications?.type === "delete")
|
|
6901
|
-
return /* @__PURE__ */ jsx(
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
textColor: "danger600",
|
|
6906
|
-
borderColor: "danger200",
|
|
6907
|
-
children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
|
|
6908
|
-
id: getTranslation("deleted"),
|
|
6909
|
-
defaultMessage: "Deleted"
|
|
6910
|
-
}) })
|
|
6911
|
-
}
|
|
6912
|
-
);
|
|
7017
|
+
return /* @__PURE__ */ jsx(Badge, { backgroundColor: "danger100", textColor: "danger600", borderColor: "danger200", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
|
|
7018
|
+
id: getTranslation("deleted"),
|
|
7019
|
+
defaultMessage: "Deleted"
|
|
7020
|
+
}) }) });
|
|
6913
7021
|
return null;
|
|
6914
7022
|
}
|
|
6915
|
-
function RouteItemIcon({
|
|
7023
|
+
function RouteItemIcon({
|
|
7024
|
+
type,
|
|
7025
|
+
color = "neutral800"
|
|
7026
|
+
}) {
|
|
6916
7027
|
switch (type) {
|
|
6917
7028
|
case "external":
|
|
6918
7029
|
return /* @__PURE__ */ jsx(ExternalLink, { color });
|
|
@@ -6966,176 +7077,191 @@ function RouteItemBadge({ item }) {
|
|
|
6966
7077
|
}
|
|
6967
7078
|
);
|
|
6968
7079
|
}
|
|
6969
|
-
const RouteItem = forwardRef(
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
const
|
|
6998
|
-
const
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7080
|
+
const RouteItem = forwardRef(
|
|
7081
|
+
({
|
|
7082
|
+
item,
|
|
7083
|
+
initialItem,
|
|
7084
|
+
setActionItemParent,
|
|
7085
|
+
setActionItem,
|
|
7086
|
+
setNavigationItems,
|
|
7087
|
+
ghost,
|
|
7088
|
+
depth,
|
|
7089
|
+
maxDepth,
|
|
7090
|
+
style,
|
|
7091
|
+
wrapperRef,
|
|
7092
|
+
handleProps,
|
|
7093
|
+
navigationItems
|
|
7094
|
+
}, ref) => {
|
|
7095
|
+
const { setModalType } = useContext(ModalContext);
|
|
7096
|
+
const parentNavItem = useMemo(
|
|
7097
|
+
() => findParentNavItem({
|
|
7098
|
+
navigationItems,
|
|
7099
|
+
targetItem: item,
|
|
7100
|
+
onlyInternalItems: true
|
|
7101
|
+
}),
|
|
7102
|
+
[navigationItems, item]
|
|
7103
|
+
);
|
|
7104
|
+
const hasStructureChanges = useMemo(() => {
|
|
7105
|
+
if (!initialItem) return false;
|
|
7106
|
+
return initialItem.order !== item.order || initialItem.depth !== item.depth;
|
|
7107
|
+
}, [initialItem, item.order, item.depth]);
|
|
7108
|
+
const isUpdated = item.clientModifications?.type === "update" || hasStructureChanges;
|
|
7109
|
+
const itemPath = useMemo(() => {
|
|
7110
|
+
if (!item.route) return "";
|
|
7111
|
+
if (item.route.type !== "internal") return item.route.path;
|
|
7112
|
+
const parentPath = parentNavItem ? `${parentNavItem.clientModifications?.path || parentNavItem.route.path}/` : "";
|
|
7113
|
+
const itemSlug = item.clientModifications?.slug || item.route.slug;
|
|
7114
|
+
return `${parentPath}${itemSlug}`;
|
|
7115
|
+
}, [item, parentNavItem, isUpdated]);
|
|
7116
|
+
const updateNavItem = (navItems) => {
|
|
7117
|
+
if (!navItems) return navItems;
|
|
7118
|
+
return navItems.map((navItem) => {
|
|
7119
|
+
if (navItem.documentId === item.documentId) {
|
|
7120
|
+
if (navItem.clientModifications?.path === itemPath) {
|
|
7121
|
+
return navItem;
|
|
7122
|
+
}
|
|
7123
|
+
return {
|
|
7124
|
+
...navItem,
|
|
7125
|
+
clientModifications: navItem.clientModifications ? {
|
|
7126
|
+
...navItem.clientModifications,
|
|
7127
|
+
path: itemPath
|
|
7128
|
+
} : {
|
|
7129
|
+
type: "update",
|
|
7130
|
+
path: itemPath,
|
|
7131
|
+
autoGenerated: true
|
|
7132
|
+
}
|
|
7133
|
+
};
|
|
7007
7134
|
}
|
|
7008
|
-
return
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
type: "update",
|
|
7015
|
-
path: itemPath,
|
|
7016
|
-
autoGenerated: true
|
|
7017
|
-
}
|
|
7018
|
-
};
|
|
7019
|
-
}
|
|
7020
|
-
return navItem;
|
|
7021
|
-
});
|
|
7022
|
-
};
|
|
7023
|
-
const removeNavItemModifications = (navItems) => {
|
|
7024
|
-
if (!navItems) return navItems;
|
|
7025
|
-
return navItems.map((navItem) => {
|
|
7026
|
-
if (navItem.documentId === item.documentId) {
|
|
7027
|
-
const { clientModifications, ...rest } = navItem;
|
|
7028
|
-
return rest;
|
|
7029
|
-
}
|
|
7030
|
-
return navItem;
|
|
7031
|
-
});
|
|
7032
|
-
};
|
|
7033
|
-
useEffect(() => {
|
|
7034
|
-
if (item.route?.type !== "internal") return;
|
|
7035
|
-
const shouldSyncPath = item.clientModifications?.path !== itemPath && (item.clientModifications?.type === "update" || itemPath !== item.route.path);
|
|
7036
|
-
if (shouldSyncPath) {
|
|
7037
|
-
setNavigationItems(updateNavItem);
|
|
7038
|
-
}
|
|
7039
|
-
}, [itemPath, item.documentId, item.route?.type, item.route?.path, item.clientModifications?.type, item.clientModifications?.path, setNavigationItems]);
|
|
7040
|
-
useEffect(() => {
|
|
7041
|
-
if (item.route?.type !== "internal") return;
|
|
7042
|
-
const canBeRemoved = item.clientModifications?.autoGenerated && item.route.path === itemPath && !hasStructureChanges;
|
|
7043
|
-
if (canBeRemoved) {
|
|
7044
|
-
setNavigationItems(removeNavItemModifications);
|
|
7045
|
-
}
|
|
7046
|
-
}, [itemPath, item.documentId, item.route?.type, item.route?.path, item.clientModifications?.autoGenerated, hasStructureChanges, setNavigationItems]);
|
|
7047
|
-
const handleAddChildren = () => {
|
|
7048
|
-
setActionItemParent(item);
|
|
7049
|
-
setModalType("ItemCreate");
|
|
7050
|
-
};
|
|
7051
|
-
const handleEdit = () => {
|
|
7052
|
-
setActionItem(item);
|
|
7053
|
-
let newModal = "ItemEdit";
|
|
7054
|
-
if (item.route.type === "external") newModal = "ExternalEdit";
|
|
7055
|
-
if (item.route.type === "wrapper") newModal = "WrapperEdit";
|
|
7056
|
-
setModalType(newModal);
|
|
7057
|
-
};
|
|
7058
|
-
const handleDelete = () => {
|
|
7059
|
-
setActionItem(item);
|
|
7060
|
-
setModalType("ItemDelete");
|
|
7061
|
-
};
|
|
7062
|
-
const handleRestore = () => {
|
|
7063
|
-
setNavigationItems(
|
|
7064
|
-
(navItems) => navItems?.map((navItem) => {
|
|
7135
|
+
return navItem;
|
|
7136
|
+
});
|
|
7137
|
+
};
|
|
7138
|
+
const removeNavItemModifications = (navItems) => {
|
|
7139
|
+
if (!navItems) return navItems;
|
|
7140
|
+
return navItems.map((navItem) => {
|
|
7065
7141
|
if (navItem.documentId === item.documentId) {
|
|
7066
|
-
const { clientModifications
|
|
7067
|
-
return
|
|
7142
|
+
const { clientModifications, ...rest } = navItem;
|
|
7143
|
+
return rest;
|
|
7068
7144
|
}
|
|
7069
7145
|
return navItem;
|
|
7070
|
-
})
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7146
|
+
});
|
|
7147
|
+
};
|
|
7148
|
+
useEffect(() => {
|
|
7149
|
+
if (item.route?.type !== "internal") return;
|
|
7150
|
+
const shouldSyncPath = item.clientModifications?.path !== itemPath && (item.clientModifications?.type === "update" || itemPath !== item.route.path);
|
|
7151
|
+
if (shouldSyncPath) {
|
|
7152
|
+
setNavigationItems(updateNavItem);
|
|
7153
|
+
}
|
|
7154
|
+
}, [
|
|
7155
|
+
itemPath,
|
|
7156
|
+
item.documentId,
|
|
7157
|
+
item.route?.type,
|
|
7158
|
+
item.route?.path,
|
|
7159
|
+
item.clientModifications?.type,
|
|
7160
|
+
item.clientModifications?.path,
|
|
7161
|
+
setNavigationItems
|
|
7162
|
+
]);
|
|
7163
|
+
useEffect(() => {
|
|
7164
|
+
if (item.route?.type !== "internal") return;
|
|
7165
|
+
const canBeRemoved = item.clientModifications?.autoGenerated && item.route.path === itemPath && !hasStructureChanges;
|
|
7166
|
+
if (canBeRemoved) {
|
|
7167
|
+
setNavigationItems(removeNavItemModifications);
|
|
7168
|
+
}
|
|
7169
|
+
}, [
|
|
7170
|
+
itemPath,
|
|
7171
|
+
item.documentId,
|
|
7172
|
+
item.route?.type,
|
|
7173
|
+
item.route?.path,
|
|
7174
|
+
item.clientModifications?.autoGenerated,
|
|
7175
|
+
hasStructureChanges,
|
|
7176
|
+
setNavigationItems
|
|
7177
|
+
]);
|
|
7178
|
+
const handleAddChildren = () => {
|
|
7179
|
+
setActionItemParent(item);
|
|
7180
|
+
setModalType("ItemCreate");
|
|
7181
|
+
};
|
|
7182
|
+
const handleEdit = () => {
|
|
7183
|
+
setActionItem(item);
|
|
7184
|
+
let newModal = "ItemEdit";
|
|
7185
|
+
if (item.route.type === "external") newModal = "ExternalEdit";
|
|
7186
|
+
if (item.route.type === "wrapper") newModal = "WrapperEdit";
|
|
7187
|
+
setModalType(newModal);
|
|
7188
|
+
};
|
|
7189
|
+
const handleDelete = () => {
|
|
7190
|
+
setActionItem(item);
|
|
7191
|
+
setModalType("ItemDelete");
|
|
7192
|
+
};
|
|
7193
|
+
const handleRestore = () => {
|
|
7194
|
+
setNavigationItems(
|
|
7195
|
+
(navItems) => navItems?.map((navItem) => {
|
|
7196
|
+
if (navItem.documentId === item.documentId) {
|
|
7197
|
+
const { clientModifications: _, ...rest } = navItem;
|
|
7198
|
+
return navItem.initialClientModifications ? {
|
|
7199
|
+
...rest,
|
|
7200
|
+
clientModifications: navItem.initialClientModifications
|
|
7201
|
+
} : rest;
|
|
7202
|
+
}
|
|
7203
|
+
return navItem;
|
|
7204
|
+
})
|
|
7205
|
+
);
|
|
7206
|
+
};
|
|
7207
|
+
const elStyle = {
|
|
7208
|
+
marginLeft: depth !== void 0 ? depth * 48 : 0,
|
|
7209
|
+
opacity: ghost || item.clientModifications?.type === "delete" ? 0.5 : 1,
|
|
7210
|
+
...style
|
|
7211
|
+
};
|
|
7212
|
+
if (!item || !item.route) return null;
|
|
7213
|
+
return /* @__PURE__ */ jsx(Box, { ref: wrapperRef, style: elStyle, children: /* @__PURE__ */ jsx(
|
|
7214
|
+
Box,
|
|
7215
|
+
{
|
|
7216
|
+
background: "neutral0",
|
|
7217
|
+
borderColor: item.clientModifications?.type === "delete" ? "danger500" : "neutral150",
|
|
7218
|
+
hasRadius: true,
|
|
7219
|
+
paddingBottom: 4,
|
|
7220
|
+
paddingLeft: 4,
|
|
7221
|
+
paddingRight: 4,
|
|
7222
|
+
paddingTop: 4,
|
|
7223
|
+
shadow: "tableShadow",
|
|
7224
|
+
ref,
|
|
7225
|
+
children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
|
|
7226
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 4, children: [
|
|
7227
|
+
/* @__PURE__ */ jsx(Drag, { color: "neutral800", ...handleProps }),
|
|
7228
|
+
/* @__PURE__ */ jsx(Box, { width: "1px", height: "32px", background: "neutral150" }),
|
|
7229
|
+
/* @__PURE__ */ jsx(RouteItemIcon, { type: item.route.type }),
|
|
7230
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
7231
|
+
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: item.clientModifications?.title ? item.clientModifications.title : item.route.title }),
|
|
7232
|
+
itemPath && /* @__PURE__ */ jsxs(Typography, { textColor: "neutral400", children: [
|
|
7233
|
+
"/",
|
|
7234
|
+
itemPath
|
|
7235
|
+
] })
|
|
7116
7236
|
] }),
|
|
7117
|
-
/* @__PURE__ */
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7237
|
+
/* @__PURE__ */ jsx(RouteItemStatus, { item, isUpdated: hasStructureChanges })
|
|
7238
|
+
] }),
|
|
7239
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "row", gap: 4, children: [
|
|
7240
|
+
/* @__PURE__ */ jsx(RouteItemBadge, { item }),
|
|
7241
|
+
/* @__PURE__ */ jsx(
|
|
7242
|
+
RouteItemMenu,
|
|
7243
|
+
{
|
|
7244
|
+
item,
|
|
7245
|
+
depth,
|
|
7246
|
+
maxDepth,
|
|
7247
|
+
handleEdit,
|
|
7248
|
+
handleAddChildren,
|
|
7249
|
+
handleDelete,
|
|
7250
|
+
handleRestore
|
|
7251
|
+
}
|
|
7252
|
+
)
|
|
7132
7253
|
] })
|
|
7133
|
-
}
|
|
7134
|
-
|
|
7135
|
-
}
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
function SortableRouteItem({
|
|
7254
|
+
] })
|
|
7255
|
+
}
|
|
7256
|
+
) });
|
|
7257
|
+
}
|
|
7258
|
+
);
|
|
7259
|
+
function SortableRouteItem({
|
|
7260
|
+
item,
|
|
7261
|
+
depth,
|
|
7262
|
+
setNavigationItems,
|
|
7263
|
+
...props
|
|
7264
|
+
}) {
|
|
7139
7265
|
if (!item) return null;
|
|
7140
7266
|
const {
|
|
7141
7267
|
isDragging,
|
|
@@ -7168,7 +7294,11 @@ function SortableRouteItem({ item, depth, setNavigationItems, ...props }) {
|
|
|
7168
7294
|
}
|
|
7169
7295
|
);
|
|
7170
7296
|
}
|
|
7171
|
-
function PageWrapper({
|
|
7297
|
+
function PageWrapper({
|
|
7298
|
+
navigations,
|
|
7299
|
+
loading = false,
|
|
7300
|
+
children
|
|
7301
|
+
}) {
|
|
7172
7302
|
const { formatMessage } = useIntl();
|
|
7173
7303
|
const { selectedNavigation } = useContext(SelectedNavigationContext);
|
|
7174
7304
|
const { setModalType } = useContext(ModalContext);
|
|
@@ -9047,13 +9177,15 @@ const Navigation = () => {
|
|
|
9047
9177
|
}, [modalType]);
|
|
9048
9178
|
useEffect(() => {
|
|
9049
9179
|
if (!selectedNavigation || !navigationItems) return;
|
|
9050
|
-
setNavigations(
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9180
|
+
setNavigations(
|
|
9181
|
+
navigations.map((nav) => {
|
|
9182
|
+
if (nav.documentId !== selectedNavigation.documentId) return nav;
|
|
9183
|
+
return {
|
|
9184
|
+
...nav,
|
|
9185
|
+
items: navigationItems
|
|
9186
|
+
};
|
|
9187
|
+
})
|
|
9188
|
+
);
|
|
9057
9189
|
}, [setNavigations, navigationItems, selectedNavigation]);
|
|
9058
9190
|
useEffect(() => {
|
|
9059
9191
|
if (!activeId || !navigationItems) return;
|
|
@@ -9062,7 +9194,9 @@ const Navigation = () => {
|
|
|
9062
9194
|
}, [navigationItems, activeId]);
|
|
9063
9195
|
function handleSoftAddedItem(newItem) {
|
|
9064
9196
|
if (newItem.clientModifications?.parent) {
|
|
9065
|
-
const parentIndex = navigationItems?.findIndex(
|
|
9197
|
+
const parentIndex = navigationItems?.findIndex(
|
|
9198
|
+
(item) => item.documentId === newItem.clientModifications?.parent
|
|
9199
|
+
);
|
|
9066
9200
|
if (parentIndex !== void 0 && parentIndex >= 0) {
|
|
9067
9201
|
const parentDepth = navigationItems ? navigationItems[parentIndex].depth || 0 : 0;
|
|
9068
9202
|
newItem.depth = parentDepth + 1;
|
|
@@ -9162,10 +9296,18 @@ const Navigation = () => {
|
|
|
9162
9296
|
return /* @__PURE__ */ jsx(ModalContext.Provider, { value: { modalType, setModalType }, children: /* @__PURE__ */ jsxs(SelectedNavigationContext.Provider, { value: { selectedNavigation, setSelectedNavigation }, children: [
|
|
9163
9297
|
/* @__PURE__ */ jsxs(PageWrapper, { navigations, children: [
|
|
9164
9298
|
selectedNavigation && /* @__PURE__ */ jsxs(Flex, { gap: 4, paddingBottom: 6, justifyContent: "flex-end", children: [
|
|
9165
|
-
/* @__PURE__ */ jsx(
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9299
|
+
/* @__PURE__ */ jsx(
|
|
9300
|
+
Button,
|
|
9301
|
+
{
|
|
9302
|
+
variant: "secondary",
|
|
9303
|
+
startIcon: /* @__PURE__ */ jsx(Plus, {}),
|
|
9304
|
+
onClick: () => setModalType("ItemCreate"),
|
|
9305
|
+
children: formatMessage({
|
|
9306
|
+
id: getTranslation("navigation.page.newItemButton"),
|
|
9307
|
+
defaultMessage: "New Item"
|
|
9308
|
+
})
|
|
9309
|
+
}
|
|
9310
|
+
),
|
|
9169
9311
|
/* @__PURE__ */ jsx(
|
|
9170
9312
|
Button,
|
|
9171
9313
|
{
|
|
@@ -9193,7 +9335,9 @@ const Navigation = () => {
|
|
|
9193
9335
|
measuring,
|
|
9194
9336
|
children: /* @__PURE__ */ jsxs(SortableContext, { items: navigationItems, strategy: verticalListSortingStrategy, children: [
|
|
9195
9337
|
navigationItems.map((item, index) => {
|
|
9196
|
-
const initialItem = initialNavigationItemsRef.current?.find(
|
|
9338
|
+
const initialItem = initialNavigationItemsRef.current?.find(
|
|
9339
|
+
(i) => i.documentId === item.documentId
|
|
9340
|
+
);
|
|
9197
9341
|
return config?.navigation.maxDepth && /* @__PURE__ */ jsx(
|
|
9198
9342
|
SortableRouteItem,
|
|
9199
9343
|
{
|
|
@@ -9228,10 +9372,15 @@ const Navigation = () => {
|
|
|
9228
9372
|
}
|
|
9229
9373
|
) }),
|
|
9230
9374
|
navigations?.length === 0 && /* @__PURE__ */ jsxs(Center, { height: 400, children: [
|
|
9231
|
-
/* @__PURE__ */ jsx(
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9375
|
+
/* @__PURE__ */ jsx(
|
|
9376
|
+
EmptyBox,
|
|
9377
|
+
{
|
|
9378
|
+
msg: formatMessage({
|
|
9379
|
+
id: getTranslation("navigation.page.emptyNavigation"),
|
|
9380
|
+
defaultMessage: "You have no navigations yet..."
|
|
9381
|
+
})
|
|
9382
|
+
}
|
|
9383
|
+
),
|
|
9235
9384
|
/* @__PURE__ */ jsx(Button, { variant: "default", onClick: () => setModalType("NavCreate"), children: formatMessage({
|
|
9236
9385
|
id: getTranslation("navigation.page.createNewNavigation"),
|
|
9237
9386
|
defaultMessage: "Create new navigation"
|
|
@@ -9245,13 +9394,7 @@ const Navigation = () => {
|
|
|
9245
9394
|
}) })
|
|
9246
9395
|
] })
|
|
9247
9396
|
] }),
|
|
9248
|
-
modalType === "NavOverview" && /* @__PURE__ */ jsx(
|
|
9249
|
-
NavOverview,
|
|
9250
|
-
{
|
|
9251
|
-
navigations,
|
|
9252
|
-
setActionItem
|
|
9253
|
-
}
|
|
9254
|
-
),
|
|
9397
|
+
modalType === "NavOverview" && /* @__PURE__ */ jsx(NavOverview, { navigations, setActionItem }),
|
|
9255
9398
|
modalType === "NavCreate" && /* @__PURE__ */ jsx(NavCreate, {}),
|
|
9256
9399
|
modalType === "NavDelete" && /* @__PURE__ */ jsx(
|
|
9257
9400
|
Delete,
|
|
@@ -9366,4 +9509,3 @@ const App = () => {
|
|
|
9366
9509
|
export {
|
|
9367
9510
|
App as default
|
|
9368
9511
|
};
|
|
9369
|
-
//# sourceMappingURL=index-BIEUXWe7.mjs.map
|