@mattisvensson/strapi-plugin-webatlas 0.11.9 → 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-p1rh5rcZ.mjs → RoutePicker-h2yWGB6S.mjs} +1 -1
- package/dist/admin/{RoutePicker-D9RNp4zS.js → RoutePicker-mEHRtXQ9.js} +1 -1
- package/dist/admin/{SettingTitle-CwB5CsY0.js → SettingTitle-CBcBCh1h.js} +1 -1
- package/dist/admin/{SettingTitle-BMHyfLrM.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-CFf370lR.js → index-BYytQZfK.js} +169 -131
- package/dist/admin/{index-LNTPJt5H.js → index-BZBUZWp1.js} +13 -8
- package/dist/admin/{index-zr90q-6H.js → index-Bn_SWdWd.js} +178 -85
- package/dist/admin/{index-zskvsDgF.js → index-CaFjiS4j.js} +21 -13
- package/dist/admin/{index-G7qx6Oy7.mjs → index-Ckaev6xU.mjs} +170 -132
- package/dist/admin/{index-BE6CLx3P.mjs → index-Do9dOMP-.mjs} +180 -87
- package/dist/admin/{index-DpS40t3Q.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-IxsV1TAn.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 +483 -494
- package/dist/server/index.mjs +496 -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
|
@@ -70,11 +70,11 @@ function transformToUrl(input, replaceSlash = true) {
|
|
|
70
70
|
input = input.replace(/-+/g, "-");
|
|
71
71
|
return input;
|
|
72
72
|
}
|
|
73
|
-
const version = "0.
|
|
74
|
-
const strapi
|
|
73
|
+
const version = "0.12.0";
|
|
74
|
+
const strapi = { "name": "webatlas", "displayName": "Webatlas" };
|
|
75
75
|
const pluginPkg = {
|
|
76
76
|
version,
|
|
77
|
-
strapi
|
|
77
|
+
strapi
|
|
78
78
|
};
|
|
79
79
|
const PLUGIN_ID = pluginPkg.strapi.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, "") || "webatlas";
|
|
80
80
|
const PLUGIN_NAME = pluginPkg.strapi.displayName;
|
|
@@ -91,62 +91,37 @@ const NavigationIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.List, {});
|
|
|
91
91
|
function useApi() {
|
|
92
92
|
const { get, put, del, post } = admin.useFetchClient();
|
|
93
93
|
const fetchAllContentTypes = async () => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return data.data;
|
|
97
|
-
} catch (error) {
|
|
98
|
-
strapi.log.error("Cannot fetch all content types:", error);
|
|
99
|
-
return [];
|
|
100
|
-
}
|
|
94
|
+
const { data } = await get("/content-manager/content-types");
|
|
95
|
+
return data.data;
|
|
101
96
|
};
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (configuredTypes.length === 0) {
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
109
|
-
const allContentTypes = await fetchAllContentTypes();
|
|
110
|
-
const configuredUIDs = new Set(configuredTypes.map((ct) => ct.uid));
|
|
111
|
-
return allContentTypes.filter((ct) => configuredUIDs.has(ct.uid));
|
|
112
|
-
} catch (err) {
|
|
113
|
-
strapi.log.error("Error fetching configured content types:", err);
|
|
97
|
+
const fetchAllEntities = async () => {
|
|
98
|
+
const { data } = await get(`/${PLUGIN_ID}/config`);
|
|
99
|
+
const contentTypes = data?.selectedContentTypes || [];
|
|
100
|
+
if (!contentTypes || contentTypes.length === 0) {
|
|
114
101
|
return [];
|
|
115
102
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
let entities = [];
|
|
125
|
-
const entityResults = await Promise.allSettled(
|
|
126
|
-
contentTypes.map(async (contentType) => {
|
|
127
|
-
try {
|
|
128
|
-
const { data: data2 } = await get(
|
|
129
|
-
`/content-manager/collection-types/${contentType.uid}?pageSize=9999`
|
|
130
|
-
);
|
|
131
|
-
if (!data2 || !data2.results) {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
entities: data2.results,
|
|
136
|
-
contentType
|
|
137
|
-
};
|
|
138
|
-
} catch (err) {
|
|
139
|
-
strapi.log.error(`Cannot access entities for ${contentType.uid}:`, err);
|
|
103
|
+
let entities = [];
|
|
104
|
+
const entityResults = await Promise.allSettled(
|
|
105
|
+
contentTypes.map(async (contentType) => {
|
|
106
|
+
try {
|
|
107
|
+
const { data: data2 } = await get(
|
|
108
|
+
`/content-manager/collection-types/${contentType.uid}?pageSize=9999`
|
|
109
|
+
);
|
|
110
|
+
if (!data2 || !data2.results) {
|
|
140
111
|
return null;
|
|
141
112
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
113
|
+
return {
|
|
114
|
+
entities: data2.results,
|
|
115
|
+
contentType
|
|
116
|
+
};
|
|
117
|
+
} catch (err) {
|
|
118
|
+
console.error(`Cannot access entities for ${contentType.uid}:`, err);
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
entities = entityResults.map((result) => result.status === "fulfilled" ? result.value : null).filter(Boolean);
|
|
124
|
+
return entities;
|
|
150
125
|
};
|
|
151
126
|
const getRelatedRoute = async (relatedDocumentId) => {
|
|
152
127
|
const { data } = await get(`/${PLUGIN_ID}/route/related?documentId=${relatedDocumentId}`);
|
|
@@ -203,7 +178,6 @@ function useApi() {
|
|
|
203
178
|
};
|
|
204
179
|
return {
|
|
205
180
|
fetchAllContentTypes,
|
|
206
|
-
fetchConfiguredContentTypes,
|
|
207
181
|
fetchAllEntities,
|
|
208
182
|
getRelatedRoute,
|
|
209
183
|
getRoute,
|
|
@@ -216,6 +190,42 @@ function useApi() {
|
|
|
216
190
|
updateNavigationItemStructure
|
|
217
191
|
};
|
|
218
192
|
}
|
|
193
|
+
function debounce(func, wait) {
|
|
194
|
+
let timeout;
|
|
195
|
+
return function executedFunction(...args) {
|
|
196
|
+
const later = () => {
|
|
197
|
+
clearTimeout(timeout);
|
|
198
|
+
func(...args);
|
|
199
|
+
};
|
|
200
|
+
clearTimeout(timeout);
|
|
201
|
+
timeout = setTimeout(later, wait);
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
async function duplicateCheck({
|
|
205
|
+
fetchFunction,
|
|
206
|
+
path,
|
|
207
|
+
routeDocumentId,
|
|
208
|
+
withoutTransform = false
|
|
209
|
+
}) {
|
|
210
|
+
if (!path) throw new Error("URL is required");
|
|
211
|
+
try {
|
|
212
|
+
const pathToCheck = withoutTransform ? path : transformToUrl(path);
|
|
213
|
+
const { data } = await fetchFunction(
|
|
214
|
+
`/${PLUGIN_ID}/checkUniquePath?path=${pathToCheck}${routeDocumentId ? `&targetRouteDocumentId=${routeDocumentId}` : ""}`
|
|
215
|
+
);
|
|
216
|
+
if (data.blacklisted) return { uniquePath: null, blacklisted: true };
|
|
217
|
+
if (!data.uniquePath) {
|
|
218
|
+
throw new Error("Network response was not ok");
|
|
219
|
+
}
|
|
220
|
+
return { uniquePath: data.uniquePath, blacklisted: false };
|
|
221
|
+
} catch (err) {
|
|
222
|
+
throw new Error("Failed to check URL uniqueness: " + err.message);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
226
|
+
function isAbortError(error) {
|
|
227
|
+
return error instanceof Error && error.name === "AbortError";
|
|
228
|
+
}
|
|
219
229
|
const useAllContentTypes = () => {
|
|
220
230
|
const { fetchAllContentTypes } = useApi();
|
|
221
231
|
const [contentTypes, setContentTypes] = React.useState([]);
|
|
@@ -228,6 +238,7 @@ const useAllContentTypes = () => {
|
|
|
228
238
|
setContentTypes(result);
|
|
229
239
|
setLoading(false);
|
|
230
240
|
} catch (err) {
|
|
241
|
+
if (isAbortError(err)) return;
|
|
231
242
|
setError(err);
|
|
232
243
|
setLoading(false);
|
|
233
244
|
}
|
|
@@ -251,6 +262,7 @@ function usePluginConfig() {
|
|
|
251
262
|
} = await get("/content-manager/content-types");
|
|
252
263
|
let { data: config2 } = await get(`/${PLUGIN_ID}/config`);
|
|
253
264
|
if (!config2 || !config2.selectedContentTypes) {
|
|
265
|
+
console.error(`Couldn't fetch plugin config`);
|
|
254
266
|
throw new Error(`Couldn't fetch plugin config`);
|
|
255
267
|
}
|
|
256
268
|
const allowedContentTypes = contentTypesArray.filter(
|
|
@@ -266,7 +278,8 @@ function usePluginConfig() {
|
|
|
266
278
|
};
|
|
267
279
|
setConfigData(displayConfig);
|
|
268
280
|
} catch (error) {
|
|
269
|
-
|
|
281
|
+
if (isAbortError(error)) return;
|
|
282
|
+
setFetchError(error);
|
|
270
283
|
} finally {
|
|
271
284
|
setLoading(false);
|
|
272
285
|
}
|
|
@@ -282,43 +295,21 @@ function usePluginConfig() {
|
|
|
282
295
|
}
|
|
283
296
|
return { config, loading, fetchError, setConfig };
|
|
284
297
|
}
|
|
285
|
-
function
|
|
286
|
-
let timeout;
|
|
287
|
-
return function executedFunction(...args) {
|
|
288
|
-
const later = () => {
|
|
289
|
-
clearTimeout(timeout);
|
|
290
|
-
func(...args);
|
|
291
|
-
};
|
|
292
|
-
clearTimeout(timeout);
|
|
293
|
-
timeout = setTimeout(later, wait);
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
async function duplicateCheck({
|
|
297
|
-
fetchFunction,
|
|
298
|
-
path,
|
|
299
|
-
routeDocumentId,
|
|
300
|
-
withoutTransform = false
|
|
301
|
-
}) {
|
|
302
|
-
if (!path) throw new Error("URL is required");
|
|
303
|
-
try {
|
|
304
|
-
const pathToCheck = withoutTransform ? path : transformToUrl(path);
|
|
305
|
-
const { data } = await fetchFunction(
|
|
306
|
-
`/${PLUGIN_ID}/checkUniquePath?path=${pathToCheck}${routeDocumentId ? `&targetRouteDocumentId=${routeDocumentId}` : ""}`
|
|
307
|
-
);
|
|
308
|
-
if (!data.uniquePath) {
|
|
309
|
-
throw new Error("Network response was not ok");
|
|
310
|
-
}
|
|
311
|
-
return data.uniquePath;
|
|
312
|
-
} catch (err) {
|
|
313
|
-
throw new Error("Failed to check URL uniqueness: " + err.message);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
317
|
-
function PathInfo({ validationState, replacement }) {
|
|
298
|
+
function PathInfo({ validationState, replacement, isBlacklisted }) {
|
|
318
299
|
const [color, setColor] = React.useState("neutral800");
|
|
319
300
|
const [text, setText] = React.useState(null);
|
|
320
301
|
const { formatMessage } = reactIntl.useIntl();
|
|
321
302
|
React.useEffect(() => {
|
|
303
|
+
if (isBlacklisted) {
|
|
304
|
+
setColor("danger500");
|
|
305
|
+
setText(
|
|
306
|
+
formatMessage({
|
|
307
|
+
id: getTranslation("components.pathInfo.blacklisted"),
|
|
308
|
+
defaultMessage: "This path is blocked by the URL blacklist and cannot be saved."
|
|
309
|
+
})
|
|
310
|
+
);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
322
313
|
if (validationState === "initial") return;
|
|
323
314
|
if (validationState === "checking") {
|
|
324
315
|
setColor("neutral800");
|
|
@@ -340,7 +331,7 @@ function PathInfo({ validationState, replacement }) {
|
|
|
340
331
|
})
|
|
341
332
|
);
|
|
342
333
|
}
|
|
343
|
-
}, [validationState, replacement, formatMessage]);
|
|
334
|
+
}, [validationState, replacement, isBlacklisted, formatMessage]);
|
|
344
335
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: color, children: text }) });
|
|
345
336
|
}
|
|
346
337
|
function OverrideCheckbox({ isOverride, setIsOverride, disabledCondition }) {
|
|
@@ -3688,10 +3679,10 @@ function PathInput({ path, dispatchPath, isOverride, config, hasUserInteracted }
|
|
|
3688
3679
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3689
3680
|
designSystem.Field.Root,
|
|
3690
3681
|
{
|
|
3691
|
-
hint: config.
|
|
3682
|
+
hint: config.routeSourceField ? formatMessage({
|
|
3692
3683
|
id: getTranslation("components.CMEditViewAside.path.input.start"),
|
|
3693
3684
|
defaultMessage: "Edit the"
|
|
3694
|
-
}) + ' "' + config.
|
|
3685
|
+
}) + ' "' + config.routeSourceField + '" ' + formatMessage({
|
|
3695
3686
|
id: getTranslation("components.CMEditViewAside.path.input.end"),
|
|
3696
3687
|
defaultMessage: "field to generate a path"
|
|
3697
3688
|
}) : formatMessage({
|
|
@@ -3747,25 +3738,40 @@ function RouteStructure({
|
|
|
3747
3738
|
selectedParent,
|
|
3748
3739
|
setSelectedParent,
|
|
3749
3740
|
canonicalPath,
|
|
3750
|
-
prohibitedRouteIds
|
|
3741
|
+
prohibitedRouteIds,
|
|
3742
|
+
defaultParentRoute,
|
|
3743
|
+
isCreatingEntry
|
|
3751
3744
|
}) {
|
|
3752
3745
|
const { formatMessage } = reactIntl.useIntl();
|
|
3746
|
+
const handleSelectParent = (value) => {
|
|
3747
|
+
const parentRoute = routes.find((route) => route.documentId === value) || null;
|
|
3748
|
+
setSelectedParent(parentRoute);
|
|
3749
|
+
};
|
|
3753
3750
|
const filteredRoutes = React.useMemo(() => {
|
|
3754
3751
|
return [...routes].sort((a, b) => a.title.localeCompare(b.title)).filter(
|
|
3755
3752
|
(route) => !prohibitedRouteIds?.includes(route.documentId) || route.documentId === selectedParent?.documentId
|
|
3756
3753
|
);
|
|
3757
3754
|
}, [routes, prohibitedRouteIds, selectedParent]);
|
|
3758
|
-
const
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3755
|
+
const defaultParentRouteValue = React.useMemo(() => {
|
|
3756
|
+
if (defaultParentRoute && isCreatingEntry) {
|
|
3757
|
+
const defaultParent = routes.find((route) => route.relatedDocumentId === defaultParentRoute);
|
|
3758
|
+
return defaultParent || null;
|
|
3759
|
+
}
|
|
3760
|
+
return null;
|
|
3761
|
+
}, [defaultParentRoute, routes, isCreatingEntry]);
|
|
3762
|
+
React.useEffect(() => {
|
|
3763
|
+
if (defaultParentRouteValue && isCreatingEntry) {
|
|
3764
|
+
handleSelectParent(defaultParentRouteValue?.documentId || "");
|
|
3765
|
+
}
|
|
3766
|
+
}, [defaultParentRouteValue, isCreatingEntry]);
|
|
3767
|
+
const selectValue = selectedParent?.documentId || defaultParentRouteValue?.documentId || "";
|
|
3762
3768
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingBottom: 2, children: [
|
|
3763
3769
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
|
|
3764
3770
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
3765
3771
|
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.label"),
|
|
3766
3772
|
defaultMessage: "Place under"
|
|
3767
3773
|
}) }),
|
|
3768
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { value:
|
|
3774
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { value: selectValue, onValueChange: handleSelectParent, children: [
|
|
3769
3775
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "", children: formatMessage({
|
|
3770
3776
|
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.rootPath"),
|
|
3771
3777
|
defaultMessage: "None (root path)"
|
|
@@ -3866,6 +3872,7 @@ const Panel = ({ config }) => {
|
|
|
3866
3872
|
const [selectedParent, setSelectedParent] = React.useState(null);
|
|
3867
3873
|
const [isOverride, setIsOverride] = React.useState(false);
|
|
3868
3874
|
const [validationState, setValidationState] = React.useState("initial");
|
|
3875
|
+
const [isBlacklisted, setIsBlacklisted] = React.useState(false);
|
|
3869
3876
|
const [initialLoadComplete, setInitialLoadComplete] = React.useState(false);
|
|
3870
3877
|
const [path, dispatchPath] = React.useReducer(reducer, {
|
|
3871
3878
|
needsUrlCheck: false,
|
|
@@ -3879,10 +3886,11 @@ const Panel = ({ config }) => {
|
|
|
3879
3886
|
});
|
|
3880
3887
|
const hasUserChangedField = React.useRef(false);
|
|
3881
3888
|
const hasUserInteracted = React.useRef(false);
|
|
3882
|
-
const
|
|
3889
|
+
const initialRouteData = React.useRef(null);
|
|
3883
3890
|
const prevSourceValueRef = React.useRef(null);
|
|
3884
|
-
const
|
|
3885
|
-
const
|
|
3891
|
+
const routeSourceField = config?.routeSourceField;
|
|
3892
|
+
const sourceFieldValue = routeSourceField ? values[routeSourceField] || "" : "";
|
|
3893
|
+
const initialSourceFieldValue = routeSourceField ? initialValues[routeSourceField] || "" : "";
|
|
3886
3894
|
const latestCheckPathRef = React.useRef(checkPath);
|
|
3887
3895
|
latestCheckPathRef.current = checkPath;
|
|
3888
3896
|
const debouncedCheckPath = React.useRef(
|
|
@@ -3909,6 +3917,10 @@ const Panel = ({ config }) => {
|
|
|
3909
3917
|
parentDocumentId: selectedParent?.documentId || null,
|
|
3910
3918
|
slug: isOverride ? overridePath : slug
|
|
3911
3919
|
};
|
|
3920
|
+
if (initialRouteData.current?.isOverride === isOverride && data.path === initialRouteData.current?.path && data.parentDocumentId === (initialRouteData.current?.parent?.documentId ?? null)) {
|
|
3921
|
+
onChange("webatlas", void 0);
|
|
3922
|
+
return;
|
|
3923
|
+
}
|
|
3912
3924
|
if (hasUserChangedField.current || hasUserInteracted.current) {
|
|
3913
3925
|
onChange("webatlas", data);
|
|
3914
3926
|
}
|
|
@@ -3952,15 +3964,25 @@ const Panel = ({ config }) => {
|
|
|
3952
3964
|
]);
|
|
3953
3965
|
React.useEffect(() => {
|
|
3954
3966
|
if (!initialLoadComplete) return;
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3967
|
+
const pathToCheck = isOverride ? path.overridePath : path.value;
|
|
3968
|
+
const initialPathToCompare = isOverride ? initialRouteData.current?.path : initialRouteData.current?.uidPath;
|
|
3969
|
+
if (path.needsUrlCheck && pathToCheck) {
|
|
3970
|
+
if (path.uidPath === pathToCheck || initialPathToCompare === pathToCheck) return;
|
|
3971
|
+
debouncedCheckPath(pathToCheck, route?.documentId || null);
|
|
3958
3972
|
dispatchPath({ type: "SET_URL_CHECK_FLAG" });
|
|
3959
3973
|
} else {
|
|
3960
3974
|
setValidationState("idle");
|
|
3961
3975
|
dispatchPath({ type: "SET_REPLACEMENT", payload: null });
|
|
3962
3976
|
}
|
|
3963
|
-
}, [
|
|
3977
|
+
}, [
|
|
3978
|
+
path.needsUrlCheck,
|
|
3979
|
+
path.value,
|
|
3980
|
+
path.uidPath,
|
|
3981
|
+
path.overridePath,
|
|
3982
|
+
route,
|
|
3983
|
+
initialLoadComplete,
|
|
3984
|
+
isOverride
|
|
3985
|
+
]);
|
|
3964
3986
|
React.useEffect(() => {
|
|
3965
3987
|
async function fetchRelatedRute() {
|
|
3966
3988
|
if (!initialValues.documentId) {
|
|
@@ -3970,7 +3992,7 @@ const Panel = ({ config }) => {
|
|
|
3970
3992
|
try {
|
|
3971
3993
|
const route2 = await getRelatedRoute(initialValues.documentId);
|
|
3972
3994
|
if (!route2) return;
|
|
3973
|
-
|
|
3995
|
+
initialRouteData.current = route2;
|
|
3974
3996
|
setRoute(route2);
|
|
3975
3997
|
setIsOverride(route2.isOverride || false);
|
|
3976
3998
|
dispatchPath({ type: "SET_OVERRIDEPATH", payload: route2.path || "" });
|
|
@@ -3984,13 +4006,12 @@ const Panel = ({ config }) => {
|
|
|
3984
4006
|
type: "SET_CANONICALPATH",
|
|
3985
4007
|
payload: route2.canonicalPath || ""
|
|
3986
4008
|
});
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
prevSourceValueRef.current = values[key];
|
|
4009
|
+
if (routeSourceField) {
|
|
4010
|
+
prevSourceValueRef.current = values[routeSourceField];
|
|
3990
4011
|
}
|
|
3991
4012
|
} catch (err) {
|
|
3992
4013
|
setRoute(null);
|
|
3993
|
-
|
|
4014
|
+
console.error(err);
|
|
3994
4015
|
} finally {
|
|
3995
4016
|
setInitialLoadComplete(true);
|
|
3996
4017
|
}
|
|
@@ -4020,15 +4041,18 @@ const Panel = ({ config }) => {
|
|
|
4020
4041
|
async function checkCanonicalPath(path2, routeDocumentId) {
|
|
4021
4042
|
if (!path2) return;
|
|
4022
4043
|
try {
|
|
4023
|
-
const
|
|
4044
|
+
const { uniquePath, blacklisted } = await duplicateCheck({
|
|
4024
4045
|
fetchFunction: get,
|
|
4025
4046
|
path: path2,
|
|
4026
4047
|
routeDocumentId,
|
|
4027
4048
|
withoutTransform: true
|
|
4028
4049
|
});
|
|
4029
|
-
|
|
4050
|
+
setIsBlacklisted(blacklisted);
|
|
4051
|
+
if (blacklisted) return;
|
|
4052
|
+
if (!uniquePath) return;
|
|
4053
|
+
dispatchPath({ type: "SET_CANONICALPATH", payload: uniquePath });
|
|
4030
4054
|
} catch (err) {
|
|
4031
|
-
|
|
4055
|
+
console.error(err);
|
|
4032
4056
|
}
|
|
4033
4057
|
}
|
|
4034
4058
|
async function checkPath(path2, routeDocumentId) {
|
|
@@ -4036,17 +4060,20 @@ const Panel = ({ config }) => {
|
|
|
4036
4060
|
setValidationState("checking");
|
|
4037
4061
|
dispatchPath({ type: "SET_REPLACEMENT", payload: "" });
|
|
4038
4062
|
try {
|
|
4039
|
-
const
|
|
4063
|
+
const { uniquePath, blacklisted } = await duplicateCheck({
|
|
4040
4064
|
fetchFunction: get,
|
|
4041
4065
|
path: path2,
|
|
4042
4066
|
routeDocumentId,
|
|
4043
4067
|
withoutTransform: true
|
|
4044
4068
|
});
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4069
|
+
setIsBlacklisted(blacklisted);
|
|
4070
|
+
if (blacklisted) return;
|
|
4071
|
+
if (!uniquePath || uniquePath === path2) return;
|
|
4072
|
+
dispatchPath({ type: "NO_URL_CHECK", payload: uniquePath });
|
|
4073
|
+
if (isOverride) dispatchPath({ type: "SET_OVERRIDEPATH", payload: uniquePath });
|
|
4074
|
+
dispatchPath({ type: "SET_REPLACEMENT", payload: uniquePath });
|
|
4048
4075
|
} catch (err) {
|
|
4049
|
-
|
|
4076
|
+
console.error(err);
|
|
4050
4077
|
} finally {
|
|
4051
4078
|
setValidationState("done");
|
|
4052
4079
|
}
|
|
@@ -4071,7 +4098,9 @@ const Panel = ({ config }) => {
|
|
|
4071
4098
|
hasUserInteracted.current = true;
|
|
4072
4099
|
setSelectedParent(val);
|
|
4073
4100
|
},
|
|
4074
|
-
prohibitedRouteIds
|
|
4101
|
+
prohibitedRouteIds,
|
|
4102
|
+
defaultParentRoute: config.defaultParentRoute || "",
|
|
4103
|
+
isCreatingEntry: !initialValues.documentId
|
|
4075
4104
|
}
|
|
4076
4105
|
),
|
|
4077
4106
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 }),
|
|
@@ -4086,7 +4115,14 @@ const Panel = ({ config }) => {
|
|
|
4086
4115
|
hasUserInteracted
|
|
4087
4116
|
}
|
|
4088
4117
|
),
|
|
4089
|
-
validationState !== "initial" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4118
|
+
(validationState !== "initial" || isBlacklisted) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4119
|
+
PathInfo,
|
|
4120
|
+
{
|
|
4121
|
+
validationState,
|
|
4122
|
+
replacement: path.replacement,
|
|
4123
|
+
isBlacklisted
|
|
4124
|
+
}
|
|
4125
|
+
)
|
|
4090
4126
|
] }),
|
|
4091
4127
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4092
4128
|
OverrideCheckbox,
|
|
@@ -4094,6 +4130,8 @@ const Panel = ({ config }) => {
|
|
|
4094
4130
|
isOverride,
|
|
4095
4131
|
setIsOverride: (val) => {
|
|
4096
4132
|
hasUserInteracted.current = true;
|
|
4133
|
+
if (val && path.overridePath)
|
|
4134
|
+
dispatchPath({ type: "SET_URL_CHECK_FLAG", payload: true });
|
|
4097
4135
|
setIsOverride(val);
|
|
4098
4136
|
},
|
|
4099
4137
|
disabledCondition: !canCreate && !canUpdate
|
|
@@ -4139,12 +4177,11 @@ const CMEditViewAside = ({ model }) => {
|
|
|
4139
4177
|
}, [config, model]);
|
|
4140
4178
|
const {
|
|
4141
4179
|
allowedActions: { canAside }
|
|
4142
|
-
} = admin.useRBAC(
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
if (!canAside || !isAllowedContentType || !isActiveContentType || !contentTypeConfig) return null;
|
|
4180
|
+
} = admin.useRBAC(pluginPermissions["cm.aside"]);
|
|
4181
|
+
if (!canAside || !isAllowedContentType || !isActiveContentType || !contentTypeConfig || !contentTypeConfig.routeSourceField)
|
|
4182
|
+
return null;
|
|
4146
4183
|
if (!config) {
|
|
4147
|
-
|
|
4184
|
+
console.error("CMEditViewAside: Plugin is not configured.");
|
|
4148
4185
|
return null;
|
|
4149
4186
|
}
|
|
4150
4187
|
if (isLoading)
|
|
@@ -4169,7 +4206,7 @@ const index = {
|
|
|
4169
4206
|
id: `${PLUGIN_ID}.link.paths`,
|
|
4170
4207
|
defaultMessage: "Paths"
|
|
4171
4208
|
},
|
|
4172
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4209
|
+
Component: () => Promise.resolve().then(() => require("./index-BZBUZWp1.js")),
|
|
4173
4210
|
permissions: [pluginPermissions["page.routes"][0]]
|
|
4174
4211
|
});
|
|
4175
4212
|
app.addMenuLink({
|
|
@@ -4179,7 +4216,7 @@ const index = {
|
|
|
4179
4216
|
id: `${PLUGIN_ID}.link.navigation`,
|
|
4180
4217
|
defaultMessage: "Navigation"
|
|
4181
4218
|
},
|
|
4182
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4219
|
+
Component: () => Promise.resolve().then(() => require("./index-Bn_SWdWd.js")),
|
|
4183
4220
|
permissions: [pluginPermissions["page.navigation"][0]]
|
|
4184
4221
|
});
|
|
4185
4222
|
app.addSettingsLink(
|
|
@@ -4197,7 +4234,7 @@ const index = {
|
|
|
4197
4234
|
},
|
|
4198
4235
|
id: `${PLUGIN_ID}-general`,
|
|
4199
4236
|
to: `${PLUGIN_ID}/general`,
|
|
4200
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4237
|
+
Component: () => Promise.resolve().then(() => require("./index-GZ_b2eve.js")),
|
|
4201
4238
|
permissions: [pluginPermissions["settings.general"][0]]
|
|
4202
4239
|
}
|
|
4203
4240
|
);
|
|
@@ -4208,7 +4245,7 @@ const index = {
|
|
|
4208
4245
|
},
|
|
4209
4246
|
id: `${PLUGIN_ID}-navigation`,
|
|
4210
4247
|
to: `${PLUGIN_ID}/navigation`,
|
|
4211
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4248
|
+
Component: () => Promise.resolve().then(() => require("./index-CaFjiS4j.js")),
|
|
4212
4249
|
permissions: [pluginPermissions["settings.navigation"][0]]
|
|
4213
4250
|
});
|
|
4214
4251
|
app.customFields.register({
|
|
@@ -4224,7 +4261,7 @@ const index = {
|
|
|
4224
4261
|
defaultMessage: "Select a route"
|
|
4225
4262
|
},
|
|
4226
4263
|
components: {
|
|
4227
|
-
Input: async () => Promise.resolve().then(() => require("./RoutePicker-
|
|
4264
|
+
Input: async () => Promise.resolve().then(() => require("./RoutePicker-mEHRtXQ9.js")).then((module2) => ({
|
|
4228
4265
|
default: module2.default
|
|
4229
4266
|
}))
|
|
4230
4267
|
},
|
|
@@ -4267,7 +4304,7 @@ const index = {
|
|
|
4267
4304
|
return Promise.all(
|
|
4268
4305
|
locales.map(async (locale) => {
|
|
4269
4306
|
try {
|
|
4270
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-
|
|
4307
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-DhwCZE_m.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-C-rPCNd2.js")) }), `./translations/${locale}.json`, 3);
|
|
4271
4308
|
return { data, locale };
|
|
4272
4309
|
} catch {
|
|
4273
4310
|
return { data: {}, locale };
|
|
@@ -4285,6 +4322,7 @@ exports.debounce = debounce;
|
|
|
4285
4322
|
exports.duplicateCheck = duplicateCheck;
|
|
4286
4323
|
exports.getTranslation = getTranslation;
|
|
4287
4324
|
exports.index = index;
|
|
4325
|
+
exports.isAbortError = isAbortError;
|
|
4288
4326
|
exports.pluginPermissions = pluginPermissions;
|
|
4289
4327
|
exports.useAllContentTypes = useAllContentTypes;
|
|
4290
4328
|
exports.useApi = useApi;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const index = require("./index-
|
|
5
|
+
const index = require("./index-BYytQZfK.js");
|
|
6
|
+
const FullLoader = require("./FullLoader-C4hXFaLP.js");
|
|
6
7
|
const admin = require("@strapi/strapi/admin");
|
|
7
8
|
const designSystem = require("@strapi/design-system");
|
|
8
9
|
require("@strapi/icons/symbols");
|
|
9
|
-
const
|
|
10
|
+
const icons = require("@strapi/icons");
|
|
10
11
|
const reactIntl = require("react-intl");
|
|
11
12
|
const reactRouterDom = require("react-router-dom");
|
|
12
|
-
const icons = require("@strapi/icons");
|
|
13
13
|
function PageWrapper({ children }) {
|
|
14
14
|
const { formatMessage } = reactIntl.useIntl();
|
|
15
15
|
return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
|
|
@@ -178,6 +178,7 @@ const Paths = () => {
|
|
|
178
178
|
const { getAllRoutes } = index.useApi();
|
|
179
179
|
const { formatMessage } = reactIntl.useIntl();
|
|
180
180
|
const { toggleNotification } = admin.useNotification();
|
|
181
|
+
const getErrorMessage = FullLoader.useErrorMessage();
|
|
181
182
|
const [allRoutes, setAllRoutes] = React.useState([]);
|
|
182
183
|
const [routes, setRoutes] = React.useState([]);
|
|
183
184
|
const [loading, setLoading] = React.useState(true);
|
|
@@ -212,13 +213,17 @@ const Paths = () => {
|
|
|
212
213
|
setAllRoutes(data);
|
|
213
214
|
setRoutes(data);
|
|
214
215
|
} catch (err) {
|
|
215
|
-
|
|
216
|
+
if (index.isAbortError(err)) return;
|
|
217
|
+
console.error("Failed to fetch paths:", err);
|
|
216
218
|
toggleNotification({
|
|
217
219
|
type: "danger",
|
|
218
|
-
message:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
message: getErrorMessage(
|
|
221
|
+
err,
|
|
222
|
+
formatMessage({
|
|
223
|
+
id: index.getTranslation("notification.paths.fetchFailed"),
|
|
224
|
+
defaultMessage: "Failed to fetch paths"
|
|
225
|
+
})
|
|
226
|
+
)
|
|
222
227
|
});
|
|
223
228
|
} finally {
|
|
224
229
|
setLoading(false);
|