@mattisvensson/strapi-plugin-webatlas 0.11.9 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-D9RNp4zS.js → RoutePicker-C3_tzz9U.js} +1 -1
- package/dist/admin/{RoutePicker-p1rh5rcZ.mjs → RoutePicker-IRZiHKFi.mjs} +1 -1
- package/dist/admin/{SettingTitle-BMHyfLrM.mjs → SettingTitle-0mKlA80i.mjs} +1 -1
- package/dist/admin/{SettingTitle-CwB5CsY0.js → SettingTitle-Ib_0AvoZ.js} +1 -1
- package/dist/admin/WarningBox-BZ3BZ5fR.js +41 -0
- package/dist/admin/WarningBox-CXEmXfVx.mjs +42 -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-88JTX1Mj.js +480 -0
- package/dist/admin/{index-zr90q-6H.js → index-BPUJTNed.js} +178 -85
- package/dist/admin/{index-BE6CLx3P.mjs → index-BY6JLZrD.mjs} +180 -87
- package/dist/admin/index-Bym1mXg1.mjs +480 -0
- package/dist/admin/{index-G7qx6Oy7.mjs → index-ByxM39aL.mjs} +170 -132
- package/dist/admin/{index-zskvsDgF.js → index-CEJBltoJ.js} +21 -13
- package/dist/admin/{index-DpS40t3Q.mjs → index-CNCyng5O.mjs} +21 -13
- package/dist/admin/{index-CFf370lR.js → index-CsKnBzp6.js} +169 -131
- package/dist/admin/{index-LNTPJt5H.js → index-DNBXz42q.js} +13 -8
- package/dist/admin/{index-IxsV1TAn.mjs → index-PD3gcnXA.mjs} +13 -8
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/server/index.js +484 -494
- package/dist/server/index.mjs +497 -507
- package/dist/server/src/index.d.ts +48 -5
- package/package.json +1 -1
- package/dist/admin/index-Df1hDvta.js +0 -243
- package/dist/admin/index-Z6ahaWtf.mjs +0 -243
|
@@ -14,6 +14,7 @@ declare const _default: {
|
|
|
14
14
|
navigation: {
|
|
15
15
|
maxDepth: number;
|
|
16
16
|
};
|
|
17
|
+
routeBlacklist: any[];
|
|
17
18
|
};
|
|
18
19
|
validator(): void;
|
|
19
20
|
};
|
|
@@ -72,7 +73,7 @@ declare const _default: {
|
|
|
72
73
|
admin: ({ strapi }: {
|
|
73
74
|
strapi: any;
|
|
74
75
|
}) => {
|
|
75
|
-
updateConfig(newConfig: Partial<import('../../types').PluginConfig>): Promise<import('../../types').PluginConfig
|
|
76
|
+
updateConfig(newConfig: Partial<import('../../types').PluginConfig>): Promise<import('../../types').PluginConfig>;
|
|
76
77
|
getConfig(): Promise<any>;
|
|
77
78
|
getRoute(documentId: string): Promise<any>;
|
|
78
79
|
getAllRoutes(): Promise<any>;
|
|
@@ -82,14 +83,56 @@ declare const _default: {
|
|
|
82
83
|
createNavigation(name: string, visible: boolean): Promise<any>;
|
|
83
84
|
updateNavigation(documentId: string, data: import('../../types').NavigationInput): Promise<any>;
|
|
84
85
|
deleteNavigation(documentId: string): Promise<any>;
|
|
85
|
-
updateNavigationItemStructure(navigationId: string, navigationItems: import('../../types').NestedNavItem[]): Promise<
|
|
86
|
-
|
|
86
|
+
updateNavigationItemStructure(navigationId: string, navigationItems: import('../../types').NestedNavItem[]): Promise<{
|
|
87
|
+
success: boolean;
|
|
88
|
+
errors: string[];
|
|
89
|
+
}>;
|
|
90
|
+
checkUniquePath(initialPath: string, targetRouteDocumentId?: string): Promise<{
|
|
91
|
+
blacklisted: boolean;
|
|
92
|
+
uniquePath?: undefined;
|
|
93
|
+
} | {
|
|
94
|
+
uniquePath: string;
|
|
95
|
+
blacklisted?: undefined;
|
|
96
|
+
}>;
|
|
87
97
|
};
|
|
88
98
|
client: ({ strapi }: {
|
|
89
99
|
strapi: any;
|
|
90
100
|
}) => {
|
|
91
|
-
getEntityByPath(slug: string, populate: string, populateDeepDepth: string, fields: any, status?: "published" | "draft"): Promise<any>;
|
|
92
|
-
getNavigation(id: string, name: string, slug: string, documentId: string, variant?: import('../../types').StructuredNavigationVariant): Promise<
|
|
101
|
+
getEntityByPath(slug: string, populate: string, populateDeepDepth: string, fields: any, status?: "published" | "draft", breadcrumb?: boolean): Promise<any>;
|
|
102
|
+
getNavigation(id: string, name: string, slug: string, documentId: string, variant?: import('../../types').StructuredNavigationVariant): Promise<{
|
|
103
|
+
items: {
|
|
104
|
+
depth: any;
|
|
105
|
+
items: any;
|
|
106
|
+
id: number;
|
|
107
|
+
documentId: string;
|
|
108
|
+
title: string;
|
|
109
|
+
slug: string;
|
|
110
|
+
path: string;
|
|
111
|
+
uidPath: string;
|
|
112
|
+
canonicalPath: string;
|
|
113
|
+
relatedContentType: string;
|
|
114
|
+
relatedId: number;
|
|
115
|
+
relatedDocumentId: string;
|
|
116
|
+
type: import('../../types').RouteType;
|
|
117
|
+
active: boolean;
|
|
118
|
+
isOverride: boolean;
|
|
119
|
+
navitem: {
|
|
120
|
+
id: number;
|
|
121
|
+
};
|
|
122
|
+
parent?: import('../../types').Route;
|
|
123
|
+
children?: import('../../types').Route[];
|
|
124
|
+
createdAt: string;
|
|
125
|
+
updatedAt: string;
|
|
126
|
+
__component: string;
|
|
127
|
+
}[];
|
|
128
|
+
id: number;
|
|
129
|
+
documentId: string;
|
|
130
|
+
name: string;
|
|
131
|
+
slug: string;
|
|
132
|
+
visible: boolean;
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
createdAt: string;
|
|
135
|
+
}>;
|
|
93
136
|
};
|
|
94
137
|
};
|
|
95
138
|
contentTypes: {
|
package/package.json
CHANGED
|
@@ -1,243 +0,0 @@
|
|
|
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-CFf370lR.js");
|
|
8
|
-
const reactIntl = require("react-intl");
|
|
9
|
-
require("@strapi/icons/symbols");
|
|
10
|
-
const FullLoader = require("./FullLoader-Da2n70bJ.js");
|
|
11
|
-
const SettingTitle = require("./SettingTitle-CwB5CsY0.js");
|
|
12
|
-
const icons = require("@strapi/icons");
|
|
13
|
-
function ContentTypeAccordion({
|
|
14
|
-
contentType,
|
|
15
|
-
contentTypeSettings,
|
|
16
|
-
dispatch
|
|
17
|
-
}) {
|
|
18
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
19
|
-
if (!contentType) return null;
|
|
20
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { borderColor: !contentTypeSettings.default ? "danger500" : void 0, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: contentType.uid, children: [
|
|
21
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: contentType?.info.displayName }) }),
|
|
22
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
23
|
-
designSystem.Field.Root,
|
|
24
|
-
{
|
|
25
|
-
name: "selectedContentTypes",
|
|
26
|
-
hint: formatMessage({
|
|
27
|
-
id: index.getTranslation("settings.page.generate.hint"),
|
|
28
|
-
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".'
|
|
29
|
-
}),
|
|
30
|
-
error: !contentTypeSettings.default && formatMessage({
|
|
31
|
-
id: index.getTranslation("settings.page.generate.error"),
|
|
32
|
-
defaultMessage: "Please select a default field"
|
|
33
|
-
}),
|
|
34
|
-
required: true,
|
|
35
|
-
children: [
|
|
36
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
37
|
-
id: index.getTranslation("settings.page.generate"),
|
|
38
|
-
defaultMessage: "Generate paths from"
|
|
39
|
-
}) }),
|
|
40
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
41
|
-
designSystem.SingleSelect,
|
|
42
|
-
{
|
|
43
|
-
name: `defaultField-${contentType.uid}`,
|
|
44
|
-
onClear: () => dispatch({
|
|
45
|
-
type: "SET_DEFAULT_FIELD",
|
|
46
|
-
payload: { ctUid: contentType.uid, field: "" }
|
|
47
|
-
}),
|
|
48
|
-
value: contentTypeSettings?.default || "",
|
|
49
|
-
onChange: (value) => dispatch({
|
|
50
|
-
type: "SET_DEFAULT_FIELD",
|
|
51
|
-
payload: { ctUid: contentType.uid, field: String(value) }
|
|
52
|
-
}),
|
|
53
|
-
children: Object.entries(contentType.attributes).map(([key], index2) => {
|
|
54
|
-
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
|
|
55
|
-
key === "webatlas_path" || key === "webatlas_override" || key === "webatlas_parent")
|
|
56
|
-
return null;
|
|
57
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: key, children: key }, index2);
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
),
|
|
61
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
) }) })
|
|
65
|
-
] }, contentType.uid) }, contentType.uid);
|
|
66
|
-
}
|
|
67
|
-
function reducer(newConfig, action) {
|
|
68
|
-
let updatedContentTypes;
|
|
69
|
-
switch (action.type) {
|
|
70
|
-
case "SET_DEFAULT_FIELD":
|
|
71
|
-
if (!newConfig) return null;
|
|
72
|
-
updatedContentTypes = newConfig?.selectedContentTypes.map(
|
|
73
|
-
(ct) => ct.uid === action.payload.ctUid ? { ...ct, default: action.payload.field } : ct
|
|
74
|
-
);
|
|
75
|
-
return { ...newConfig, selectedContentTypes: updatedContentTypes || [] };
|
|
76
|
-
case "SET_CONFIG":
|
|
77
|
-
return action.payload;
|
|
78
|
-
default:
|
|
79
|
-
throw new Error();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const Settings = () => {
|
|
83
|
-
const { config: fetchedConfig, setConfig, loading, fetchError } = index.usePluginConfig();
|
|
84
|
-
const [config, dispatch] = React.useReducer(reducer, fetchedConfig);
|
|
85
|
-
const { contentTypes: allContentTypesData } = index.useAllContentTypes();
|
|
86
|
-
const allContentTypes = allContentTypesData?.filter(
|
|
87
|
-
(ct) => ct.pluginOptions?.webatlas?.enabled === true
|
|
88
|
-
);
|
|
89
|
-
const { toggleNotification } = admin.useNotification();
|
|
90
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
91
|
-
const [isSaving, setIsSaving] = React.useState(false);
|
|
92
|
-
const initialConfig = React.useRef(fetchedConfig);
|
|
93
|
-
React.useEffect(() => {
|
|
94
|
-
initialConfig.current = fetchedConfig;
|
|
95
|
-
if (fetchedConfig) dispatch({ type: "SET_CONFIG", payload: fetchedConfig });
|
|
96
|
-
}, [fetchedConfig]);
|
|
97
|
-
React.useEffect(() => {
|
|
98
|
-
if (fetchError) {
|
|
99
|
-
toggleNotification({
|
|
100
|
-
type: "danger",
|
|
101
|
-
message: formatMessage({
|
|
102
|
-
id: index.getTranslation("notification.error"),
|
|
103
|
-
defaultMessage: "An error occurred"
|
|
104
|
-
}) + ": " + fetchError
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}, [fetchError, toggleNotification, formatMessage]);
|
|
108
|
-
async function save() {
|
|
109
|
-
if (!config || config.selectedContentTypes.find((cta) => !cta.default) !== void 0)
|
|
110
|
-
return;
|
|
111
|
-
setIsSaving(true);
|
|
112
|
-
try {
|
|
113
|
-
await setConfig({ selectedContentTypes: config.selectedContentTypes });
|
|
114
|
-
initialConfig.current = config;
|
|
115
|
-
toggleNotification({
|
|
116
|
-
type: "success",
|
|
117
|
-
message: formatMessage({
|
|
118
|
-
id: index.getTranslation("notification.settings.saved"),
|
|
119
|
-
defaultMessage: "Settings saved successfully"
|
|
120
|
-
})
|
|
121
|
-
});
|
|
122
|
-
setIsSaving(false);
|
|
123
|
-
} catch (err) {
|
|
124
|
-
setIsSaving(false);
|
|
125
|
-
toggleNotification({
|
|
126
|
-
type: "danger",
|
|
127
|
-
message: formatMessage({
|
|
128
|
-
id: index.getTranslation("notification.error"),
|
|
129
|
-
defaultMessage: "An error occurred"
|
|
130
|
-
}) + ": " + err
|
|
131
|
-
});
|
|
132
|
-
strapi.log.error(err);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (loading) {
|
|
136
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
137
|
-
SettingTitle.PageWrapper,
|
|
138
|
-
{
|
|
139
|
-
isSaving,
|
|
140
|
-
subtitle: formatMessage({
|
|
141
|
-
id: index.getTranslation("loading"),
|
|
142
|
-
defaultMessage: "Loading..."
|
|
143
|
-
}),
|
|
144
|
-
disabledCondition: true,
|
|
145
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, { height: 200 })
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.pluginPermissions["settings.general"], children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
150
|
-
SettingTitle.PageWrapper,
|
|
151
|
-
{
|
|
152
|
-
save,
|
|
153
|
-
isSaving,
|
|
154
|
-
subtitle: formatMessage({
|
|
155
|
-
id: index.getTranslation("settings.page.general.subtitle"),
|
|
156
|
-
defaultMessage: "Configure general settings"
|
|
157
|
-
}),
|
|
158
|
-
disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current),
|
|
159
|
-
children: [
|
|
160
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
161
|
-
SettingTitle.ContentBox,
|
|
162
|
-
{
|
|
163
|
-
title: formatMessage({
|
|
164
|
-
id: index.getTranslation("settings.page.general.contentTypes"),
|
|
165
|
-
defaultMessage: "Content Types"
|
|
166
|
-
}),
|
|
167
|
-
children: config?.selectedContentTypes && config.selectedContentTypes.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "selectedContentTypesAccordion", children: [
|
|
168
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingTitle.SettingTitle, { children: formatMessage({
|
|
169
|
-
id: index.getTranslation("settings.page.contentTypeSettings"),
|
|
170
|
-
defaultMessage: "Content Type settings"
|
|
171
|
-
}) }) }),
|
|
172
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { children: config.selectedContentTypes?.map((contentTypeSettings) => {
|
|
173
|
-
const ct = allContentTypes?.find(
|
|
174
|
-
(item) => item.uid === contentTypeSettings.uid
|
|
175
|
-
);
|
|
176
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
177
|
-
ContentTypeAccordion,
|
|
178
|
-
{
|
|
179
|
-
contentType: ct,
|
|
180
|
-
contentTypeSettings,
|
|
181
|
-
dispatch
|
|
182
|
-
},
|
|
183
|
-
contentTypeSettings.uid
|
|
184
|
-
);
|
|
185
|
-
}) })
|
|
186
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { children: [
|
|
187
|
-
formatMessage({
|
|
188
|
-
id: index.getTranslation("settings.page.general.noContentTypesEnabled"),
|
|
189
|
-
defaultMessage: "No content types are enabled for Webatlas. Please enable at least one content type to use this plugin."
|
|
190
|
-
}),
|
|
191
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
192
|
-
designSystem.Link,
|
|
193
|
-
{
|
|
194
|
-
href: "https://github.com/mattisvensson/strapi-plugin-webatlas?tab=readme-ov-file#-configuration",
|
|
195
|
-
isExternal: true,
|
|
196
|
-
style: { marginLeft: 4 },
|
|
197
|
-
children: formatMessage({
|
|
198
|
-
id: index.getTranslation("settings.page.general.noContentTypesEnabled.moreInfo"),
|
|
199
|
-
defaultMessage: "More info"
|
|
200
|
-
})
|
|
201
|
-
}
|
|
202
|
-
)
|
|
203
|
-
] })
|
|
204
|
-
}
|
|
205
|
-
),
|
|
206
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
207
|
-
SettingTitle.ContentBox,
|
|
208
|
-
{
|
|
209
|
-
title: formatMessage({
|
|
210
|
-
id: index.getTranslation("settings.page.general.details"),
|
|
211
|
-
defaultMessage: "Details"
|
|
212
|
-
}),
|
|
213
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "selectedContentTypesAccordion", children: [
|
|
214
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsxs(SettingTitle.SettingTitle, { children: [
|
|
215
|
-
index.PLUGIN_NAME,
|
|
216
|
-
" ",
|
|
217
|
-
formatMessage({
|
|
218
|
-
id: index.getTranslation("version"),
|
|
219
|
-
defaultMessage: "Version"
|
|
220
|
-
})
|
|
221
|
-
] }) }),
|
|
222
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { children: [
|
|
223
|
-
"v",
|
|
224
|
-
index.PLUGIN_VERSION,
|
|
225
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
226
|
-
designSystem.Link,
|
|
227
|
-
{
|
|
228
|
-
href: `https://github.com/mattisvensson/strapi-plugin-webatlas/releases/tag/v${index.PLUGIN_VERSION}`,
|
|
229
|
-
target: "_blank",
|
|
230
|
-
rel: "noopener noreferrer",
|
|
231
|
-
style: { marginLeft: 4 },
|
|
232
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.ExternalLink, {})
|
|
233
|
-
}
|
|
234
|
-
)
|
|
235
|
-
] })
|
|
236
|
-
] })
|
|
237
|
-
}
|
|
238
|
-
)
|
|
239
|
-
]
|
|
240
|
-
}
|
|
241
|
-
) });
|
|
242
|
-
};
|
|
243
|
-
exports.default = Settings;
|
|
@@ -1,243 +0,0 @@
|
|
|
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-G7qx6Oy7.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-BMHyfLrM.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
|
-
};
|