@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
|
@@ -52,11 +52,11 @@ function transformToUrl(input, replaceSlash = true) {
|
|
|
52
52
|
input = input.replace(/-+/g, "-");
|
|
53
53
|
return input;
|
|
54
54
|
}
|
|
55
|
-
const version = "0.
|
|
56
|
-
const strapi
|
|
55
|
+
const version = "0.12.1";
|
|
56
|
+
const strapi = { "name": "webatlas", "displayName": "Webatlas" };
|
|
57
57
|
const pluginPkg = {
|
|
58
58
|
version,
|
|
59
|
-
strapi
|
|
59
|
+
strapi
|
|
60
60
|
};
|
|
61
61
|
const PLUGIN_ID = pluginPkg.strapi.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, "") || "webatlas";
|
|
62
62
|
const PLUGIN_NAME = pluginPkg.strapi.displayName;
|
|
@@ -73,62 +73,37 @@ const NavigationIcon = () => /* @__PURE__ */ jsx(List, {});
|
|
|
73
73
|
function useApi() {
|
|
74
74
|
const { get, put, del, post } = useFetchClient();
|
|
75
75
|
const fetchAllContentTypes = async () => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return data.data;
|
|
79
|
-
} catch (error) {
|
|
80
|
-
strapi.log.error("Cannot fetch all content types:", error);
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
76
|
+
const { data } = await get("/content-manager/content-types");
|
|
77
|
+
return data.data;
|
|
83
78
|
};
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (configuredTypes.length === 0) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
const allContentTypes = await fetchAllContentTypes();
|
|
92
|
-
const configuredUIDs = new Set(configuredTypes.map((ct) => ct.uid));
|
|
93
|
-
return allContentTypes.filter((ct) => configuredUIDs.has(ct.uid));
|
|
94
|
-
} catch (err) {
|
|
95
|
-
strapi.log.error("Error fetching configured content types:", err);
|
|
79
|
+
const fetchAllEntities = async () => {
|
|
80
|
+
const { data } = await get(`/${PLUGIN_ID}/config`);
|
|
81
|
+
const contentTypes = data?.selectedContentTypes || [];
|
|
82
|
+
if (!contentTypes || contentTypes.length === 0) {
|
|
96
83
|
return [];
|
|
97
84
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
let entities = [];
|
|
107
|
-
const entityResults = await Promise.allSettled(
|
|
108
|
-
contentTypes.map(async (contentType) => {
|
|
109
|
-
try {
|
|
110
|
-
const { data: data2 } = await get(
|
|
111
|
-
`/content-manager/collection-types/${contentType.uid}?pageSize=9999`
|
|
112
|
-
);
|
|
113
|
-
if (!data2 || !data2.results) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
entities: data2.results,
|
|
118
|
-
contentType
|
|
119
|
-
};
|
|
120
|
-
} catch (err) {
|
|
121
|
-
strapi.log.error(`Cannot access entities for ${contentType.uid}:`, err);
|
|
85
|
+
let entities = [];
|
|
86
|
+
const entityResults = await Promise.allSettled(
|
|
87
|
+
contentTypes.map(async (contentType) => {
|
|
88
|
+
try {
|
|
89
|
+
const { data: data2 } = await get(
|
|
90
|
+
`/content-manager/collection-types/${contentType.uid}?pageSize=9999`
|
|
91
|
+
);
|
|
92
|
+
if (!data2 || !data2.results) {
|
|
122
93
|
return null;
|
|
123
94
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
95
|
+
return {
|
|
96
|
+
entities: data2.results,
|
|
97
|
+
contentType
|
|
98
|
+
};
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.error(`Cannot access entities for ${contentType.uid}:`, err);
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
entities = entityResults.map((result) => result.status === "fulfilled" ? result.value : null).filter(Boolean);
|
|
106
|
+
return entities;
|
|
132
107
|
};
|
|
133
108
|
const getRelatedRoute = async (relatedDocumentId) => {
|
|
134
109
|
const { data } = await get(`/${PLUGIN_ID}/route/related?documentId=${relatedDocumentId}`);
|
|
@@ -185,7 +160,6 @@ function useApi() {
|
|
|
185
160
|
};
|
|
186
161
|
return {
|
|
187
162
|
fetchAllContentTypes,
|
|
188
|
-
fetchConfiguredContentTypes,
|
|
189
163
|
fetchAllEntities,
|
|
190
164
|
getRelatedRoute,
|
|
191
165
|
getRoute,
|
|
@@ -198,6 +172,42 @@ function useApi() {
|
|
|
198
172
|
updateNavigationItemStructure
|
|
199
173
|
};
|
|
200
174
|
}
|
|
175
|
+
function debounce(func, wait) {
|
|
176
|
+
let timeout;
|
|
177
|
+
return function executedFunction(...args) {
|
|
178
|
+
const later = () => {
|
|
179
|
+
clearTimeout(timeout);
|
|
180
|
+
func(...args);
|
|
181
|
+
};
|
|
182
|
+
clearTimeout(timeout);
|
|
183
|
+
timeout = setTimeout(later, wait);
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
async function duplicateCheck({
|
|
187
|
+
fetchFunction,
|
|
188
|
+
path,
|
|
189
|
+
routeDocumentId,
|
|
190
|
+
withoutTransform = false
|
|
191
|
+
}) {
|
|
192
|
+
if (!path) throw new Error("URL is required");
|
|
193
|
+
try {
|
|
194
|
+
const pathToCheck = withoutTransform ? path : transformToUrl(path);
|
|
195
|
+
const { data } = await fetchFunction(
|
|
196
|
+
`/${PLUGIN_ID}/checkUniquePath?path=${pathToCheck}${routeDocumentId ? `&targetRouteDocumentId=${routeDocumentId}` : ""}`
|
|
197
|
+
);
|
|
198
|
+
if (data.blacklisted) return { uniquePath: null, blacklisted: true };
|
|
199
|
+
if (!data.uniquePath) {
|
|
200
|
+
throw new Error("Network response was not ok");
|
|
201
|
+
}
|
|
202
|
+
return { uniquePath: data.uniquePath, blacklisted: false };
|
|
203
|
+
} catch (err) {
|
|
204
|
+
throw new Error("Failed to check URL uniqueness: " + err.message);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
208
|
+
function isAbortError(error) {
|
|
209
|
+
return error instanceof Error && error.name === "AbortError";
|
|
210
|
+
}
|
|
201
211
|
const useAllContentTypes = () => {
|
|
202
212
|
const { fetchAllContentTypes } = useApi();
|
|
203
213
|
const [contentTypes, setContentTypes] = useState([]);
|
|
@@ -210,6 +220,7 @@ const useAllContentTypes = () => {
|
|
|
210
220
|
setContentTypes(result);
|
|
211
221
|
setLoading(false);
|
|
212
222
|
} catch (err) {
|
|
223
|
+
if (isAbortError(err)) return;
|
|
213
224
|
setError(err);
|
|
214
225
|
setLoading(false);
|
|
215
226
|
}
|
|
@@ -233,6 +244,7 @@ function usePluginConfig() {
|
|
|
233
244
|
} = await get("/content-manager/content-types");
|
|
234
245
|
let { data: config2 } = await get(`/${PLUGIN_ID}/config`);
|
|
235
246
|
if (!config2 || !config2.selectedContentTypes) {
|
|
247
|
+
console.error(`Couldn't fetch plugin config`);
|
|
236
248
|
throw new Error(`Couldn't fetch plugin config`);
|
|
237
249
|
}
|
|
238
250
|
const allowedContentTypes = contentTypesArray.filter(
|
|
@@ -248,7 +260,8 @@ function usePluginConfig() {
|
|
|
248
260
|
};
|
|
249
261
|
setConfigData(displayConfig);
|
|
250
262
|
} catch (error) {
|
|
251
|
-
|
|
263
|
+
if (isAbortError(error)) return;
|
|
264
|
+
setFetchError(error);
|
|
252
265
|
} finally {
|
|
253
266
|
setLoading(false);
|
|
254
267
|
}
|
|
@@ -264,43 +277,21 @@ function usePluginConfig() {
|
|
|
264
277
|
}
|
|
265
278
|
return { config, loading, fetchError, setConfig };
|
|
266
279
|
}
|
|
267
|
-
function
|
|
268
|
-
let timeout;
|
|
269
|
-
return function executedFunction(...args) {
|
|
270
|
-
const later = () => {
|
|
271
|
-
clearTimeout(timeout);
|
|
272
|
-
func(...args);
|
|
273
|
-
};
|
|
274
|
-
clearTimeout(timeout);
|
|
275
|
-
timeout = setTimeout(later, wait);
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
async function duplicateCheck({
|
|
279
|
-
fetchFunction,
|
|
280
|
-
path,
|
|
281
|
-
routeDocumentId,
|
|
282
|
-
withoutTransform = false
|
|
283
|
-
}) {
|
|
284
|
-
if (!path) throw new Error("URL is required");
|
|
285
|
-
try {
|
|
286
|
-
const pathToCheck = withoutTransform ? path : transformToUrl(path);
|
|
287
|
-
const { data } = await fetchFunction(
|
|
288
|
-
`/${PLUGIN_ID}/checkUniquePath?path=${pathToCheck}${routeDocumentId ? `&targetRouteDocumentId=${routeDocumentId}` : ""}`
|
|
289
|
-
);
|
|
290
|
-
if (!data.uniquePath) {
|
|
291
|
-
throw new Error("Network response was not ok");
|
|
292
|
-
}
|
|
293
|
-
return data.uniquePath;
|
|
294
|
-
} catch (err) {
|
|
295
|
-
throw new Error("Failed to check URL uniqueness: " + err.message);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
299
|
-
function PathInfo({ validationState, replacement }) {
|
|
280
|
+
function PathInfo({ validationState, replacement, isBlacklisted }) {
|
|
300
281
|
const [color, setColor] = useState("neutral800");
|
|
301
282
|
const [text, setText] = useState(null);
|
|
302
283
|
const { formatMessage } = useIntl();
|
|
303
284
|
useEffect(() => {
|
|
285
|
+
if (isBlacklisted) {
|
|
286
|
+
setColor("danger500");
|
|
287
|
+
setText(
|
|
288
|
+
formatMessage({
|
|
289
|
+
id: getTranslation("components.pathInfo.blacklisted"),
|
|
290
|
+
defaultMessage: "This path is blocked by the URL blacklist and cannot be saved."
|
|
291
|
+
})
|
|
292
|
+
);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
304
295
|
if (validationState === "initial") return;
|
|
305
296
|
if (validationState === "checking") {
|
|
306
297
|
setColor("neutral800");
|
|
@@ -322,7 +313,7 @@ function PathInfo({ validationState, replacement }) {
|
|
|
322
313
|
})
|
|
323
314
|
);
|
|
324
315
|
}
|
|
325
|
-
}, [validationState, replacement, formatMessage]);
|
|
316
|
+
}, [validationState, replacement, isBlacklisted, formatMessage]);
|
|
326
317
|
return /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { textColor: color, children: text }) });
|
|
327
318
|
}
|
|
328
319
|
function OverrideCheckbox({ isOverride, setIsOverride, disabledCondition }) {
|
|
@@ -3670,10 +3661,10 @@ function PathInput({ path, dispatchPath, isOverride, config, hasUserInteracted }
|
|
|
3670
3661
|
return /* @__PURE__ */ jsxs(
|
|
3671
3662
|
Field.Root,
|
|
3672
3663
|
{
|
|
3673
|
-
hint: config.
|
|
3664
|
+
hint: config.routeSourceField ? formatMessage({
|
|
3674
3665
|
id: getTranslation("components.CMEditViewAside.path.input.start"),
|
|
3675
3666
|
defaultMessage: "Edit the"
|
|
3676
|
-
}) + ' "' + config.
|
|
3667
|
+
}) + ' "' + config.routeSourceField + '" ' + formatMessage({
|
|
3677
3668
|
id: getTranslation("components.CMEditViewAside.path.input.end"),
|
|
3678
3669
|
defaultMessage: "field to generate a path"
|
|
3679
3670
|
}) : formatMessage({
|
|
@@ -3729,25 +3720,40 @@ function RouteStructure({
|
|
|
3729
3720
|
selectedParent,
|
|
3730
3721
|
setSelectedParent,
|
|
3731
3722
|
canonicalPath,
|
|
3732
|
-
prohibitedRouteIds
|
|
3723
|
+
prohibitedRouteIds,
|
|
3724
|
+
defaultParentRoute,
|
|
3725
|
+
isCreatingEntry
|
|
3733
3726
|
}) {
|
|
3734
3727
|
const { formatMessage } = useIntl();
|
|
3728
|
+
const handleSelectParent = (value) => {
|
|
3729
|
+
const parentRoute = routes.find((route) => route.documentId === value) || null;
|
|
3730
|
+
setSelectedParent(parentRoute);
|
|
3731
|
+
};
|
|
3735
3732
|
const filteredRoutes = useMemo(() => {
|
|
3736
3733
|
return [...routes].sort((a, b) => a.title.localeCompare(b.title)).filter(
|
|
3737
3734
|
(route) => !prohibitedRouteIds?.includes(route.documentId) || route.documentId === selectedParent?.documentId
|
|
3738
3735
|
);
|
|
3739
3736
|
}, [routes, prohibitedRouteIds, selectedParent]);
|
|
3740
|
-
const
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3737
|
+
const defaultParentRouteValue = useMemo(() => {
|
|
3738
|
+
if (defaultParentRoute && isCreatingEntry) {
|
|
3739
|
+
const defaultParent = routes.find((route) => route.relatedDocumentId === defaultParentRoute);
|
|
3740
|
+
return defaultParent || null;
|
|
3741
|
+
}
|
|
3742
|
+
return null;
|
|
3743
|
+
}, [defaultParentRoute, routes, isCreatingEntry]);
|
|
3744
|
+
useEffect(() => {
|
|
3745
|
+
if (defaultParentRouteValue && isCreatingEntry) {
|
|
3746
|
+
handleSelectParent(defaultParentRouteValue?.documentId || "");
|
|
3747
|
+
}
|
|
3748
|
+
}, [defaultParentRouteValue, isCreatingEntry]);
|
|
3749
|
+
const selectValue = selectedParent?.documentId || defaultParentRouteValue?.documentId || "";
|
|
3744
3750
|
return /* @__PURE__ */ jsxs(Box, { paddingBottom: 2, children: [
|
|
3745
3751
|
/* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
3746
3752
|
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
|
3747
3753
|
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.label"),
|
|
3748
3754
|
defaultMessage: "Place under"
|
|
3749
3755
|
}) }),
|
|
3750
|
-
/* @__PURE__ */ jsxs(SingleSelect, { value:
|
|
3756
|
+
/* @__PURE__ */ jsxs(SingleSelect, { value: selectValue, onValueChange: handleSelectParent, children: [
|
|
3751
3757
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: formatMessage({
|
|
3752
3758
|
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.rootPath"),
|
|
3753
3759
|
defaultMessage: "None (root path)"
|
|
@@ -3848,6 +3854,7 @@ const Panel = ({ config }) => {
|
|
|
3848
3854
|
const [selectedParent, setSelectedParent] = useState(null);
|
|
3849
3855
|
const [isOverride, setIsOverride] = useState(false);
|
|
3850
3856
|
const [validationState, setValidationState] = useState("initial");
|
|
3857
|
+
const [isBlacklisted, setIsBlacklisted] = useState(false);
|
|
3851
3858
|
const [initialLoadComplete, setInitialLoadComplete] = useState(false);
|
|
3852
3859
|
const [path, dispatchPath] = useReducer(reducer, {
|
|
3853
3860
|
needsUrlCheck: false,
|
|
@@ -3861,10 +3868,11 @@ const Panel = ({ config }) => {
|
|
|
3861
3868
|
});
|
|
3862
3869
|
const hasUserChangedField = useRef(false);
|
|
3863
3870
|
const hasUserInteracted = useRef(false);
|
|
3864
|
-
const
|
|
3871
|
+
const initialRouteData = useRef(null);
|
|
3865
3872
|
const prevSourceValueRef = useRef(null);
|
|
3866
|
-
const
|
|
3867
|
-
const
|
|
3873
|
+
const routeSourceField = config?.routeSourceField;
|
|
3874
|
+
const sourceFieldValue = routeSourceField ? values[routeSourceField] || "" : "";
|
|
3875
|
+
const initialSourceFieldValue = routeSourceField ? initialValues[routeSourceField] || "" : "";
|
|
3868
3876
|
const latestCheckPathRef = useRef(checkPath);
|
|
3869
3877
|
latestCheckPathRef.current = checkPath;
|
|
3870
3878
|
const debouncedCheckPath = useRef(
|
|
@@ -3891,6 +3899,10 @@ const Panel = ({ config }) => {
|
|
|
3891
3899
|
parentDocumentId: selectedParent?.documentId || null,
|
|
3892
3900
|
slug: isOverride ? overridePath : slug
|
|
3893
3901
|
};
|
|
3902
|
+
if (initialRouteData.current?.isOverride === isOverride && data.path === initialRouteData.current?.path && data.parentDocumentId === (initialRouteData.current?.parent?.documentId ?? null)) {
|
|
3903
|
+
onChange("webatlas", void 0);
|
|
3904
|
+
return;
|
|
3905
|
+
}
|
|
3894
3906
|
if (hasUserChangedField.current || hasUserInteracted.current) {
|
|
3895
3907
|
onChange("webatlas", data);
|
|
3896
3908
|
}
|
|
@@ -3934,15 +3946,25 @@ const Panel = ({ config }) => {
|
|
|
3934
3946
|
]);
|
|
3935
3947
|
useEffect(() => {
|
|
3936
3948
|
if (!initialLoadComplete) return;
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3949
|
+
const pathToCheck = isOverride ? path.overridePath : path.value;
|
|
3950
|
+
const initialPathToCompare = isOverride ? initialRouteData.current?.path : initialRouteData.current?.uidPath;
|
|
3951
|
+
if (path.needsUrlCheck && pathToCheck) {
|
|
3952
|
+
if (path.uidPath === pathToCheck || initialPathToCompare === pathToCheck) return;
|
|
3953
|
+
debouncedCheckPath(pathToCheck, route?.documentId || null);
|
|
3940
3954
|
dispatchPath({ type: "SET_URL_CHECK_FLAG" });
|
|
3941
3955
|
} else {
|
|
3942
3956
|
setValidationState("idle");
|
|
3943
3957
|
dispatchPath({ type: "SET_REPLACEMENT", payload: null });
|
|
3944
3958
|
}
|
|
3945
|
-
}, [
|
|
3959
|
+
}, [
|
|
3960
|
+
path.needsUrlCheck,
|
|
3961
|
+
path.value,
|
|
3962
|
+
path.uidPath,
|
|
3963
|
+
path.overridePath,
|
|
3964
|
+
route,
|
|
3965
|
+
initialLoadComplete,
|
|
3966
|
+
isOverride
|
|
3967
|
+
]);
|
|
3946
3968
|
useEffect(() => {
|
|
3947
3969
|
async function fetchRelatedRute() {
|
|
3948
3970
|
if (!initialValues.documentId) {
|
|
@@ -3952,7 +3974,7 @@ const Panel = ({ config }) => {
|
|
|
3952
3974
|
try {
|
|
3953
3975
|
const route2 = await getRelatedRoute(initialValues.documentId);
|
|
3954
3976
|
if (!route2) return;
|
|
3955
|
-
|
|
3977
|
+
initialRouteData.current = route2;
|
|
3956
3978
|
setRoute(route2);
|
|
3957
3979
|
setIsOverride(route2.isOverride || false);
|
|
3958
3980
|
dispatchPath({ type: "SET_OVERRIDEPATH", payload: route2.path || "" });
|
|
@@ -3966,13 +3988,12 @@ const Panel = ({ config }) => {
|
|
|
3966
3988
|
type: "SET_CANONICALPATH",
|
|
3967
3989
|
payload: route2.canonicalPath || ""
|
|
3968
3990
|
});
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
prevSourceValueRef.current = values[key];
|
|
3991
|
+
if (routeSourceField) {
|
|
3992
|
+
prevSourceValueRef.current = values[routeSourceField];
|
|
3972
3993
|
}
|
|
3973
3994
|
} catch (err) {
|
|
3974
3995
|
setRoute(null);
|
|
3975
|
-
|
|
3996
|
+
console.error(err);
|
|
3976
3997
|
} finally {
|
|
3977
3998
|
setInitialLoadComplete(true);
|
|
3978
3999
|
}
|
|
@@ -4002,15 +4023,18 @@ const Panel = ({ config }) => {
|
|
|
4002
4023
|
async function checkCanonicalPath(path2, routeDocumentId) {
|
|
4003
4024
|
if (!path2) return;
|
|
4004
4025
|
try {
|
|
4005
|
-
const
|
|
4026
|
+
const { uniquePath, blacklisted } = await duplicateCheck({
|
|
4006
4027
|
fetchFunction: get,
|
|
4007
4028
|
path: path2,
|
|
4008
4029
|
routeDocumentId,
|
|
4009
4030
|
withoutTransform: true
|
|
4010
4031
|
});
|
|
4011
|
-
|
|
4032
|
+
setIsBlacklisted(blacklisted);
|
|
4033
|
+
if (blacklisted) return;
|
|
4034
|
+
if (!uniquePath) return;
|
|
4035
|
+
dispatchPath({ type: "SET_CANONICALPATH", payload: uniquePath });
|
|
4012
4036
|
} catch (err) {
|
|
4013
|
-
|
|
4037
|
+
console.error(err);
|
|
4014
4038
|
}
|
|
4015
4039
|
}
|
|
4016
4040
|
async function checkPath(path2, routeDocumentId) {
|
|
@@ -4018,17 +4042,20 @@ const Panel = ({ config }) => {
|
|
|
4018
4042
|
setValidationState("checking");
|
|
4019
4043
|
dispatchPath({ type: "SET_REPLACEMENT", payload: "" });
|
|
4020
4044
|
try {
|
|
4021
|
-
const
|
|
4045
|
+
const { uniquePath, blacklisted } = await duplicateCheck({
|
|
4022
4046
|
fetchFunction: get,
|
|
4023
4047
|
path: path2,
|
|
4024
4048
|
routeDocumentId,
|
|
4025
4049
|
withoutTransform: true
|
|
4026
4050
|
});
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4051
|
+
setIsBlacklisted(blacklisted);
|
|
4052
|
+
if (blacklisted) return;
|
|
4053
|
+
if (!uniquePath || uniquePath === path2) return;
|
|
4054
|
+
dispatchPath({ type: "NO_URL_CHECK", payload: uniquePath });
|
|
4055
|
+
if (isOverride) dispatchPath({ type: "SET_OVERRIDEPATH", payload: uniquePath });
|
|
4056
|
+
dispatchPath({ type: "SET_REPLACEMENT", payload: uniquePath });
|
|
4030
4057
|
} catch (err) {
|
|
4031
|
-
|
|
4058
|
+
console.error(err);
|
|
4032
4059
|
} finally {
|
|
4033
4060
|
setValidationState("done");
|
|
4034
4061
|
}
|
|
@@ -4053,7 +4080,9 @@ const Panel = ({ config }) => {
|
|
|
4053
4080
|
hasUserInteracted.current = true;
|
|
4054
4081
|
setSelectedParent(val);
|
|
4055
4082
|
},
|
|
4056
|
-
prohibitedRouteIds
|
|
4083
|
+
prohibitedRouteIds,
|
|
4084
|
+
defaultParentRoute: config.defaultParentRoute || "",
|
|
4085
|
+
isCreatingEntry: !initialValues.documentId
|
|
4057
4086
|
}
|
|
4058
4087
|
),
|
|
4059
4088
|
/* @__PURE__ */ jsx(Divider, { marginTop: 2, marginBottom: 2 }),
|
|
@@ -4068,7 +4097,14 @@ const Panel = ({ config }) => {
|
|
|
4068
4097
|
hasUserInteracted
|
|
4069
4098
|
}
|
|
4070
4099
|
),
|
|
4071
|
-
validationState !== "initial" && /* @__PURE__ */ jsx(
|
|
4100
|
+
(validationState !== "initial" || isBlacklisted) && /* @__PURE__ */ jsx(
|
|
4101
|
+
PathInfo,
|
|
4102
|
+
{
|
|
4103
|
+
validationState,
|
|
4104
|
+
replacement: path.replacement,
|
|
4105
|
+
isBlacklisted
|
|
4106
|
+
}
|
|
4107
|
+
)
|
|
4072
4108
|
] }),
|
|
4073
4109
|
/* @__PURE__ */ jsx(
|
|
4074
4110
|
OverrideCheckbox,
|
|
@@ -4076,6 +4112,8 @@ const Panel = ({ config }) => {
|
|
|
4076
4112
|
isOverride,
|
|
4077
4113
|
setIsOverride: (val) => {
|
|
4078
4114
|
hasUserInteracted.current = true;
|
|
4115
|
+
if (val && path.overridePath)
|
|
4116
|
+
dispatchPath({ type: "SET_URL_CHECK_FLAG", payload: true });
|
|
4079
4117
|
setIsOverride(val);
|
|
4080
4118
|
},
|
|
4081
4119
|
disabledCondition: !canCreate && !canUpdate
|
|
@@ -4121,12 +4159,11 @@ const CMEditViewAside = ({ model }) => {
|
|
|
4121
4159
|
}, [config, model]);
|
|
4122
4160
|
const {
|
|
4123
4161
|
allowedActions: { canAside }
|
|
4124
|
-
} = useRBAC(
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
if (!canAside || !isAllowedContentType || !isActiveContentType || !contentTypeConfig) return null;
|
|
4162
|
+
} = useRBAC(pluginPermissions["cm.aside"]);
|
|
4163
|
+
if (!canAside || !isAllowedContentType || !isActiveContentType || !contentTypeConfig || !contentTypeConfig.routeSourceField)
|
|
4164
|
+
return null;
|
|
4128
4165
|
if (!config) {
|
|
4129
|
-
|
|
4166
|
+
console.error("CMEditViewAside: Plugin is not configured.");
|
|
4130
4167
|
return null;
|
|
4131
4168
|
}
|
|
4132
4169
|
if (isLoading)
|
|
@@ -4151,7 +4188,7 @@ const index = {
|
|
|
4151
4188
|
id: `${PLUGIN_ID}.link.paths`,
|
|
4152
4189
|
defaultMessage: "Paths"
|
|
4153
4190
|
},
|
|
4154
|
-
Component: () => import("./index-
|
|
4191
|
+
Component: () => import("./index-PD3gcnXA.mjs"),
|
|
4155
4192
|
permissions: [pluginPermissions["page.routes"][0]]
|
|
4156
4193
|
});
|
|
4157
4194
|
app.addMenuLink({
|
|
@@ -4161,7 +4198,7 @@ const index = {
|
|
|
4161
4198
|
id: `${PLUGIN_ID}.link.navigation`,
|
|
4162
4199
|
defaultMessage: "Navigation"
|
|
4163
4200
|
},
|
|
4164
|
-
Component: () => import("./index-
|
|
4201
|
+
Component: () => import("./index-BY6JLZrD.mjs"),
|
|
4165
4202
|
permissions: [pluginPermissions["page.navigation"][0]]
|
|
4166
4203
|
});
|
|
4167
4204
|
app.addSettingsLink(
|
|
@@ -4179,7 +4216,7 @@ const index = {
|
|
|
4179
4216
|
},
|
|
4180
4217
|
id: `${PLUGIN_ID}-general`,
|
|
4181
4218
|
to: `${PLUGIN_ID}/general`,
|
|
4182
|
-
Component: () => import("./index-
|
|
4219
|
+
Component: () => import("./index-Bym1mXg1.mjs"),
|
|
4183
4220
|
permissions: [pluginPermissions["settings.general"][0]]
|
|
4184
4221
|
}
|
|
4185
4222
|
);
|
|
@@ -4190,7 +4227,7 @@ const index = {
|
|
|
4190
4227
|
},
|
|
4191
4228
|
id: `${PLUGIN_ID}-navigation`,
|
|
4192
4229
|
to: `${PLUGIN_ID}/navigation`,
|
|
4193
|
-
Component: () => import("./index-
|
|
4230
|
+
Component: () => import("./index-CNCyng5O.mjs"),
|
|
4194
4231
|
permissions: [pluginPermissions["settings.navigation"][0]]
|
|
4195
4232
|
});
|
|
4196
4233
|
app.customFields.register({
|
|
@@ -4206,7 +4243,7 @@ const index = {
|
|
|
4206
4243
|
defaultMessage: "Select a route"
|
|
4207
4244
|
},
|
|
4208
4245
|
components: {
|
|
4209
|
-
Input: async () => import("./RoutePicker-
|
|
4246
|
+
Input: async () => import("./RoutePicker-IRZiHKFi.mjs").then((module) => ({
|
|
4210
4247
|
default: module.default
|
|
4211
4248
|
}))
|
|
4212
4249
|
},
|
|
@@ -4249,7 +4286,7 @@ const index = {
|
|
|
4249
4286
|
return Promise.all(
|
|
4250
4287
|
locales.map(async (locale) => {
|
|
4251
4288
|
try {
|
|
4252
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-
|
|
4289
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-BFjenpyN.mjs"), "./translations/en.json": () => import("./en-CGCh9ld_.mjs") }), `./translations/${locale}.json`, 3);
|
|
4253
4290
|
return { data, locale };
|
|
4254
4291
|
} catch {
|
|
4255
4292
|
return { data: {}, locale };
|
|
@@ -4269,7 +4306,8 @@ export {
|
|
|
4269
4306
|
PLUGIN_NAME as f,
|
|
4270
4307
|
getTranslation as g,
|
|
4271
4308
|
PLUGIN_VERSION as h,
|
|
4272
|
-
|
|
4309
|
+
isAbortError as i,
|
|
4310
|
+
index as j,
|
|
4273
4311
|
pluginPermissions as p,
|
|
4274
4312
|
useApi as u
|
|
4275
4313
|
};
|
|
@@ -4,11 +4,12 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const designSystem = require("@strapi/design-system");
|
|
6
6
|
const admin = require("@strapi/strapi/admin");
|
|
7
|
-
const index = require("./index-
|
|
7
|
+
const index = require("./index-CsKnBzp6.js");
|
|
8
|
+
const FullLoader = require("./FullLoader-C4hXFaLP.js");
|
|
8
9
|
const reactIntl = require("react-intl");
|
|
9
10
|
require("@strapi/icons/symbols");
|
|
10
|
-
|
|
11
|
-
const SettingTitle = require("./SettingTitle-
|
|
11
|
+
require("@strapi/icons");
|
|
12
|
+
const SettingTitle = require("./SettingTitle-Ib_0AvoZ.js");
|
|
12
13
|
function reducer(newConfig, action) {
|
|
13
14
|
switch (action.type) {
|
|
14
15
|
case "SET_MAX_DEPTH":
|
|
@@ -28,6 +29,7 @@ const Settings = () => {
|
|
|
28
29
|
const { config: fetchedConfig, setConfig, loading, fetchError } = index.usePluginConfig();
|
|
29
30
|
const [config, dispatch] = React.useReducer(reducer, fetchedConfig);
|
|
30
31
|
const { toggleNotification } = admin.useNotification();
|
|
32
|
+
const getErrorMessage = FullLoader.useErrorMessage();
|
|
31
33
|
const { formatMessage } = reactIntl.useIntl();
|
|
32
34
|
const [isSaving, setIsSaving] = React.useState(false);
|
|
33
35
|
const initialConfig = React.useRef(fetchedConfig);
|
|
@@ -39,13 +41,16 @@ const Settings = () => {
|
|
|
39
41
|
if (fetchError) {
|
|
40
42
|
toggleNotification({
|
|
41
43
|
type: "danger",
|
|
42
|
-
message:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
message: getErrorMessage(
|
|
45
|
+
fetchError,
|
|
46
|
+
formatMessage({
|
|
47
|
+
id: index.getTranslation("notification.error"),
|
|
48
|
+
defaultMessage: "An error occurred"
|
|
49
|
+
})
|
|
50
|
+
)
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
|
-
}, [fetchError, toggleNotification, formatMessage]);
|
|
53
|
+
}, [fetchError, toggleNotification, getErrorMessage, formatMessage]);
|
|
49
54
|
async function save() {
|
|
50
55
|
if (!config) return;
|
|
51
56
|
setIsSaving(true);
|
|
@@ -64,12 +69,15 @@ const Settings = () => {
|
|
|
64
69
|
setIsSaving(false);
|
|
65
70
|
toggleNotification({
|
|
66
71
|
type: "danger",
|
|
67
|
-
message:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
message: getErrorMessage(
|
|
73
|
+
err,
|
|
74
|
+
formatMessage({
|
|
75
|
+
id: index.getTranslation("notification.error"),
|
|
76
|
+
defaultMessage: "An error occurred"
|
|
77
|
+
})
|
|
78
|
+
)
|
|
71
79
|
});
|
|
72
|
-
|
|
80
|
+
console.error(err);
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
if (loading) {
|