@mattisvensson/strapi-plugin-webatlas 0.11.0 → 0.11.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 (50) hide show
  1. package/README.md +14 -8
  2. package/dist/admin/{FullLoader-CrPED_dY.mjs → FullLoader-Btjb2W2p.mjs} +4 -2
  3. package/dist/admin/{FullLoader-Cmsf8xS6.js → FullLoader-Da2n70bJ.js} +4 -2
  4. package/dist/admin/{SettingTitle-BjE_2u6R.js → SettingTitle-B0quw3f8.js} +5 -3
  5. package/dist/admin/{SettingTitle-B1IaU3qs.mjs → SettingTitle-HMfQOJnK.mjs} +5 -3
  6. package/dist/admin/de-B5pRvs13.mjs +0 -1
  7. package/dist/admin/de-CqU1FU8C.js +0 -1
  8. package/dist/admin/en-BE-zzIv8.mjs +0 -1
  9. package/dist/admin/en-C7I90FwV.js +0 -1
  10. package/dist/admin/{index-Cf9j0bn2.mjs → index-9_HhKDUC.mjs} +31 -59
  11. package/dist/admin/{index-DCYCtKrj.mjs → index-B79ELMEC.mjs} +220 -215
  12. package/dist/admin/{index-JLpXBQVL.js → index-BEVoxEAm.js} +31 -59
  13. package/dist/admin/index-Bmg-ERct.mjs +243 -0
  14. package/dist/admin/{index-AVI3QJ0R.js → index-C8YjuuOx.js} +496 -354
  15. package/dist/admin/{index-Yq-QR8t0.js → index-Cx_mktdk.js} +220 -215
  16. package/dist/admin/{index-BbnlyBrZ.mjs → index-Cz_k_jjp.mjs} +41 -31
  17. package/dist/admin/{index-D8bG0YFB.js → index-D2hB1vTw.js} +41 -31
  18. package/dist/admin/index-YdWxpvOH.js +243 -0
  19. package/dist/admin/{index-BIEUXWe7.mjs → index-oEJT_mvw.mjs} +496 -354
  20. package/dist/admin/index.js +1 -2
  21. package/dist/admin/index.mjs +1 -2
  22. package/dist/admin/src/index.d.ts +12 -0
  23. package/dist/server/index.js +174 -145
  24. package/dist/server/index.mjs +174 -145
  25. package/dist/server/src/index.d.ts +305 -0
  26. package/package.json +108 -108
  27. package/dist/admin/FullLoader-Cmsf8xS6.js.map +0 -1
  28. package/dist/admin/FullLoader-CrPED_dY.mjs.map +0 -1
  29. package/dist/admin/SettingTitle-B1IaU3qs.mjs.map +0 -1
  30. package/dist/admin/SettingTitle-BjE_2u6R.js.map +0 -1
  31. package/dist/admin/de-B5pRvs13.mjs.map +0 -1
  32. package/dist/admin/de-CqU1FU8C.js.map +0 -1
  33. package/dist/admin/en-BE-zzIv8.mjs.map +0 -1
  34. package/dist/admin/en-C7I90FwV.js.map +0 -1
  35. package/dist/admin/index-AVI3QJ0R.js.map +0 -1
  36. package/dist/admin/index-B90eSO4a.js +0 -219
  37. package/dist/admin/index-B90eSO4a.js.map +0 -1
  38. package/dist/admin/index-BIEUXWe7.mjs.map +0 -1
  39. package/dist/admin/index-BbnlyBrZ.mjs.map +0 -1
  40. package/dist/admin/index-Cf9j0bn2.mjs.map +0 -1
  41. package/dist/admin/index-D8bG0YFB.js.map +0 -1
  42. package/dist/admin/index-DCYCtKrj.mjs.map +0 -1
  43. package/dist/admin/index-JLpXBQVL.js.map +0 -1
  44. package/dist/admin/index-Y_PYIiRA.mjs +0 -219
  45. package/dist/admin/index-Y_PYIiRA.mjs.map +0 -1
  46. package/dist/admin/index-Yq-QR8t0.js.map +0 -1
  47. package/dist/admin/index.js.map +0 -1
  48. package/dist/admin/index.mjs.map +0 -1
  49. package/dist/server/index.js.map +0 -1
  50. package/dist/server/index.mjs.map +0 -1
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
- const index = require("./index-Yq-QR8t0.js");
5
+ const index = require("./index-Cx_mktdk.js");
6
6
  const admin = require("@strapi/strapi/admin");
7
7
  const designSystem = require("@strapi/design-system");
8
8
  require("@strapi/icons/symbols");
9
- const FullLoader = require("./FullLoader-Cmsf8xS6.js");
9
+ const FullLoader = require("./FullLoader-Da2n70bJ.js");
10
10
  const reactIntl = require("react-intl");
11
11
  const reactRouterDom = require("react-router-dom");
12
12
  const icons = require("@strapi/icons");
@@ -75,8 +75,15 @@ function SearchInput({
75
75
  "button",
76
76
  {
77
77
  type: "button",
78
- onClick: () => handleSearchChange({ target: { value: "" } }),
79
- style: { color: "inherit", background: "none", border: "none", cursor: "pointer" },
78
+ onClick: () => handleSearchChange({
79
+ target: { value: "" }
80
+ }),
81
+ style: {
82
+ color: "inherit",
83
+ background: "none",
84
+ border: "none",
85
+ cursor: "pointer"
86
+ },
80
87
  "aria-label": "Clear search",
81
88
  children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {})
82
89
  }
@@ -127,25 +134,11 @@ function TableHeader({
127
134
  function TableRow({ route }) {
128
135
  const { formatMessage } = reactIntl.useIntl();
129
136
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
130
- [route.title, route.canonicalPath, route.path].map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
131
- designSystem.Typography,
132
- {
133
- title: field,
134
- textColor: "neutral800",
135
- children: field || "-"
136
- }
137
- ) }, index2)),
138
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
139
- designSystem.Typography,
140
- {
141
- title: route.type,
142
- textColor: "neutral800",
143
- children: formatMessage({
144
- id: index.getTranslation(`path.type.${route.type}`),
145
- defaultMessage: "-"
146
- })
147
- }
148
- ) }),
137
+ [route.title, route.canonicalPath, route.path].map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { title: field, textColor: "neutral800", children: field || "-" }) }, index2)),
138
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { title: route.type, textColor: "neutral800", children: formatMessage({
139
+ id: index.getTranslation(`path.type.${route.type}`),
140
+ defaultMessage: "-"
141
+ }) }) }),
149
142
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, justifyContent: "end", children: route.type === "internal" && /* @__PURE__ */ jsxRuntime.jsx(
150
143
  designSystem.LinkButton,
151
144
  {
@@ -167,26 +160,19 @@ function PathTable({
167
160
  }) {
168
161
  const { formatMessage } = reactIntl.useIntl();
169
162
  const TABLE_COL_COUNT = 5;
170
- return /* @__PURE__ */ jsxRuntime.jsxs(
171
- designSystem.Table,
172
- {
173
- colCount: TABLE_COL_COUNT,
174
- rowCount: routes.length,
175
- children: [
176
- /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { sortKey, handleSort }),
177
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsxRuntime.jsx(TableRow, { route }, route.id)) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: TABLE_COL_COUNT, children: /* @__PURE__ */ jsxRuntime.jsx(
178
- designSystem.EmptyStateLayout,
179
- {
180
- shadow: "none",
181
- content: formatMessage({
182
- id: index.getTranslation("paths.page.emptyPaths"),
183
- defaultMessage: "No paths found"
184
- })
185
- }
186
- ) }) }) })
187
- ]
188
- }
189
- );
163
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: TABLE_COL_COUNT, rowCount: routes.length, children: [
164
+ /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { sortKey, handleSort }),
165
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsxRuntime.jsx(TableRow, { route }, route.id)) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: TABLE_COL_COUNT, children: /* @__PURE__ */ jsxRuntime.jsx(
166
+ designSystem.EmptyStateLayout,
167
+ {
168
+ shadow: "none",
169
+ content: formatMessage({
170
+ id: index.getTranslation("paths.page.emptyPaths"),
171
+ defaultMessage: "No paths found"
172
+ })
173
+ }
174
+ ) }) }) })
175
+ ] });
190
176
  }
191
177
  const Paths = () => {
192
178
  const { getAllRoutes } = index.useApi();
@@ -251,22 +237,8 @@ const Paths = () => {
251
237
  return /* @__PURE__ */ jsxRuntime.jsx(PageWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, {}) });
252
238
  }
253
239
  return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.pluginPermissions["page.routes"], children: /* @__PURE__ */ jsxRuntime.jsxs(PageWrapper, { children: [
254
- /* @__PURE__ */ jsxRuntime.jsx(
255
- SearchInput,
256
- {
257
- handleSearchChange,
258
- searchQuery
259
- }
260
- ),
261
- /* @__PURE__ */ jsxRuntime.jsx(
262
- PathTable,
263
- {
264
- routes: sortedRoutes,
265
- sortKey,
266
- handleSort
267
- }
268
- )
240
+ /* @__PURE__ */ jsxRuntime.jsx(SearchInput, { handleSearchChange, searchQuery }),
241
+ /* @__PURE__ */ jsxRuntime.jsx(PathTable, { routes: sortedRoutes, sortKey, handleSort })
269
242
  ] }) });
270
243
  };
271
244
  exports.default = Paths;
272
- //# sourceMappingURL=index-JLpXBQVL.js.map
@@ -0,0 +1,243 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useReducer, useState, useRef, useEffect } from "react";
3
+ import { Box, Accordion, Field, SingleSelect, SingleSelectOption, Typography, Link } from "@strapi/design-system";
4
+ import { useNotification, Page } from "@strapi/strapi/admin";
5
+ import { g as getTranslation, c as usePluginConfig, e as useAllContentTypes, p as pluginPermissions, f as PLUGIN_NAME, h as PLUGIN_VERSION } from "./index-B79ELMEC.mjs";
6
+ import { useIntl } from "react-intl";
7
+ import "@strapi/icons/symbols";
8
+ import { F as FullLoader } from "./FullLoader-Btjb2W2p.mjs";
9
+ import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-HMfQOJnK.mjs";
10
+ import { ExternalLink } from "@strapi/icons";
11
+ function ContentTypeAccordion({
12
+ contentType,
13
+ contentTypeSettings,
14
+ dispatch
15
+ }) {
16
+ const { formatMessage } = useIntl();
17
+ if (!contentType) return null;
18
+ return /* @__PURE__ */ jsx(Box, { borderColor: !contentTypeSettings.default ? "danger500" : void 0, children: /* @__PURE__ */ jsxs(Accordion.Item, { value: contentType.uid, children: [
19
+ /* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: contentType?.info.displayName }) }),
20
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsxs(
21
+ Field.Root,
22
+ {
23
+ name: "selectedContentTypes",
24
+ hint: formatMessage({
25
+ id: getTranslation("settings.page.generate.hint"),
26
+ defaultMessage: 'The selected field from the content type will be used to generate the path. Use a field that is unique and descriptive, such as a "title" or "name".'
27
+ }),
28
+ error: !contentTypeSettings.default && formatMessage({
29
+ id: getTranslation("settings.page.generate.error"),
30
+ defaultMessage: "Please select a default field"
31
+ }),
32
+ required: true,
33
+ children: [
34
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
35
+ id: getTranslation("settings.page.generate"),
36
+ defaultMessage: "Generate paths from"
37
+ }) }),
38
+ /* @__PURE__ */ jsx(
39
+ SingleSelect,
40
+ {
41
+ name: `defaultField-${contentType.uid}`,
42
+ onClear: () => dispatch({
43
+ type: "SET_DEFAULT_FIELD",
44
+ payload: { ctUid: contentType.uid, field: "" }
45
+ }),
46
+ value: contentTypeSettings?.default || "",
47
+ onChange: (value) => dispatch({
48
+ type: "SET_DEFAULT_FIELD",
49
+ payload: { ctUid: contentType.uid, field: String(value) }
50
+ }),
51
+ children: Object.entries(contentType.attributes).map(([key], index) => {
52
+ if (key === "id" || key === "documentId" || key === "createdAt" || key === "updatedAt" || key === "createdBy" || key === "updatedBy" || key === "webatlas" || // The following fields are not longer used in the new implementation, but we keep them hidden just in case
53
+ key === "webatlas_path" || key === "webatlas_override" || key === "webatlas_parent")
54
+ return null;
55
+ return /* @__PURE__ */ jsx(SingleSelectOption, { value: key, children: key }, index);
56
+ })
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsx(Field.Hint, {})
60
+ ]
61
+ }
62
+ ) }) })
63
+ ] }, contentType.uid) }, contentType.uid);
64
+ }
65
+ function reducer(newConfig, action) {
66
+ let updatedContentTypes;
67
+ switch (action.type) {
68
+ case "SET_DEFAULT_FIELD":
69
+ if (!newConfig) return null;
70
+ updatedContentTypes = newConfig?.selectedContentTypes.map(
71
+ (ct) => ct.uid === action.payload.ctUid ? { ...ct, default: action.payload.field } : ct
72
+ );
73
+ return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
74
+ case "SET_CONFIG":
75
+ return action.payload;
76
+ default:
77
+ throw new Error();
78
+ }
79
+ }
80
+ const Settings = () => {
81
+ const { config: fetchedConfig, setConfig, loading, fetchError } = usePluginConfig();
82
+ const [config, dispatch] = useReducer(reducer, fetchedConfig);
83
+ const { contentTypes: allContentTypesData } = useAllContentTypes();
84
+ const allContentTypes = allContentTypesData?.filter(
85
+ (ct) => ct.pluginOptions?.webatlas?.enabled === true
86
+ );
87
+ const { toggleNotification } = useNotification();
88
+ const { formatMessage } = useIntl();
89
+ const [isSaving, setIsSaving] = useState(false);
90
+ const initialConfig = useRef(fetchedConfig);
91
+ useEffect(() => {
92
+ initialConfig.current = fetchedConfig;
93
+ if (fetchedConfig) dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
94
+ }, [fetchedConfig]);
95
+ useEffect(() => {
96
+ if (fetchError) {
97
+ toggleNotification({
98
+ type: "danger",
99
+ message: formatMessage({
100
+ id: getTranslation("notification.error"),
101
+ defaultMessage: "An error occurred"
102
+ }) + ": " + fetchError
103
+ });
104
+ }
105
+ }, [fetchError, toggleNotification, formatMessage]);
106
+ async function save() {
107
+ if (!config || config.selectedContentTypes.find((cta) => !cta.default) !== void 0)
108
+ return;
109
+ setIsSaving(true);
110
+ try {
111
+ await setConfig({ selectedContentTypes: config.selectedContentTypes });
112
+ initialConfig.current = config;
113
+ toggleNotification({
114
+ type: "success",
115
+ message: formatMessage({
116
+ id: getTranslation("notification.settings.saved"),
117
+ defaultMessage: "Settings saved successfully"
118
+ })
119
+ });
120
+ setIsSaving(false);
121
+ } catch (err) {
122
+ setIsSaving(false);
123
+ toggleNotification({
124
+ type: "danger",
125
+ message: formatMessage({
126
+ id: getTranslation("notification.error"),
127
+ defaultMessage: "An error occurred"
128
+ }) + ": " + err
129
+ });
130
+ strapi.log.error(err);
131
+ }
132
+ }
133
+ if (loading) {
134
+ return /* @__PURE__ */ jsx(
135
+ PageWrapper,
136
+ {
137
+ isSaving,
138
+ subtitle: formatMessage({
139
+ id: getTranslation("loading"),
140
+ defaultMessage: "Loading..."
141
+ }),
142
+ disabledCondition: true,
143
+ children: /* @__PURE__ */ jsx(FullLoader, { height: 200 })
144
+ }
145
+ );
146
+ }
147
+ return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions["settings.general"], children: /* @__PURE__ */ jsxs(
148
+ PageWrapper,
149
+ {
150
+ save,
151
+ isSaving,
152
+ subtitle: formatMessage({
153
+ id: getTranslation("settings.page.general.subtitle"),
154
+ defaultMessage: "Configure general settings"
155
+ }),
156
+ disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current),
157
+ children: [
158
+ /* @__PURE__ */ jsx(
159
+ ContentBox,
160
+ {
161
+ title: formatMessage({
162
+ id: getTranslation("settings.page.general.contentTypes"),
163
+ defaultMessage: "Content Types"
164
+ }),
165
+ children: config?.selectedContentTypes && config.selectedContentTypes.length > 0 ? /* @__PURE__ */ jsxs(Field.Root, { name: "selectedContentTypesAccordion", children: [
166
+ /* @__PURE__ */ jsx(Field.Label, { children: /* @__PURE__ */ jsx(SettingTitle, { children: formatMessage({
167
+ id: getTranslation("settings.page.contentTypeSettings"),
168
+ defaultMessage: "Content Type settings"
169
+ }) }) }),
170
+ /* @__PURE__ */ jsx(Accordion.Root, { children: config.selectedContentTypes?.map((contentTypeSettings) => {
171
+ const ct = allContentTypes?.find(
172
+ (item) => item.uid === contentTypeSettings.uid
173
+ );
174
+ return /* @__PURE__ */ jsx(
175
+ ContentTypeAccordion,
176
+ {
177
+ contentType: ct,
178
+ contentTypeSettings,
179
+ dispatch
180
+ },
181
+ contentTypeSettings.uid
182
+ );
183
+ }) })
184
+ ] }) : /* @__PURE__ */ jsxs(Typography, { children: [
185
+ formatMessage({
186
+ id: getTranslation("settings.page.general.noContentTypesEnabled"),
187
+ defaultMessage: "No content types are enabled for Webatlas. Please enable at least one content type to use this plugin."
188
+ }),
189
+ /* @__PURE__ */ jsx(
190
+ Link,
191
+ {
192
+ href: "https://github.com/mattisvensson/strapi-plugin-webatlas?tab=readme-ov-file#-configuration",
193
+ isExternal: true,
194
+ style: { marginLeft: 4 },
195
+ children: formatMessage({
196
+ id: getTranslation("settings.page.general.noContentTypesEnabled.moreInfo"),
197
+ defaultMessage: "More info"
198
+ })
199
+ }
200
+ )
201
+ ] })
202
+ }
203
+ ),
204
+ /* @__PURE__ */ jsx(
205
+ ContentBox,
206
+ {
207
+ title: formatMessage({
208
+ id: getTranslation("settings.page.general.details"),
209
+ defaultMessage: "Details"
210
+ }),
211
+ children: /* @__PURE__ */ jsxs(Field.Root, { name: "selectedContentTypesAccordion", children: [
212
+ /* @__PURE__ */ jsx(Field.Label, { children: /* @__PURE__ */ jsxs(SettingTitle, { children: [
213
+ PLUGIN_NAME,
214
+ " ",
215
+ formatMessage({
216
+ id: getTranslation("version"),
217
+ defaultMessage: "Version"
218
+ })
219
+ ] }) }),
220
+ /* @__PURE__ */ jsxs(Typography, { children: [
221
+ "v",
222
+ PLUGIN_VERSION,
223
+ /* @__PURE__ */ jsx(
224
+ Link,
225
+ {
226
+ href: `https://github.com/mattisvensson/strapi-plugin-webatlas/releases/tag/v${PLUGIN_VERSION}`,
227
+ target: "_blank",
228
+ rel: "noopener noreferrer",
229
+ style: { marginLeft: 4 },
230
+ children: /* @__PURE__ */ jsx(ExternalLink, {})
231
+ }
232
+ )
233
+ ] })
234
+ ] })
235
+ }
236
+ )
237
+ ]
238
+ }
239
+ ) });
240
+ };
241
+ export {
242
+ Settings as default
243
+ };