@mattisvensson/strapi-plugin-webatlas 0.11.9 → 0.12.1

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 (31) hide show
  1. package/README.md +6 -2
  2. package/dist/admin/{FullLoader-Btjb2W2p.mjs → FullLoader-BTZzPY8g.mjs} +11 -1
  3. package/dist/admin/{FullLoader-Da2n70bJ.js → FullLoader-C4hXFaLP.js} +10 -0
  4. package/dist/admin/{RoutePicker-D9RNp4zS.js → RoutePicker-C3_tzz9U.js} +1 -1
  5. package/dist/admin/{RoutePicker-p1rh5rcZ.mjs → RoutePicker-IRZiHKFi.mjs} +1 -1
  6. package/dist/admin/{SettingTitle-BMHyfLrM.mjs → SettingTitle-0mKlA80i.mjs} +1 -1
  7. package/dist/admin/{SettingTitle-CwB5CsY0.js → SettingTitle-Ib_0AvoZ.js} +1 -1
  8. package/dist/admin/WarningBox-BZ3BZ5fR.js +41 -0
  9. package/dist/admin/WarningBox-CXEmXfVx.mjs +42 -0
  10. package/dist/admin/{de-B5pRvs13.mjs → de-BFjenpyN.mjs} +16 -1
  11. package/dist/admin/{de-CqU1FU8C.js → de-DhwCZE_m.js} +16 -1
  12. package/dist/admin/{en-C7I90FwV.js → en-C-rPCNd2.js} +16 -1
  13. package/dist/admin/{en-BE-zzIv8.mjs → en-CGCh9ld_.mjs} +16 -1
  14. package/dist/admin/index-88JTX1Mj.js +480 -0
  15. package/dist/admin/{index-zr90q-6H.js → index-BPUJTNed.js} +178 -85
  16. package/dist/admin/{index-BE6CLx3P.mjs → index-BY6JLZrD.mjs} +180 -87
  17. package/dist/admin/index-Bym1mXg1.mjs +480 -0
  18. package/dist/admin/{index-G7qx6Oy7.mjs → index-ByxM39aL.mjs} +170 -132
  19. package/dist/admin/{index-zskvsDgF.js → index-CEJBltoJ.js} +21 -13
  20. package/dist/admin/{index-DpS40t3Q.mjs → index-CNCyng5O.mjs} +21 -13
  21. package/dist/admin/{index-CFf370lR.js → index-CsKnBzp6.js} +169 -131
  22. package/dist/admin/{index-LNTPJt5H.js → index-DNBXz42q.js} +13 -8
  23. package/dist/admin/{index-IxsV1TAn.mjs → index-PD3gcnXA.mjs} +13 -8
  24. package/dist/admin/index.js +1 -1
  25. package/dist/admin/index.mjs +2 -2
  26. package/dist/server/index.js +484 -494
  27. package/dist/server/index.mjs +497 -507
  28. package/dist/server/src/index.d.ts +48 -5
  29. package/package.json +1 -1
  30. package/dist/admin/index-Df1hDvta.js +0 -243
  31. package/dist/admin/index-Z6ahaWtf.mjs +0 -243
@@ -7,33 +7,14 @@ const designSystem = require("@strapi/design-system");
7
7
  const React = require("react");
8
8
  const ReactDOM = require("react-dom");
9
9
  const reactIntl = require("react-intl");
10
- const index = require("./index-CFf370lR.js");
10
+ const index = require("./index-CsKnBzp6.js");
11
+ const FullLoader = require("./FullLoader-C4hXFaLP.js");
11
12
  const admin = require("@strapi/strapi/admin");
12
- const FullLoader = require("./FullLoader-Da2n70bJ.js");
13
13
  const symbols = require("@strapi/icons/symbols");
14
+ const WarningBox = require("./WarningBox-BZ3BZ5fR.js");
14
15
  const core = require("@dnd-kit/core");
15
16
  const sortable = require("@dnd-kit/sortable");
16
17
  const utilities = require("@dnd-kit/utilities");
17
- const useAllEntities = () => {
18
- const { fetchAllEntities } = index.useApi();
19
- const [entities, setEntities] = React.useState([]);
20
- const [loading, setLoading] = React.useState(true);
21
- const [error, setError] = React.useState(null);
22
- React.useEffect(() => {
23
- const fetchEntities = async () => {
24
- try {
25
- const result = await fetchAllEntities();
26
- setEntities(result);
27
- setLoading(false);
28
- } catch (err) {
29
- setError(err);
30
- setLoading(false);
31
- }
32
- };
33
- fetchEntities();
34
- }, []);
35
- return { entities, loading, error };
36
- };
37
18
  function createTempNavItemObject({
38
19
  actionItemParentId,
39
20
  entityRoute,
@@ -156,7 +137,11 @@ function Delete({ variant, item, onDelete }) {
156
137
  const { setModalType } = React.useContext(ModalContext);
157
138
  const { formatMessage } = reactIntl.useIntl();
158
139
  const { deleteNavigation } = index.useApi();
140
+ const { toggleNotification } = admin.useNotification();
141
+ const getErrorMessage = FullLoader.useErrorMessage();
142
+ const [isDeleting, setIsDeleting] = React.useState(false);
159
143
  const handleDelete = async () => {
144
+ setIsDeleting(true);
160
145
  try {
161
146
  if (variant === "NavDelete") {
162
147
  await deleteNavigation(item.documentId);
@@ -172,7 +157,18 @@ function Delete({ variant, item, onDelete }) {
172
157
  onDelete(editedItem);
173
158
  }
174
159
  } catch (err) {
175
- strapi.log.error(err);
160
+ if (index.isAbortError(err)) return;
161
+ console.error(err);
162
+ toggleNotification({
163
+ type: "danger",
164
+ message: getErrorMessage(
165
+ err,
166
+ formatMessage({
167
+ id: index.getTranslation("notification.navigation.deleteFailed"),
168
+ defaultMessage: "Deleting failed"
169
+ })
170
+ )
171
+ });
176
172
  }
177
173
  setModalType(closeModalState.current);
178
174
  };
@@ -227,10 +223,22 @@ function Delete({ variant, item, onDelete }) {
227
223
  id: index.getTranslation("modal.delete.cancelText"),
228
224
  defaultMessage: "No, keep"
229
225
  }) }) }),
230
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Action, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "danger-light", onClick: () => handleDelete(), startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}), children: formatMessage({
231
- id: index.getTranslation("modal.delete.confirmText"),
232
- defaultMessage: "Yes, delete"
233
- }) }) })
226
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Action, { children: /* @__PURE__ */ jsxRuntime.jsx(
227
+ designSystem.Button,
228
+ {
229
+ variant: "danger-light",
230
+ disabled: isDeleting,
231
+ onClick: (e) => {
232
+ e.preventDefault();
233
+ handleDelete();
234
+ },
235
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}),
236
+ children: formatMessage({
237
+ id: index.getTranslation("modal.delete.confirmText"),
238
+ defaultMessage: "Yes, delete"
239
+ })
240
+ }
241
+ ) })
234
242
  ] })
235
243
  ] })
236
244
  }
@@ -318,6 +326,7 @@ function NavCreate() {
318
326
  const { toggleNotification } = admin.useNotification();
319
327
  const navigate = reactRouterDom.useNavigate();
320
328
  const { createNavigation } = index.useApi();
329
+ const getErrorMessage = FullLoader.useErrorMessage();
321
330
  const onConfirm = async () => {
322
331
  setLoading(true);
323
332
  try {
@@ -326,13 +335,16 @@ function NavCreate() {
326
335
  navigate(`/plugins/${index.PLUGIN_ID}/navigation/${data.documentId}`);
327
336
  setModalType("");
328
337
  } catch (err) {
329
- strapi.log.error(err);
338
+ console.error(err);
330
339
  toggleNotification({
331
340
  type: "danger",
332
- message: formatMessage({
333
- id: index.getTranslation("notification.navigation.creationFailed"),
334
- defaultMessage: "Creation of navigation failed"
335
- })
341
+ message: getErrorMessage(
342
+ err,
343
+ formatMessage({
344
+ id: index.getTranslation("notification.navigation.creationFailed"),
345
+ defaultMessage: "Creation of navigation failed"
346
+ })
347
+ )
336
348
  });
337
349
  } finally {
338
350
  setLoading(false);
@@ -385,6 +397,7 @@ function NavEdit({ item, onEdit }) {
385
397
  const { updateNavigation } = index.useApi();
386
398
  const { formatMessage } = reactIntl.useIntl();
387
399
  const { toggleNotification } = admin.useNotification();
400
+ const getErrorMessage = FullLoader.useErrorMessage();
388
401
  const initialNavState = { name: item.name, visible: item.visible };
389
402
  const updateNav = async () => {
390
403
  setLoading(true);
@@ -393,13 +406,16 @@ function NavEdit({ item, onEdit }) {
393
406
  setModalType("NavOverview");
394
407
  onEdit({ ...item, name, visible });
395
408
  } catch (err) {
396
- strapi.log.error(err);
409
+ console.error(err);
397
410
  toggleNotification({
398
411
  type: "danger",
399
- message: formatMessage({
400
- id: index.getTranslation("notification.navigation.updateFailed"),
401
- defaultMessage: "Updating navigation failed"
402
- })
412
+ message: getErrorMessage(
413
+ err,
414
+ formatMessage({
415
+ id: index.getTranslation("notification.navigation.updateFailed"),
416
+ defaultMessage: "Updating navigation failed"
417
+ })
418
+ )
403
419
  });
404
420
  } finally {
405
421
  setLoading(false);
@@ -601,11 +617,12 @@ function pathReducer(state, action) {
601
617
  function useModalSharedLogic() {
602
618
  const [selectedContentType, setSelectedContentType] = React.useState();
603
619
  const [validationState, setValidationState] = React.useState("initial");
604
- const { entities } = useAllEntities();
620
+ const [isBlacklisted, setIsBlacklisted] = React.useState(false);
621
+ const { entities } = WarningBox.useAllEntities();
605
622
  const { get } = admin.useFetchClient();
606
623
  const availableEntities = React.useMemo(() => {
607
624
  if (!entities) return [];
608
- return entities;
625
+ return entities.filter((group) => group.contentType.routeSourceField);
609
626
  }, [entities]);
610
627
  const initialState = React.useRef({
611
628
  title: "",
@@ -626,6 +643,7 @@ function useModalSharedLogic() {
626
643
  initialPath: ""
627
644
  });
628
645
  const debouncedCheckUrl = React.useCallback(index.debounce(checkUrl, 500), []);
646
+ const debouncedCheckBlacklist = React.useCallback(index.debounce(checkBlacklist, 500), []);
629
647
  const { modalType, setModalType } = React.useContext(ModalContext);
630
648
  const { selectedNavigation } = React.useContext(SelectedNavigationContext);
631
649
  async function checkUrl({
@@ -637,21 +655,39 @@ function useModalSharedLogic() {
637
655
  setValidationState("checking");
638
656
  dispatchPath({ type: "SET_REPLACEMENT", payload: "" });
639
657
  try {
640
- const data = await index.duplicateCheck({
658
+ const { uniquePath, blacklisted } = await index.duplicateCheck({
641
659
  fetchFunction: get,
642
660
  path: url,
643
661
  routeDocumentId,
644
662
  withoutTransform
645
663
  });
646
- if (!data || data === url) return;
647
- dispatchPath({ type: "NO_URL_CHECK", payload: data });
648
- dispatchPath({ type: "SET_REPLACEMENT", payload: data });
664
+ setIsBlacklisted(blacklisted);
665
+ if (blacklisted) return;
666
+ if (!uniquePath || uniquePath === url) return;
667
+ dispatchPath({ type: "NO_URL_CHECK", payload: uniquePath });
668
+ dispatchPath({ type: "SET_REPLACEMENT", payload: uniquePath });
649
669
  } catch (err) {
650
- strapi.log.error(err);
670
+ console.error(err);
651
671
  } finally {
652
672
  setValidationState("done");
653
673
  }
654
674
  }
675
+ async function checkBlacklist({ url }) {
676
+ if (!url) {
677
+ setIsBlacklisted(false);
678
+ return;
679
+ }
680
+ try {
681
+ const { blacklisted } = await index.duplicateCheck({
682
+ fetchFunction: get,
683
+ path: url,
684
+ withoutTransform: true
685
+ });
686
+ setIsBlacklisted(blacklisted);
687
+ } catch (err) {
688
+ console.error(err);
689
+ }
690
+ }
655
691
  const modalSharedLogic = {
656
692
  availableEntities,
657
693
  selectedContentType,
@@ -659,12 +695,14 @@ function useModalSharedLogic() {
659
695
  entities,
660
696
  validationState,
661
697
  setValidationState,
698
+ isBlacklisted,
662
699
  initialState,
663
700
  navItemState,
664
701
  dispatchNavItemState,
665
702
  path,
666
703
  dispatchPath,
667
704
  debouncedCheckUrl,
705
+ debouncedCheckBlacklist,
668
706
  modalType,
669
707
  setModalType,
670
708
  selectedNavigation
@@ -733,7 +771,7 @@ function ExternalItemComponent(props) {
733
771
  }
734
772
  setModalType("");
735
773
  } catch (err) {
736
- strapi.log.error(err);
774
+ console.error(err);
737
775
  }
738
776
  };
739
777
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -816,25 +854,18 @@ function ExternalItemComponent(props) {
816
854
  );
817
855
  }
818
856
  const ExternalItem = withModalSharedLogic(ExternalItemComponent);
819
- function Warning({ main, info }) {
820
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, s: 12, alignItems: "baseline", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { variant: "warning", minWidth: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 2, children: [
821
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, children: [
822
- /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, {}),
823
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: main })
824
- ] }),
825
- info && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: info })
826
- ] }) }) });
827
- }
828
857
  function ItemDetails({
829
858
  navItemState,
830
859
  dispatchNavItemState,
831
860
  path,
832
861
  dispatchPath,
833
862
  validationState,
863
+ isBlacklisted,
834
864
  parentNavItem,
835
865
  navigationItems,
836
866
  navigations,
837
867
  debouncedCheckUrl,
868
+ debouncedCheckBlacklist,
838
869
  item,
839
870
  route,
840
871
  modalVariant
@@ -869,6 +900,9 @@ function ItemDetails({
869
900
  dispatchPath({ type: "SET_URL_CHECK_FLAG" });
870
901
  }
871
902
  }, [path.needsUrlCheck, route.documentId]);
903
+ React.useEffect(() => {
904
+ debouncedCheckBlacklist({ url: path.value || "" });
905
+ }, [path.value]);
872
906
  React.useEffect(() => {
873
907
  if (!path.slug) return;
874
908
  const parentPath = parentNavItem?.clientModifications?.path || parentNavItem?.route.path || "";
@@ -876,19 +910,19 @@ function ItemDetails({
876
910
  dispatchPath({ type: "DEFAULT", payload: newPath });
877
911
  }, [path.slug, parentNavItem]);
878
912
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
879
- path.canonicalPath !== path.value && /* @__PURE__ */ jsxRuntime.jsx(
880
- Warning,
913
+ path.canonicalPath !== path.value && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, s: 12, alignItems: "baseline", children: /* @__PURE__ */ jsxRuntime.jsx(
914
+ WarningBox.WarningBox,
881
915
  {
882
- main: formatMessage({
916
+ title: formatMessage({
883
917
  id: index.getTranslation("modal.item.canonicalPathMismatch"),
884
918
  defaultMessage: "Warning: Canonical Path does not match navigation path"
885
919
  })
886
920
  }
887
- ),
888
- navigationWhereRouteExists && /* @__PURE__ */ jsxRuntime.jsx(
889
- Warning,
921
+ ) }),
922
+ navigationWhereRouteExists && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, s: 12, alignItems: "baseline", children: /* @__PURE__ */ jsxRuntime.jsx(
923
+ WarningBox.WarningBox,
890
924
  {
891
- main: formatMessage(
925
+ title: formatMessage(
892
926
  {
893
927
  id: index.getTranslation("modal.item.routeAlreadyUsed"),
894
928
  defaultMessage: 'Warning: This route is already used in the navigation "{navigationName}"'
@@ -897,12 +931,12 @@ function ItemDetails({
897
931
  navigationName: navigationWhereRouteExists.name
898
932
  }
899
933
  ),
900
- info: formatMessage({
934
+ description: formatMessage({
901
935
  id: index.getTranslation("modal.item.routeAlreadyUsed.info"),
902
936
  defaultMessage: "Changing the path for this item will also update the path in the existing item."
903
937
  })
904
938
  }
905
- ),
939
+ ) }),
906
940
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, s: 12, alignItems: "baseline", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { required: true, children: [
907
941
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
908
942
  id: index.getTranslation("modal.item.titleField.label"),
@@ -972,7 +1006,14 @@ function ItemDetails({
972
1006
  }) }),
973
1007
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Input, { name: "path", value: path.value, disabled: true })
974
1008
  ] }),
975
- /* @__PURE__ */ jsxRuntime.jsx(index.PathInfo, { validationState, replacement: path.replacement })
1009
+ /* @__PURE__ */ jsxRuntime.jsx(
1010
+ index.PathInfo,
1011
+ {
1012
+ validationState,
1013
+ replacement: path.replacement,
1014
+ isBlacklisted
1015
+ }
1016
+ )
976
1017
  ] }) })
977
1018
  ] });
978
1019
  }
@@ -981,11 +1022,13 @@ function ItemCreateComponent({
981
1022
  selectedContentType,
982
1023
  setSelectedContentType,
983
1024
  validationState,
1025
+ isBlacklisted,
984
1026
  navItemState,
985
1027
  dispatchNavItemState,
986
1028
  path,
987
1029
  dispatchPath,
988
1030
  debouncedCheckUrl,
1031
+ debouncedCheckBlacklist,
989
1032
  setModalType,
990
1033
  selectedNavigation,
991
1034
  actionItemParent,
@@ -998,6 +1041,18 @@ function ItemCreateComponent({
998
1041
  const [loadingRoute, setLoadingRoute] = React.useState(true);
999
1042
  const { formatMessage } = reactIntl.useIntl();
1000
1043
  const { getRelatedRoute } = index.useApi();
1044
+ const { toggleNotification } = admin.useNotification();
1045
+ const getErrorMessage = FullLoader.useErrorMessage();
1046
+ const sortedEntities = React.useMemo(() => {
1047
+ if (!selectedContentType || !selectedContentType.entities) return [];
1048
+ return [...selectedContentType.entities].sort((a, b) => {
1049
+ const field = selectedContentType.contentType.routeSourceField;
1050
+ if (!field) return 0;
1051
+ const aValue = String(a[field] ?? "");
1052
+ const bValue = String(b[field] ?? "");
1053
+ return aValue.localeCompare(bValue, void 0, { sensitivity: "base", numeric: true });
1054
+ });
1055
+ }, [selectedContentType]);
1001
1056
  React.useEffect(() => {
1002
1057
  async function fetchRoute() {
1003
1058
  if (!selectedContentType?.contentType || !entity?.documentId) return setLoadingRoute(false);
@@ -1023,7 +1078,18 @@ function ItemCreateComponent({
1023
1078
  });
1024
1079
  setRoute(relatedRoute);
1025
1080
  } catch (err) {
1026
- strapi.log.error(err);
1081
+ if (index.isAbortError(err)) return;
1082
+ console.error(err);
1083
+ toggleNotification({
1084
+ type: "danger",
1085
+ message: getErrorMessage(
1086
+ err,
1087
+ formatMessage({
1088
+ id: index.getTranslation("notification.navigation.relatedRouteFetchFailed"),
1089
+ defaultMessage: "Failed to load the route of the selected entry"
1090
+ })
1091
+ )
1092
+ });
1027
1093
  } finally {
1028
1094
  setLoadingRoute(false);
1029
1095
  }
@@ -1046,7 +1112,7 @@ function ItemCreateComponent({
1046
1112
  onCreate(newItem);
1047
1113
  setModalType("");
1048
1114
  } catch (err) {
1049
- strapi.log.error(err);
1115
+ console.error(err);
1050
1116
  }
1051
1117
  };
1052
1118
  if (availableEntities && availableEntities.length === 0) {
@@ -1093,7 +1159,7 @@ function ItemCreateComponent({
1093
1159
  modalToOpen: "",
1094
1160
  currentModalType: "ItemCreate",
1095
1161
  currentModalMode: "create",
1096
- disabled: !selectedContentType?.contentType || !entity?.documentId || !path || !path.value?.trim() || !path.slug?.trim() || !navItemState.title || !navItemState.title?.trim(),
1162
+ disabled: !selectedContentType?.contentType || !entity?.documentId || !path || !path.value?.trim() || !path.slug?.trim() || !navItemState.title || !navItemState.title?.trim() || isBlacklisted,
1097
1163
  children: [
1098
1164
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
1099
1165
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
@@ -1146,7 +1212,10 @@ function ItemCreateComponent({
1146
1212
  if (route2) setEntity(route2);
1147
1213
  },
1148
1214
  disabled: !selectedContentType || selectedContentType?.entities && selectedContentType?.entities.length === 0,
1149
- children: selectedContentType && selectedContentType.entities?.map((entity2) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: entity2.documentId, children: entity2[selectedContentType.contentType.default] }, entity2.id))
1215
+ children: selectedContentType && sortedEntities.map((entity2) => {
1216
+ if (!selectedContentType.contentType.routeSourceField) return null;
1217
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: entity2.documentId, children: entity2[selectedContentType.contentType.routeSourceField] }, entity2.id);
1218
+ })
1150
1219
  }
1151
1220
  )
1152
1221
  ] }) }) })
@@ -1161,10 +1230,12 @@ function ItemCreateComponent({
1161
1230
  path,
1162
1231
  dispatchPath,
1163
1232
  validationState,
1233
+ isBlacklisted,
1164
1234
  parentNavItem: actionItemParent,
1165
1235
  navigationItems,
1166
1236
  navigations,
1167
1237
  debouncedCheckUrl,
1238
+ debouncedCheckBlacklist,
1168
1239
  route,
1169
1240
  modalVariant: "create"
1170
1241
  }
@@ -6691,12 +6762,14 @@ function ItemEditComponent({
6691
6762
  setSelectedContentType,
6692
6763
  entities,
6693
6764
  validationState,
6765
+ isBlacklisted,
6694
6766
  initialState,
6695
6767
  navItemState,
6696
6768
  dispatchNavItemState,
6697
6769
  path,
6698
6770
  dispatchPath,
6699
6771
  debouncedCheckUrl,
6772
+ debouncedCheckBlacklist,
6700
6773
  setModalType,
6701
6774
  navigationItems,
6702
6775
  onEdit
@@ -6766,7 +6839,7 @@ function ItemEditComponent({
6766
6839
  });
6767
6840
  setModalType("");
6768
6841
  } catch (err) {
6769
- strapi.log.error(err);
6842
+ console.error(err);
6770
6843
  }
6771
6844
  };
6772
6845
  if (!selectedContentType) return null;
@@ -6790,7 +6863,7 @@ function ItemEditComponent({
6790
6863
  modalToOpen: "",
6791
6864
  currentModalType: "ItemCreate",
6792
6865
  currentModalMode: "edit",
6793
- disabled: lodashExports.isEqual(navItemState, initialState.current) && path.value === path.initialPath,
6866
+ disabled: lodashExports.isEqual(navItemState, initialState.current) && path.value === path.initialPath || isBlacklisted,
6794
6867
  children: [
6795
6868
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 8, children: [
6796
6869
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
@@ -6818,9 +6891,11 @@ function ItemEditComponent({
6818
6891
  path,
6819
6892
  dispatchPath,
6820
6893
  validationState,
6894
+ isBlacklisted,
6821
6895
  parentNavItem,
6822
6896
  navigationItems,
6823
6897
  debouncedCheckUrl,
6898
+ debouncedCheckBlacklist,
6824
6899
  item,
6825
6900
  route: item.route,
6826
6901
  modalVariant: "edit"
@@ -6884,7 +6959,7 @@ function WrapperItemComponent(props) {
6884
6959
  }
6885
6960
  setModalType("");
6886
6961
  } catch (err) {
6887
- strapi.log.error(err);
6962
+ console.error(err);
6888
6963
  }
6889
6964
  };
6890
6965
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -9109,6 +9184,7 @@ const Navigation = () => {
9109
9184
  const [offsetLeft, setOffsetLeft] = React.useState(0);
9110
9185
  const { formatMessage } = reactIntl.useIntl();
9111
9186
  const { toggleNotification } = admin.useNotification();
9187
+ const getErrorMessage = FullLoader.useErrorMessage();
9112
9188
  const { get } = admin.useFetchClient();
9113
9189
  const { navigationId } = reactRouterDom.useParams();
9114
9190
  const navigate = reactRouterDom.useNavigate();
@@ -9126,7 +9202,7 @@ const Navigation = () => {
9126
9202
  const { data: data2 } = await get(`/content-manager/collection-types/${ct}/${id}`);
9127
9203
  return { ...item, status: data2.data.status };
9128
9204
  } catch (err) {
9129
- strapi.log.error(err);
9205
+ console.error(err);
9130
9206
  return item;
9131
9207
  }
9132
9208
  })
@@ -9150,13 +9226,17 @@ const Navigation = () => {
9150
9226
  cachedNavigations.current = updatedNavigations;
9151
9227
  switchNavigation(selectedNav, updatedNavigations);
9152
9228
  } catch (error) {
9153
- strapi.log.error("Error fetching navigations: ", error);
9229
+ if (index.isAbortError(error)) return;
9230
+ console.error("Error fetching navigations: ", error);
9154
9231
  toggleNotification({
9155
9232
  type: "danger",
9156
- message: formatMessage({
9157
- id: index.getTranslation("notification.navigation.fetchFailed"),
9158
- defaultMessage: "Failed to fetch navigations"
9159
- })
9233
+ message: getErrorMessage(
9234
+ error,
9235
+ formatMessage({
9236
+ id: index.getTranslation("notification.navigation.fetchFailed"),
9237
+ defaultMessage: "Failed to fetch navigations"
9238
+ })
9239
+ )
9160
9240
  });
9161
9241
  }
9162
9242
  }
@@ -9235,7 +9315,11 @@ const Navigation = () => {
9235
9315
  if (!navigationItems || !selectedNavigation) return;
9236
9316
  setIsSavingNavigation(true);
9237
9317
  try {
9238
- await updateNavigationItemStructure(selectedNavigation.documentId, navigationItems);
9318
+ const result = await updateNavigationItemStructure(
9319
+ selectedNavigation.documentId,
9320
+ navigationItems
9321
+ );
9322
+ if (result?.success === false) throw new Error(result.errors?.[0]);
9239
9323
  toggleNotification({
9240
9324
  type: "success",
9241
9325
  message: formatMessage({
@@ -9244,13 +9328,17 @@ const Navigation = () => {
9244
9328
  })
9245
9329
  });
9246
9330
  } catch (e) {
9247
- strapi.log.error(e);
9331
+ console.error(e);
9248
9332
  toggleNotification({
9249
9333
  type: "danger",
9250
- message: formatMessage({
9251
- id: index.getTranslation("notification.navigation.saveNavigationFailed"),
9252
- defaultMessage: "Error updating navigation item"
9253
- })
9334
+ message: getErrorMessage(
9335
+ e,
9336
+ // The per-item failures of updateNavigationItemStructure arrive as a local Error
9337
+ e instanceof Error && e.message ? e.message : formatMessage({
9338
+ id: index.getTranslation("notification.navigation.saveNavigationFailed"),
9339
+ defaultMessage: "Error updating navigation item"
9340
+ })
9341
+ )
9254
9342
  });
9255
9343
  } finally {
9256
9344
  await loadNavigations();
@@ -9423,8 +9511,13 @@ const Navigation = () => {
9423
9511
  item: actionItem,
9424
9512
  onDelete: (deletedItem) => {
9425
9513
  cachedNavigations.current = null;
9426
- setNavigations((navs) => navs.filter((nav) => nav.id !== deletedItem.id));
9427
- navigate(`/plugins/${index.PLUGIN_ID}/navigation`);
9514
+ const remaining = navigations.filter((nav) => nav.id !== deletedItem.id);
9515
+ setNavigations(remaining);
9516
+ if (deletedItem.documentId === navigationId) {
9517
+ navigate(
9518
+ remaining.length > 0 ? `/plugins/${index.PLUGIN_ID}/navigation/${remaining[0].documentId}` : `/plugins/${index.PLUGIN_ID}/navigation`
9519
+ );
9520
+ }
9428
9521
  }
9429
9522
  }
9430
9523
  ),