@mattisvensson/strapi-plugin-webatlas 0.11.8 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/admin/{FullLoader-Btjb2W2p.mjs → FullLoader-BTZzPY8g.mjs} +11 -1
- package/dist/admin/{FullLoader-Da2n70bJ.js → FullLoader-C4hXFaLP.js} +10 -0
- package/dist/admin/{RoutePicker-CFqZfjDu.mjs → RoutePicker-h2yWGB6S.mjs} +1 -1
- package/dist/admin/{RoutePicker-BEmAG6aK.js → RoutePicker-mEHRtXQ9.js} +1 -1
- package/dist/admin/{SettingTitle-DRvX07-B.js → SettingTitle-CBcBCh1h.js} +1 -1
- package/dist/admin/{SettingTitle-D_X8W1mC.mjs → SettingTitle-DTXdYICP.mjs} +1 -1
- package/dist/admin/WarningBox-CMQuE_Ov.mjs +42 -0
- package/dist/admin/WarningBox-DsBtzhs3.js +41 -0
- package/dist/admin/{de-B5pRvs13.mjs → de-BFjenpyN.mjs} +16 -1
- package/dist/admin/{de-CqU1FU8C.js → de-DhwCZE_m.js} +16 -1
- package/dist/admin/{en-C7I90FwV.js → en-C-rPCNd2.js} +16 -1
- package/dist/admin/{en-BE-zzIv8.mjs → en-CGCh9ld_.mjs} +16 -1
- package/dist/admin/{index-lZ3-1icm.js → index-BYytQZfK.js} +169 -131
- package/dist/admin/{index-_8exe5fa.js → index-BZBUZWp1.js} +13 -8
- package/dist/admin/{index-CSknqklZ.js → index-Bn_SWdWd.js} +178 -85
- package/dist/admin/{index-ClG-B5Tr.js → index-CaFjiS4j.js} +21 -13
- package/dist/admin/{index-DZkauelU.mjs → index-Ckaev6xU.mjs} +170 -132
- package/dist/admin/{index-B9kmIJ1Y.mjs → index-Do9dOMP-.mjs} +180 -87
- package/dist/admin/{index-HCnLKUJN.mjs → index-DuwTQMlZ.mjs} +21 -13
- package/dist/admin/index-GZ_b2eve.js +480 -0
- package/dist/admin/index-aSdHc104.mjs +480 -0
- package/dist/admin/{index-CYF5Yipx.mjs → index-l4-tTCw9.mjs} +13 -8
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/server/index.js +485 -496
- package/dist/server/index.mjs +498 -509
- package/dist/server/src/index.d.ts +48 -5
- package/package.json +1 -1
- package/dist/admin/index-CTbP2yjO.js +0 -243
- package/dist/admin/index-uD-voTpW.mjs +0 -243
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useReducer, useRef, useMemo } from "react";
|
|
3
|
+
import { Box, Accordion, Field, SingleSelect, SingleSelectOption, Grid, Typography, Link } from "@strapi/design-system";
|
|
4
|
+
import { useNotification, Page } from "@strapi/strapi/admin";
|
|
5
|
+
import { g as getTranslation, T as Tooltip, c as usePluginConfig, e as useAllContentTypes, p as pluginPermissions, f as PLUGIN_NAME, h as PLUGIN_VERSION } from "./index-Ckaev6xU.mjs";
|
|
6
|
+
import { W as WarningBox, u as useAllEntities } from "./WarningBox-CMQuE_Ov.mjs";
|
|
7
|
+
import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
|
|
8
|
+
import { useIntl } from "react-intl";
|
|
9
|
+
import "@strapi/icons/symbols";
|
|
10
|
+
import { ExternalLink } from "@strapi/icons";
|
|
11
|
+
import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-DTXdYICP.mjs";
|
|
12
|
+
function getRouteSourceFields(contentType) {
|
|
13
|
+
if (!contentType?.attributes) return [];
|
|
14
|
+
return Object.entries(contentType.attributes).filter(
|
|
15
|
+
([key, attribute]) => attribute.type === "string" && key !== "documentId"
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function ContentTypeAccordion({
|
|
19
|
+
contentType,
|
|
20
|
+
contentTypeSettings,
|
|
21
|
+
dispatch,
|
|
22
|
+
allGroupedEntities,
|
|
23
|
+
entitiesLoading
|
|
24
|
+
}) {
|
|
25
|
+
const { formatMessage } = useIntl();
|
|
26
|
+
const [selectedContentType, setSelectedContentType] = useState(null);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (entitiesLoading || !contentType || selectedContentType || !contentTypeSettings?.defaultParentRoute)
|
|
29
|
+
return;
|
|
30
|
+
const groupedEntity = allGroupedEntities.find(
|
|
31
|
+
(group) => group.entities.some((entity) => entity.documentId === contentTypeSettings.defaultParentRoute)
|
|
32
|
+
);
|
|
33
|
+
if (!groupedEntity) {
|
|
34
|
+
dispatch({
|
|
35
|
+
type: "SET_DEFAULT_PARENT_ROUTE",
|
|
36
|
+
payload: { ctUid: contentType.uid, parentRoute: null }
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
setSelectedContentType(groupedEntity);
|
|
41
|
+
dispatch({
|
|
42
|
+
type: "SET_DEFAULT_PARENT_ROUTE",
|
|
43
|
+
payload: { ctUid: contentType.uid, parentRoute: contentTypeSettings.defaultParentRoute }
|
|
44
|
+
});
|
|
45
|
+
}, [contentTypeSettings?.defaultParentRoute, allGroupedEntities, contentType, entitiesLoading]);
|
|
46
|
+
const defaultParentRoute = selectedContentType?.entities.find(
|
|
47
|
+
(entity) => entity.documentId === contentTypeSettings.defaultParentRoute
|
|
48
|
+
);
|
|
49
|
+
const filteredAttributes = getRouteSourceFields(contentType);
|
|
50
|
+
if (!contentType) return null;
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
Box,
|
|
53
|
+
{
|
|
54
|
+
borderColor: !contentTypeSettings.routeSourceField ? "danger500" : void 0,
|
|
55
|
+
children: /* @__PURE__ */ jsxs(Accordion.Item, { value: contentType.uid, children: [
|
|
56
|
+
/* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: contentType?.info.displayName }) }),
|
|
57
|
+
/* @__PURE__ */ jsxs(Accordion.Content, { children: [
|
|
58
|
+
filteredAttributes.length === 0 && /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsx(
|
|
59
|
+
WarningBox,
|
|
60
|
+
{
|
|
61
|
+
title: formatMessage({
|
|
62
|
+
id: getTranslation("settings.page.generate.warning.title"),
|
|
63
|
+
defaultMessage: "No route source field available"
|
|
64
|
+
}),
|
|
65
|
+
description: formatMessage({
|
|
66
|
+
id: getTranslation("settings.page.generate.warning.description"),
|
|
67
|
+
defaultMessage: "Please add a string field to the content type in order to use this content type with Webatlas."
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
) }),
|
|
71
|
+
/* @__PURE__ */ jsxs(Box, { padding: 3, children: [
|
|
72
|
+
/* @__PURE__ */ jsxs(
|
|
73
|
+
Field.Root,
|
|
74
|
+
{
|
|
75
|
+
name: "selectedContentTypes",
|
|
76
|
+
error: filteredAttributes.length > 0 && !contentTypeSettings.routeSourceField && formatMessage({
|
|
77
|
+
id: getTranslation("settings.page.generate.error"),
|
|
78
|
+
defaultMessage: "Please select a default field"
|
|
79
|
+
}),
|
|
80
|
+
required: true,
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ jsxs(Field.Label, { children: [
|
|
83
|
+
formatMessage({
|
|
84
|
+
id: getTranslation("settings.page.generate"),
|
|
85
|
+
defaultMessage: "Generate paths from"
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ jsx(
|
|
88
|
+
Tooltip,
|
|
89
|
+
{
|
|
90
|
+
description: formatMessage({
|
|
91
|
+
id: getTranslation("settings.page.generate.hint"),
|
|
92
|
+
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".'
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
] }),
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
SingleSelect,
|
|
99
|
+
{
|
|
100
|
+
name: `defaultField-${contentType.uid}`,
|
|
101
|
+
onClear: () => dispatch({
|
|
102
|
+
type: "SET_DEFAULT_FIELD",
|
|
103
|
+
payload: { ctUid: contentType.uid, field: "" }
|
|
104
|
+
}),
|
|
105
|
+
value: contentTypeSettings?.routeSourceField || "",
|
|
106
|
+
onChange: (value) => dispatch({
|
|
107
|
+
type: "SET_DEFAULT_FIELD",
|
|
108
|
+
payload: { ctUid: contentType.uid, field: String(value) }
|
|
109
|
+
}),
|
|
110
|
+
disabled: filteredAttributes.length === 0,
|
|
111
|
+
children: filteredAttributes.map(([key], index) => {
|
|
112
|
+
return /* @__PURE__ */ jsx(SingleSelectOption, { value: key, children: key }, index);
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ jsxs(Grid.Root, { gap: 4, marginTop: 4, children: [
|
|
121
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Field.Root, { name: "defaultParentRouteContentType", children: [
|
|
122
|
+
/* @__PURE__ */ jsxs(Field.Label, { children: [
|
|
123
|
+
formatMessage({
|
|
124
|
+
id: getTranslation("settings.page.defaultParentRoute"),
|
|
125
|
+
defaultMessage: "Default parent route"
|
|
126
|
+
}),
|
|
127
|
+
/* @__PURE__ */ jsx(
|
|
128
|
+
Tooltip,
|
|
129
|
+
{
|
|
130
|
+
description: formatMessage({
|
|
131
|
+
id: getTranslation("settings.page.defaultParentRoute.hint"),
|
|
132
|
+
defaultMessage: "Select a default parent route for the content type. When creating a new entry, the default parent route will be pre-selected."
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
] }),
|
|
137
|
+
/* @__PURE__ */ jsx(
|
|
138
|
+
SingleSelect,
|
|
139
|
+
{
|
|
140
|
+
name: `defaultParentRoute-${contentType.uid}`,
|
|
141
|
+
onClear: () => {
|
|
142
|
+
setSelectedContentType(null);
|
|
143
|
+
dispatch({
|
|
144
|
+
type: "SET_DEFAULT_PARENT_ROUTE",
|
|
145
|
+
payload: { ctUid: contentType.uid, parentRoute: null }
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
value: selectedContentType?.contentType.uid || "",
|
|
149
|
+
onChange: (value) => {
|
|
150
|
+
const [filteredContentType] = allGroupedEntities.filter(
|
|
151
|
+
(group) => group.contentType.uid === value
|
|
152
|
+
);
|
|
153
|
+
if (filteredContentType) {
|
|
154
|
+
setSelectedContentType(filteredContentType);
|
|
155
|
+
dispatch({
|
|
156
|
+
type: "SET_DEFAULT_PARENT_ROUTE",
|
|
157
|
+
payload: { ctUid: contentType.uid, parentRoute: null }
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
placeholder: formatMessage({
|
|
162
|
+
id: getTranslation(
|
|
163
|
+
"settings.page.defaultParentRoute.contentType.placeholder"
|
|
164
|
+
),
|
|
165
|
+
defaultMessage: "Select a content type"
|
|
166
|
+
}),
|
|
167
|
+
children: allGroupedEntities.map((groupedEntity) => {
|
|
168
|
+
return /* @__PURE__ */ jsx(
|
|
169
|
+
SingleSelectOption,
|
|
170
|
+
{
|
|
171
|
+
value: groupedEntity.contentType.uid,
|
|
172
|
+
children: groupedEntity.contentType.label
|
|
173
|
+
},
|
|
174
|
+
groupedEntity.contentType.uid
|
|
175
|
+
);
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
|
180
|
+
] }) }) }),
|
|
181
|
+
/* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, alignItems: "flex-end", children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Field.Root, { name: "defaultParentRouteEntity", children: [
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
SingleSelect,
|
|
184
|
+
{
|
|
185
|
+
name: `defaultParentRoute-${contentType.uid}`,
|
|
186
|
+
onClear: () => dispatch({
|
|
187
|
+
type: "SET_DEFAULT_PARENT_ROUTE",
|
|
188
|
+
payload: { ctUid: contentType.uid, parentRoute: null }
|
|
189
|
+
}),
|
|
190
|
+
placeholder: formatMessage({
|
|
191
|
+
id: getTranslation("settings.page.defaultParentRoute.entity.placeholder"),
|
|
192
|
+
defaultMessage: "Select an entity"
|
|
193
|
+
}),
|
|
194
|
+
value: defaultParentRoute?.documentId || "",
|
|
195
|
+
onChange: (value) => dispatch({
|
|
196
|
+
type: "SET_DEFAULT_PARENT_ROUTE",
|
|
197
|
+
payload: { ctUid: contentType.uid, parentRoute: String(value) }
|
|
198
|
+
}),
|
|
199
|
+
disabled: !selectedContentType || selectedContentType.entities.length === 0 || !selectedContentType.contentType.routeSourceField,
|
|
200
|
+
children: selectedContentType?.entities.map((entity) => {
|
|
201
|
+
if (!selectedContentType.contentType.routeSourceField) return null;
|
|
202
|
+
return /* @__PURE__ */ jsx(SingleSelectOption, { value: entity.documentId, children: entity[selectedContentType.contentType.routeSourceField] }, entity.documentId);
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
|
207
|
+
] }) }) })
|
|
208
|
+
] })
|
|
209
|
+
] })
|
|
210
|
+
] })
|
|
211
|
+
] }, contentType.uid)
|
|
212
|
+
},
|
|
213
|
+
contentType.uid
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
function reducer(newConfig, action) {
|
|
217
|
+
let updatedContentTypes;
|
|
218
|
+
switch (action.type) {
|
|
219
|
+
case "SET_DEFAULT_FIELD":
|
|
220
|
+
if (!newConfig) return null;
|
|
221
|
+
updatedContentTypes = newConfig?.selectedContentTypes.map(
|
|
222
|
+
(ct) => ct.uid === action.payload.ctUid ? { ...ct, routeSourceField: action.payload.field } : ct
|
|
223
|
+
);
|
|
224
|
+
return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
|
|
225
|
+
case "SET_DEFAULT_PARENT_ROUTE":
|
|
226
|
+
if (!newConfig) return null;
|
|
227
|
+
updatedContentTypes = newConfig?.selectedContentTypes.map(
|
|
228
|
+
(ct) => ct.uid === action.payload.ctUid ? { ...ct, defaultParentRoute: action.payload.parentRoute } : ct
|
|
229
|
+
);
|
|
230
|
+
return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
|
|
231
|
+
case "SET_ROUTE_BLACKLIST":
|
|
232
|
+
if (!newConfig) return null;
|
|
233
|
+
return { ...newConfig, routeBlacklist: action.payload.blacklist };
|
|
234
|
+
case "SET_CONFIG":
|
|
235
|
+
return action.payload;
|
|
236
|
+
default:
|
|
237
|
+
throw new Error();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const Settings = () => {
|
|
241
|
+
const { config: fetchedConfig, setConfig, loading, fetchError } = usePluginConfig();
|
|
242
|
+
const [config, dispatch] = useReducer(reducer, fetchedConfig);
|
|
243
|
+
const { contentTypes: allContentTypesData, error: contentTypesError } = useAllContentTypes();
|
|
244
|
+
const allContentTypes = allContentTypesData?.filter(
|
|
245
|
+
(ct) => ct.pluginOptions?.webatlas?.enabled === true
|
|
246
|
+
);
|
|
247
|
+
const { toggleNotification } = useNotification();
|
|
248
|
+
const getErrorMessage = useErrorMessage();
|
|
249
|
+
const { formatMessage } = useIntl();
|
|
250
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
251
|
+
const [blacklistInput, setBlacklistInput] = useState("");
|
|
252
|
+
const initialConfig = useRef(fetchedConfig);
|
|
253
|
+
const { entities, loading: entitiesLoading, error: entitiesError } = useAllEntities();
|
|
254
|
+
const selectableEntities = useMemo(
|
|
255
|
+
() => entities.filter(
|
|
256
|
+
(groupedEntity) => config?.selectedContentTypes.some(
|
|
257
|
+
(ct) => ct.uid === groupedEntity.contentType.uid && ct.routeSourceField
|
|
258
|
+
)
|
|
259
|
+
),
|
|
260
|
+
[entities, config?.selectedContentTypes]
|
|
261
|
+
);
|
|
262
|
+
const hasMissingRouteSourceField = config?.selectedContentTypes.some(
|
|
263
|
+
(ct) => !ct.routeSourceField && getRouteSourceFields(allContentTypes?.find((item) => item.uid === ct.uid)).length > 0
|
|
264
|
+
) ?? false;
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
initialConfig.current = fetchedConfig;
|
|
267
|
+
if (fetchedConfig) {
|
|
268
|
+
dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
|
|
269
|
+
setBlacklistInput(fetchedConfig.routeBlacklist?.join(", ") || "");
|
|
270
|
+
}
|
|
271
|
+
}, [fetchedConfig]);
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
const error = contentTypesError ?? entitiesError;
|
|
274
|
+
if (!error) return;
|
|
275
|
+
toggleNotification({
|
|
276
|
+
type: "danger",
|
|
277
|
+
message: getErrorMessage(
|
|
278
|
+
error,
|
|
279
|
+
formatMessage({
|
|
280
|
+
id: getTranslation("notification.settings.fetchFailed"),
|
|
281
|
+
defaultMessage: "Failed to load content types"
|
|
282
|
+
})
|
|
283
|
+
)
|
|
284
|
+
});
|
|
285
|
+
}, [contentTypesError, entitiesError, toggleNotification, getErrorMessage, formatMessage]);
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
if (fetchError) {
|
|
288
|
+
toggleNotification({
|
|
289
|
+
type: "danger",
|
|
290
|
+
message: getErrorMessage(
|
|
291
|
+
fetchError,
|
|
292
|
+
formatMessage({
|
|
293
|
+
id: getTranslation("notification.error"),
|
|
294
|
+
defaultMessage: "An error occurred"
|
|
295
|
+
})
|
|
296
|
+
)
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}, [fetchError, toggleNotification, getErrorMessage, formatMessage]);
|
|
300
|
+
async function save() {
|
|
301
|
+
if (!config || hasMissingRouteSourceField) return;
|
|
302
|
+
setIsSaving(true);
|
|
303
|
+
try {
|
|
304
|
+
await setConfig({
|
|
305
|
+
selectedContentTypes: config.selectedContentTypes,
|
|
306
|
+
routeBlacklist: config.routeBlacklist
|
|
307
|
+
});
|
|
308
|
+
initialConfig.current = config;
|
|
309
|
+
toggleNotification({
|
|
310
|
+
type: "success",
|
|
311
|
+
message: formatMessage({
|
|
312
|
+
id: getTranslation("notification.settings.saved"),
|
|
313
|
+
defaultMessage: "Settings saved successfully"
|
|
314
|
+
})
|
|
315
|
+
});
|
|
316
|
+
setIsSaving(false);
|
|
317
|
+
} catch (err) {
|
|
318
|
+
setIsSaving(false);
|
|
319
|
+
toggleNotification({
|
|
320
|
+
type: "danger",
|
|
321
|
+
message: getErrorMessage(
|
|
322
|
+
err,
|
|
323
|
+
formatMessage({
|
|
324
|
+
id: getTranslation("notification.error"),
|
|
325
|
+
defaultMessage: "An error occurred"
|
|
326
|
+
})
|
|
327
|
+
)
|
|
328
|
+
});
|
|
329
|
+
console.error(err);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (loading) {
|
|
333
|
+
return /* @__PURE__ */ jsx(
|
|
334
|
+
PageWrapper,
|
|
335
|
+
{
|
|
336
|
+
isSaving,
|
|
337
|
+
subtitle: formatMessage({
|
|
338
|
+
id: getTranslation("loading"),
|
|
339
|
+
defaultMessage: "Loading..."
|
|
340
|
+
}),
|
|
341
|
+
disabledCondition: true,
|
|
342
|
+
children: /* @__PURE__ */ jsx(FullLoader, { height: 200 })
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions["settings.general"], children: /* @__PURE__ */ jsxs(
|
|
347
|
+
PageWrapper,
|
|
348
|
+
{
|
|
349
|
+
save,
|
|
350
|
+
isSaving,
|
|
351
|
+
subtitle: formatMessage({
|
|
352
|
+
id: getTranslation("settings.page.general.subtitle"),
|
|
353
|
+
defaultMessage: "Configure general settings"
|
|
354
|
+
}),
|
|
355
|
+
disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current) || hasMissingRouteSourceField,
|
|
356
|
+
children: [
|
|
357
|
+
/* @__PURE__ */ jsxs(
|
|
358
|
+
ContentBox,
|
|
359
|
+
{
|
|
360
|
+
title: formatMessage({
|
|
361
|
+
id: getTranslation("settings.page.general.contentTypes"),
|
|
362
|
+
defaultMessage: "Content Types"
|
|
363
|
+
}),
|
|
364
|
+
children: [
|
|
365
|
+
config?.selectedContentTypes && config.selectedContentTypes.length > 0 ? /* @__PURE__ */ jsxs(Field.Root, { name: "selectedContentTypesAccordion", children: [
|
|
366
|
+
/* @__PURE__ */ jsx(Field.Label, { children: /* @__PURE__ */ jsx(SettingTitle, { children: formatMessage({
|
|
367
|
+
id: getTranslation("settings.page.contentTypeSettings"),
|
|
368
|
+
defaultMessage: "Content Type settings"
|
|
369
|
+
}) }) }),
|
|
370
|
+
/* @__PURE__ */ jsx(Accordion.Root, { children: config.selectedContentTypes?.map((contentTypeSettings) => {
|
|
371
|
+
const ct = allContentTypes?.find(
|
|
372
|
+
(item) => item.uid === contentTypeSettings.uid
|
|
373
|
+
);
|
|
374
|
+
return /* @__PURE__ */ jsx(
|
|
375
|
+
ContentTypeAccordion,
|
|
376
|
+
{
|
|
377
|
+
contentType: ct,
|
|
378
|
+
contentTypeSettings,
|
|
379
|
+
dispatch,
|
|
380
|
+
allGroupedEntities: selectableEntities,
|
|
381
|
+
entitiesLoading
|
|
382
|
+
},
|
|
383
|
+
contentTypeSettings.uid
|
|
384
|
+
);
|
|
385
|
+
}) })
|
|
386
|
+
] }) : /* @__PURE__ */ jsxs(Typography, { children: [
|
|
387
|
+
formatMessage({
|
|
388
|
+
id: getTranslation("settings.page.general.noContentTypesEnabled"),
|
|
389
|
+
defaultMessage: "No content types are enabled for Webatlas. Please enable at least one content type to use this plugin."
|
|
390
|
+
}),
|
|
391
|
+
/* @__PURE__ */ jsx(
|
|
392
|
+
Link,
|
|
393
|
+
{
|
|
394
|
+
href: "https://github.com/mattisvensson/strapi-plugin-webatlas?tab=readme-ov-file#-configuration",
|
|
395
|
+
isExternal: true,
|
|
396
|
+
style: { marginLeft: 4 },
|
|
397
|
+
children: formatMessage({
|
|
398
|
+
id: getTranslation("settings.page.general.noContentTypesEnabled.moreInfo"),
|
|
399
|
+
defaultMessage: "More info"
|
|
400
|
+
})
|
|
401
|
+
}
|
|
402
|
+
)
|
|
403
|
+
] }),
|
|
404
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 4, children: /* @__PURE__ */ jsxs(
|
|
405
|
+
Field.Root,
|
|
406
|
+
{
|
|
407
|
+
name: "routeBlacklist",
|
|
408
|
+
hint: formatMessage({
|
|
409
|
+
id: getTranslation("settings.page.blacklist.hint"),
|
|
410
|
+
defaultMessage: 'Enter a comma-separated list of URL segments that should be blocked from being used in generated paths. For example, if you enter "admin, login", then any generated path that starts with "/admin" or "/login" will be blocked, while paths like "/admin-guide" stay allowed. The blacklist only applies to routes that are created or updated after saving — it does not affect existing routes.'
|
|
411
|
+
}),
|
|
412
|
+
children: [
|
|
413
|
+
/* @__PURE__ */ jsx(Field.Label, { children: /* @__PURE__ */ jsx(SettingTitle, { children: formatMessage({
|
|
414
|
+
id: getTranslation("settings.page.blacklist.label"),
|
|
415
|
+
defaultMessage: "URL Blacklist"
|
|
416
|
+
}) }) }),
|
|
417
|
+
/* @__PURE__ */ jsx(
|
|
418
|
+
Field.Input,
|
|
419
|
+
{
|
|
420
|
+
type: "text",
|
|
421
|
+
placeholder: formatMessage({
|
|
422
|
+
id: getTranslation("settings.page.blacklist.placeholder"),
|
|
423
|
+
defaultMessage: "Enter comma-separated URL segments to block"
|
|
424
|
+
}),
|
|
425
|
+
value: blacklistInput,
|
|
426
|
+
onChange: (e) => setBlacklistInput(e.target.value),
|
|
427
|
+
onBlur: () => {
|
|
428
|
+
const blacklist = blacklistInput.split(",").map((s) => s.trim().toLowerCase().replace(/^\/+/, "").replace(/\/+$/, "")).filter(Boolean);
|
|
429
|
+
dispatch({ type: "SET_ROUTE_BLACKLIST", payload: { blacklist } });
|
|
430
|
+
setBlacklistInput(blacklist.join(", "));
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
),
|
|
434
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
|
435
|
+
]
|
|
436
|
+
}
|
|
437
|
+
) })
|
|
438
|
+
]
|
|
439
|
+
}
|
|
440
|
+
),
|
|
441
|
+
/* @__PURE__ */ jsx(
|
|
442
|
+
ContentBox,
|
|
443
|
+
{
|
|
444
|
+
title: formatMessage({
|
|
445
|
+
id: getTranslation("settings.page.general.details"),
|
|
446
|
+
defaultMessage: "Details"
|
|
447
|
+
}),
|
|
448
|
+
children: /* @__PURE__ */ jsxs(Field.Root, { name: "selectedContentTypesAccordion", children: [
|
|
449
|
+
/* @__PURE__ */ jsx(Field.Label, { children: /* @__PURE__ */ jsxs(SettingTitle, { children: [
|
|
450
|
+
PLUGIN_NAME,
|
|
451
|
+
" ",
|
|
452
|
+
formatMessage({
|
|
453
|
+
id: getTranslation("version"),
|
|
454
|
+
defaultMessage: "Version"
|
|
455
|
+
})
|
|
456
|
+
] }) }),
|
|
457
|
+
/* @__PURE__ */ jsxs(Typography, { children: [
|
|
458
|
+
"v",
|
|
459
|
+
PLUGIN_VERSION,
|
|
460
|
+
/* @__PURE__ */ jsx(
|
|
461
|
+
Link,
|
|
462
|
+
{
|
|
463
|
+
href: `https://github.com/mattisvensson/strapi-plugin-webatlas/releases/tag/v${PLUGIN_VERSION}`,
|
|
464
|
+
target: "_blank",
|
|
465
|
+
rel: "noopener noreferrer",
|
|
466
|
+
style: { marginLeft: 4 },
|
|
467
|
+
children: /* @__PURE__ */ jsx(ExternalLink, {})
|
|
468
|
+
}
|
|
469
|
+
)
|
|
470
|
+
] })
|
|
471
|
+
] })
|
|
472
|
+
}
|
|
473
|
+
)
|
|
474
|
+
]
|
|
475
|
+
}
|
|
476
|
+
) });
|
|
477
|
+
};
|
|
478
|
+
export {
|
|
479
|
+
Settings as default
|
|
480
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect, useMemo } from "react";
|
|
3
|
-
import { g as getTranslation, u as useApi, d as debounce, p as pluginPermissions } from "./index-
|
|
3
|
+
import { g as getTranslation, u as useApi, d as debounce, p as pluginPermissions, i as isAbortError } from "./index-Ckaev6xU.mjs";
|
|
4
|
+
import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
|
|
4
5
|
import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
|
|
5
6
|
import { Grid, Box, Field, Thead, Tr, Th, Typography, VisuallyHidden, Td, Flex, LinkButton, Table, Tbody, EmptyStateLayout } from "@strapi/design-system";
|
|
6
7
|
import "@strapi/icons/symbols";
|
|
7
|
-
import {
|
|
8
|
+
import { Cross, ChevronDown, Pencil } from "@strapi/icons";
|
|
8
9
|
import { useIntl } from "react-intl";
|
|
9
10
|
import { useSearchParams } from "react-router-dom";
|
|
10
|
-
import { Cross, ChevronDown, Pencil } from "@strapi/icons";
|
|
11
11
|
function PageWrapper({ children }) {
|
|
12
12
|
const { formatMessage } = useIntl();
|
|
13
13
|
return /* @__PURE__ */ jsxs(Page.Main, { children: [
|
|
@@ -176,6 +176,7 @@ const Paths = () => {
|
|
|
176
176
|
const { getAllRoutes } = useApi();
|
|
177
177
|
const { formatMessage } = useIntl();
|
|
178
178
|
const { toggleNotification } = useNotification();
|
|
179
|
+
const getErrorMessage = useErrorMessage();
|
|
179
180
|
const [allRoutes, setAllRoutes] = useState([]);
|
|
180
181
|
const [routes, setRoutes] = useState([]);
|
|
181
182
|
const [loading, setLoading] = useState(true);
|
|
@@ -210,13 +211,17 @@ const Paths = () => {
|
|
|
210
211
|
setAllRoutes(data);
|
|
211
212
|
setRoutes(data);
|
|
212
213
|
} catch (err) {
|
|
213
|
-
|
|
214
|
+
if (isAbortError(err)) return;
|
|
215
|
+
console.error("Failed to fetch paths:", err);
|
|
214
216
|
toggleNotification({
|
|
215
217
|
type: "danger",
|
|
216
|
-
message:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
message: getErrorMessage(
|
|
219
|
+
err,
|
|
220
|
+
formatMessage({
|
|
221
|
+
id: getTranslation("notification.paths.fetchFailed"),
|
|
222
|
+
defaultMessage: "Failed to fetch paths"
|
|
223
|
+
})
|
|
224
|
+
)
|
|
220
225
|
});
|
|
221
226
|
} finally {
|
|
222
227
|
setLoading(false);
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED