@mattisvensson/strapi-plugin-webatlas 0.11.7 → 0.11.8
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/dist/admin/FullLoader-Btjb2W2p.mjs +15 -0
- package/dist/admin/FullLoader-Da2n70bJ.js +14 -0
- package/dist/admin/RoutePicker-BEmAG6aK.js +102 -0
- package/dist/admin/RoutePicker-CFqZfjDu.mjs +102 -0
- package/dist/admin/SettingTitle-DRvX07-B.js +70 -0
- package/dist/admin/SettingTitle-D_X8W1mC.mjs +71 -0
- package/dist/admin/de-B5pRvs13.mjs +128 -0
- package/dist/admin/de-CqU1FU8C.js +128 -0
- package/dist/admin/en-BE-zzIv8.mjs +128 -0
- package/dist/admin/en-C7I90FwV.js +128 -0
- package/dist/admin/index-B9kmIJ1Y.mjs +9529 -0
- package/dist/admin/index-CSknqklZ.js +9529 -0
- package/dist/admin/index-CTbP2yjO.js +243 -0
- package/dist/admin/index-CYF5Yipx.mjs +244 -0
- package/dist/admin/index-ClG-B5Tr.js +139 -0
- package/dist/admin/index-DZkauelU.mjs +4275 -0
- package/dist/admin/index-HCnLKUJN.mjs +139 -0
- package/dist/admin/index-_8exe5fa.js +244 -0
- package/dist/admin/index-lZ3-1icm.js +4291 -0
- package/dist/admin/index-uD-voTpW.mjs +243 -0
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/admin/src/index.d.ts +12 -0
- package/dist/server/index.js +6321 -0
- package/dist/server/index.mjs +6321 -0
- package/dist/server/src/index.d.ts +308 -0
- package/package.json +1 -1
|
@@ -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-DZkauelU.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-D_X8W1mC.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
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StrapiApp } from '@strapi/admin/strapi-admin';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
register(app: StrapiApp): void;
|
|
4
|
+
bootstrap(app: StrapiApp): void;
|
|
5
|
+
registerTrads({ locales }: {
|
|
6
|
+
locales: string[];
|
|
7
|
+
}): Promise<{
|
|
8
|
+
data: any;
|
|
9
|
+
locale: string;
|
|
10
|
+
}[]>;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|