@mattisvensson/strapi-plugin-webatlas 0.11.9 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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-p1rh5rcZ.mjs → RoutePicker-h2yWGB6S.mjs} +1 -1
  5. package/dist/admin/{RoutePicker-D9RNp4zS.js → RoutePicker-mEHRtXQ9.js} +1 -1
  6. package/dist/admin/{SettingTitle-CwB5CsY0.js → SettingTitle-CBcBCh1h.js} +1 -1
  7. package/dist/admin/{SettingTitle-BMHyfLrM.mjs → SettingTitle-DTXdYICP.mjs} +1 -1
  8. package/dist/admin/WarningBox-CMQuE_Ov.mjs +42 -0
  9. package/dist/admin/WarningBox-DsBtzhs3.js +41 -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-CFf370lR.js → index-BYytQZfK.js} +169 -131
  15. package/dist/admin/{index-LNTPJt5H.js → index-BZBUZWp1.js} +13 -8
  16. package/dist/admin/{index-zr90q-6H.js → index-Bn_SWdWd.js} +178 -85
  17. package/dist/admin/{index-zskvsDgF.js → index-CaFjiS4j.js} +21 -13
  18. package/dist/admin/{index-G7qx6Oy7.mjs → index-Ckaev6xU.mjs} +170 -132
  19. package/dist/admin/{index-BE6CLx3P.mjs → index-Do9dOMP-.mjs} +180 -87
  20. package/dist/admin/{index-DpS40t3Q.mjs → index-DuwTQMlZ.mjs} +21 -13
  21. package/dist/admin/index-GZ_b2eve.js +480 -0
  22. package/dist/admin/index-aSdHc104.mjs +480 -0
  23. package/dist/admin/{index-IxsV1TAn.mjs → index-l4-tTCw9.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 +483 -494
  27. package/dist/server/index.mjs +496 -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
@@ -1,37 +1,18 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useNavigate, useParams, Routes, Route } from "react-router-dom";
3
- import { Trash, Pencil, Check, WarningCircle, More, Link, OneToMany, ExternalLink, Drag, Plus } from "@strapi/icons";
4
- import { Box, Typography, Dialog, Button, Modal, Flex, SingleSelect, SingleSelectOption, Grid, Field, Toggle, Divider, Badge, SimpleMenu, IconButton, MenuItem } from "@strapi/design-system";
5
- import { useState, useEffect, createContext, useRef, useContext, useMemo, useReducer, useCallback, forwardRef } from "react";
3
+ import { Trash, Pencil, Check, More, Link, OneToMany, ExternalLink, Drag, Plus } from "@strapi/icons";
4
+ import { Box, Typography, Dialog, Button, Modal, Flex, SingleSelect, SingleSelectOption, Grid, Field, Toggle, Divider, SimpleMenu, IconButton, MenuItem, Badge } from "@strapi/design-system";
5
+ import { createContext, useRef, useContext, useState, useMemo, useReducer, useCallback, useEffect, 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-G7qx6Oy7.mjs";
8
+ import { u as useApi, g as getTranslation, i as isAbortError, P as PLUGIN_ID, d as debounce, a as duplicateCheck, T as Tooltip, b as PathInfo, c as usePluginConfig, p as pluginPermissions } from "./index-Ckaev6xU.mjs";
9
+ import { u as useErrorMessage, C as Center, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
9
10
  import { useNotification, useFetchClient, Page, Layouts } from "@strapi/strapi/admin";
10
- import { C as Center, F as FullLoader } from "./FullLoader-Btjb2W2p.mjs";
11
11
  import { EmptyDocuments } from "@strapi/icons/symbols";
12
+ import { u as useAllEntities, W as WarningBox } from "./WarningBox-CMQuE_Ov.mjs";
12
13
  import { MeasuringStrategy, DndContext, DragOverlay, closestCenter } from "@dnd-kit/core";
13
14
  import { arrayMove, useSortable, SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
14
15
  import { CSS } from "@dnd-kit/utilities";
15
- const useAllEntities = () => {
16
- const { fetchAllEntities } = useApi();
17
- const [entities, setEntities] = useState([]);
18
- const [loading, setLoading] = useState(true);
19
- const [error, setError] = useState(null);
20
- useEffect(() => {
21
- const fetchEntities = async () => {
22
- try {
23
- const result = await fetchAllEntities();
24
- setEntities(result);
25
- setLoading(false);
26
- } catch (err) {
27
- setError(err);
28
- setLoading(false);
29
- }
30
- };
31
- fetchEntities();
32
- }, []);
33
- return { entities, loading, error };
34
- };
35
16
  function createTempNavItemObject({
36
17
  actionItemParentId,
37
18
  entityRoute,
@@ -154,7 +135,11 @@ function Delete({ variant, item, onDelete }) {
154
135
  const { setModalType } = useContext(ModalContext);
155
136
  const { formatMessage } = useIntl();
156
137
  const { deleteNavigation } = useApi();
138
+ const { toggleNotification } = useNotification();
139
+ const getErrorMessage = useErrorMessage();
140
+ const [isDeleting, setIsDeleting] = useState(false);
157
141
  const handleDelete = async () => {
142
+ setIsDeleting(true);
158
143
  try {
159
144
  if (variant === "NavDelete") {
160
145
  await deleteNavigation(item.documentId);
@@ -170,7 +155,18 @@ function Delete({ variant, item, onDelete }) {
170
155
  onDelete(editedItem);
171
156
  }
172
157
  } catch (err) {
173
- strapi.log.error(err);
158
+ if (isAbortError(err)) return;
159
+ console.error(err);
160
+ toggleNotification({
161
+ type: "danger",
162
+ message: getErrorMessage(
163
+ err,
164
+ formatMessage({
165
+ id: getTranslation("notification.navigation.deleteFailed"),
166
+ defaultMessage: "Deleting failed"
167
+ })
168
+ )
169
+ });
174
170
  }
175
171
  setModalType(closeModalState.current);
176
172
  };
@@ -225,10 +221,22 @@ function Delete({ variant, item, onDelete }) {
225
221
  id: getTranslation("modal.delete.cancelText"),
226
222
  defaultMessage: "No, keep"
227
223
  }) }) }),
228
- /* @__PURE__ */ jsx(Dialog.Action, { children: /* @__PURE__ */ jsx(Button, { variant: "danger-light", onClick: () => handleDelete(), startIcon: /* @__PURE__ */ jsx(Trash, {}), children: formatMessage({
229
- id: getTranslation("modal.delete.confirmText"),
230
- defaultMessage: "Yes, delete"
231
- }) }) })
224
+ /* @__PURE__ */ jsx(Dialog.Action, { children: /* @__PURE__ */ jsx(
225
+ Button,
226
+ {
227
+ variant: "danger-light",
228
+ disabled: isDeleting,
229
+ onClick: (e) => {
230
+ e.preventDefault();
231
+ handleDelete();
232
+ },
233
+ startIcon: /* @__PURE__ */ jsx(Trash, {}),
234
+ children: formatMessage({
235
+ id: getTranslation("modal.delete.confirmText"),
236
+ defaultMessage: "Yes, delete"
237
+ })
238
+ }
239
+ ) })
232
240
  ] })
233
241
  ] })
234
242
  }
@@ -316,6 +324,7 @@ function NavCreate() {
316
324
  const { toggleNotification } = useNotification();
317
325
  const navigate = useNavigate();
318
326
  const { createNavigation } = useApi();
327
+ const getErrorMessage = useErrorMessage();
319
328
  const onConfirm = async () => {
320
329
  setLoading(true);
321
330
  try {
@@ -324,13 +333,16 @@ function NavCreate() {
324
333
  navigate(`/plugins/${PLUGIN_ID}/navigation/${data.documentId}`);
325
334
  setModalType("");
326
335
  } catch (err) {
327
- strapi.log.error(err);
336
+ console.error(err);
328
337
  toggleNotification({
329
338
  type: "danger",
330
- message: formatMessage({
331
- id: getTranslation("notification.navigation.creationFailed"),
332
- defaultMessage: "Creation of navigation failed"
333
- })
339
+ message: getErrorMessage(
340
+ err,
341
+ formatMessage({
342
+ id: getTranslation("notification.navigation.creationFailed"),
343
+ defaultMessage: "Creation of navigation failed"
344
+ })
345
+ )
334
346
  });
335
347
  } finally {
336
348
  setLoading(false);
@@ -383,6 +395,7 @@ function NavEdit({ item, onEdit }) {
383
395
  const { updateNavigation } = useApi();
384
396
  const { formatMessage } = useIntl();
385
397
  const { toggleNotification } = useNotification();
398
+ const getErrorMessage = useErrorMessage();
386
399
  const initialNavState = { name: item.name, visible: item.visible };
387
400
  const updateNav = async () => {
388
401
  setLoading(true);
@@ -391,13 +404,16 @@ function NavEdit({ item, onEdit }) {
391
404
  setModalType("NavOverview");
392
405
  onEdit({ ...item, name, visible });
393
406
  } catch (err) {
394
- strapi.log.error(err);
407
+ console.error(err);
395
408
  toggleNotification({
396
409
  type: "danger",
397
- message: formatMessage({
398
- id: getTranslation("notification.navigation.updateFailed"),
399
- defaultMessage: "Updating navigation failed"
400
- })
410
+ message: getErrorMessage(
411
+ err,
412
+ formatMessage({
413
+ id: getTranslation("notification.navigation.updateFailed"),
414
+ defaultMessage: "Updating navigation failed"
415
+ })
416
+ )
401
417
  });
402
418
  } finally {
403
419
  setLoading(false);
@@ -599,11 +615,12 @@ function pathReducer(state, action) {
599
615
  function useModalSharedLogic() {
600
616
  const [selectedContentType, setSelectedContentType] = useState();
601
617
  const [validationState, setValidationState] = useState("initial");
618
+ const [isBlacklisted, setIsBlacklisted] = useState(false);
602
619
  const { entities } = useAllEntities();
603
620
  const { get } = useFetchClient();
604
621
  const availableEntities = useMemo(() => {
605
622
  if (!entities) return [];
606
- return entities;
623
+ return entities.filter((group) => group.contentType.routeSourceField);
607
624
  }, [entities]);
608
625
  const initialState = useRef({
609
626
  title: "",
@@ -624,6 +641,7 @@ function useModalSharedLogic() {
624
641
  initialPath: ""
625
642
  });
626
643
  const debouncedCheckUrl = useCallback(debounce(checkUrl, 500), []);
644
+ const debouncedCheckBlacklist = useCallback(debounce(checkBlacklist, 500), []);
627
645
  const { modalType, setModalType } = useContext(ModalContext);
628
646
  const { selectedNavigation } = useContext(SelectedNavigationContext);
629
647
  async function checkUrl({
@@ -635,21 +653,39 @@ function useModalSharedLogic() {
635
653
  setValidationState("checking");
636
654
  dispatchPath({ type: "SET_REPLACEMENT", payload: "" });
637
655
  try {
638
- const data = await duplicateCheck({
656
+ const { uniquePath, blacklisted } = await duplicateCheck({
639
657
  fetchFunction: get,
640
658
  path: url,
641
659
  routeDocumentId,
642
660
  withoutTransform
643
661
  });
644
- if (!data || data === url) return;
645
- dispatchPath({ type: "NO_URL_CHECK", payload: data });
646
- dispatchPath({ type: "SET_REPLACEMENT", payload: data });
662
+ setIsBlacklisted(blacklisted);
663
+ if (blacklisted) return;
664
+ if (!uniquePath || uniquePath === url) return;
665
+ dispatchPath({ type: "NO_URL_CHECK", payload: uniquePath });
666
+ dispatchPath({ type: "SET_REPLACEMENT", payload: uniquePath });
647
667
  } catch (err) {
648
- strapi.log.error(err);
668
+ console.error(err);
649
669
  } finally {
650
670
  setValidationState("done");
651
671
  }
652
672
  }
673
+ async function checkBlacklist({ url }) {
674
+ if (!url) {
675
+ setIsBlacklisted(false);
676
+ return;
677
+ }
678
+ try {
679
+ const { blacklisted } = await duplicateCheck({
680
+ fetchFunction: get,
681
+ path: url,
682
+ withoutTransform: true
683
+ });
684
+ setIsBlacklisted(blacklisted);
685
+ } catch (err) {
686
+ console.error(err);
687
+ }
688
+ }
653
689
  const modalSharedLogic = {
654
690
  availableEntities,
655
691
  selectedContentType,
@@ -657,12 +693,14 @@ function useModalSharedLogic() {
657
693
  entities,
658
694
  validationState,
659
695
  setValidationState,
696
+ isBlacklisted,
660
697
  initialState,
661
698
  navItemState,
662
699
  dispatchNavItemState,
663
700
  path,
664
701
  dispatchPath,
665
702
  debouncedCheckUrl,
703
+ debouncedCheckBlacklist,
666
704
  modalType,
667
705
  setModalType,
668
706
  selectedNavigation
@@ -731,7 +769,7 @@ function ExternalItemComponent(props) {
731
769
  }
732
770
  setModalType("");
733
771
  } catch (err) {
734
- strapi.log.error(err);
772
+ console.error(err);
735
773
  }
736
774
  };
737
775
  return /* @__PURE__ */ jsx(
@@ -814,25 +852,18 @@ function ExternalItemComponent(props) {
814
852
  );
815
853
  }
816
854
  const ExternalItem = withModalSharedLogic(ExternalItemComponent);
817
- function Warning({ main, info }) {
818
- return /* @__PURE__ */ jsx(Grid.Item, { col: 12, s: 12, alignItems: "baseline", children: /* @__PURE__ */ jsx(Badge, { variant: "warning", minWidth: "100%", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 2, children: [
819
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 2, children: [
820
- /* @__PURE__ */ jsx(WarningCircle, {}),
821
- /* @__PURE__ */ jsx(Typography, { children: main })
822
- ] }),
823
- info && /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: info })
824
- ] }) }) });
825
- }
826
855
  function ItemDetails({
827
856
  navItemState,
828
857
  dispatchNavItemState,
829
858
  path,
830
859
  dispatchPath,
831
860
  validationState,
861
+ isBlacklisted,
832
862
  parentNavItem,
833
863
  navigationItems,
834
864
  navigations,
835
865
  debouncedCheckUrl,
866
+ debouncedCheckBlacklist,
836
867
  item,
837
868
  route,
838
869
  modalVariant
@@ -867,6 +898,9 @@ function ItemDetails({
867
898
  dispatchPath({ type: "SET_URL_CHECK_FLAG" });
868
899
  }
869
900
  }, [path.needsUrlCheck, route.documentId]);
901
+ useEffect(() => {
902
+ debouncedCheckBlacklist({ url: path.value || "" });
903
+ }, [path.value]);
870
904
  useEffect(() => {
871
905
  if (!path.slug) return;
872
906
  const parentPath = parentNavItem?.clientModifications?.path || parentNavItem?.route.path || "";
@@ -874,19 +908,19 @@ function ItemDetails({
874
908
  dispatchPath({ type: "DEFAULT", payload: newPath });
875
909
  }, [path.slug, parentNavItem]);
876
910
  return /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
877
- path.canonicalPath !== path.value && /* @__PURE__ */ jsx(
878
- Warning,
911
+ path.canonicalPath !== path.value && /* @__PURE__ */ jsx(Grid.Item, { col: 12, s: 12, alignItems: "baseline", children: /* @__PURE__ */ jsx(
912
+ WarningBox,
879
913
  {
880
- main: formatMessage({
914
+ title: formatMessage({
881
915
  id: getTranslation("modal.item.canonicalPathMismatch"),
882
916
  defaultMessage: "Warning: Canonical Path does not match navigation path"
883
917
  })
884
918
  }
885
- ),
886
- navigationWhereRouteExists && /* @__PURE__ */ jsx(
887
- Warning,
919
+ ) }),
920
+ navigationWhereRouteExists && /* @__PURE__ */ jsx(Grid.Item, { col: 12, s: 12, alignItems: "baseline", children: /* @__PURE__ */ jsx(
921
+ WarningBox,
888
922
  {
889
- main: formatMessage(
923
+ title: formatMessage(
890
924
  {
891
925
  id: getTranslation("modal.item.routeAlreadyUsed"),
892
926
  defaultMessage: 'Warning: This route is already used in the navigation "{navigationName}"'
@@ -895,12 +929,12 @@ function ItemDetails({
895
929
  navigationName: navigationWhereRouteExists.name
896
930
  }
897
931
  ),
898
- info: formatMessage({
932
+ description: formatMessage({
899
933
  id: getTranslation("modal.item.routeAlreadyUsed.info"),
900
934
  defaultMessage: "Changing the path for this item will also update the path in the existing item."
901
935
  })
902
936
  }
903
- ),
937
+ ) }),
904
938
  /* @__PURE__ */ jsx(Grid.Item, { col: 12, s: 12, alignItems: "baseline", children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Field.Root, { required: true, children: [
905
939
  /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
906
940
  id: getTranslation("modal.item.titleField.label"),
@@ -970,7 +1004,14 @@ function ItemDetails({
970
1004
  }) }),
971
1005
  /* @__PURE__ */ jsx(Field.Input, { name: "path", value: path.value, disabled: true })
972
1006
  ] }),
973
- /* @__PURE__ */ jsx(PathInfo, { validationState, replacement: path.replacement })
1007
+ /* @__PURE__ */ jsx(
1008
+ PathInfo,
1009
+ {
1010
+ validationState,
1011
+ replacement: path.replacement,
1012
+ isBlacklisted
1013
+ }
1014
+ )
974
1015
  ] }) })
975
1016
  ] });
976
1017
  }
@@ -979,11 +1020,13 @@ function ItemCreateComponent({
979
1020
  selectedContentType,
980
1021
  setSelectedContentType,
981
1022
  validationState,
1023
+ isBlacklisted,
982
1024
  navItemState,
983
1025
  dispatchNavItemState,
984
1026
  path,
985
1027
  dispatchPath,
986
1028
  debouncedCheckUrl,
1029
+ debouncedCheckBlacklist,
987
1030
  setModalType,
988
1031
  selectedNavigation,
989
1032
  actionItemParent,
@@ -996,6 +1039,18 @@ function ItemCreateComponent({
996
1039
  const [loadingRoute, setLoadingRoute] = useState(true);
997
1040
  const { formatMessage } = useIntl();
998
1041
  const { getRelatedRoute } = useApi();
1042
+ const { toggleNotification } = useNotification();
1043
+ const getErrorMessage = useErrorMessage();
1044
+ const sortedEntities = useMemo(() => {
1045
+ if (!selectedContentType || !selectedContentType.entities) return [];
1046
+ return [...selectedContentType.entities].sort((a, b) => {
1047
+ const field = selectedContentType.contentType.routeSourceField;
1048
+ if (!field) return 0;
1049
+ const aValue = String(a[field] ?? "");
1050
+ const bValue = String(b[field] ?? "");
1051
+ return aValue.localeCompare(bValue, void 0, { sensitivity: "base", numeric: true });
1052
+ });
1053
+ }, [selectedContentType]);
999
1054
  useEffect(() => {
1000
1055
  async function fetchRoute() {
1001
1056
  if (!selectedContentType?.contentType || !entity?.documentId) return setLoadingRoute(false);
@@ -1021,7 +1076,18 @@ function ItemCreateComponent({
1021
1076
  });
1022
1077
  setRoute(relatedRoute);
1023
1078
  } catch (err) {
1024
- strapi.log.error(err);
1079
+ if (isAbortError(err)) return;
1080
+ console.error(err);
1081
+ toggleNotification({
1082
+ type: "danger",
1083
+ message: getErrorMessage(
1084
+ err,
1085
+ formatMessage({
1086
+ id: getTranslation("notification.navigation.relatedRouteFetchFailed"),
1087
+ defaultMessage: "Failed to load the route of the selected entry"
1088
+ })
1089
+ )
1090
+ });
1025
1091
  } finally {
1026
1092
  setLoadingRoute(false);
1027
1093
  }
@@ -1044,7 +1110,7 @@ function ItemCreateComponent({
1044
1110
  onCreate(newItem);
1045
1111
  setModalType("");
1046
1112
  } catch (err) {
1047
- strapi.log.error(err);
1113
+ console.error(err);
1048
1114
  }
1049
1115
  };
1050
1116
  if (availableEntities && availableEntities.length === 0) {
@@ -1091,7 +1157,7 @@ function ItemCreateComponent({
1091
1157
  modalToOpen: "",
1092
1158
  currentModalType: "ItemCreate",
1093
1159
  currentModalMode: "create",
1094
- disabled: !selectedContentType?.contentType || !entity?.documentId || !path || !path.value?.trim() || !path.slug?.trim() || !navItemState.title || !navItemState.title?.trim(),
1160
+ disabled: !selectedContentType?.contentType || !entity?.documentId || !path || !path.value?.trim() || !path.slug?.trim() || !navItemState.title || !navItemState.title?.trim() || isBlacklisted,
1095
1161
  children: [
1096
1162
  /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
1097
1163
  /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Field.Root, { children: [
@@ -1144,7 +1210,10 @@ function ItemCreateComponent({
1144
1210
  if (route2) setEntity(route2);
1145
1211
  },
1146
1212
  disabled: !selectedContentType || selectedContentType?.entities && selectedContentType?.entities.length === 0,
1147
- children: selectedContentType && selectedContentType.entities?.map((entity2) => /* @__PURE__ */ jsx(SingleSelectOption, { value: entity2.documentId, children: entity2[selectedContentType.contentType.default] }, entity2.id))
1213
+ children: selectedContentType && sortedEntities.map((entity2) => {
1214
+ if (!selectedContentType.contentType.routeSourceField) return null;
1215
+ return /* @__PURE__ */ jsx(SingleSelectOption, { value: entity2.documentId, children: entity2[selectedContentType.contentType.routeSourceField] }, entity2.id);
1216
+ })
1148
1217
  }
1149
1218
  )
1150
1219
  ] }) }) })
@@ -1159,10 +1228,12 @@ function ItemCreateComponent({
1159
1228
  path,
1160
1229
  dispatchPath,
1161
1230
  validationState,
1231
+ isBlacklisted,
1162
1232
  parentNavItem: actionItemParent,
1163
1233
  navigationItems,
1164
1234
  navigations,
1165
1235
  debouncedCheckUrl,
1236
+ debouncedCheckBlacklist,
1166
1237
  route,
1167
1238
  modalVariant: "create"
1168
1239
  }
@@ -6689,12 +6760,14 @@ function ItemEditComponent({
6689
6760
  setSelectedContentType,
6690
6761
  entities,
6691
6762
  validationState,
6763
+ isBlacklisted,
6692
6764
  initialState,
6693
6765
  navItemState,
6694
6766
  dispatchNavItemState,
6695
6767
  path,
6696
6768
  dispatchPath,
6697
6769
  debouncedCheckUrl,
6770
+ debouncedCheckBlacklist,
6698
6771
  setModalType,
6699
6772
  navigationItems,
6700
6773
  onEdit
@@ -6764,7 +6837,7 @@ function ItemEditComponent({
6764
6837
  });
6765
6838
  setModalType("");
6766
6839
  } catch (err) {
6767
- strapi.log.error(err);
6840
+ console.error(err);
6768
6841
  }
6769
6842
  };
6770
6843
  if (!selectedContentType) return null;
@@ -6788,7 +6861,7 @@ function ItemEditComponent({
6788
6861
  modalToOpen: "",
6789
6862
  currentModalType: "ItemCreate",
6790
6863
  currentModalMode: "edit",
6791
- disabled: lodashExports.isEqual(navItemState, initialState.current) && path.value === path.initialPath,
6864
+ disabled: lodashExports.isEqual(navItemState, initialState.current) && path.value === path.initialPath || isBlacklisted,
6792
6865
  children: [
6793
6866
  /* @__PURE__ */ jsxs(Grid.Root, { gap: 8, children: [
6794
6867
  /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Field.Root, { children: [
@@ -6816,9 +6889,11 @@ function ItemEditComponent({
6816
6889
  path,
6817
6890
  dispatchPath,
6818
6891
  validationState,
6892
+ isBlacklisted,
6819
6893
  parentNavItem,
6820
6894
  navigationItems,
6821
6895
  debouncedCheckUrl,
6896
+ debouncedCheckBlacklist,
6822
6897
  item,
6823
6898
  route: item.route,
6824
6899
  modalVariant: "edit"
@@ -6882,7 +6957,7 @@ function WrapperItemComponent(props) {
6882
6957
  }
6883
6958
  setModalType("");
6884
6959
  } catch (err) {
6885
- strapi.log.error(err);
6960
+ console.error(err);
6886
6961
  }
6887
6962
  };
6888
6963
  return /* @__PURE__ */ jsx(
@@ -9107,6 +9182,7 @@ const Navigation = () => {
9107
9182
  const [offsetLeft, setOffsetLeft] = useState(0);
9108
9183
  const { formatMessage } = useIntl();
9109
9184
  const { toggleNotification } = useNotification();
9185
+ const getErrorMessage = useErrorMessage();
9110
9186
  const { get } = useFetchClient();
9111
9187
  const { navigationId } = useParams();
9112
9188
  const navigate = useNavigate();
@@ -9124,7 +9200,7 @@ const Navigation = () => {
9124
9200
  const { data: data2 } = await get(`/content-manager/collection-types/${ct}/${id}`);
9125
9201
  return { ...item, status: data2.data.status };
9126
9202
  } catch (err) {
9127
- strapi.log.error(err);
9203
+ console.error(err);
9128
9204
  return item;
9129
9205
  }
9130
9206
  })
@@ -9148,13 +9224,17 @@ const Navigation = () => {
9148
9224
  cachedNavigations.current = updatedNavigations;
9149
9225
  switchNavigation(selectedNav, updatedNavigations);
9150
9226
  } catch (error) {
9151
- strapi.log.error("Error fetching navigations: ", error);
9227
+ if (isAbortError(error)) return;
9228
+ console.error("Error fetching navigations: ", error);
9152
9229
  toggleNotification({
9153
9230
  type: "danger",
9154
- message: formatMessage({
9155
- id: getTranslation("notification.navigation.fetchFailed"),
9156
- defaultMessage: "Failed to fetch navigations"
9157
- })
9231
+ message: getErrorMessage(
9232
+ error,
9233
+ formatMessage({
9234
+ id: getTranslation("notification.navigation.fetchFailed"),
9235
+ defaultMessage: "Failed to fetch navigations"
9236
+ })
9237
+ )
9158
9238
  });
9159
9239
  }
9160
9240
  }
@@ -9233,7 +9313,11 @@ const Navigation = () => {
9233
9313
  if (!navigationItems || !selectedNavigation) return;
9234
9314
  setIsSavingNavigation(true);
9235
9315
  try {
9236
- await updateNavigationItemStructure(selectedNavigation.documentId, navigationItems);
9316
+ const result = await updateNavigationItemStructure(
9317
+ selectedNavigation.documentId,
9318
+ navigationItems
9319
+ );
9320
+ if (result?.success === false) throw new Error(result.errors?.[0]);
9237
9321
  toggleNotification({
9238
9322
  type: "success",
9239
9323
  message: formatMessage({
@@ -9242,13 +9326,17 @@ const Navigation = () => {
9242
9326
  })
9243
9327
  });
9244
9328
  } catch (e) {
9245
- strapi.log.error(e);
9329
+ console.error(e);
9246
9330
  toggleNotification({
9247
9331
  type: "danger",
9248
- message: formatMessage({
9249
- id: getTranslation("notification.navigation.saveNavigationFailed"),
9250
- defaultMessage: "Error updating navigation item"
9251
- })
9332
+ message: getErrorMessage(
9333
+ e,
9334
+ // The per-item failures of updateNavigationItemStructure arrive as a local Error
9335
+ e instanceof Error && e.message ? e.message : formatMessage({
9336
+ id: getTranslation("notification.navigation.saveNavigationFailed"),
9337
+ defaultMessage: "Error updating navigation item"
9338
+ })
9339
+ )
9252
9340
  });
9253
9341
  } finally {
9254
9342
  await loadNavigations();
@@ -9421,8 +9509,13 @@ const Navigation = () => {
9421
9509
  item: actionItem,
9422
9510
  onDelete: (deletedItem) => {
9423
9511
  cachedNavigations.current = null;
9424
- setNavigations((navs) => navs.filter((nav) => nav.id !== deletedItem.id));
9425
- navigate(`/plugins/${PLUGIN_ID}/navigation`);
9512
+ const remaining = navigations.filter((nav) => nav.id !== deletedItem.id);
9513
+ setNavigations(remaining);
9514
+ if (deletedItem.documentId === navigationId) {
9515
+ navigate(
9516
+ remaining.length > 0 ? `/plugins/${PLUGIN_ID}/navigation/${remaining[0].documentId}` : `/plugins/${PLUGIN_ID}/navigation`
9517
+ );
9518
+ }
9426
9519
  }
9427
9520
  }
9428
9521
  ),
@@ -2,11 +2,12 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useReducer, useState, useRef, useEffect } from "react";
3
3
  import { Field } from "@strapi/design-system";
4
4
  import { useNotification, Page } from "@strapi/strapi/admin";
5
- import { c as usePluginConfig, g as getTranslation, p as pluginPermissions } from "./index-G7qx6Oy7.mjs";
5
+ import { c as usePluginConfig, g as getTranslation, p as pluginPermissions } from "./index-Ckaev6xU.mjs";
6
+ import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
6
7
  import { useIntl } from "react-intl";
7
8
  import "@strapi/icons/symbols";
8
- import { F as FullLoader } from "./FullLoader-Btjb2W2p.mjs";
9
- import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-BMHyfLrM.mjs";
9
+ import "@strapi/icons";
10
+ import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-DTXdYICP.mjs";
10
11
  function reducer(newConfig, action) {
11
12
  switch (action.type) {
12
13
  case "SET_MAX_DEPTH":
@@ -26,6 +27,7 @@ const Settings = () => {
26
27
  const { config: fetchedConfig, setConfig, loading, fetchError } = usePluginConfig();
27
28
  const [config, dispatch] = useReducer(reducer, fetchedConfig);
28
29
  const { toggleNotification } = useNotification();
30
+ const getErrorMessage = useErrorMessage();
29
31
  const { formatMessage } = useIntl();
30
32
  const [isSaving, setIsSaving] = useState(false);
31
33
  const initialConfig = useRef(fetchedConfig);
@@ -37,13 +39,16 @@ const Settings = () => {
37
39
  if (fetchError) {
38
40
  toggleNotification({
39
41
  type: "danger",
40
- message: formatMessage({
41
- id: getTranslation("notification.error"),
42
- defaultMessage: "An error occurred"
43
- }) + ": " + fetchError
42
+ message: getErrorMessage(
43
+ fetchError,
44
+ formatMessage({
45
+ id: getTranslation("notification.error"),
46
+ defaultMessage: "An error occurred"
47
+ })
48
+ )
44
49
  });
45
50
  }
46
- }, [fetchError, toggleNotification, formatMessage]);
51
+ }, [fetchError, toggleNotification, getErrorMessage, formatMessage]);
47
52
  async function save() {
48
53
  if (!config) return;
49
54
  setIsSaving(true);
@@ -62,12 +67,15 @@ const Settings = () => {
62
67
  setIsSaving(false);
63
68
  toggleNotification({
64
69
  type: "danger",
65
- message: formatMessage({
66
- id: getTranslation("notification.error"),
67
- defaultMessage: "An error occurred"
68
- }) + ": " + err
70
+ message: getErrorMessage(
71
+ err,
72
+ formatMessage({
73
+ id: getTranslation("notification.error"),
74
+ defaultMessage: "An error occurred"
75
+ })
76
+ )
69
77
  });
70
- strapi.log.error(err);
78
+ console.error(err);
71
79
  }
72
80
  }
73
81
  if (loading) {