@mattisvensson/strapi-plugin-webatlas 0.3.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/_chunks/{EmptyBox-7D4LrvdH.mjs → EmptyBox-BM4IscSk.mjs} +2 -6
  2. package/dist/_chunks/{EmptyBox-DT6D5gcf.js → EmptyBox-T8t29l25.js} +1 -5
  3. package/dist/_chunks/FullLoader-Cmsf8xS6.js +11 -0
  4. package/dist/_chunks/FullLoader-CrPED_dY.mjs +12 -0
  5. package/dist/_chunks/{de-C8PE3n3B.mjs → de-Dn24NwJf.mjs} +11 -1
  6. package/dist/_chunks/{de-4tL_cJTC.js → de-RiCps8UH.js} +11 -1
  7. package/dist/_chunks/{en-CR1YZvJo.mjs → en-D9Lxaugc.mjs} +11 -1
  8. package/dist/_chunks/{en-Bg4z3fR7.js → en-JLW5S3ZC.js} +11 -1
  9. package/dist/_chunks/index-9db80XRS.mjs +126 -0
  10. package/dist/_chunks/{index-CwHhwtOU.mjs → index-B4pe6Yuh.mjs} +1375 -357
  11. package/dist/_chunks/{index-CKoxbSC0.js → index-CSYue_D0.js} +42 -60
  12. package/dist/_chunks/index-CVj7qbwh.mjs +281 -0
  13. package/dist/_chunks/index-CiY-8z8F.js +126 -0
  14. package/dist/_chunks/{index-BAqGJ3TM.js → index-Clikpy91.js} +1381 -363
  15. package/dist/_chunks/{index-BBL_eQ0G.mjs → index-CtJ_9-RB.mjs} +42 -60
  16. package/dist/_chunks/index-IHvD3566.js +281 -0
  17. package/dist/admin/index.js +1 -1
  18. package/dist/admin/index.mjs +1 -1
  19. package/dist/admin/src/components/UI/FullLoader.d.ts +3 -0
  20. package/dist/admin/src/components/UI/index.d.ts +2 -1
  21. package/dist/admin/src/components/modals/Delete.d.ts +3 -3
  22. package/dist/admin/src/components/modals/NavEdit.d.ts +2 -2
  23. package/dist/admin/src/components/modals/externalItem/index.d.ts +10 -4
  24. package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +1 -1
  25. package/dist/admin/src/components/modals/wrapperItem/index.d.ts +11 -5
  26. package/dist/admin/src/hooks/useApi.d.ts +6 -5
  27. package/dist/admin/src/hooks/useNavigations.d.ts +2 -0
  28. package/dist/admin/src/hooks/usePluginConfig.d.ts +3 -3
  29. package/dist/admin/src/pages/Navigation/PageWrapper.d.ts +7 -0
  30. package/dist/admin/src/pages/Navigation/index.d.ts +1 -1
  31. package/dist/admin/src/pages/Routes/PageWrapper.d.ts +4 -0
  32. package/dist/admin/src/pages/Routes/TableHeader.d.ts +1 -0
  33. package/dist/admin/src/pages/Routes/TableRow.d.ts +4 -0
  34. package/dist/admin/src/pages/Settings/ContentTypeAccordion.d.ts +7 -0
  35. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +8 -0
  36. package/dist/admin/src/utils/createTempNavItemObject.d.ts +25 -0
  37. package/dist/admin/src/utils/index.d.ts +2 -1
  38. package/dist/server/index.js +225 -176
  39. package/dist/server/index.mjs +225 -176
  40. package/dist/server/src/controllers/admin.d.ts +1 -4
  41. package/dist/server/src/controllers/index.d.ts +1 -4
  42. package/dist/server/src/index.d.ts +2 -8
  43. package/dist/server/src/services/admin.d.ts +2 -5
  44. package/dist/server/src/services/index.d.ts +1 -4
  45. package/dist/server/src/utils/navItemHandler.d.ts +5 -0
  46. package/dist/server/src/utils/routeHandler.d.ts +3 -0
  47. package/package.json +1 -1
  48. package/dist/_chunks/_baseConvert-B84_vf8X.js +0 -864
  49. package/dist/_chunks/_baseConvert-C2SW1VHq.mjs +0 -865
  50. package/dist/_chunks/index-BOq-WidK.mjs +0 -17176
  51. package/dist/_chunks/index-C4ou6MTp.js +0 -17195
  52. package/dist/_chunks/index-DZmhgSeq.mjs +0 -92
  53. package/dist/_chunks/index-DsTyLL2l.js +0 -92
  54. package/dist/admin/src/pages/Navigation/Header.d.ts +0 -6
  55. package/dist/server/index.js.map +0 -1
  56. package/dist/server/index.mjs.map +0 -1
@@ -23,7 +23,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
23
23
  );
24
24
  });
25
25
  };
26
- const version = "0.3.0";
26
+ const version = "0.4.1";
27
27
  const keywords = [];
28
28
  const type = "commonjs";
29
29
  const exports = {
@@ -197,14 +197,6 @@ function useApi() {
197
197
  const { data } = await get(`/webatlas/route/related?documentId=${relatedDocumentId}`);
198
198
  return data;
199
199
  };
200
- const createExternalRoute = async (body) => {
201
- const { data } = await post("/webatlas/route/external", {
202
- data: {
203
- ...body
204
- }
205
- });
206
- return data;
207
- };
208
200
  const getRoutes = async () => {
209
201
  const { data } = await get("/webatlas/route");
210
202
  return data;
@@ -217,30 +209,17 @@ function useApi() {
217
209
  });
218
210
  return data;
219
211
  };
220
- const createNavItem = async (body) => {
221
- const { data } = await post("/webatlas/navitem", {
222
- data: {
223
- ...body
224
- }
225
- });
226
- return data;
227
- };
228
- const updateNavItem = async (documentId, body) => {
229
- const { data } = await put(`/webatlas/navitem?documentId=${documentId}`, {
230
- data: {
231
- ...body
232
- }
233
- });
234
- return data;
235
- };
236
- const deleteNavItem = async (documentId) => {
237
- const { data } = await del(`/webatlas/navitem?documentId=${documentId}`);
238
- return data;
239
- };
240
212
  const getStructuredNavigation = async (documentId, variant = "nested") => {
241
213
  const { data } = await get(`/webatlas/navigation?documentId=${documentId}&variant=${variant}`);
242
214
  return data;
243
215
  };
216
+ const getNavigation = async ({ documentId, variant } = {}) => {
217
+ const query = [];
218
+ if (documentId) query.push(`documentId=${documentId}`);
219
+ if (variant) query.push(`variant=${variant}`);
220
+ const { data } = await get(`/webatlas/navigation${query.length > 0 ? `?${query.join("&")}` : ""}`);
221
+ return data;
222
+ };
244
223
  const deleteNavigation = async (documentId) => {
245
224
  const { data } = await del(`/webatlas/navigation?documentId=${documentId}`);
246
225
  return data;
@@ -251,19 +230,24 @@ function useApi() {
251
230
  });
252
231
  return data;
253
232
  };
233
+ const updateNavigationItemStructure = async (documentId, navigationItems) => {
234
+ const { data } = await put(`/webatlas/navigation/items`, {
235
+ navigationId: documentId,
236
+ navigationItems
237
+ });
238
+ return data;
239
+ };
254
240
  return {
255
241
  fetchAllContentTypes,
256
242
  fetchAllEntities,
257
243
  getRelatedRoute,
258
- createExternalRoute,
259
244
  getRoutes,
260
245
  updateRoute,
261
- createNavItem,
262
- updateNavItem,
263
- deleteNavItem,
264
246
  getStructuredNavigation,
247
+ getNavigation,
265
248
  deleteNavigation,
266
- updateNavigation
249
+ updateNavigation,
250
+ updateNavigationItemStructure
267
251
  };
268
252
  }
269
253
  const useAllContentTypes = () => {
@@ -288,31 +272,32 @@ const useAllContentTypes = () => {
288
272
  };
289
273
  function usePluginConfig() {
290
274
  const { put, get } = useFetchClient();
291
- const [data, setData] = useState(null);
292
- const [loading, setLoading] = useState(false);
293
- const [error, setError] = useState(null);
275
+ const [config, setConfigData] = useState(null);
276
+ const [loading, setLoading] = useState(true);
277
+ const [fetchError, setFetchError] = useState(null);
294
278
  useEffect(() => {
295
279
  const fetchData = async () => {
296
280
  setLoading(true);
281
+ setFetchError(null);
297
282
  try {
298
283
  const { data: { data: contentTypesArray } } = await get("/content-manager/content-types");
299
- let { data: config } = await get("/webatlas/config");
300
- if (!config || !config.selectedContentTypes) {
301
- throw new Error(`HTTP error! Couldn't fetch plugin config`);
284
+ let { data: config2 } = await get("/webatlas/config");
285
+ if (!config2 || !config2.selectedContentTypes) {
286
+ throw new Error(`Couldn't fetch plugin config`);
302
287
  }
303
288
  const allowedContentTypes = contentTypesArray.filter(
304
289
  (type2) => type2.pluginOptions?.webatlas?.active === true
305
290
  );
306
291
  const contentTypeUids = new Set(allowedContentTypes.map((type2) => type2.uid));
307
- const activeContentTypes = config.selectedContentTypes.filter((type2) => contentTypeUids.has(type2.uid));
308
- if (JSON.stringify(activeContentTypes) !== JSON.stringify(config.selectedContentTypes)) {
309
- config = { ...config, selectedContentTypes: activeContentTypes };
310
- setConfig(config);
292
+ const activeContentTypes = config2.selectedContentTypes.filter((type2) => contentTypeUids.has(type2.uid));
293
+ if (JSON.stringify(activeContentTypes) !== JSON.stringify(config2.selectedContentTypes)) {
294
+ config2 = { ...config2, selectedContentTypes: activeContentTypes };
295
+ await setConfig(config2);
311
296
  }
312
- setData(config);
313
- setLoading(false);
314
- } catch (error2) {
315
- setError(error2.message);
297
+ setConfigData(config2);
298
+ } catch (error) {
299
+ setFetchError(error.message);
300
+ } finally {
316
301
  setLoading(false);
317
302
  }
318
303
  };
@@ -320,14 +305,12 @@ function usePluginConfig() {
320
305
  }, []);
321
306
  async function setConfig(body) {
322
307
  try {
323
- await put("/webatlas/config", {
324
- ...body
325
- });
326
- } catch (error2) {
327
- setError(error2.message);
308
+ await put("/webatlas/config", { ...body });
309
+ } catch (error) {
310
+ throw error;
328
311
  }
329
312
  }
330
- return { data, loading, error, setConfig };
313
+ return { config, loading, fetchError, setConfig };
331
314
  }
332
315
  function transformToUrl(input) {
333
316
  const specialCharMap = {
@@ -3988,7 +3971,7 @@ const Alias = ({ config }) => {
3988
3971
  const CMEditViewAside = () => {
3989
3972
  const { model } = unstable_useContentManagerContext();
3990
3973
  const { contentTypes } = useAllContentTypes();
3991
- const { data: config } = usePluginConfig();
3974
+ const { config } = usePluginConfig();
3992
3975
  const [contentTypeConfig, setContentTypeConfig] = useState(null);
3993
3976
  const [isAllowedContentType, setIsAllowedContentType] = useState(false);
3994
3977
  const [isActiveContentType, setIsActiveContentType] = useState(false);
@@ -4076,7 +4059,7 @@ const index = {
4076
4059
  defaultMessage: "Routes"
4077
4060
  },
4078
4061
  Component: async () => {
4079
- const component = await import("./index-DZmhgSeq.mjs");
4062
+ const component = await import("./index-9db80XRS.mjs");
4080
4063
  return { default: component.default };
4081
4064
  },
4082
4065
  permissions: [
@@ -4095,7 +4078,7 @@ const index = {
4095
4078
  defaultMessage: "Navigation"
4096
4079
  },
4097
4080
  Component: async () => {
4098
- const component = await import("./index-CwHhwtOU.mjs");
4081
+ const component = await import("./index-B4pe6Yuh.mjs");
4099
4082
  return { default: component.default };
4100
4083
  },
4101
4084
  permissions: [
@@ -4124,7 +4107,7 @@ const index = {
4124
4107
  Component: async () => {
4125
4108
  return await import(
4126
4109
  /* webpackChunkName: "webatlas-settings-page" */
4127
- "./index-BOq-WidK.mjs"
4110
+ "./index-CVj7qbwh.mjs"
4128
4111
  );
4129
4112
  },
4130
4113
  permissions: [
@@ -4153,7 +4136,7 @@ const index = {
4153
4136
  return Promise.all(
4154
4137
  locales.map(async (locale) => {
4155
4138
  try {
4156
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-C8PE3n3B.mjs"), "./translations/en.json": () => import("./en-CR1YZvJo.mjs") }), `./translations/${locale}.json`, 3);
4139
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-Dn24NwJf.mjs"), "./translations/en.json": () => import("./en-D9Lxaugc.mjs") }), `./translations/${locale}.json`, 3);
4157
4140
  return { data, locale };
4158
4141
  } catch {
4159
4142
  return { data: {}, locale };
@@ -4166,7 +4149,6 @@ export {
4166
4149
  PLUGIN_NAME as P,
4167
4150
  Tooltip as T,
4168
4151
  URLInfo as U,
4169
- _extends as _,
4170
4152
  duplicateCheck as a,
4171
4153
  usePluginConfig as b,
4172
4154
  useAllContentTypes as c,
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const designSystem = require("@strapi/design-system");
6
+ const admin = require("@strapi/strapi/admin");
7
+ const index = require("./index-CSYue_D0.js");
8
+ const reactIntl = require("react-intl");
9
+ require("@strapi/icons/symbols");
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
+ }
59
+ function ContentTypeAccordion({
60
+ contentType,
61
+ contentTypeSettings,
62
+ dispatch
63
+ }) {
64
+ const { formatMessage } = reactIntl.useIntl();
65
+ if (!contentType) return null;
66
+ return /* @__PURE__ */ jsxRuntime.jsx(
67
+ designSystem.Box,
68
+ {
69
+ borderColor: !contentTypeSettings.default && "danger500",
70
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: contentType.uid, size: "S", children: [
71
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: contentType?.info.displayName }) }),
72
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 3, children: [
73
+ /* @__PURE__ */ jsxRuntime.jsxs(
74
+ designSystem.Field.Root,
75
+ {
76
+ name: "selectedContentTypes",
77
+ hint: formatMessage({
78
+ id: index.getTranslation("settings.page.defaultField.hint"),
79
+ defaultMessage: 'The selected field from the content type will be used to generate the URL alias. Use a field that is unique and descriptive, such as a "title" or "name".'
80
+ }),
81
+ error: !contentTypeSettings.default && formatMessage({
82
+ id: index.getTranslation("settings.page.defaultField.error"),
83
+ defaultMessage: "Please select a default field"
84
+ }),
85
+ required: true,
86
+ children: [
87
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
88
+ id: index.getTranslation("settings.page.defaultField"),
89
+ defaultMessage: "Default URL Alias field"
90
+ }) }),
91
+ /* @__PURE__ */ jsxRuntime.jsx(
92
+ designSystem.SingleSelect,
93
+ {
94
+ name: `defaultField-${contentType.uid}`,
95
+ onClear: () => dispatch({ type: "SET_DEFAULT_FIELD", payload: { ctUid: contentType.uid, field: "" } }),
96
+ value: contentTypeSettings?.default || "",
97
+ onChange: (value) => dispatch({ type: "SET_DEFAULT_FIELD", payload: { ctUid: contentType.uid, field: value } }),
98
+ children: Object.entries(contentType.attributes).map(([key], index2) => {
99
+ if (key === "id" || key === "documentId" || key === "createdAt" || key === "updatedAt" || key === "createdBy" || key === "updatedBy" || key === "webatlas_path" || key === "webatlas_override") return null;
100
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: key, children: key }, index2);
101
+ })
102
+ }
103
+ ),
104
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
105
+ ]
106
+ }
107
+ ),
108
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
109
+ designSystem.Field.Root,
110
+ {
111
+ name: "urlAliasPattern",
112
+ hint: formatMessage({
113
+ id: index.getTranslation("settings.page.urlAliasPattern.hint"),
114
+ defaultMessage: 'The pattern to prepend to the generated URL alias. For example, if you enter "blog" and the value of default field is "My First Post", the generated URL alias will be "blog/my-first-post". Leave empty for no prefix.'
115
+ }),
116
+ children: [
117
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { children: [
118
+ formatMessage({
119
+ id: index.getTranslation("settings.page.urlAliasPattern"),
120
+ defaultMessage: "URL Alias Pattern"
121
+ }),
122
+ /* @__PURE__ */ jsxRuntime.jsx(index.Tooltip, { description: formatMessage({
123
+ id: index.getTranslation("settings.page.urlAliasPattern.tooltip"),
124
+ defaultMessage: "Leading and trailing slashes will be removed. Spaces will be replaced with hyphens. Special characters will be encoded."
125
+ }) })
126
+ ] }),
127
+ /* @__PURE__ */ jsxRuntime.jsx(
128
+ designSystem.Field.Input,
129
+ {
130
+ value: contentTypeSettings.pattern,
131
+ onChange: (e) => dispatch({ type: "SET_PATTERN", payload: { ctUid: contentType.uid, pattern: e.target.value } }),
132
+ disabled: !contentTypeSettings.default,
133
+ type: "text",
134
+ placeholder: formatMessage({
135
+ id: index.getTranslation("settings.page.urlAliasPattern.placeholder"),
136
+ defaultMessage: "e.g. blog"
137
+ })
138
+ }
139
+ ),
140
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
141
+ ]
142
+ }
143
+ ) })
144
+ ] }) })
145
+ ] }, contentType.uid)
146
+ },
147
+ contentType.uid
148
+ );
149
+ }
150
+ function reducer(settingsState, action) {
151
+ let updatedContentTypes;
152
+ switch (action.type) {
153
+ case "SET_SELECTED_CONTENT_TYPES":
154
+ updatedContentTypes = action.payload.map((ct) => {
155
+ return settingsState.selectedContentTypes.find((cta) => cta.uid === ct.uid) || ct;
156
+ });
157
+ return { ...settingsState, selectedContentTypes: updatedContentTypes };
158
+ case "SET_DEFAULT_FIELD":
159
+ updatedContentTypes = settingsState.selectedContentTypes.map(
160
+ (ct) => ct.uid === action.payload.ctUid ? { ...ct, default: action.payload.field } : ct
161
+ );
162
+ return { ...settingsState, selectedContentTypes: updatedContentTypes };
163
+ case "SET_PATTERN":
164
+ updatedContentTypes = settingsState.selectedContentTypes.map(
165
+ (ct) => ct.uid === action.payload.ctUid ? { ...ct, pattern: index.transformToUrl(action.payload.pattern) } : ct
166
+ );
167
+ return { ...settingsState, selectedContentTypes: updatedContentTypes };
168
+ default:
169
+ throw new Error();
170
+ }
171
+ }
172
+ const Settings = () => {
173
+ const { config, setConfig, loading, fetchError } = index.usePluginConfig();
174
+ const [settingsState, dispatch] = React.useReducer(reducer, config || { selectedContentTypes: [] });
175
+ const { contentTypes: allContentTypesData } = index.useAllContentTypes();
176
+ const allContentTypes = allContentTypesData?.filter((ct) => ct.pluginOptions?.webatlas?.active === true);
177
+ const [initialState, setInitialState] = React.useState(config || { selectedContentTypes: [] });
178
+ const { toggleNotification } = admin.useNotification();
179
+ const { formatMessage } = reactIntl.useIntl();
180
+ const [isSaving, setIsSaving] = React.useState(false);
181
+ 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]);
188
+ React.useEffect(() => {
189
+ if (fetchError) {
190
+ toggleNotification({
191
+ type: "danger",
192
+ message: formatMessage({
193
+ id: index.getTranslation("notification.error"),
194
+ defaultMessage: "An error occurred"
195
+ }) + ": " + fetchError
196
+ });
197
+ }
198
+ }, [fetchError, toggleNotification, formatMessage]);
199
+ async function save() {
200
+ if (!settingsState || settingsState.selectedContentTypes.find((cta) => !cta.default) !== void 0) return;
201
+ setIsSaving(true);
202
+ try {
203
+ await setConfig(settingsState);
204
+ setInitialState(settingsState);
205
+ toggleNotification({
206
+ type: "success",
207
+ message: formatMessage({
208
+ id: index.getTranslation("notification.settings.saved"),
209
+ defaultMessage: "Settings saved successfully"
210
+ })
211
+ });
212
+ setIsSaving(false);
213
+ } catch (err) {
214
+ setIsSaving(false);
215
+ toggleNotification({
216
+ type: "danger",
217
+ message: formatMessage({
218
+ id: index.getTranslation("notification.error"),
219
+ defaultMessage: "An error occurred"
220
+ }) + ": " + err
221
+ });
222
+ console.error(err);
223
+ }
224
+ }
225
+ 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,
231
+ {
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: [
238
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
239
+ id: index.getTranslation("settings.page.enabledContentTypes"),
240
+ defaultMessage: "Enabled Content Types"
241
+ }) }),
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
+ ] });
280
+ };
281
+ exports.default = Settings;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-CKoxbSC0.js");
2
+ const index = require("../_chunks/index-CSYue_D0.js");
3
3
  require("react/jsx-runtime");
4
4
  module.exports = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "../_chunks/index-BBL_eQ0G.mjs";
1
+ import { i } from "../_chunks/index-CtJ_9-RB.mjs";
2
2
  import "react/jsx-runtime";
3
3
  export {
4
4
  i as default
@@ -0,0 +1,3 @@
1
+ export default function FullLoader({ height }: {
2
+ height?: number;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
1
  import Center from "./Center";
2
2
  import EmptyBox from "./EmptyBox";
3
- export { Center, EmptyBox, };
3
+ import FullLoader from "./FullLoader";
4
+ export { Center, EmptyBox, FullLoader, };
@@ -2,13 +2,13 @@ import { NestedNavigation, NestedNavItem } from '../../../../types';
2
2
  type NavDelete = {
3
3
  variant: "NavDelete";
4
4
  item: NestedNavigation;
5
- fetchNavigations: () => void;
5
+ onDelete: (editedItem: NestedNavigation) => void;
6
6
  };
7
7
  type ItemDelete = {
8
8
  variant: "ItemDelete";
9
9
  item: NestedNavItem;
10
- fetchNavigations: () => void;
10
+ onDelete: (editedItem: NestedNavItem) => void;
11
11
  };
12
12
  type DeleteProps = NavDelete | ItemDelete;
13
- export default function Delete({ variant, item, fetchNavigations }: DeleteProps): import("react/jsx-runtime").JSX.Element;
13
+ export default function Delete({ variant, item, onDelete }: DeleteProps): import("react/jsx-runtime").JSX.Element;
14
14
  export {};
@@ -1,7 +1,7 @@
1
1
  import { NestedNavigation } from '../../../../types';
2
2
  type NavEditProps = {
3
3
  item: NestedNavigation;
4
- fetchNavigations: () => void;
4
+ onEdit: () => void;
5
5
  };
6
- export default function NavEdit({ item, fetchNavigations }: NavEditProps): import("react/jsx-runtime").JSX.Element;
6
+ export default function NavEdit({ item, onEdit }: NavEditProps): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -1,9 +1,15 @@
1
1
  import { NestedNavItem } from '../../../../../types';
2
2
  import React from 'react';
3
- type externalItemProps = {
4
- variant: 'ExternalCreate' | 'ExternalEdit';
5
- item?: NestedNavItem;
6
- parentDocumentId?: string;
3
+ type externalCreateProps = {
4
+ variant: 'ExternalCreate';
5
+ parentId?: string;
6
+ onCreate: (newItem: NestedNavItem) => void;
7
7
  };
8
+ type externalEditProps = {
9
+ variant: 'ExternalEdit';
10
+ item: NestedNavItem;
11
+ onSave: (editedItem: NestedNavItem) => void;
12
+ };
13
+ type externalItemProps = externalCreateProps | externalEditProps;
8
14
  export declare const ExternalItem: React.FC<externalItemProps>;
9
15
  export {};
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { ModalItem_VariantCreate } from '../../../../../types';
2
+ import type { ModalItem_VariantCreate } from '../../../../../types';
3
3
  export declare const ItemCreate: import("react").FC<ModalItem_VariantCreate>;
@@ -1,9 +1,15 @@
1
1
  import { NestedNavItem } from '../../../../../types';
2
2
  import React from 'react';
3
- type externalItemProps = {
4
- variant: 'WrapperCreate' | 'WrapperEdit';
5
- item?: NestedNavItem;
6
- parentDocumentId?: string;
3
+ type wrapperCreateProps = {
4
+ variant: 'WrapperCreate';
5
+ parentId?: string;
6
+ onCreate: (newItem: NestedNavItem) => void;
7
7
  };
8
- export declare const WrapperItem: React.FC<externalItemProps>;
8
+ type wrapperEditProps = {
9
+ variant: 'WrapperEdit';
10
+ item: NestedNavItem;
11
+ onSave: (editedItem: NestedNavItem) => void;
12
+ };
13
+ type wrapperItemProps = wrapperCreateProps | wrapperEditProps;
14
+ export declare const WrapperItem: React.FC<wrapperItemProps>;
9
15
  export {};
@@ -1,15 +1,16 @@
1
- import { GroupedEntities, RouteSettings, NavItemSettings, ConfigContentType, StructuredNavigationVariant, NavigationInput } from '../../../types';
1
+ import { GroupedEntities, RouteSettings, ConfigContentType, StructuredNavigationVariant, NavigationInput, NestedNavItem } from '../../../types';
2
2
  export default function useApi(): {
3
3
  fetchAllContentTypes: () => Promise<any>;
4
4
  fetchAllEntities: (contentTypes?: ConfigContentType[]) => Promise<GroupedEntities[]>;
5
5
  getRelatedRoute: (relatedDocumentId: string) => Promise<any>;
6
- createExternalRoute: (body: RouteSettings) => Promise<any>;
7
6
  getRoutes: () => Promise<any>;
8
7
  updateRoute: (body: RouteSettings, documentId: string) => Promise<any>;
9
- createNavItem: (body: NavItemSettings) => Promise<any>;
10
- updateNavItem: (documentId: string, body: NavItemSettings) => Promise<any>;
11
- deleteNavItem: (documentId: string) => Promise<any>;
12
8
  getStructuredNavigation: (documentId: string, variant?: StructuredNavigationVariant) => Promise<any>;
9
+ getNavigation: ({ documentId, variant }?: {
10
+ documentId?: string;
11
+ variant?: StructuredNavigationVariant;
12
+ }) => Promise<any>;
13
13
  deleteNavigation: (documentId: string) => Promise<any>;
14
14
  updateNavigation: (documentId: string, body: NavigationInput) => Promise<any>;
15
+ updateNavigationItemStructure: (documentId: string, navigationItems: NestedNavItem[]) => Promise<any>;
15
16
  };
@@ -2,4 +2,6 @@ import { NestedNavigation } from '../../../types';
2
2
  export default function useNavigations(): {
3
3
  navigations: NestedNavigation[];
4
4
  fetchNavigations: () => Promise<void>;
5
+ loading: boolean;
6
+ fetchError: string | null;
5
7
  };
@@ -1,9 +1,9 @@
1
1
  import { PluginConfig } from '../../../types';
2
2
  type UsePluginConfigResponse = {
3
- data: PluginConfig | null;
3
+ config: PluginConfig | null;
4
4
  loading: boolean;
5
- error: string | null;
6
- setConfig: (body: PluginConfig) => Promise<boolean | void>;
5
+ fetchError: string | null;
6
+ setConfig: (body: PluginConfig) => Promise<void>;
7
7
  };
8
8
  export default function usePluginConfig(): UsePluginConfigResponse;
9
9
  export {};
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { NestedNavigation } from '../../../../types';
3
+ export default function PageWrapper({ navigations, loading, children }: {
4
+ navigations: NestedNavigation[];
5
+ loading?: boolean;
6
+ children: React.ReactNode;
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- declare const Navigation: () => import("react/jsx-runtime").JSX.Element | null;
1
+ declare const Navigation: () => import("react/jsx-runtime").JSX.Element;
2
2
  export default Navigation;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export default function PageWrapper({ children }: {
3
+ children: React.ReactNode;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function TableHeader(): import("react/jsx-runtime").JSX.Element;