@mattisvensson/strapi-plugin-webatlas 0.7.0 → 0.8.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 (72) hide show
  1. package/dist/_chunks/FullLoader-Cmsf8xS6.js +0 -12
  2. package/dist/_chunks/FullLoader-Cmsf8xS6.js.map +0 -1
  3. package/dist/_chunks/FullLoader-CrPED_dY.mjs +0 -1
  4. package/dist/_chunks/PageWrapper-B6nLPFak.mjs +55 -0
  5. package/dist/_chunks/PageWrapper-BMzPDWn4.js +0 -0
  6. package/dist/_chunks/PageWrapper-BMzPDWn4.js.map +0 -0
  7. package/dist/_chunks/{de-oxxH8hft.mjs → de-C1QgkRoj.mjs} +3 -2
  8. package/dist/_chunks/de-DYxCPOdb.js +0 -0
  9. package/dist/_chunks/de-DYxCPOdb.js.map +0 -0
  10. package/dist/_chunks/{en-DqC5aDzA.mjs → en--8p5hbLP.mjs} +3 -2
  11. package/dist/_chunks/en-Be-athEA.js +0 -0
  12. package/dist/_chunks/en-Be-athEA.js.map +0 -0
  13. package/dist/_chunks/{index-DKdAgBbF.mjs → index-7rox7tGX.mjs} +94 -123
  14. package/dist/_chunks/index-Bu-uQ9jA.js +0 -0
  15. package/dist/_chunks/index-Bu-uQ9jA.js.map +0 -0
  16. package/dist/_chunks/index-C53yDU_z.js +0 -0
  17. package/dist/_chunks/index-C53yDU_z.js.map +0 -0
  18. package/dist/_chunks/index-CAz59RSr.js +0 -0
  19. package/dist/_chunks/index-CAz59RSr.js.map +0 -0
  20. package/dist/_chunks/{index-BdlPAWj6.mjs → index-DGSjLYNl.mjs} +1 -1
  21. package/dist/_chunks/index-DKfUSLPc.js +0 -0
  22. package/dist/_chunks/index-DKfUSLPc.js.map +0 -0
  23. package/dist/_chunks/index-DPMhcaxW.js +0 -0
  24. package/dist/_chunks/index-DPMhcaxW.js.map +0 -0
  25. package/dist/_chunks/{index-CZ5qsGXH.mjs → index-DSPh-fHL.mjs} +39 -12
  26. package/dist/_chunks/index-VcxUbdMO.mjs +123 -0
  27. package/dist/_chunks/{index-B6MYtu3A.mjs → index-Z3qq1ab8.mjs} +39 -39
  28. package/dist/admin/index.js +0 -5
  29. package/dist/admin/index.js.map +0 -1
  30. package/dist/admin/index.mjs +1 -2
  31. package/dist/admin/src/hooks/usePluginConfig.d.ts +1 -1
  32. package/dist/admin/src/pages/Settings/{ContentTypeAccordion.d.ts → General/ContentTypeAccordion.d.ts} +1 -1
  33. package/dist/admin/src/pages/Settings/Navigation/index.d.ts +2 -0
  34. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +3 -4
  35. package/dist/admin/src/utils/dnd.d.ts +1 -1
  36. package/dist/server/index.js +22 -13
  37. package/dist/server/index.mjs +22 -13
  38. package/dist/server/src/index.d.ts +1 -1
  39. package/dist/server/src/services/admin.d.ts +2 -2
  40. package/dist/server/src/services/index.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/dist/_chunks/FullLoader-CrPED_dY.mjs.map +0 -1
  43. package/dist/_chunks/de-BZc1BkzH.js +0 -121
  44. package/dist/_chunks/de-BZc1BkzH.js.map +0 -1
  45. package/dist/_chunks/de-oxxH8hft.mjs.map +0 -1
  46. package/dist/_chunks/en-Deg4n_IM.js +0 -121
  47. package/dist/_chunks/en-Deg4n_IM.js.map +0 -1
  48. package/dist/_chunks/en-DqC5aDzA.mjs.map +0 -1
  49. package/dist/_chunks/index-B6MYtu3A.mjs.map +0 -1
  50. package/dist/_chunks/index-BEgpEtto.mjs +0 -247
  51. package/dist/_chunks/index-BEgpEtto.mjs.map +0 -1
  52. package/dist/_chunks/index-BOEv4jIJ.js +0 -4177
  53. package/dist/_chunks/index-BOEv4jIJ.js.map +0 -1
  54. package/dist/_chunks/index-BPhRQoGD.mjs +0 -282
  55. package/dist/_chunks/index-BPhRQoGD.mjs.map +0 -1
  56. package/dist/_chunks/index-Bg96TqDm.js +0 -247
  57. package/dist/_chunks/index-Bg96TqDm.js.map +0 -1
  58. package/dist/_chunks/index-BgzZLDPv.mjs +0 -12229
  59. package/dist/_chunks/index-BoVX1KF8.js +0 -246
  60. package/dist/_chunks/index-ByU38WNH.js +0 -4176
  61. package/dist/_chunks/index-CZ5qsGXH.mjs.map +0 -1
  62. package/dist/_chunks/index-D3xDvB4d.mjs +0 -4160
  63. package/dist/_chunks/index-D_QCV5Z5.js +0 -282
  64. package/dist/_chunks/index-D_QCV5Z5.js.map +0 -1
  65. package/dist/_chunks/index-UJ0LQ3Y3.js +0 -281
  66. package/dist/_chunks/index-dSU20yZ4.js +0 -12229
  67. package/dist/_chunks/index-mObQ5NXj.js +0 -12230
  68. package/dist/_chunks/index-mObQ5NXj.js.map +0 -1
  69. package/dist/admin/index.mjs.map +0 -1
  70. package/dist/server/index.js.map +0 -1
  71. package/dist/server/index.mjs.map +0 -1
  72. /package/dist/admin/src/pages/Settings/{index.d.ts → General/index.d.ts} +0 -0
@@ -1,12 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const designSystem = require("@strapi/design-system");
4
- function Center({ height = 400, children }) {
5
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", minHeight: `${height}px`, justifyContent: "center", children });
6
- }
7
- function FullLoader({ height }) {
8
- return /* @__PURE__ */ jsxRuntime.jsx(Center, { height, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: "Loading..." }) });
9
- }
10
- exports.Center = Center;
11
- exports.FullLoader = FullLoader;
12
- //# sourceMappingURL=FullLoader-Cmsf8xS6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FullLoader-Cmsf8xS6.js","sources":["../../admin/src/components/UI/Center.tsx","../../admin/src/components/UI/FullLoader.tsx"],"sourcesContent":["import { Flex } from '@strapi/design-system';\n\nexport default function Center({ height = 400, children }: { height?: number, children: React.ReactNode }) {\n\n return (\n <Flex direction=\"column\" minHeight={`${height}px`} justifyContent=\"center\">\n {children}\n </Flex>\n )\n}","import { Loader, Box } from '@strapi/design-system';\nimport Center from './Center';\n\nexport default function FullLoader({ height }: { height?: number }) {\n return (\n <Center height={height}>\n <Loader>Loading...</Loader>\n </Center>\n );\n}"],"names":["jsx","Flex","Loader"],"mappings":";;;AAEA,SAAwB,OAAO,EAAE,SAAS,KAAK,YAA4D;AAGvG,SAAAA,2BAAA,IAACC,aAAK,MAAA,EAAA,WAAU,UAAS,WAAW,GAAG,MAAM,MAAM,gBAAe,UAC/D,SACH,CAAA;AAEJ;ACNwB,SAAA,WAAW,EAAE,UAA+B;AAClE,wCACG,QAAO,EAAA,QACN,UAACD,+BAAAE,aAAAA,QAAA,EAAO,wBAAU,EACpB,CAAA;AAEJ;;;"}
@@ -10,4 +10,3 @@ export {
10
10
  Center as C,
11
11
  FullLoader as F
12
12
  };
13
- //# sourceMappingURL=FullLoader-CrPED_dY.mjs.map
@@ -0,0 +1,55 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { Button, Box } from "@strapi/design-system";
3
+ import { Page, Layouts } from "@strapi/strapi/admin";
4
+ import { P as PLUGIN_NAME, g as getTranslation } from "./index-DSPh-fHL.mjs";
5
+ import { useIntl } from "react-intl";
6
+ function PageWrapper({
7
+ save,
8
+ isSaving,
9
+ disabledCondition,
10
+ children
11
+ }) {
12
+ const { formatMessage } = useIntl();
13
+ return /* @__PURE__ */ jsxs(Page.Main, { children: [
14
+ /* @__PURE__ */ jsx(
15
+ Layouts.Header,
16
+ {
17
+ title: PLUGIN_NAME,
18
+ subtitle: formatMessage({
19
+ id: getTranslation("settings.page.subtitle"),
20
+ defaultMessage: "Settings"
21
+ }),
22
+ primaryAction: disabledCondition !== void 0 && save && /* @__PURE__ */ jsx(
23
+ Button,
24
+ {
25
+ type: "submit",
26
+ onClick: () => save(),
27
+ loading: isSaving,
28
+ disabled: disabledCondition || isSaving,
29
+ children: formatMessage({
30
+ id: getTranslation("save"),
31
+ defaultMessage: "Save"
32
+ })
33
+ }
34
+ )
35
+ }
36
+ ),
37
+ /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(
38
+ Box,
39
+ {
40
+ background: "neutral0",
41
+ borderColor: "neutral150",
42
+ hasRadius: true,
43
+ paddingBottom: 4,
44
+ paddingLeft: 4,
45
+ paddingRight: 4,
46
+ paddingTop: 6,
47
+ shadow: "tableShadow",
48
+ children
49
+ }
50
+ ) })
51
+ ] });
52
+ }
53
+ export {
54
+ PageWrapper as P
55
+ };
File without changes
File without changes
@@ -113,9 +113,10 @@ const de = {
113
113
  "webatlas.notification.navigation.navigationSaved": "Navigation erfolgreich aktualisiert",
114
114
  "webatlas.notification.navigation.fetchFailed": "Fehler beim Abrufen der Navigationen",
115
115
  "webatlas.notification.navigation.notFound": "Navigation nicht gefunden. Zur Navigation weitergeleitet",
116
- "webatlas.notification.navigation.creationFailed": "Erstellung der Navigation fehlgeschlagen"
116
+ "webatlas.notification.navigation.creationFailed": "Erstellung der Navigation fehlgeschlagen",
117
+ "webatlas.settings.section.general": "Allgemein",
118
+ "webatlas.settings.section.navigation": "Navigation"
117
119
  };
118
120
  export {
119
121
  de as default
120
122
  };
121
- //# sourceMappingURL=de-oxxH8hft.mjs.map
File without changes
File without changes
@@ -113,9 +113,10 @@ const en = {
113
113
  "webatlas.notification.navigation.navigationSaved": "Navigation updated successfully",
114
114
  "webatlas.notification.navigation.fetchFailed": "Failed to fetch navigations",
115
115
  "webatlas.notification.navigation.notFound": "Navigation not found. Redirected to navigation",
116
- "webatlas.notification.navigation.creationFailed": "Creation of navigation failed"
116
+ "webatlas.notification.navigation.creationFailed": "Creation of navigation failed",
117
+ "webatlas.settings.section.general": "General",
118
+ "webatlas.settings.section.navigation": "Navigation"
117
119
  };
118
120
  export {
119
121
  en as default
120
122
  };
121
- //# sourceMappingURL=en-DqC5aDzA.mjs.map
File without changes
File without changes
@@ -1,59 +1,12 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useReducer, useState, useEffect } from "react";
3
- import { Button, Box, Accordion, Field, SingleSelect, SingleSelectOption, MultiSelect, MultiSelectOption } from "@strapi/design-system";
4
- import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
5
- import { P as PLUGIN_NAME, g as getTranslation, T as Tooltip, b as usePluginConfig, c as useAllContentTypes, t as transformToUrl } from "./index-D3xDvB4d.mjs";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useReducer, useState, useRef, useEffect } from "react";
3
+ import { Box, Accordion, Field, SingleSelect, SingleSelectOption, MultiSelect, MultiSelectOption } from "@strapi/design-system";
4
+ import { useNotification } from "@strapi/strapi/admin";
5
+ import { g as getTranslation, T as Tooltip, b as usePluginConfig, c as useAllContentTypes, t as transformToUrl } from "./index-DSPh-fHL.mjs";
6
6
  import { useIntl } from "react-intl";
7
7
  import "@strapi/icons/symbols";
8
8
  import { F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
9
- function PageWrapper({
10
- settingsState,
11
- initialState,
12
- save,
13
- isSaving,
14
- children
15
- }) {
16
- const { formatMessage } = useIntl();
17
- return /* @__PURE__ */ jsxs(Page.Main, { children: [
18
- /* @__PURE__ */ jsx(
19
- Layouts.Header,
20
- {
21
- title: PLUGIN_NAME,
22
- subtitle: formatMessage({
23
- id: getTranslation("settings.page.subtitle"),
24
- defaultMessage: "Settings"
25
- }),
26
- primaryAction: settingsState && initialState && save && /* @__PURE__ */ jsx(
27
- Button,
28
- {
29
- type: "submit",
30
- onClick: () => save(),
31
- loading: isSaving,
32
- disabled: JSON.stringify(settingsState) === JSON.stringify(initialState) || settingsState.selectedContentTypes.find((cta) => !cta.default) !== void 0 || isSaving,
33
- children: formatMessage({
34
- id: getTranslation("save"),
35
- defaultMessage: "Save"
36
- })
37
- }
38
- )
39
- }
40
- ),
41
- /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(
42
- Box,
43
- {
44
- background: "neutral0",
45
- borderColor: "neutral150",
46
- hasRadius: true,
47
- paddingBottom: 4,
48
- paddingLeft: 4,
49
- paddingRight: 4,
50
- paddingTop: 6,
51
- shadow: "tableShadow",
52
- children
53
- }
54
- ) })
55
- ] });
56
- }
9
+ import { P as PageWrapper } from "./PageWrapper-B6nLPFak.mjs";
57
10
  function ContentTypeAccordion({
58
11
  contentType,
59
12
  contentTypeSettings,
@@ -145,44 +98,47 @@ function ContentTypeAccordion({
145
98
  contentType.uid
146
99
  );
147
100
  }
148
- function reducer(settingsState, action) {
101
+ function reducer(newConfig, action) {
149
102
  let updatedContentTypes;
150
103
  switch (action.type) {
151
104
  case "SET_SELECTED_CONTENT_TYPES":
105
+ if (!newConfig) return null;
152
106
  updatedContentTypes = action.payload.map((ct) => {
153
- return settingsState.selectedContentTypes.find((cta) => cta.uid === ct.uid) || ct;
107
+ return newConfig?.selectedContentTypes.find((cta) => cta.uid === ct.uid) || ct;
154
108
  });
155
- return { ...settingsState, selectedContentTypes: updatedContentTypes };
109
+ return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
156
110
  case "SET_DEFAULT_FIELD":
157
- updatedContentTypes = settingsState.selectedContentTypes.map(
111
+ if (!newConfig) return null;
112
+ updatedContentTypes = newConfig?.selectedContentTypes.map(
158
113
  (ct) => ct.uid === action.payload.ctUid ? { ...ct, default: action.payload.field } : ct
159
114
  );
160
- return { ...settingsState, selectedContentTypes: updatedContentTypes };
115
+ return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
161
116
  case "SET_PATTERN":
162
- updatedContentTypes = settingsState.selectedContentTypes.map(
117
+ if (!newConfig) return null;
118
+ updatedContentTypes = newConfig?.selectedContentTypes.map(
163
119
  (ct) => ct.uid === action.payload.ctUid ? { ...ct, pattern: transformToUrl(action.payload.pattern) } : ct
164
120
  );
165
- return { ...settingsState, selectedContentTypes: updatedContentTypes };
121
+ return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
122
+ case "SET_CONFIG":
123
+ return action.payload;
166
124
  default:
167
125
  throw new Error();
168
126
  }
169
127
  }
170
128
  const Settings = () => {
171
- const { config, setConfig, loading, fetchError } = usePluginConfig();
172
- const [settingsState, dispatch] = useReducer(reducer, config || { selectedContentTypes: [] });
129
+ const { config: fetchedConfig, setConfig, loading, fetchError } = usePluginConfig();
130
+ const [config, dispatch] = useReducer(reducer, fetchedConfig);
173
131
  const { contentTypes: allContentTypesData } = useAllContentTypes();
174
132
  const allContentTypes = allContentTypesData?.filter((ct) => ct.pluginOptions?.webatlas?.active === true);
175
- const [initialState, setInitialState] = useState(config || { selectedContentTypes: [] });
176
133
  const { toggleNotification } = useNotification();
177
134
  const { formatMessage } = useIntl();
178
135
  const [isSaving, setIsSaving] = useState(false);
136
+ const initialConfig = useRef(fetchedConfig);
179
137
  useEffect(() => {
180
- setInitialState(config || { selectedContentTypes: [] });
181
- }, [config]);
182
- useEffect(() => {
183
- if (!config) return;
184
- dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: config.selectedContentTypes });
185
- }, [config]);
138
+ initialConfig.current = fetchedConfig;
139
+ if (fetchedConfig)
140
+ dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
141
+ }, [fetchedConfig]);
186
142
  useEffect(() => {
187
143
  if (fetchError) {
188
144
  toggleNotification({
@@ -195,11 +151,11 @@ const Settings = () => {
195
151
  }
196
152
  }, [fetchError, toggleNotification, formatMessage]);
197
153
  async function save() {
198
- if (!settingsState || settingsState.selectedContentTypes.find((cta) => !cta.default) !== void 0) return;
154
+ if (!config || config.selectedContentTypes.find((cta) => !cta.default) !== void 0) return;
199
155
  setIsSaving(true);
200
156
  try {
201
- await setConfig(settingsState);
202
- setInitialState(settingsState);
157
+ await setConfig({ selectedContentTypes: config.selectedContentTypes });
158
+ initialConfig.current = config;
203
159
  toggleNotification({
204
160
  type: "success",
205
161
  message: formatMessage({
@@ -221,60 +177,75 @@ const Settings = () => {
221
177
  }
222
178
  }
223
179
  if (loading) {
224
- return /* @__PURE__ */ jsx(PageWrapper, { children: /* @__PURE__ */ jsx(FullLoader, { height: 200 }) });
225
- }
226
- return /* @__PURE__ */ jsxs(PageWrapper, { settingsState, initialState, save, isSaving, children: [
227
- /* @__PURE__ */ jsxs(
228
- Field.Root,
180
+ return /* @__PURE__ */ jsx(
181
+ PageWrapper,
229
182
  {
230
- name: "selectedContentTypes",
231
- hint: formatMessage({
232
- id: getTranslation("settings.page.enabledContentTypes.hint"),
233
- defaultMessage: "Select the content types for which you want to enable URL aliases"
234
- }),
235
- children: [
183
+ isSaving,
184
+ disabledCondition: true,
185
+ children: /* @__PURE__ */ jsx(FullLoader, { height: 200 })
186
+ }
187
+ );
188
+ }
189
+ return /* @__PURE__ */ jsxs(
190
+ PageWrapper,
191
+ {
192
+ save,
193
+ isSaving,
194
+ disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current),
195
+ children: [
196
+ /* @__PURE__ */ jsxs(
197
+ Field.Root,
198
+ {
199
+ name: "selectedContentTypes",
200
+ hint: formatMessage({
201
+ id: getTranslation("settings.page.enabledContentTypes.hint"),
202
+ defaultMessage: "Select the content types for which you want to enable URL aliases"
203
+ }),
204
+ children: [
205
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
206
+ id: getTranslation("settings.page.enabledContentTypes"),
207
+ defaultMessage: "Enabled Content Types"
208
+ }) }),
209
+ /* @__PURE__ */ jsx(
210
+ MultiSelect,
211
+ {
212
+ placeholder: formatMessage({
213
+ id: getTranslation("settings.page.enabledContentTypes.placeholder"),
214
+ defaultMessage: "Select content types..."
215
+ }),
216
+ onClear: () => dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: [] }),
217
+ value: [...config?.selectedContentTypes.map((ct) => ct.uid) || []],
218
+ onChange: (value) => dispatch({
219
+ type: "SET_SELECTED_CONTENT_TYPES",
220
+ payload: value.map((v) => ({
221
+ uid: v,
222
+ default: "",
223
+ pattern: ""
224
+ }))
225
+ }),
226
+ withTags: true,
227
+ children: allContentTypes && allContentTypes.map(
228
+ (item) => /* @__PURE__ */ jsx(MultiSelectOption, { value: item.uid, children: item.info.displayName }, item.uid)
229
+ )
230
+ }
231
+ ),
232
+ /* @__PURE__ */ jsx(Field.Hint, {})
233
+ ]
234
+ }
235
+ ),
236
+ config?.selectedContentTypes && config.selectedContentTypes.length > 0 && /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsxs(Field.Root, { name: "selectedContentTypesAccordion", children: [
236
237
  /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
237
- id: getTranslation("settings.page.enabledContentTypes"),
238
- defaultMessage: "Enabled Content Types"
238
+ id: getTranslation("settings.page.contentTypeSettings"),
239
+ defaultMessage: "Content Type settings"
239
240
  }) }),
240
- /* @__PURE__ */ jsx(
241
- MultiSelect,
242
- {
243
- placeholder: formatMessage({
244
- id: getTranslation("settings.page.enabledContentTypes.placeholder"),
245
- defaultMessage: "Select content types..."
246
- }),
247
- onClear: () => dispatch({ type: "SET_SELECTED_CONTENT_TYPES", payload: [] }),
248
- value: [...settingsState.selectedContentTypes.map((ct) => ct.uid)],
249
- onChange: (value) => dispatch({
250
- type: "SET_SELECTED_CONTENT_TYPES",
251
- payload: value.map((v) => ({
252
- uid: v,
253
- default: "",
254
- pattern: ""
255
- }))
256
- }),
257
- withTags: true,
258
- children: allContentTypes && allContentTypes.map(
259
- (item) => /* @__PURE__ */ jsx(MultiSelectOption, { value: item.uid, children: item.info.displayName }, item.uid)
260
- )
261
- }
262
- ),
263
- /* @__PURE__ */ jsx(Field.Hint, {})
264
- ]
265
- }
266
- ),
267
- settingsState.selectedContentTypes && settingsState.selectedContentTypes.length > 0 && /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsxs(Field.Root, { name: "selectedContentTypesAccordion", children: [
268
- /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
269
- id: getTranslation("settings.page.contentTypeSettings"),
270
- defaultMessage: "Content Type settings"
271
- }) }),
272
- /* @__PURE__ */ jsx(Accordion.Root, { children: settingsState.selectedContentTypes?.map((contentTypeSettings) => {
273
- const ct = allContentTypes?.find((item) => item.uid === contentTypeSettings.uid);
274
- return /* @__PURE__ */ jsx(ContentTypeAccordion, { contentType: ct, contentTypeSettings, dispatch }, contentTypeSettings.uid);
275
- }) })
276
- ] }) })
277
- ] });
241
+ /* @__PURE__ */ jsx(Accordion.Root, { children: config.selectedContentTypes?.map((contentTypeSettings) => {
242
+ const ct = allContentTypes?.find((item) => item.uid === contentTypeSettings.uid);
243
+ return /* @__PURE__ */ jsx(ContentTypeAccordion, { contentType: ct, contentTypeSettings, dispatch }, contentTypeSettings.uid);
244
+ }) })
245
+ ] }) })
246
+ ]
247
+ }
248
+ );
278
249
  };
279
250
  export {
280
251
  Settings as default
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useMemo } from "react";
3
3
  import { Thead, Tr, Th, Typography, VisuallyHidden, Td, Flex, LinkButton, Grid, Box, Field, Table, Tbody, EmptyStateLayout } from "@strapi/design-system";
4
4
  import { ChevronDown, Pencil, Cross } from "@strapi/icons";
5
- import { g as getTranslation, u as useApi, d as debounce } from "./index-D3xDvB4d.mjs";
5
+ import { g as getTranslation, u as useApi, d as debounce } from "./index-DSPh-fHL.mjs";
6
6
  import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
7
7
  import "@strapi/icons/symbols";
8
8
  import { F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
File without changes
File without changes
File without changes
File without changes
@@ -23,7 +23,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
23
23
  );
24
24
  });
25
25
  };
26
- const version = "0.7.0";
26
+ const version = "0.7.1";
27
27
  const keywords = [];
28
28
  const type = "commonjs";
29
29
  const exports = {
@@ -294,6 +294,10 @@ function usePluginConfig() {
294
294
  config2 = { ...config2, selectedContentTypes: activeContentTypes };
295
295
  await setConfig(config2);
296
296
  }
297
+ if (config2.navigation?.maxDepth === void 0) {
298
+ config2.navigation = { ...config2.navigation, maxDepth: 3 };
299
+ await setConfig(config2);
300
+ }
297
301
  setConfigData(config2);
298
302
  } catch (error) {
299
303
  setFetchError(error.message);
@@ -4059,7 +4063,7 @@ const index = {
4059
4063
  defaultMessage: "Routes"
4060
4064
  },
4061
4065
  Component: async () => {
4062
- const component = await import("./index-BEgpEtto.mjs");
4066
+ const component = await import("./index-DGSjLYNl.mjs");
4063
4067
  return { default: component.default };
4064
4068
  },
4065
4069
  permissions: [
@@ -4078,7 +4082,7 @@ const index = {
4078
4082
  defaultMessage: "Navigation"
4079
4083
  },
4080
4084
  Component: async () => {
4081
- const component = await import("./index-B6MYtu3A.mjs");
4085
+ const component = await import("./index-Z3qq1ab8.mjs");
4082
4086
  return { default: component.default };
4083
4087
  },
4084
4088
  permissions: [
@@ -4094,20 +4098,44 @@ const index = {
4094
4098
  id: PLUGIN_ID,
4095
4099
  intlLabel: {
4096
4100
  id: `${PLUGIN_ID}.settings.section`,
4097
- defaultMessage: "Webatlas"
4101
+ defaultMessage: PLUGIN_NAME
4098
4102
  }
4099
4103
  },
4100
4104
  {
4101
4105
  intlLabel: {
4102
- id: `${PLUGIN_ID}.settings.section`,
4103
- defaultMessage: "Configuration"
4106
+ id: `${PLUGIN_ID}.settings.section.general`,
4107
+ defaultMessage: "General"
4104
4108
  },
4105
- id: PLUGIN_ID,
4106
- to: `/settings/${PLUGIN_ID}/configuration`,
4109
+ id: `${PLUGIN_ID}-general`,
4110
+ to: `/settings/${PLUGIN_ID}/general`,
4111
+ Component: async () => {
4112
+ return await import(
4113
+ /* webpackChunkName: "webatlas-settings-general-page" */
4114
+ "./index-7rox7tGX.mjs"
4115
+ );
4116
+ },
4117
+ permissions: [
4118
+ // Uncomment to set the permissions of the plugin here
4119
+ // {
4120
+ // action: '', // the action name should be plugin::plugin-name.actionType
4121
+ // subject: null,
4122
+ // },
4123
+ ]
4124
+ }
4125
+ );
4126
+ app.addSettingsLink(
4127
+ PLUGIN_ID,
4128
+ {
4129
+ intlLabel: {
4130
+ id: `${PLUGIN_ID}.settings.navigation`,
4131
+ defaultMessage: "Navigation"
4132
+ },
4133
+ id: `${PLUGIN_ID}-navigation`,
4134
+ to: `/settings/${PLUGIN_ID}/navigation`,
4107
4135
  Component: async () => {
4108
4136
  return await import(
4109
- /* webpackChunkName: "webatlas-settings-page" */
4110
- "./index-BPhRQoGD.mjs"
4137
+ /* webpackChunkName: "webatlas-settings-navigation-page" */
4138
+ "./index-VcxUbdMO.mjs"
4111
4139
  );
4112
4140
  },
4113
4141
  permissions: [
@@ -4136,7 +4164,7 @@ const index = {
4136
4164
  return Promise.all(
4137
4165
  locales.map(async (locale) => {
4138
4166
  try {
4139
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-oxxH8hft.mjs"), "./translations/en.json": () => import("./en-DqC5aDzA.mjs") }), `./translations/${locale}.json`, 3);
4167
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-C1QgkRoj.mjs"), "./translations/en.json": () => import("./en--8p5hbLP.mjs") }), `./translations/${locale}.json`, 3);
4140
4168
  return { data, locale };
4141
4169
  } catch {
4142
4170
  return { data: {}, locale };
@@ -4158,4 +4186,3 @@ export {
4158
4186
  transformToUrl as t,
4159
4187
  useApi as u
4160
4188
  };
4161
- //# sourceMappingURL=index-CZ5qsGXH.mjs.map
@@ -0,0 +1,123 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useReducer, useState, useRef, useEffect } from "react";
3
+ import { Field } from "@strapi/design-system";
4
+ import { useNotification } from "@strapi/strapi/admin";
5
+ import { b as usePluginConfig, g as getTranslation } from "./index-DSPh-fHL.mjs";
6
+ import { useIntl } from "react-intl";
7
+ import "@strapi/icons/symbols";
8
+ import { F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
9
+ import { P as PageWrapper } from "./PageWrapper-B6nLPFak.mjs";
10
+ function reducer(newConfig, action) {
11
+ switch (action.type) {
12
+ case "SET_MAX_DEPTH":
13
+ if (!newConfig) return null;
14
+ return {
15
+ ...newConfig,
16
+ navigation: { ...newConfig.navigation, maxDepth: action.payload },
17
+ selectedContentTypes: newConfig.selectedContentTypes || []
18
+ };
19
+ case "SET_CONFIG":
20
+ return action.payload;
21
+ default:
22
+ throw new Error();
23
+ }
24
+ }
25
+ const Settings = () => {
26
+ const { config: fetchedConfig, setConfig, loading, fetchError } = usePluginConfig();
27
+ const [config, dispatch] = useReducer(reducer, fetchedConfig);
28
+ const { toggleNotification } = useNotification();
29
+ const { formatMessage } = useIntl();
30
+ const [isSaving, setIsSaving] = useState(false);
31
+ const initialConfig = useRef(fetchedConfig);
32
+ useEffect(() => {
33
+ initialConfig.current = fetchedConfig;
34
+ if (fetchedConfig)
35
+ dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
36
+ }, [fetchedConfig]);
37
+ useEffect(() => {
38
+ if (fetchError) {
39
+ toggleNotification({
40
+ type: "danger",
41
+ message: formatMessage({
42
+ id: getTranslation("notification.error"),
43
+ defaultMessage: "An error occurred"
44
+ }) + ": " + fetchError
45
+ });
46
+ }
47
+ }, [fetchError, toggleNotification, formatMessage]);
48
+ async function save() {
49
+ if (!config) return;
50
+ setIsSaving(true);
51
+ try {
52
+ await setConfig({ navigation: config.navigation });
53
+ initialConfig.current = config;
54
+ toggleNotification({
55
+ type: "success",
56
+ message: formatMessage({
57
+ id: getTranslation("notification.settings.saved"),
58
+ defaultMessage: "Settings saved successfully"
59
+ })
60
+ });
61
+ setIsSaving(false);
62
+ } catch (err) {
63
+ setIsSaving(false);
64
+ toggleNotification({
65
+ type: "danger",
66
+ message: formatMessage({
67
+ id: getTranslation("notification.error"),
68
+ defaultMessage: "An error occurred"
69
+ }) + ": " + err
70
+ });
71
+ console.error(err);
72
+ }
73
+ }
74
+ if (loading) {
75
+ return /* @__PURE__ */ jsx(
76
+ PageWrapper,
77
+ {
78
+ isSaving,
79
+ disabledCondition: true,
80
+ children: /* @__PURE__ */ jsx(FullLoader, { height: 200 })
81
+ }
82
+ );
83
+ }
84
+ return /* @__PURE__ */ jsx(
85
+ PageWrapper,
86
+ {
87
+ save,
88
+ isSaving,
89
+ disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current),
90
+ children: /* @__PURE__ */ jsxs(
91
+ Field.Root,
92
+ {
93
+ name: "maxNavDepth",
94
+ children: [
95
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
96
+ id: getTranslation("settings.page.maxNavDepth.label"),
97
+ defaultMessage: "Max depth of navigation tree"
98
+ }) }),
99
+ /* @__PURE__ */ jsx(
100
+ Field.Input,
101
+ {
102
+ id: "maxNavDepth",
103
+ type: "number",
104
+ min: 1,
105
+ step: 1,
106
+ value: config?.navigation?.maxDepth !== void 0 ? config.navigation.maxDepth : "",
107
+ onChange: (e) => dispatch({ type: "SET_MAX_DEPTH", payload: Number(e.target.value) }),
108
+ onBlur: (e) => {
109
+ if (e.target.value === "") return;
110
+ dispatch({ type: "SET_MAX_DEPTH", payload: Number(e.target.value) });
111
+ }
112
+ }
113
+ ),
114
+ /* @__PURE__ */ jsx(Field.Hint, {})
115
+ ]
116
+ }
117
+ )
118
+ }
119
+ );
120
+ };
121
+ export {
122
+ Settings as default
123
+ };