@mattisvensson/strapi-plugin-webatlas 0.7.1 → 0.8.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 (77) hide show
  1. package/dist/_chunks/PageWrapper-Bp9vGwpG.js +54 -0
  2. package/dist/_chunks/PageWrapper-BvOY7VCN.mjs +55 -0
  3. package/dist/_chunks/PageWrapper-BzDrMm2d.js +55 -0
  4. package/dist/_chunks/PageWrapper-BzDrMm2d.js.map +1 -0
  5. package/dist/_chunks/PageWrapper-oLhcg9BA.mjs +56 -0
  6. package/dist/_chunks/PageWrapper-oLhcg9BA.mjs.map +1 -0
  7. package/dist/_chunks/{de-BZc1BkzH.js → de-CDBoUBzw.js} +5 -2
  8. package/dist/_chunks/{en-Deg4n_IM.js.map → de-CDBoUBzw.js.map} +1 -1
  9. package/dist/_chunks/{de-oxxH8hft.mjs → de-Dt80IqMG.mjs} +5 -2
  10. package/dist/_chunks/{en-DqC5aDzA.mjs.map → de-Dt80IqMG.mjs.map} +1 -1
  11. package/dist/_chunks/{en-DqC5aDzA.mjs → en-BHxDiueo.mjs} +5 -2
  12. package/dist/_chunks/{de-oxxH8hft.mjs.map → en-BHxDiueo.mjs.map} +1 -1
  13. package/dist/_chunks/{en-Deg4n_IM.js → en-DfvURaup.js} +5 -2
  14. package/dist/_chunks/{de-BZc1BkzH.js.map → en-DfvURaup.js.map} +1 -1
  15. package/dist/_chunks/{index-dzRHjemo.js → index--oj1eNcM.js} +2 -2
  16. package/dist/_chunks/{index-CHB_8c7e.js.map → index--oj1eNcM.js.map} +1 -1
  17. package/dist/_chunks/index-BBn1ZvsE.mjs +123 -0
  18. package/dist/_chunks/index-BCPgfhBx.js +124 -0
  19. package/dist/_chunks/index-BCPgfhBx.js.map +1 -0
  20. package/dist/_chunks/{index-CHB_8c7e.js → index-BKdvSgDB.js} +1 -1
  21. package/dist/_chunks/{index-DzqTj_0f.mjs → index-CAged_xE.mjs} +2 -2
  22. package/dist/_chunks/{index-KC82xDAD.mjs.map → index-CAged_xE.mjs.map} +1 -1
  23. package/dist/_chunks/index-CHRBu9Xy.mjs +124 -0
  24. package/dist/_chunks/index-CHRBu9Xy.mjs.map +1 -0
  25. package/dist/_chunks/{index-C6Dorrjz.mjs → index-CTA8agp7.mjs} +40 -13
  26. package/dist/_chunks/{index-BFMLU2kR.mjs → index-CUlRMqGG.mjs} +57 -60
  27. package/dist/_chunks/{index-C6e9wLau.js → index-CbW6k4FH.js} +41 -12
  28. package/dist/_chunks/index-CbW6k4FH.js.map +1 -0
  29. package/dist/_chunks/{index-B79--vLg.js → index-CtFERXkl.js} +91 -119
  30. package/dist/_chunks/index-CtFERXkl.js.map +1 -0
  31. package/dist/_chunks/{index-D5Uc0GLu.mjs → index-D29zBs5w.mjs} +58 -59
  32. package/dist/_chunks/index-D29zBs5w.mjs.map +1 -0
  33. package/dist/_chunks/index-D72CZ5b7.js +123 -0
  34. package/dist/_chunks/{index-DcFYhqke.mjs → index-DJBXRNlE.mjs} +95 -123
  35. package/dist/_chunks/index-DJBXRNlE.mjs.map +1 -0
  36. package/dist/_chunks/{index-DY1ICa5c.mjs → index-DMpiX4hP.mjs} +41 -12
  37. package/dist/_chunks/index-DMpiX4hP.mjs.map +1 -0
  38. package/dist/_chunks/{index-DeCgextE.js → index-DTPDMxs_.js} +57 -59
  39. package/dist/_chunks/{index-NZpDoHIv.js → index-DUgh4AJb.js} +90 -120
  40. package/dist/_chunks/{index-2J9mPFyV.js → index-Dxn0NT06.js} +40 -13
  41. package/dist/_chunks/{index-DLZJ_sUK.mjs → index-Nx4IRYIK.mjs} +94 -124
  42. package/dist/_chunks/{index-KC82xDAD.mjs → index-Rfm9O167.mjs} +1 -1
  43. package/dist/_chunks/{index-DCejsR9X.js → index-YzPuPn68.js} +58 -60
  44. package/dist/_chunks/index-YzPuPn68.js.map +1 -0
  45. package/dist/admin/index.js +1 -1
  46. package/dist/admin/index.mjs +1 -1
  47. package/dist/admin/src/components/modals/NavEdit.d.ts +1 -1
  48. package/dist/admin/src/components/modals/fields/Visibility.d.ts +5 -0
  49. package/dist/admin/src/components/modals/fields/index.d.ts +2 -0
  50. package/dist/admin/src/hooks/usePluginConfig.d.ts +1 -1
  51. package/dist/admin/src/pages/Settings/{ContentTypeAccordion.d.ts → General/ContentTypeAccordion.d.ts} +1 -1
  52. package/dist/admin/src/pages/Settings/Navigation/index.d.ts +2 -0
  53. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +3 -4
  54. package/dist/admin/src/utils/dnd.d.ts +1 -1
  55. package/dist/server/index.js +32 -14
  56. package/dist/server/index.js.map +1 -1
  57. package/dist/server/index.mjs +32 -14
  58. package/dist/server/index.mjs.map +1 -1
  59. package/dist/server/src/index.d.ts +1 -1
  60. package/dist/server/src/services/admin.d.ts +2 -2
  61. package/dist/server/src/services/index.d.ts +1 -1
  62. package/package.json +1 -1
  63. package/dist/_chunks/index-2J9mPFyV.js.map +0 -1
  64. package/dist/_chunks/index-B79--vLg.js.map +0 -1
  65. package/dist/_chunks/index-BFMLU2kR.mjs.map +0 -1
  66. package/dist/_chunks/index-C6Dorrjz.mjs.map +0 -1
  67. package/dist/_chunks/index-C6e9wLau.js.map +0 -1
  68. package/dist/_chunks/index-D5Uc0GLu.mjs.map +0 -1
  69. package/dist/_chunks/index-DCejsR9X.js.map +0 -1
  70. package/dist/_chunks/index-DLZJ_sUK.mjs.map +0 -1
  71. package/dist/_chunks/index-DY1ICa5c.mjs.map +0 -1
  72. package/dist/_chunks/index-DcFYhqke.mjs.map +0 -1
  73. package/dist/_chunks/index-DeCgextE.js.map +0 -1
  74. package/dist/_chunks/index-DzqTj_0f.mjs.map +0 -1
  75. package/dist/_chunks/index-NZpDoHIv.js.map +0 -1
  76. package/dist/_chunks/index-dzRHjemo.js.map +0 -1
  77. /package/dist/admin/src/pages/Settings/{index.d.ts → General/index.d.ts} +0 -0
@@ -7,7 +7,7 @@ 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-C6e9wLau.js");
10
+ const index = require("./index-Dxn0NT06.js");
11
11
  const admin = require("@strapi/strapi/admin");
12
12
  const FullLoader = require("./FullLoader-Cmsf8xS6.js");
13
13
  const symbols = require("@strapi/icons/symbols");
@@ -233,23 +233,21 @@ function NavCreate() {
233
233
  setLoading(true);
234
234
  try {
235
235
  const { data } = await post("/webatlas/navigation", { name, isActive });
236
- if (data.documentId) {
237
- navigate(`/plugins/webatlas/navigation/${data.documentId}`);
238
- setModalType("");
239
- } else {
240
- toggleNotification({
241
- type: "danger",
242
- message: formatMessage({
243
- id: index.getTranslation("notification.navigation.creationFailed"),
244
- defaultMessage: "Creation of navigation failed"
245
- })
246
- });
247
- }
236
+ if (!data.documentId) throw new Error("No documentId returned");
237
+ navigate(`/plugins/webatlas/navigation/${data.documentId}`);
238
+ setModalType("");
248
239
  } catch (err) {
249
240
  console.log(err);
241
+ toggleNotification({
242
+ type: "danger",
243
+ message: formatMessage({
244
+ id: index.getTranslation("notification.navigation.creationFailed"),
245
+ defaultMessage: "Creation of navigation failed"
246
+ })
247
+ });
250
248
  } finally {
249
+ setLoading(false);
251
250
  }
252
- setLoading(false);
253
251
  };
254
252
  return /* @__PURE__ */ jsxRuntime.jsx(
255
253
  NavModal,
@@ -284,14 +282,22 @@ function NavEdit({ item, onEdit }) {
284
282
  const [loading, setLoading] = React.useState(false);
285
283
  const { updateNavigation } = index.useApi();
286
284
  const { formatMessage } = reactIntl.useIntl();
285
+ const { toggleNotification } = admin.useNotification();
287
286
  const updateNav = async () => {
288
287
  setLoading(true);
289
288
  try {
290
289
  await updateNavigation(item.documentId, { name, visible });
291
290
  setModalType("NavOverview");
292
- onEdit();
291
+ onEdit({ ...item, name, visible });
293
292
  } catch (err) {
294
293
  console.log(err);
294
+ toggleNotification({
295
+ type: "danger",
296
+ message: formatMessage({
297
+ id: index.getTranslation("notification.navigation.updateFailed"),
298
+ defaultMessage: "Updating navigation failed"
299
+ })
300
+ });
295
301
  } finally {
296
302
  setLoading(false);
297
303
  }
@@ -305,17 +311,6 @@ function NavEdit({ item, onEdit }) {
305
311
  loadingText: formatMessage({ id: index.getTranslation("modal.navEdit.loadingText"), defaultMessage: "Updating" }),
306
312
  onConfirm: updateNav,
307
313
  loading,
308
- modalToOpen: "NavOverview",
309
- footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
310
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: () => setModalType("NavOverview"), variant: "tertiary", children: formatMessage({
311
- id: index.getTranslation("modal.navEdit.closeText"),
312
- defaultMessage: "Cancel"
313
- }) }),
314
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { children: formatMessage({
315
- id: index.getTranslation("modal.navEdit.confirmText"),
316
- defaultMessage: "Update"
317
- }) })
318
- ] }),
319
314
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
320
315
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { s: 12, m: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
321
316
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
@@ -4651,31 +4646,30 @@ function ItemCreateComponent({
4651
4646
  }, [path.needsUrlCheck, entityRoute?.documentId]);
4652
4647
  React.useEffect(() => {
4653
4648
  async function fetchRoute() {
4654
- if (selectedContentType?.contentType && selectedEntity?.id) {
4655
- setLoadingRoute(true);
4656
- try {
4657
- const route = await getRelatedRoute(selectedEntity.documentId);
4658
- if (!route) throw new Error("No route found for the selected entity");
4659
- dispatchPath({ type: "NO_URL_CHECK", payload: route.fullPath });
4660
- dispatchPath({ type: "SET_UIDPATH", payload: route.uidPath });
4661
- dispatchPath({ type: "SET_INITIALPATH", payload: route.fullPath });
4662
- dispatchItemState({ type: "SET_TITLE", payload: route.title });
4663
- dispatchItemState({ type: "SET_ACTIVE", payload: route.active });
4664
- dispatchItemState({ type: "SET_INTERNAL", payload: route.internal });
4665
- dispatchItemState({ type: "SET_OVERRIDE", payload: route.isOverride });
4666
- initialState.current = {
4667
- title: route.title,
4668
- slug: route.fullPath,
4669
- active: route.active,
4670
- internal: route.internal,
4671
- isOverride: route.isOverride
4672
- };
4673
- setEntityRoute(route);
4674
- } catch (err) {
4675
- console.log(err);
4676
- } finally {
4677
- setLoadingRoute(false);
4678
- }
4649
+ if (!selectedContentType?.contentType || !selectedEntity?.documentId) return;
4650
+ setLoadingRoute(true);
4651
+ try {
4652
+ const route = await getRelatedRoute(selectedEntity.documentId);
4653
+ if (!route) throw new Error("No route found for the selected entity");
4654
+ dispatchPath({ type: "NO_URL_CHECK", payload: route.fullPath });
4655
+ dispatchPath({ type: "SET_UIDPATH", payload: route.uidPath });
4656
+ dispatchPath({ type: "SET_INITIALPATH", payload: route.fullPath });
4657
+ dispatchItemState({ type: "SET_TITLE", payload: route.title });
4658
+ dispatchItemState({ type: "SET_ACTIVE", payload: route.active });
4659
+ dispatchItemState({ type: "SET_INTERNAL", payload: route.internal });
4660
+ dispatchItemState({ type: "SET_OVERRIDE", payload: route.isOverride });
4661
+ initialState.current = {
4662
+ title: route.title,
4663
+ slug: route.fullPath,
4664
+ active: route.active,
4665
+ internal: route.internal,
4666
+ isOverride: route.isOverride
4667
+ };
4668
+ setEntityRoute(route);
4669
+ } catch (err) {
4670
+ console.log(err);
4671
+ } finally {
4672
+ setLoadingRoute(false);
4679
4673
  }
4680
4674
  }
4681
4675
  fetchRoute();
@@ -10588,7 +10582,7 @@ const measuring = {
10588
10582
  }
10589
10583
  };
10590
10584
  const indentationWidth = 48;
10591
- function getProjection(items, activeId, overId, dragOffset) {
10585
+ function getProjection(items, activeId, overId, dragOffset, maxDepthValue) {
10592
10586
  if (!items) return { depth: 0, maxDepth: 0, minDepth: 0 };
10593
10587
  const overItemIndex = items.findIndex(({ id }) => id === overId);
10594
10588
  const activeItemIndex = items.findIndex(({ id }) => id === activeId);
@@ -10597,7 +10591,7 @@ function getProjection(items, activeId, overId, dragOffset) {
10597
10591
  const previousItem = newItems[overItemIndex - 1];
10598
10592
  const dragDepth = getDragDepth(dragOffset, indentationWidth);
10599
10593
  const projectedDepth = activeItem && typeof activeItem.depth === "number" ? activeItem.depth + dragDepth : 0;
10600
- let maxDepth = getMaxDepth({ previousItem });
10594
+ let maxDepth = getMaxDepth({ previousItem, maxDepthValue });
10601
10595
  let minDepth = 0;
10602
10596
  let depth = projectedDepth;
10603
10597
  if (projectedDepth >= maxDepth) {
@@ -10607,9 +10601,9 @@ function getProjection(items, activeId, overId, dragOffset) {
10607
10601
  }
10608
10602
  return { depth, maxDepth, minDepth };
10609
10603
  }
10610
- function getMaxDepth({ previousItem }) {
10604
+ function getMaxDepth({ previousItem, maxDepthValue }) {
10611
10605
  if (previousItem && typeof previousItem.depth === "number") {
10612
- return previousItem.depth + 1;
10606
+ return Math.min(previousItem.depth + 1, maxDepthValue - 1);
10613
10607
  }
10614
10608
  return 0;
10615
10609
  }
@@ -11840,6 +11834,7 @@ const Navigation = () => {
11840
11834
  const [isSavingNavigation, setIsSavingNavigation] = React.useState(false);
11841
11835
  const [loading, setLoading] = React.useState(true);
11842
11836
  const cachedNavigations = React.useRef(null);
11837
+ const { config } = index.usePluginConfig();
11843
11838
  const [projected, setProjected] = React.useState(null);
11844
11839
  const [activeItem, setActiveItem] = React.useState();
11845
11840
  const [activeId, setActiveId] = React.useState(null);
@@ -12029,7 +12024,8 @@ const Navigation = () => {
12029
12024
  navigationItems,
12030
12025
  activeId,
12031
12026
  overId,
12032
- offsetLeft
12027
+ offsetLeft,
12028
+ config?.navigation.maxDepth || 3
12033
12029
  ) : null;
12034
12030
  setProjected(projection);
12035
12031
  }, [activeId, overId, offsetLeft, navigationItems]);
@@ -12126,7 +12122,7 @@ const Navigation = () => {
12126
12122
  {
12127
12123
  variant: "NavDelete",
12128
12124
  item: actionItem,
12129
- onDelete: async (deletedItem) => {
12125
+ onDelete: (deletedItem) => {
12130
12126
  cachedNavigations.current = null;
12131
12127
  setNavigations((navs) => navs.filter((nav) => nav.id !== deletedItem.id));
12132
12128
  navigate("/plugins/webatlas/navigation");
@@ -12137,7 +12133,10 @@ const Navigation = () => {
12137
12133
  NavEdit,
12138
12134
  {
12139
12135
  item: actionItem,
12140
- onEdit: () => {
12136
+ onEdit: (editedNavigation) => {
12137
+ setNavigations(
12138
+ (navs) => navs?.map((nav) => nav.id === editedNavigation.id ? editedNavigation : nav)
12139
+ );
12141
12140
  }
12142
12141
  }
12143
12142
  ),
@@ -12167,7 +12166,6 @@ const Navigation = () => {
12167
12166
  {
12168
12167
  item: actionItem,
12169
12168
  onEdit: (editedItem) => {
12170
- console.log(editedItem);
12171
12169
  setNavigationItems(
12172
12170
  (items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
12173
12171
  );
@@ -4,58 +4,11 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const designSystem = require("@strapi/design-system");
6
6
  const admin = require("@strapi/strapi/admin");
7
- const index = require("./index-2J9mPFyV.js");
7
+ const index = require("./index-Dxn0NT06.js");
8
8
  const reactIntl = require("react-intl");
9
9
  require("@strapi/icons/symbols");
10
10
  const FullLoader = require("./FullLoader-Cmsf8xS6.js");
11
- function PageWrapper({
12
- settingsState,
13
- initialState,
14
- save,
15
- isSaving,
16
- children
17
- }) {
18
- const { formatMessage } = reactIntl.useIntl();
19
- return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
20
- /* @__PURE__ */ jsxRuntime.jsx(
21
- admin.Layouts.Header,
22
- {
23
- title: index.PLUGIN_NAME,
24
- subtitle: formatMessage({
25
- id: index.getTranslation("settings.page.subtitle"),
26
- defaultMessage: "Settings"
27
- }),
28
- primaryAction: settingsState && initialState && save && /* @__PURE__ */ jsxRuntime.jsx(
29
- designSystem.Button,
30
- {
31
- type: "submit",
32
- onClick: () => save(),
33
- loading: isSaving,
34
- disabled: JSON.stringify(settingsState) === JSON.stringify(initialState) || settingsState.selectedContentTypes.find((cta) => !cta.default) !== void 0 || isSaving,
35
- children: formatMessage({
36
- id: index.getTranslation("save"),
37
- defaultMessage: "Save"
38
- })
39
- }
40
- )
41
- }
42
- ),
43
- /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
44
- designSystem.Box,
45
- {
46
- background: "neutral0",
47
- borderColor: "neutral150",
48
- hasRadius: true,
49
- paddingBottom: 4,
50
- paddingLeft: 4,
51
- paddingRight: 4,
52
- paddingTop: 6,
53
- shadow: "tableShadow",
54
- children
55
- }
56
- ) })
57
- ] });
58
- }
11
+ const PageWrapper = require("./PageWrapper-Bp9vGwpG.js");
59
12
  function ContentTypeAccordion({
60
13
  contentType,
61
14
  contentTypeSettings,
@@ -147,44 +100,47 @@ function ContentTypeAccordion({
147
100
  contentType.uid
148
101
  );
149
102
  }
150
- function reducer(settingsState, action) {
103
+ function reducer(newConfig, action) {
151
104
  let updatedContentTypes;
152
105
  switch (action.type) {
153
106
  case "SET_SELECTED_CONTENT_TYPES":
107
+ if (!newConfig) return null;
154
108
  updatedContentTypes = action.payload.map((ct) => {
155
- return settingsState.selectedContentTypes.find((cta) => cta.uid === ct.uid) || ct;
109
+ return newConfig?.selectedContentTypes.find((cta) => cta.uid === ct.uid) || ct;
156
110
  });
157
- return { ...settingsState, selectedContentTypes: updatedContentTypes };
111
+ return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
158
112
  case "SET_DEFAULT_FIELD":
159
- updatedContentTypes = settingsState.selectedContentTypes.map(
113
+ if (!newConfig) return null;
114
+ updatedContentTypes = newConfig?.selectedContentTypes.map(
160
115
  (ct) => ct.uid === action.payload.ctUid ? { ...ct, default: action.payload.field } : ct
161
116
  );
162
- return { ...settingsState, selectedContentTypes: updatedContentTypes };
117
+ return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
163
118
  case "SET_PATTERN":
164
- updatedContentTypes = settingsState.selectedContentTypes.map(
119
+ if (!newConfig) return null;
120
+ updatedContentTypes = newConfig?.selectedContentTypes.map(
165
121
  (ct) => ct.uid === action.payload.ctUid ? { ...ct, pattern: index.transformToUrl(action.payload.pattern) } : ct
166
122
  );
167
- return { ...settingsState, selectedContentTypes: updatedContentTypes };
123
+ return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
124
+ case "SET_CONFIG":
125
+ return action.payload;
168
126
  default:
169
127
  throw new Error();
170
128
  }
171
129
  }
172
130
  const Settings = () => {
173
- const { config, setConfig, loading, fetchError } = index.usePluginConfig();
174
- const [settingsState, dispatch] = React.useReducer(reducer, config || { selectedContentTypes: [] });
131
+ const { config: fetchedConfig, setConfig, loading, fetchError } = index.usePluginConfig();
132
+ const [config, dispatch] = React.useReducer(reducer, fetchedConfig);
175
133
  const { contentTypes: allContentTypesData } = index.useAllContentTypes();
176
134
  const allContentTypes = allContentTypesData?.filter((ct) => ct.pluginOptions?.webatlas?.active === true);
177
- const [initialState, setInitialState] = React.useState(config || { selectedContentTypes: [] });
178
135
  const { toggleNotification } = admin.useNotification();
179
136
  const { formatMessage } = reactIntl.useIntl();
180
137
  const [isSaving, setIsSaving] = React.useState(false);
138
+ const initialConfig = React.useRef(fetchedConfig);
181
139
  React.useEffect(() => {
182
- setInitialState(config || { selectedContentTypes: [] });
183
- }, [config]);
184
- React.useEffect(() => {
185
- if (!config) return;
186
- dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: config.selectedContentTypes });
187
- }, [config]);
140
+ initialConfig.current = fetchedConfig;
141
+ if (fetchedConfig)
142
+ dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
143
+ }, [fetchedConfig]);
188
144
  React.useEffect(() => {
189
145
  if (fetchError) {
190
146
  toggleNotification({
@@ -197,11 +153,11 @@ const Settings = () => {
197
153
  }
198
154
  }, [fetchError, toggleNotification, formatMessage]);
199
155
  async function save() {
200
- if (!settingsState || settingsState.selectedContentTypes.find((cta) => !cta.default) !== void 0) return;
156
+ if (!config || config.selectedContentTypes.find((cta) => !cta.default) !== void 0) return;
201
157
  setIsSaving(true);
202
158
  try {
203
- await setConfig(settingsState);
204
- setInitialState(settingsState);
159
+ await setConfig({ selectedContentTypes: config.selectedContentTypes });
160
+ initialConfig.current = config;
205
161
  toggleNotification({
206
162
  type: "success",
207
163
  message: formatMessage({
@@ -223,60 +179,74 @@ const Settings = () => {
223
179
  }
224
180
  }
225
181
  if (loading) {
226
- return /* @__PURE__ */ jsxRuntime.jsx(PageWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, { height: 200 }) });
227
- }
228
- return /* @__PURE__ */ jsxRuntime.jsxs(PageWrapper, { settingsState, initialState, save, isSaving, children: [
229
- /* @__PURE__ */ jsxRuntime.jsxs(
230
- designSystem.Field.Root,
182
+ return /* @__PURE__ */ jsxRuntime.jsx(
183
+ PageWrapper.PageWrapper,
231
184
  {
232
- name: "selectedContentTypes",
233
- hint: formatMessage({
234
- id: index.getTranslation("settings.page.enabledContentTypes.hint"),
235
- defaultMessage: "Select the content types for which you want to enable URL aliases"
236
- }),
237
- children: [
185
+ isSaving,
186
+ disabledCondition: true,
187
+ children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, { height: 200 })
188
+ }
189
+ );
190
+ }
191
+ return /* @__PURE__ */ jsxRuntime.jsxs(
192
+ PageWrapper.PageWrapper,
193
+ {
194
+ save,
195
+ isSaving,
196
+ disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current),
197
+ children: [
198
+ /* @__PURE__ */ jsxRuntime.jsxs(
199
+ designSystem.Field.Root,
200
+ {
201
+ name: "selectedContentTypes",
202
+ hint: formatMessage({
203
+ id: index.getTranslation("settings.page.enabledContentTypes.hint"),
204
+ defaultMessage: "Select the content types for which you want to enable URL aliases"
205
+ }),
206
+ children: [
207
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
208
+ id: index.getTranslation("settings.page.enabledContentTypes"),
209
+ defaultMessage: "Enabled Content Types"
210
+ }) }),
211
+ /* @__PURE__ */ jsxRuntime.jsx(
212
+ designSystem.MultiSelect,
213
+ {
214
+ placeholder: formatMessage({
215
+ id: index.getTranslation("settings.page.enabledContentTypes.placeholder"),
216
+ defaultMessage: "Select content types..."
217
+ }),
218
+ onClear: () => dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: [] }),
219
+ value: [...config?.selectedContentTypes.map((ct) => ct.uid) || []],
220
+ onChange: (value) => dispatch({
221
+ type: "SET_SELECTED_CONTENT_TYPES",
222
+ payload: value.map((v) => ({
223
+ uid: v,
224
+ default: "",
225
+ pattern: ""
226
+ }))
227
+ }),
228
+ withTags: true,
229
+ children: allContentTypes && allContentTypes.map(
230
+ (item) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MultiSelectOption, { value: item.uid, children: item.info.displayName }, item.uid)
231
+ )
232
+ }
233
+ ),
234
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
235
+ ]
236
+ }
237
+ ),
238
+ config?.selectedContentTypes && config.selectedContentTypes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "selectedContentTypesAccordion", children: [
238
239
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
239
- id: index.getTranslation("settings.page.enabledContentTypes"),
240
- defaultMessage: "Enabled Content Types"
240
+ id: index.getTranslation("settings.page.contentTypeSettings"),
241
+ defaultMessage: "Content Type settings"
241
242
  }) }),
242
- /* @__PURE__ */ jsxRuntime.jsx(
243
- designSystem.MultiSelect,
244
- {
245
- placeholder: formatMessage({
246
- id: index.getTranslation("settings.page.enabledContentTypes.placeholder"),
247
- defaultMessage: "Select content types..."
248
- }),
249
- onClear: () => dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: [] }),
250
- value: [...settingsState.selectedContentTypes.map((ct) => ct.uid)],
251
- onChange: (value) => dispatch({
252
- type: "SET_SELECTED_CONTENT_TYPES",
253
- payload: value.map((v) => ({
254
- uid: v,
255
- default: "",
256
- pattern: ""
257
- }))
258
- }),
259
- withTags: true,
260
- children: allContentTypes && allContentTypes.map(
261
- (item) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MultiSelectOption, { value: item.uid, children: item.info.displayName }, item.uid)
262
- )
263
- }
264
- ),
265
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
266
- ]
267
- }
268
- ),
269
- settingsState.selectedContentTypes && settingsState.selectedContentTypes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "selectedContentTypesAccordion", children: [
270
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
271
- id: index.getTranslation("settings.page.contentTypeSettings"),
272
- defaultMessage: "Content Type settings"
273
- }) }),
274
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { children: settingsState.selectedContentTypes?.map((contentTypeSettings) => {
275
- const ct = allContentTypes?.find((item) => item.uid === contentTypeSettings.uid);
276
- return /* @__PURE__ */ jsxRuntime.jsx(ContentTypeAccordion, { contentType: ct, contentTypeSettings, dispatch }, contentTypeSettings.uid);
277
- }) })
278
- ] }) })
279
- ] });
243
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { children: config.selectedContentTypes?.map((contentTypeSettings) => {
244
+ const ct = allContentTypes?.find((item) => item.uid === contentTypeSettings.uid);
245
+ return /* @__PURE__ */ jsxRuntime.jsx(ContentTypeAccordion, { contentType: ct, contentTypeSettings, dispatch }, contentTypeSettings.uid);
246
+ }) })
247
+ ] }) })
248
+ ]
249
+ }
250
+ );
280
251
  };
281
252
  exports.default = Settings;
282
- //# sourceMappingURL=index-NZpDoHIv.js.map
@@ -41,7 +41,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
41
41
  );
42
42
  });
43
43
  };
44
- const version = "0.7.1";
44
+ const version = "0.8.0";
45
45
  const keywords = [];
46
46
  const type = "commonjs";
47
47
  const exports$1 = {
@@ -312,6 +312,10 @@ function usePluginConfig() {
312
312
  config2 = { ...config2, selectedContentTypes: activeContentTypes };
313
313
  await setConfig(config2);
314
314
  }
315
+ if (config2.navigation?.maxDepth === void 0) {
316
+ config2.navigation = { ...config2.navigation, maxDepth: 3 };
317
+ await setConfig(config2);
318
+ }
315
319
  setConfigData(config2);
316
320
  } catch (error) {
317
321
  setFetchError(error.message);
@@ -3636,7 +3640,7 @@ const $a093c7e1ec25a057$export$7c6e2c02157bb7d2 = $a093c7e1ec25a057$export$e9003
3636
3640
  function Tooltip({ description: description2 }) {
3637
3641
  return /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$2881499e37b75b9a, { children: /* @__PURE__ */ jsxRuntime.jsxs($a093c7e1ec25a057$export$be92b6f5f03c0fe9, { children: [
3638
3642
  /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$41fb9f06171c75f4, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Information, { "aria-hidden": "true" }) }),
3639
- /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { sideOffset: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
3643
+ /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntime.jsx($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { sideOffset: 5, style: { zIndex: 9999 }, children: /* @__PURE__ */ jsxRuntime.jsx(
3640
3644
  designSystem.Box,
3641
3645
  {
3642
3646
  padding: 2,
@@ -4077,7 +4081,7 @@ const index = {
4077
4081
  defaultMessage: "Routes"
4078
4082
  },
4079
4083
  Component: async () => {
4080
- const component = await Promise.resolve().then(() => require("./index-dzRHjemo.js"));
4084
+ const component = await Promise.resolve().then(() => require("./index-BKdvSgDB.js"));
4081
4085
  return { default: component.default };
4082
4086
  },
4083
4087
  permissions: [
@@ -4096,7 +4100,7 @@ const index = {
4096
4100
  defaultMessage: "Navigation"
4097
4101
  },
4098
4102
  Component: async () => {
4099
- const component = await Promise.resolve().then(() => require("./index-DCejsR9X.js"));
4103
+ const component = await Promise.resolve().then(() => require("./index-DTPDMxs_.js"));
4100
4104
  return { default: component.default };
4101
4105
  },
4102
4106
  permissions: [
@@ -4112,20 +4116,44 @@ const index = {
4112
4116
  id: PLUGIN_ID,
4113
4117
  intlLabel: {
4114
4118
  id: `${PLUGIN_ID}.settings.section`,
4115
- defaultMessage: "Webatlas"
4119
+ defaultMessage: PLUGIN_NAME
4116
4120
  }
4117
4121
  },
4118
4122
  {
4119
4123
  intlLabel: {
4120
- id: `${PLUGIN_ID}.settings.section`,
4121
- defaultMessage: "Configuration"
4124
+ id: `${PLUGIN_ID}.settings.section.general`,
4125
+ defaultMessage: "General"
4122
4126
  },
4123
- id: PLUGIN_ID,
4124
- to: `/settings/${PLUGIN_ID}/configuration`,
4127
+ id: `${PLUGIN_ID}-general`,
4128
+ to: `/settings/${PLUGIN_ID}/general`,
4129
+ Component: async () => {
4130
+ return await Promise.resolve().then(() => require(
4131
+ /* webpackChunkName: "webatlas-settings-general-page" */
4132
+ "./index-DUgh4AJb.js"
4133
+ ));
4134
+ },
4135
+ permissions: [
4136
+ // Uncomment to set the permissions of the plugin here
4137
+ // {
4138
+ // action: '', // the action name should be plugin::plugin-name.actionType
4139
+ // subject: null,
4140
+ // },
4141
+ ]
4142
+ }
4143
+ );
4144
+ app.addSettingsLink(
4145
+ PLUGIN_ID,
4146
+ {
4147
+ intlLabel: {
4148
+ id: `${PLUGIN_ID}.settings.navigation`,
4149
+ defaultMessage: "Navigation"
4150
+ },
4151
+ id: `${PLUGIN_ID}-navigation`,
4152
+ to: `/settings/${PLUGIN_ID}/navigation`,
4125
4153
  Component: async () => {
4126
4154
  return await Promise.resolve().then(() => require(
4127
- /* webpackChunkName: "webatlas-settings-page" */
4128
- "./index-NZpDoHIv.js"
4155
+ /* webpackChunkName: "webatlas-settings-navigation-page" */
4156
+ "./index-D72CZ5b7.js"
4129
4157
  ));
4130
4158
  },
4131
4159
  permissions: [
@@ -4154,7 +4182,7 @@ const index = {
4154
4182
  return Promise.all(
4155
4183
  locales.map(async (locale) => {
4156
4184
  try {
4157
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-BZc1BkzH.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-Deg4n_IM.js")) }), `./translations/${locale}.json`, 3);
4185
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-CDBoUBzw.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-DfvURaup.js")) }), `./translations/${locale}.json`, 3);
4158
4186
  return { data, locale };
4159
4187
  } catch {
4160
4188
  return { data: {}, locale };
@@ -4174,4 +4202,3 @@ exports.transformToUrl = transformToUrl;
4174
4202
  exports.useAllContentTypes = useAllContentTypes;
4175
4203
  exports.useApi = useApi;
4176
4204
  exports.usePluginConfig = usePluginConfig;
4177
- //# sourceMappingURL=index-2J9mPFyV.js.map