@mattisvensson/strapi-plugin-webatlas 0.9.5 → 0.10.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 +24 -36
- package/dist/_chunks/FullLoader-Cmsf8xS6.js +0 -1
- package/dist/_chunks/FullLoader-CrPED_dY.mjs +0 -1
- package/dist/_chunks/{SettingTitle-CiMKrd_1.mjs → SettingTitle-CdR3SVn_.mjs} +1 -2
- package/dist/_chunks/{SettingTitle-CAoYbTar.js → SettingTitle-RU1azFIM.js} +1 -1
- package/dist/_chunks/{de-C-uxto84.mjs → de-B5pRvs13.mjs} +13 -8
- package/dist/_chunks/{de-CGXL_3o_.js → de-CqU1FU8C.js} +13 -8
- package/dist/_chunks/{en-B1CHnIH7.mjs → en-BE-zzIv8.mjs} +13 -8
- package/dist/_chunks/{en-DWEd5BXK.js → en-C7I90FwV.js} +13 -8
- package/dist/_chunks/{index-Bqsd7oPS.mjs → index-B07UVUOa.mjs} +387 -230
- package/dist/_chunks/{index-DJBnQbrp.mjs → index-BmyxSosC.mjs} +3 -3
- package/dist/_chunks/{index-BOZDZiAv.js → index-BucL4va6.js} +38 -82
- package/dist/_chunks/{index-DU58LJ2w.mjs → index-BvcX9hcc.mjs} +61 -25
- package/dist/_chunks/{index-ezabqLEP.js → index-BxpDM360.js} +386 -228
- package/dist/_chunks/{index-qrC_n9-7.mjs → index-CIM-JzLK.mjs} +38 -82
- package/dist/_chunks/{index-qrrfKpw1.mjs → index-CNKWb8pn.mjs} +615 -321
- package/dist/_chunks/{index-m2ivL3ht.js → index-D-vJE_K8.js} +3 -3
- package/dist/_chunks/{index-BkB1x9Sn.js → index-IRSCe8PX.js} +610 -316
- package/dist/_chunks/{index-CC073vGB.js → index-d09V61nm.js} +61 -24
- package/dist/admin/index.js +1 -2
- package/dist/admin/index.mjs +1 -2
- package/dist/admin/src/components/CMEditViewAside/NewPathInfo.d.ts +2 -0
- package/dist/admin/src/components/CMEditViewAside/OverrideCheckbox.d.ts +7 -0
- package/dist/admin/src/components/CMEditViewAside/Panel.d.ts +5 -0
- package/dist/admin/src/components/CMEditViewAside/PathInput.d.ts +11 -0
- package/dist/admin/src/components/CMEditViewAside/RouteStructure.d.ts +3 -0
- package/dist/admin/src/components/CMEditViewAside/UidPathDisplay.d.ts +4 -0
- package/dist/admin/src/components/PathInfo.d.ts +2 -3
- package/dist/admin/src/components/modals/externalItem/index.d.ts +1 -1
- package/dist/admin/src/components/modals/internalItem/ItemDetails.d.ts +13 -0
- package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +1 -1
- package/dist/admin/src/components/modals/internalItem/internalItemEdit.d.ts +1 -1
- package/dist/admin/src/components/modals/useModalSharedLogic.d.ts +1 -1
- package/dist/admin/src/components/modals/wrapperItem/index.d.ts +1 -1
- package/dist/admin/src/hooks/useApi.d.ts +4 -3
- package/dist/admin/src/pages/Navigation/RouteItem.d.ts +1 -15
- package/dist/admin/src/pages/Navigation/RouteItemBadge.d.ts +4 -0
- package/dist/admin/src/pages/Navigation/RouteItemIcon.d.ts +5 -0
- package/dist/admin/src/pages/Navigation/RouteItemMenu.d.ts +10 -0
- package/dist/admin/src/pages/Navigation/RouteItemStatus.d.ts +5 -0
- package/dist/admin/src/pages/Navigation/SortableRouteItem.d.ts +1 -1
- package/dist/admin/src/types/index.d.ts +3 -0
- package/dist/admin/src/types/modal.d.ts +56 -0
- package/dist/admin/src/types/navigation.d.ts +18 -0
- package/dist/admin/src/types/panel.d.ts +41 -0
- package/dist/admin/src/types/route.d.ts +1 -1
- package/dist/admin/src/utils/buildBreadcrumbString.d.ts +16 -0
- package/dist/admin/src/utils/createTempNavItemObject.d.ts +6 -8
- package/dist/admin/src/utils/duplicateCheck.d.ts +10 -4
- package/dist/admin/src/utils/findParentNavItem.d.ts +13 -0
- package/dist/admin/src/utils/index.d.ts +3 -2
- package/dist/server/index.js +636 -209
- package/dist/server/index.mjs +636 -209
- package/dist/server/src/content-types/index.d.ts +18 -0
- package/dist/server/src/content-types/route/index.d.ts +18 -0
- package/dist/server/src/content-types/route/schema.d.ts +18 -0
- package/dist/server/src/controllers/admin.d.ts +3 -2
- package/dist/server/src/controllers/index.d.ts +3 -2
- package/dist/server/src/index.d.ts +24 -4
- package/dist/server/src/migrations/001-canonical-path.d.ts +7 -0
- package/dist/server/src/migrations/index.d.ts +3 -0
- package/dist/server/src/services/admin.d.ts +3 -2
- package/dist/server/src/services/index.d.ts +3 -2
- package/dist/server/src/utils/buildCanonicalPath.d.ts +1 -0
- package/dist/server/src/utils/buildNavigationPath.d.ts +5 -0
- package/dist/server/src/utils/cascadeCanonicalPathUpdates.d.ts +1 -0
- package/dist/server/src/utils/getNonInternalRouteIds.d.ts +1 -0
- package/dist/server/src/utils/getRouteAncestors.d.ts +1 -0
- package/dist/server/src/utils/getRouteDescendants.d.ts +1 -0
- package/dist/server/src/utils/index.d.ts +10 -2
- package/dist/server/src/utils/navigationItemStructure.d.ts +27 -0
- package/dist/server/src/utils/routeHandler.d.ts +4 -2
- package/dist/server/src/utils/validateRouteDependencies.d.ts +4 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/navigation.d.ts +13 -12
- package/dist/types/route.d.ts +7 -2
- package/dist/types/strapi.d.ts +1 -2
- package/dist/utils/index.d.ts +1 -2
- package/package.json +1 -1
- package/dist/_chunks/FullLoader-Cmsf8xS6.js.map +0 -1
- package/dist/_chunks/FullLoader-CrPED_dY.mjs.map +0 -1
- package/dist/_chunks/SettingTitle-ByAhjihc.js +0 -68
- package/dist/_chunks/SettingTitle-ByAhjihc.js.map +0 -1
- package/dist/_chunks/SettingTitle-CiMKrd_1.mjs.map +0 -1
- package/dist/_chunks/SettingTitle-ZM5Yf2b4.mjs +0 -68
- package/dist/_chunks/de-C-uxto84.mjs.map +0 -1
- package/dist/_chunks/de-CGXL_3o_.js.map +0 -1
- package/dist/_chunks/en-B1CHnIH7.mjs.map +0 -1
- package/dist/_chunks/en-DWEd5BXK.js.map +0 -1
- package/dist/_chunks/index-BqceJPRl.js +0 -235
- package/dist/_chunks/index-BqceJPRl.js.map +0 -1
- package/dist/_chunks/index-Bqsd7oPS.mjs.map +0 -1
- package/dist/_chunks/index-CK1wisw5.mjs +0 -129
- package/dist/_chunks/index-CK1wisw5.mjs.map +0 -1
- package/dist/_chunks/index-CQ2raqxe.js +0 -129
- package/dist/_chunks/index-CQ2raqxe.js.map +0 -1
- package/dist/_chunks/index-Ca9T36AU.mjs +0 -263
- package/dist/_chunks/index-Ca9T36AU.mjs.map +0 -1
- package/dist/_chunks/index-DDN4T6c7.mjs +0 -4188
- package/dist/_chunks/index-DH4Rd7aA.mjs +0 -8311
- package/dist/_chunks/index-DH4Rd7aA.mjs.map +0 -1
- package/dist/_chunks/index-DU58LJ2w.mjs.map +0 -1
- package/dist/_chunks/index-DnE_cDwy.js +0 -8311
- package/dist/_chunks/index-DnE_cDwy.js.map +0 -1
- package/dist/_chunks/index-DzpXVfQ_.js +0 -263
- package/dist/_chunks/index-DzpXVfQ_.js.map +0 -1
- package/dist/_chunks/index-R7qsEu2N.js +0 -4205
- package/dist/_chunks/index-R7qsEu2N.js.map +0 -1
- package/dist/_chunks/index-fbC3magu.mjs +0 -234
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/index.mjs.map +0 -1
- package/dist/admin/src/components/CMEditViewAside/Path.d.ts +0 -5
- package/dist/admin/src/utils/countChildren.d.ts +0 -2
- package/dist/server/index.js.map +0 -1
- package/dist/server/index.mjs.map +0 -1
- package/dist/types/modal.d.ts +0 -36
- package/dist/utils/getPath.d.ts +0 -1
|
@@ -4,8 +4,8 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const icons = require("@strapi/icons");
|
|
5
5
|
const admin = require("@strapi/strapi/admin");
|
|
6
6
|
const designSystem = require("@strapi/design-system");
|
|
7
|
-
const ReactDOM = require("react-dom");
|
|
8
7
|
const reactIntl = require("react-intl");
|
|
8
|
+
const ReactDOM = require("react-dom");
|
|
9
9
|
function _interopNamespace(e) {
|
|
10
10
|
if (e && e.__esModule) return e;
|
|
11
11
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -52,6 +52,7 @@ function transformToUrl(input) {
|
|
|
52
52
|
input = input.replace(/\/+/g, "/");
|
|
53
53
|
input = input.startsWith("/") ? input.slice(1) : input;
|
|
54
54
|
input = input.endsWith("/") ? input.slice(0, -1) : input;
|
|
55
|
+
input = input.replace(/\//g, "-");
|
|
55
56
|
for (const char in specialCharMap) {
|
|
56
57
|
const regex = new RegExp(char, "g");
|
|
57
58
|
input = input.replace(regex, specialCharMap[char]);
|
|
@@ -62,7 +63,7 @@ function transformToUrl(input) {
|
|
|
62
63
|
input = input.replace(/-+/g, "-");
|
|
63
64
|
return input;
|
|
64
65
|
}
|
|
65
|
-
const version = "0.9.
|
|
66
|
+
const version = "0.9.6";
|
|
66
67
|
const keywords = [];
|
|
67
68
|
const type = "commonjs";
|
|
68
69
|
const exports$1 = {
|
|
@@ -129,7 +130,7 @@ const peerDependencies = {
|
|
|
129
130
|
"styled-components": "^6.0.0"
|
|
130
131
|
};
|
|
131
132
|
const description = "A strapi plugin to manage URL routes and navigations.";
|
|
132
|
-
const strapi = {
|
|
133
|
+
const strapi$1 = {
|
|
133
134
|
name: "webatlas",
|
|
134
135
|
displayName: "Webatlas",
|
|
135
136
|
description: "A strapi plugin to manage URL routes and navigations.",
|
|
@@ -169,7 +170,7 @@ const pluginPkg = {
|
|
|
169
170
|
devDependencies,
|
|
170
171
|
peerDependencies,
|
|
171
172
|
description,
|
|
172
|
-
strapi,
|
|
173
|
+
strapi: strapi$1,
|
|
173
174
|
name,
|
|
174
175
|
license,
|
|
175
176
|
repository,
|
|
@@ -198,7 +199,7 @@ function useApi() {
|
|
|
198
199
|
const { data } = await get("/content-manager/content-types");
|
|
199
200
|
return data.data;
|
|
200
201
|
} catch (error) {
|
|
201
|
-
|
|
202
|
+
strapi.log.error("Cannot fetch all content types:", error);
|
|
202
203
|
return [];
|
|
203
204
|
}
|
|
204
205
|
};
|
|
@@ -213,7 +214,7 @@ function useApi() {
|
|
|
213
214
|
const configuredUIDs = new Set(configuredTypes.map((ct) => ct.uid));
|
|
214
215
|
return allContentTypes.filter((ct) => configuredUIDs.has(ct.uid));
|
|
215
216
|
} catch (err) {
|
|
216
|
-
|
|
217
|
+
strapi.log.error("Error fetching configured content types:", err);
|
|
217
218
|
return [];
|
|
218
219
|
}
|
|
219
220
|
};
|
|
@@ -237,7 +238,7 @@ function useApi() {
|
|
|
237
238
|
contentType
|
|
238
239
|
};
|
|
239
240
|
} catch (err) {
|
|
240
|
-
|
|
241
|
+
strapi.log.error(`Cannot access entities for ${contentType.uid}:`, err);
|
|
241
242
|
return null;
|
|
242
243
|
}
|
|
243
244
|
})
|
|
@@ -245,7 +246,7 @@ function useApi() {
|
|
|
245
246
|
entities = entityResults.map((result) => result.status === "fulfilled" ? result.value : null).filter(Boolean);
|
|
246
247
|
return entities;
|
|
247
248
|
} catch (err) {
|
|
248
|
-
|
|
249
|
+
strapi.log.error("Error fetching entities:", err);
|
|
249
250
|
throw err;
|
|
250
251
|
}
|
|
251
252
|
};
|
|
@@ -253,16 +254,16 @@ function useApi() {
|
|
|
253
254
|
const { data } = await get(`/${PLUGIN_ID}/route/related?documentId=${relatedDocumentId}`);
|
|
254
255
|
return data;
|
|
255
256
|
};
|
|
256
|
-
const
|
|
257
|
+
const getRoute = async (documentId) => {
|
|
258
|
+
const { data } = await get(`/${PLUGIN_ID}/route/${documentId}`);
|
|
259
|
+
return data;
|
|
260
|
+
};
|
|
261
|
+
const getAllRoutes = async () => {
|
|
257
262
|
const { data } = await get(`/${PLUGIN_ID}/route`);
|
|
258
263
|
return data;
|
|
259
264
|
};
|
|
260
|
-
const
|
|
261
|
-
const { data } = await
|
|
262
|
-
data: {
|
|
263
|
-
...body
|
|
264
|
-
}
|
|
265
|
-
});
|
|
265
|
+
const getProhibitedRouteIds = async (documentId) => {
|
|
266
|
+
const { data } = await get(`/${PLUGIN_ID}/route/prohibitedIds/${documentId ? `${documentId}` : ""}`);
|
|
266
267
|
return data;
|
|
267
268
|
};
|
|
268
269
|
const getNavigation = async ({ documentId, variant } = {}) => {
|
|
@@ -300,8 +301,9 @@ function useApi() {
|
|
|
300
301
|
fetchConfiguredContentTypes,
|
|
301
302
|
fetchAllEntities,
|
|
302
303
|
getRelatedRoute,
|
|
303
|
-
|
|
304
|
-
|
|
304
|
+
getRoute,
|
|
305
|
+
getAllRoutes,
|
|
306
|
+
getProhibitedRouteIds,
|
|
305
307
|
getNavigation,
|
|
306
308
|
createNavigation,
|
|
307
309
|
deleteNavigation,
|
|
@@ -371,6 +373,113 @@ function usePluginConfig() {
|
|
|
371
373
|
}
|
|
372
374
|
return { config, loading, fetchError, setConfig };
|
|
373
375
|
}
|
|
376
|
+
function debounce(func, wait) {
|
|
377
|
+
let timeout;
|
|
378
|
+
return function executedFunction(...args) {
|
|
379
|
+
const later = () => {
|
|
380
|
+
clearTimeout(timeout);
|
|
381
|
+
func(...args);
|
|
382
|
+
};
|
|
383
|
+
clearTimeout(timeout);
|
|
384
|
+
timeout = setTimeout(later, wait);
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
async function duplicateCheck({
|
|
388
|
+
fetchFunction,
|
|
389
|
+
path,
|
|
390
|
+
routeDocumentId,
|
|
391
|
+
withoutTransform = false
|
|
392
|
+
}) {
|
|
393
|
+
if (!path) throw new Error("URL is required");
|
|
394
|
+
try {
|
|
395
|
+
const pathToCheck = withoutTransform ? path : transformToUrl(path);
|
|
396
|
+
const { data } = await fetchFunction(`/${PLUGIN_ID}/checkUniquePath?path=${pathToCheck}${routeDocumentId ? `&targetRouteDocumentId=${routeDocumentId}` : ""}`);
|
|
397
|
+
if (!data.uniquePath) {
|
|
398
|
+
throw new Error("Network response was not ok");
|
|
399
|
+
}
|
|
400
|
+
return data.uniquePath;
|
|
401
|
+
} catch (err) {
|
|
402
|
+
throw new Error("Failed to check URL uniqueness: " + err.message);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
406
|
+
function PathInfo({ validationState, replacement }) {
|
|
407
|
+
const [color, setColor] = React.useState(null);
|
|
408
|
+
const [text, setText] = React.useState(null);
|
|
409
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
410
|
+
React.useEffect(() => {
|
|
411
|
+
if (validationState === "initial") return;
|
|
412
|
+
if (validationState === "checking") {
|
|
413
|
+
setColor("neutral800");
|
|
414
|
+
setText(formatMessage({
|
|
415
|
+
id: getTranslation("components.pathInfo.checking"),
|
|
416
|
+
defaultMessage: "Checking if path is available..."
|
|
417
|
+
}));
|
|
418
|
+
} else if (validationState === "done") {
|
|
419
|
+
setColor(replacement ? "danger500" : "success500");
|
|
420
|
+
setText(replacement ? `${formatMessage({
|
|
421
|
+
id: getTranslation("components.pathInfo.notAvailable"),
|
|
422
|
+
defaultMessage: "Path is not available. Replaced with"
|
|
423
|
+
})} "${replacement}".` : formatMessage({
|
|
424
|
+
id: getTranslation("components.pathInfo.available"),
|
|
425
|
+
defaultMessage: "Path is available."
|
|
426
|
+
}));
|
|
427
|
+
}
|
|
428
|
+
}, [validationState, replacement, formatMessage]);
|
|
429
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: color, children: text }) });
|
|
430
|
+
}
|
|
431
|
+
function OverrideCheckbox({ isOverride, setIsOverride, disabledCondition }) {
|
|
432
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
433
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
434
|
+
designSystem.Flex,
|
|
435
|
+
{
|
|
436
|
+
gap: 2,
|
|
437
|
+
paddingTop: 2,
|
|
438
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
439
|
+
designSystem.Checkbox,
|
|
440
|
+
{
|
|
441
|
+
id: "path-override-checkbox",
|
|
442
|
+
checked: isOverride,
|
|
443
|
+
onCheckedChange: () => setIsOverride(!isOverride),
|
|
444
|
+
disabled: disabledCondition,
|
|
445
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
|
|
446
|
+
id: getTranslation("components.CMEditViewAside.path.overrideCheckbox"),
|
|
447
|
+
defaultMessage: "Override automatic path generation"
|
|
448
|
+
}) })
|
|
449
|
+
}
|
|
450
|
+
)
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
function NewPathInfo() {
|
|
455
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
456
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
|
|
457
|
+
id: getTranslation("components.CMEditViewAside.path.newPathInfo"),
|
|
458
|
+
defaultMessage: "A new path will be created upon saving this entry."
|
|
459
|
+
}) });
|
|
460
|
+
}
|
|
461
|
+
function UidPathDisplay({ path }) {
|
|
462
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
463
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
464
|
+
designSystem.Field.Root,
|
|
465
|
+
{
|
|
466
|
+
hint: formatMessage({
|
|
467
|
+
id: getTranslation("components.CMEditViewAside.path.uidPath.hint"),
|
|
468
|
+
defaultMessage: "Permanent UID path, cannot be changed"
|
|
469
|
+
}),
|
|
470
|
+
children: [
|
|
471
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
472
|
+
designSystem.Field.Input,
|
|
473
|
+
{
|
|
474
|
+
value: path,
|
|
475
|
+
disabled: true
|
|
476
|
+
}
|
|
477
|
+
),
|
|
478
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
}
|
|
374
483
|
function _extends() {
|
|
375
484
|
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
376
485
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -3670,70 +3779,132 @@ function Tooltip({ description: description2 }) {
|
|
|
3670
3779
|
) }) })
|
|
3671
3780
|
] }) });
|
|
3672
3781
|
}
|
|
3673
|
-
function
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
}
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3782
|
+
function PathInput({ path, dispatchPath, isOverride, config }) {
|
|
3783
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
3784
|
+
const displayedPath = isOverride && path.overridePath !== void 0 ? path.overridePath : path.value ?? "";
|
|
3785
|
+
const inputBorder = path.replacement === null ? "" : path.replacement ? "1px solid #ee5e52" : "1px solid #5cb176";
|
|
3786
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3787
|
+
designSystem.Field.Root,
|
|
3788
|
+
{
|
|
3789
|
+
hint: config.default ? formatMessage({
|
|
3790
|
+
id: getTranslation("components.CMEditViewAside.path.input.start"),
|
|
3791
|
+
defaultMessage: "Edit the"
|
|
3792
|
+
}) + ' "' + config.default + '" ' + formatMessage({
|
|
3793
|
+
id: getTranslation("components.CMEditViewAside.path.input.end"),
|
|
3794
|
+
defaultMessage: "field to generate a path"
|
|
3795
|
+
}) : formatMessage({
|
|
3796
|
+
id: getTranslation("components.CMEditViewAside.path.input.noSourceField"),
|
|
3797
|
+
defaultMessage: "Use the override option to set a custom path"
|
|
3798
|
+
}),
|
|
3799
|
+
children: [
|
|
3800
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { children: [
|
|
3801
|
+
formatMessage({
|
|
3802
|
+
id: getTranslation("components.CMEditViewAside.path.input.label"),
|
|
3803
|
+
defaultMessage: "Path"
|
|
3804
|
+
}),
|
|
3805
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip, { description: formatMessage({
|
|
3806
|
+
id: getTranslation("components.CMEditViewAside.path.input.tooltip"),
|
|
3807
|
+
defaultMessage: "The following characters are valid: A-Z, a-z, 0-9, /, -, _, $, ., +, !, *, ', (, )"
|
|
3808
|
+
}) })
|
|
3809
|
+
] }),
|
|
3810
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3811
|
+
designSystem.Field.Input,
|
|
3812
|
+
{
|
|
3813
|
+
id: "path-input",
|
|
3814
|
+
value: displayedPath,
|
|
3815
|
+
onChange: (e) => dispatchPath({ type: "SET_OVERRIDEPATH", payload: e.target.value }),
|
|
3816
|
+
disabled: !isOverride,
|
|
3817
|
+
onBlur: (e) => {
|
|
3818
|
+
if (e.target.value === path.prevValue) return;
|
|
3819
|
+
dispatchPath({ type: "DEFAULT", payload: e.target.value });
|
|
3820
|
+
},
|
|
3821
|
+
style: { outline: inputBorder }
|
|
3822
|
+
}
|
|
3823
|
+
),
|
|
3824
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
|
3825
|
+
]
|
|
3690
3826
|
}
|
|
3691
|
-
|
|
3692
|
-
} catch (err) {
|
|
3693
|
-
console.error("Error in duplicateCheck:", err);
|
|
3694
|
-
throw new Error("Failed to check URL uniqueness");
|
|
3695
|
-
}
|
|
3827
|
+
);
|
|
3696
3828
|
}
|
|
3697
|
-
|
|
3698
|
-
function PathInfo({ validationState, replacement, setUrlStatus }) {
|
|
3699
|
-
const [color, setColor] = React.useState(null);
|
|
3700
|
-
const [text, setText] = React.useState(null);
|
|
3829
|
+
function RouteStructure({ routes, selectedParent, setSelectedParent, canonicalPath, prohibitedRouteIds }) {
|
|
3701
3830
|
const { formatMessage } = reactIntl.useIntl();
|
|
3702
|
-
React.
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3831
|
+
const sortedRoutes = React.useMemo(() => {
|
|
3832
|
+
return [...routes].sort((a, b) => a.title.localeCompare(b.title));
|
|
3833
|
+
}, [routes]);
|
|
3834
|
+
const handleSelectParent = (value) => {
|
|
3835
|
+
const parentRoute = routes.find((route) => route.documentId === value) || null;
|
|
3836
|
+
setSelectedParent(parentRoute);
|
|
3837
|
+
};
|
|
3838
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingBottom: 2, children: [
|
|
3839
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
|
|
3840
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
3841
|
+
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.label"),
|
|
3842
|
+
defaultMessage: "Place under"
|
|
3843
|
+
}) }),
|
|
3844
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3845
|
+
designSystem.SingleSelect,
|
|
3846
|
+
{
|
|
3847
|
+
value: selectedParent?.documentId || "",
|
|
3848
|
+
onValueChange: handleSelectParent,
|
|
3849
|
+
children: [
|
|
3850
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "", children: formatMessage({
|
|
3851
|
+
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.rootPath"),
|
|
3852
|
+
defaultMessage: "None (root path)"
|
|
3853
|
+
}) }),
|
|
3854
|
+
sortedRoutes.filter((route) => !prohibitedRouteIds?.includes(route.documentId) || route.documentId === selectedParent?.documentId).map(
|
|
3855
|
+
(route) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3856
|
+
designSystem.SingleSelectOption,
|
|
3857
|
+
{
|
|
3858
|
+
value: route.documentId,
|
|
3859
|
+
children: route.title
|
|
3860
|
+
},
|
|
3861
|
+
route.documentId
|
|
3862
|
+
)
|
|
3863
|
+
)
|
|
3864
|
+
]
|
|
3865
|
+
}
|
|
3866
|
+
)
|
|
3867
|
+
] }),
|
|
3868
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { marginTop: 4, children: [
|
|
3869
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { children: [
|
|
3870
|
+
formatMessage({
|
|
3871
|
+
id: getTranslation("components.CMEditViewAside.canonicalPath.input.label"),
|
|
3872
|
+
defaultMessage: "Canonical Path"
|
|
3873
|
+
}),
|
|
3874
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip, { description: formatMessage({
|
|
3875
|
+
id: getTranslation("components.CMEditViewAside.canonicalPath.input.tooltip"),
|
|
3876
|
+
defaultMessage: "The path determined by your content's natural hierarchy, independent of where it appears in navigation menus."
|
|
3877
|
+
}) })
|
|
3878
|
+
] }),
|
|
3879
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3880
|
+
designSystem.Field.Input,
|
|
3881
|
+
{
|
|
3882
|
+
id: "canonicalPath-input",
|
|
3883
|
+
value: canonicalPath,
|
|
3884
|
+
disabled: true
|
|
3885
|
+
}
|
|
3886
|
+
),
|
|
3887
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
|
3888
|
+
] })
|
|
3889
|
+
] });
|
|
3890
|
+
}
|
|
3891
|
+
function getCanonicalPath(selectedParent, sourceFieldValue) {
|
|
3892
|
+
const parentPath = selectedParent ? selectedParent.canonicalPath + "/" : "";
|
|
3893
|
+
return `${parentPath}${transformToUrl(sourceFieldValue)}`;
|
|
3723
3894
|
}
|
|
3724
3895
|
function reducer(state, action) {
|
|
3725
3896
|
switch (action.type) {
|
|
3726
3897
|
case "DEFAULT":
|
|
3727
3898
|
return {
|
|
3728
3899
|
...state,
|
|
3729
|
-
value:
|
|
3900
|
+
value: action.payload,
|
|
3730
3901
|
prevValue: state.value,
|
|
3731
3902
|
needsUrlCheck: true
|
|
3732
3903
|
};
|
|
3733
3904
|
case "NO_URL_CHECK":
|
|
3734
3905
|
return {
|
|
3735
3906
|
...state,
|
|
3736
|
-
value:
|
|
3907
|
+
value: action.payload,
|
|
3737
3908
|
prevValue: state.value,
|
|
3738
3909
|
needsUrlCheck: false
|
|
3739
3910
|
};
|
|
@@ -3746,16 +3917,22 @@ function reducer(state, action) {
|
|
|
3746
3917
|
};
|
|
3747
3918
|
case "RESET_URL_CHECK_FLAG":
|
|
3748
3919
|
return { ...state, needsUrlCheck: false };
|
|
3920
|
+
case "SET_REPLACEMENT":
|
|
3921
|
+
return { ...state, replacement: action.payload };
|
|
3749
3922
|
case "SET_UIDPATH":
|
|
3750
|
-
return { ...state,
|
|
3923
|
+
return { ...state, uidPath: action.payload };
|
|
3924
|
+
case "SET_CANONICALPATH":
|
|
3925
|
+
return { ...state, canonicalPath: action.payload };
|
|
3926
|
+
case "SET_OVERRIDEPATH":
|
|
3927
|
+
return { ...state, overridePath: action.payload };
|
|
3751
3928
|
default:
|
|
3752
3929
|
throw new Error();
|
|
3753
3930
|
}
|
|
3754
3931
|
}
|
|
3755
|
-
const
|
|
3932
|
+
const Panel = ({ config }) => {
|
|
3756
3933
|
const { form, model } = admin.unstable_useContentManagerContext();
|
|
3757
3934
|
const { initialValues, values, onChange } = form;
|
|
3758
|
-
const { getRelatedRoute } = useApi();
|
|
3935
|
+
const { getRelatedRoute, getAllRoutes, getProhibitedRouteIds } = useApi();
|
|
3759
3936
|
const { formatMessage } = reactIntl.useIntl();
|
|
3760
3937
|
const { get } = admin.useFetchClient();
|
|
3761
3938
|
const { allowedActions: {
|
|
@@ -3775,26 +3952,39 @@ const Path = ({ config }) => {
|
|
|
3775
3952
|
conditions: []
|
|
3776
3953
|
}
|
|
3777
3954
|
]);
|
|
3778
|
-
const [
|
|
3955
|
+
const [route, setRoute] = React.useState(null);
|
|
3956
|
+
const [routes, setRoutes] = React.useState([]);
|
|
3957
|
+
const [prohibitedRouteIds, setProhibitedRouteIds] = React.useState([]);
|
|
3958
|
+
const [selectedParent, setSelectedParent] = React.useState(null);
|
|
3779
3959
|
const [isOverride, setIsOverride] = React.useState(false);
|
|
3780
3960
|
const [validationState, setValidationState] = React.useState("initial");
|
|
3781
|
-
const [replacement, setReplacement] = React.useState("");
|
|
3782
3961
|
const [initialLoadComplete, setInitialLoadComplete] = React.useState(false);
|
|
3783
|
-
const [urlIsValid, setUrlIsValid] = React.useState(null);
|
|
3784
3962
|
const [path, dispatchPath] = React.useReducer(reducer, {
|
|
3785
3963
|
needsUrlCheck: false,
|
|
3786
3964
|
value: "",
|
|
3787
3965
|
prevValue: "",
|
|
3788
|
-
|
|
3966
|
+
replacement: null,
|
|
3967
|
+
uidPath: "",
|
|
3968
|
+
canonicalPath: "",
|
|
3969
|
+
overridePath: ""
|
|
3789
3970
|
});
|
|
3790
3971
|
const hasUserChangedField = React.useRef(false);
|
|
3791
3972
|
const initialPath = React.useRef("");
|
|
3792
|
-
const
|
|
3793
|
-
const
|
|
3973
|
+
const prevSourceValueRef = React.useRef(null);
|
|
3974
|
+
const sourceFieldValue = React.useMemo(() => {
|
|
3975
|
+
const key = config?.default;
|
|
3976
|
+
if (!key) return "";
|
|
3977
|
+
const currentValue = values[key];
|
|
3978
|
+
if (!currentValue) return "";
|
|
3979
|
+
return currentValue;
|
|
3980
|
+
}, [values, config]);
|
|
3981
|
+
const debouncedCheckPath = React.useCallback(debounce(checkPath, 250), []);
|
|
3982
|
+
const debouncedCheckCanonicalPath = React.useCallback(debounce(checkCanonicalPath, 250), []);
|
|
3794
3983
|
React.useEffect(() => {
|
|
3795
|
-
onChange("webatlas_path", path.
|
|
3984
|
+
if (isOverride) onChange("webatlas_path", path.overridePath);
|
|
3796
3985
|
onChange("webatlas_override", isOverride);
|
|
3797
|
-
|
|
3986
|
+
onChange("webatlas_parent", selectedParent?.documentId || null);
|
|
3987
|
+
}, [path.value, path.overridePath, isOverride, selectedParent]);
|
|
3798
3988
|
const debouncedValueEffect = React.useMemo(() => debounce((currentValues) => {
|
|
3799
3989
|
const key = config?.default;
|
|
3800
3990
|
if (!key) return;
|
|
@@ -3803,38 +3993,37 @@ const Path = ({ config }) => {
|
|
|
3803
3993
|
dispatchPath({ type: "NO_URL_CHECK", payload: "" });
|
|
3804
3994
|
return;
|
|
3805
3995
|
}
|
|
3806
|
-
if (initialLoadComplete && (hasUserChangedField.current || !
|
|
3807
|
-
const path2 =
|
|
3996
|
+
if (initialLoadComplete && (hasUserChangedField.current || !route) && prevSourceValueRef.current !== currentValue && !isOverride) {
|
|
3997
|
+
const path2 = getCanonicalPath(selectedParent, currentValue);
|
|
3808
3998
|
if (currentValue === initialValues[key]) {
|
|
3809
3999
|
dispatchPath({ type: "NO_URL_CHECK", payload: path2 });
|
|
3810
4000
|
} else {
|
|
3811
4001
|
dispatchPath({ type: "DEFAULT", payload: path2 });
|
|
3812
4002
|
}
|
|
3813
|
-
|
|
4003
|
+
prevSourceValueRef.current = currentValue;
|
|
3814
4004
|
}
|
|
3815
|
-
}, 500), [config?.default,
|
|
4005
|
+
}, 500), [config?.default, initialValues, isOverride, initialLoadComplete, route, selectedParent]);
|
|
3816
4006
|
React.useEffect(() => {
|
|
3817
4007
|
const key = config?.default;
|
|
3818
4008
|
if (!key) return;
|
|
3819
4009
|
const currentValue = values[key];
|
|
3820
4010
|
const initialValue = initialValues[key];
|
|
3821
|
-
if (currentValue && !isOverride) {
|
|
3822
|
-
|
|
3823
|
-
onChange("webatlas_path", transformToUrl(path2));
|
|
4011
|
+
if (currentValue !== initialValue && currentValue && !isOverride) {
|
|
4012
|
+
onChange("webatlas_path", transformToUrl(currentValue));
|
|
3824
4013
|
}
|
|
3825
4014
|
if (!initialLoadComplete) return;
|
|
3826
4015
|
if (currentValue !== initialValue) {
|
|
3827
4016
|
hasUserChangedField.current = true;
|
|
3828
4017
|
}
|
|
3829
4018
|
debouncedValueEffect(values);
|
|
3830
|
-
}, [values, debouncedValueEffect, initialLoadComplete]);
|
|
4019
|
+
}, [values, debouncedValueEffect, initialLoadComplete, selectedParent]);
|
|
3831
4020
|
React.useEffect(() => {
|
|
3832
4021
|
if (path.needsUrlCheck && path.value) {
|
|
3833
|
-
if (path.
|
|
3834
|
-
|
|
4022
|
+
if (path.uidPath === path.value || initialPath.current === path.value) return;
|
|
4023
|
+
debouncedCheckPath(path.value, route?.documentId || null);
|
|
3835
4024
|
dispatchPath({ type: "RESET_URL_CHECK_FLAG" });
|
|
3836
4025
|
}
|
|
3837
|
-
}, [path.needsUrlCheck]);
|
|
4026
|
+
}, [path.needsUrlCheck, path.value, path.uidPath, route]);
|
|
3838
4027
|
React.useEffect(() => {
|
|
3839
4028
|
async function getTypes() {
|
|
3840
4029
|
if (!initialValues.documentId) {
|
|
@@ -3842,42 +4031,84 @@ const Path = ({ config }) => {
|
|
|
3842
4031
|
return;
|
|
3843
4032
|
}
|
|
3844
4033
|
try {
|
|
3845
|
-
const
|
|
3846
|
-
if (!
|
|
3847
|
-
initialPath.current = initialValues.webatlas_path ||
|
|
3848
|
-
|
|
3849
|
-
setIsOverride(
|
|
3850
|
-
|
|
3851
|
-
|
|
4034
|
+
const route2 = await getRelatedRoute(initialValues.documentId);
|
|
4035
|
+
if (!route2) return;
|
|
4036
|
+
initialPath.current = initialValues.webatlas_path || route2.uidPath;
|
|
4037
|
+
setRoute(route2);
|
|
4038
|
+
setIsOverride(route2.isOverride || false);
|
|
4039
|
+
if (route2.isOverride) {
|
|
4040
|
+
dispatchPath({ type: "SET_OVERRIDEPATH", payload: route2.path || "" });
|
|
4041
|
+
} else {
|
|
4042
|
+
dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: route2.path || "" });
|
|
4043
|
+
}
|
|
4044
|
+
dispatchPath({ type: "SET_UIDPATH", payload: route2.uidPath || "" });
|
|
3852
4045
|
const key = config?.default;
|
|
3853
4046
|
if (key) {
|
|
3854
|
-
|
|
4047
|
+
prevSourceValueRef.current = values[key];
|
|
3855
4048
|
}
|
|
3856
4049
|
} catch (err) {
|
|
3857
|
-
|
|
3858
|
-
|
|
4050
|
+
setRoute(null);
|
|
4051
|
+
strapi.log.error(err);
|
|
3859
4052
|
}
|
|
3860
4053
|
setInitialLoadComplete(true);
|
|
3861
4054
|
}
|
|
3862
4055
|
getTypes();
|
|
3863
4056
|
}, [config]);
|
|
4057
|
+
React.useEffect(() => {
|
|
4058
|
+
if (initialValues.webatlas_parent && routes.length > 0 && !selectedParent) {
|
|
4059
|
+
const parentRoute = routes.find((route2) => route2.documentId === initialValues.webatlas_parent);
|
|
4060
|
+
if (parentRoute) {
|
|
4061
|
+
setSelectedParent(parentRoute);
|
|
4062
|
+
const canonicalPath = getCanonicalPath(parentRoute, sourceFieldValue);
|
|
4063
|
+
dispatchPath({ type: "DEFAULT", payload: canonicalPath });
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
}, [initialValues, routes]);
|
|
3864
4067
|
React.useEffect(() => {
|
|
3865
4068
|
if (initialValues.webatlas_path) dispatchPath({ type: "NO_URL_CHECK", payload: initialValues.webatlas_path });
|
|
3866
4069
|
if (initialValues.webatlas_override) setIsOverride(initialValues.webatlas_override);
|
|
4070
|
+
async function fetchAllRoutes() {
|
|
4071
|
+
const allRoutes = await getAllRoutes();
|
|
4072
|
+
setRoutes(allRoutes);
|
|
4073
|
+
}
|
|
4074
|
+
fetchAllRoutes();
|
|
3867
4075
|
}, []);
|
|
3868
|
-
|
|
3869
|
-
|
|
4076
|
+
React.useEffect(() => {
|
|
4077
|
+
async function fetchProhibitedRouteIds() {
|
|
4078
|
+
const prohibitedIds = await getProhibitedRouteIds(route?.documentId);
|
|
4079
|
+
setProhibitedRouteIds(prohibitedIds);
|
|
4080
|
+
}
|
|
4081
|
+
fetchProhibitedRouteIds();
|
|
4082
|
+
}, [route]);
|
|
4083
|
+
React.useEffect(() => {
|
|
4084
|
+
if (!sourceFieldValue) return;
|
|
4085
|
+
const canonicalPath = getCanonicalPath(selectedParent, sourceFieldValue);
|
|
4086
|
+
!isOverride && dispatchPath({ type: "DEFAULT", payload: canonicalPath });
|
|
4087
|
+
dispatchPath({ type: "SET_CANONICALPATH", payload: canonicalPath });
|
|
4088
|
+
debouncedCheckCanonicalPath(canonicalPath, route?.documentId || null);
|
|
4089
|
+
dispatchPath({ type: "RESET_URL_CHECK_FLAG" });
|
|
4090
|
+
}, [selectedParent, sourceFieldValue, route, isOverride]);
|
|
4091
|
+
async function checkCanonicalPath(path2, documentId) {
|
|
4092
|
+
if (!path2) return;
|
|
4093
|
+
try {
|
|
4094
|
+
const result = await duplicateCheck({ fetchFunction: get, path: path2, routeDocumentId: documentId, withoutTransform: true });
|
|
4095
|
+
dispatchPath({ type: "SET_CANONICALPATH", payload: result });
|
|
4096
|
+
} catch (err) {
|
|
4097
|
+
strapi.log.error(err);
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
async function checkPath(path2, route2) {
|
|
4101
|
+
if (!path2) return;
|
|
3870
4102
|
setValidationState("checking");
|
|
3871
|
-
|
|
4103
|
+
dispatchPath({ type: "SET_REPLACEMENT", payload: "" });
|
|
3872
4104
|
try {
|
|
3873
|
-
const data = await duplicateCheck(get,
|
|
3874
|
-
if (!data || data ===
|
|
4105
|
+
const data = await duplicateCheck({ fetchFunction: get, path: path2, routeDocumentId: route2, withoutTransform: true });
|
|
4106
|
+
if (!data || data === path2) return;
|
|
3875
4107
|
dispatchPath({ type: "NO_URL_CHECK", payload: data });
|
|
3876
|
-
|
|
4108
|
+
dispatchPath({ type: "SET_REPLACEMENT", payload: data });
|
|
3877
4109
|
} catch (err) {
|
|
3878
|
-
|
|
4110
|
+
strapi.log.error(err);
|
|
3879
4111
|
} finally {
|
|
3880
|
-
setUrlIsValid(null);
|
|
3881
4112
|
setValidationState("done");
|
|
3882
4113
|
}
|
|
3883
4114
|
}
|
|
@@ -3896,101 +4127,52 @@ const Path = ({ config }) => {
|
|
|
3896
4127
|
{
|
|
3897
4128
|
direction: "column",
|
|
3898
4129
|
alignItems: "stretch",
|
|
3899
|
-
gap:
|
|
4130
|
+
gap: 1,
|
|
3900
4131
|
children: [
|
|
4132
|
+
!route && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4133
|
+
/* @__PURE__ */ jsxRuntime.jsx(NewPathInfo, {}),
|
|
4134
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 })
|
|
4135
|
+
] }),
|
|
4136
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4137
|
+
RouteStructure,
|
|
4138
|
+
{
|
|
4139
|
+
canonicalPath: path.canonicalPath,
|
|
4140
|
+
routes,
|
|
4141
|
+
selectedParent,
|
|
4142
|
+
setSelectedParent,
|
|
4143
|
+
prohibitedRouteIds
|
|
4144
|
+
}
|
|
4145
|
+
),
|
|
4146
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 }),
|
|
3901
4147
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
id: getTranslation("components.CMEditViewAside.path.newPathInfo"),
|
|
3905
|
-
defaultMessage: "A new path will be created upon saving this entry."
|
|
3906
|
-
}) }),
|
|
3907
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 2, paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}) })
|
|
3908
|
-
] }),
|
|
3909
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3910
|
-
designSystem.Field.Root,
|
|
4148
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4149
|
+
PathInput,
|
|
3911
4150
|
{
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
id: getTranslation("components.CMEditViewAside.path.input.end"),
|
|
3917
|
-
defaultMessage: "field to generate a path"
|
|
3918
|
-
}) : formatMessage({
|
|
3919
|
-
id: getTranslation("components.CMEditViewAside.path.input.noSourceField"),
|
|
3920
|
-
defaultMessage: "Use the override option to set a custom path"
|
|
3921
|
-
}),
|
|
3922
|
-
children: [
|
|
3923
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { children: [
|
|
3924
|
-
formatMessage({
|
|
3925
|
-
id: getTranslation("components.CMEditViewAside.path.input.label"),
|
|
3926
|
-
defaultMessage: "Path"
|
|
3927
|
-
}),
|
|
3928
|
-
/* @__PURE__ */ jsxRuntime.jsx(Tooltip, { description: formatMessage({
|
|
3929
|
-
id: getTranslation("components.CMEditViewAside.path.input.tooltip"),
|
|
3930
|
-
defaultMessage: "The following characters are valid: A-Z, a-z, 0-9, /, -, _, $, ., +, !, *, ', (, )"
|
|
3931
|
-
}) })
|
|
3932
|
-
] }),
|
|
3933
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3934
|
-
designSystem.Field.Input,
|
|
3935
|
-
{
|
|
3936
|
-
id: "path-input",
|
|
3937
|
-
value: path.value,
|
|
3938
|
-
onChange: (e) => dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: e.target.value }),
|
|
3939
|
-
disabled: !isOverride,
|
|
3940
|
-
onBlur: (e) => {
|
|
3941
|
-
if (e.target.value === path.prevValue) return;
|
|
3942
|
-
dispatchPath({ type: "DEFAULT", payload: e.target.value });
|
|
3943
|
-
},
|
|
3944
|
-
style: { outline: urlIsValid !== null ? urlIsValid === "valid" ? "1px solid #5cb176" : "1px solid #ee5e52" : void 0 }
|
|
3945
|
-
}
|
|
3946
|
-
),
|
|
3947
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
|
3948
|
-
]
|
|
4151
|
+
path,
|
|
4152
|
+
dispatchPath,
|
|
4153
|
+
isOverride,
|
|
4154
|
+
config
|
|
3949
4155
|
}
|
|
3950
4156
|
),
|
|
3951
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3952
|
-
|
|
3953
|
-
designSystem.Flex,
|
|
4157
|
+
validationState !== "initial" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4158
|
+
PathInfo,
|
|
3954
4159
|
{
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3958
|
-
designSystem.Checkbox,
|
|
3959
|
-
{
|
|
3960
|
-
id: "path-override-checkbox",
|
|
3961
|
-
checked: isOverride,
|
|
3962
|
-
onCheckedChange: () => setIsOverride((prev) => !prev),
|
|
3963
|
-
disabled: !routeId && !canCreate || routeId && !canUpdate,
|
|
3964
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
|
|
3965
|
-
id: getTranslation("components.CMEditViewAside.path.overrideCheckbox"),
|
|
3966
|
-
defaultMessage: "Override automatic path generation"
|
|
3967
|
-
}) })
|
|
3968
|
-
}
|
|
3969
|
-
)
|
|
4160
|
+
validationState,
|
|
4161
|
+
replacement: path.replacement
|
|
3970
4162
|
}
|
|
3971
4163
|
)
|
|
3972
4164
|
] }),
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
designSystem.Field.Input,
|
|
3985
|
-
{
|
|
3986
|
-
value: path.uIdPath,
|
|
3987
|
-
disabled: true
|
|
3988
|
-
}
|
|
3989
|
-
),
|
|
3990
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
|
3991
|
-
]
|
|
3992
|
-
}
|
|
3993
|
-
) })
|
|
4165
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4166
|
+
OverrideCheckbox,
|
|
4167
|
+
{
|
|
4168
|
+
isOverride,
|
|
4169
|
+
setIsOverride,
|
|
4170
|
+
disabledCondition: !canCreate && !canUpdate
|
|
4171
|
+
}
|
|
4172
|
+
),
|
|
4173
|
+
path.uidPath && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4174
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 }),
|
|
4175
|
+
/* @__PURE__ */ jsxRuntime.jsx(UidPathDisplay, { path: path.uidPath })
|
|
3994
4176
|
] })
|
|
3995
4177
|
]
|
|
3996
4178
|
}
|
|
@@ -4005,14 +4187,7 @@ const pluginPermissions = {
|
|
|
4005
4187
|
"settings.general": [{ action: `plugin::${PLUGIN_ID}.settings.general`, subject: null }],
|
|
4006
4188
|
"settings.navigation": [{ action: `plugin::${PLUGIN_ID}.settings.navigation`, subject: null }]
|
|
4007
4189
|
};
|
|
4008
|
-
const CMEditViewAside = ({
|
|
4009
|
-
// activeTab,
|
|
4010
|
-
// collectionType,
|
|
4011
|
-
// document,
|
|
4012
|
-
documentId,
|
|
4013
|
-
// meta,
|
|
4014
|
-
model
|
|
4015
|
-
}) => {
|
|
4190
|
+
const CMEditViewAside = ({ documentId, model }) => {
|
|
4016
4191
|
const { contentTypes } = useAllContentTypes();
|
|
4017
4192
|
const { config } = usePluginConfig();
|
|
4018
4193
|
const { formatMessage } = reactIntl.useIntl();
|
|
@@ -4072,7 +4247,7 @@ const CMEditViewAside = ({
|
|
|
4072
4247
|
});
|
|
4073
4248
|
if (!canAside || !isAllowedContentType || !isActiveContentType || !contentTypeConfig) return null;
|
|
4074
4249
|
if (!config) {
|
|
4075
|
-
|
|
4250
|
+
strapi.log.error("CMEditViewAside: Plugin is not configured.");
|
|
4076
4251
|
return null;
|
|
4077
4252
|
}
|
|
4078
4253
|
if (isLoading) return {
|
|
@@ -4084,37 +4259,31 @@ const CMEditViewAside = ({
|
|
|
4084
4259
|
};
|
|
4085
4260
|
return {
|
|
4086
4261
|
title: panelTitle,
|
|
4087
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4262
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(Panel, { config: contentTypeConfig })
|
|
4088
4263
|
};
|
|
4089
4264
|
};
|
|
4090
4265
|
const index = {
|
|
4091
4266
|
register(app) {
|
|
4092
4267
|
app.addMenuLink({
|
|
4093
|
-
to:
|
|
4268
|
+
to: `plugins/${PLUGIN_ID}/paths`,
|
|
4094
4269
|
icon: PathIcon,
|
|
4095
4270
|
intlLabel: {
|
|
4096
4271
|
id: `${PLUGIN_ID}.link.paths`,
|
|
4097
4272
|
defaultMessage: "Paths"
|
|
4098
4273
|
},
|
|
4099
|
-
Component:
|
|
4100
|
-
const component = await Promise.resolve().then(() => require("./index-CC073vGB.js"));
|
|
4101
|
-
return { default: component.default };
|
|
4102
|
-
},
|
|
4274
|
+
Component: () => Promise.resolve().then(() => require("./index-d09V61nm.js")),
|
|
4103
4275
|
permissions: [
|
|
4104
4276
|
pluginPermissions["page.routes"][0]
|
|
4105
4277
|
]
|
|
4106
4278
|
});
|
|
4107
4279
|
app.addMenuLink({
|
|
4108
|
-
to:
|
|
4280
|
+
to: `plugins/${PLUGIN_ID}/navigation`,
|
|
4109
4281
|
icon: NavigationIcon,
|
|
4110
4282
|
intlLabel: {
|
|
4111
4283
|
id: `${PLUGIN_ID}.link.navigation`,
|
|
4112
4284
|
defaultMessage: "Navigation"
|
|
4113
4285
|
},
|
|
4114
|
-
Component:
|
|
4115
|
-
const component = await Promise.resolve().then(() => require("./index-BkB1x9Sn.js"));
|
|
4116
|
-
return { default: component.default };
|
|
4117
|
-
},
|
|
4286
|
+
Component: () => Promise.resolve().then(() => require("./index-IRSCe8PX.js")),
|
|
4118
4287
|
permissions: [
|
|
4119
4288
|
pluginPermissions["page.navigation"][0]
|
|
4120
4289
|
]
|
|
@@ -4133,13 +4302,8 @@ const index = {
|
|
|
4133
4302
|
defaultMessage: "General"
|
|
4134
4303
|
},
|
|
4135
4304
|
id: `${PLUGIN_ID}-general`,
|
|
4136
|
-
to:
|
|
4137
|
-
Component:
|
|
4138
|
-
return await Promise.resolve().then(() => require(
|
|
4139
|
-
/* webpackChunkName: "webatlas-settings-general-page" */
|
|
4140
|
-
"./index-BOZDZiAv.js"
|
|
4141
|
-
));
|
|
4142
|
-
},
|
|
4305
|
+
to: `${PLUGIN_ID}/general`,
|
|
4306
|
+
Component: () => Promise.resolve().then(() => require("./index-BucL4va6.js")),
|
|
4143
4307
|
permissions: [
|
|
4144
4308
|
pluginPermissions["settings.general"][0]
|
|
4145
4309
|
]
|
|
@@ -4153,13 +4317,8 @@ const index = {
|
|
|
4153
4317
|
defaultMessage: "Navigation"
|
|
4154
4318
|
},
|
|
4155
4319
|
id: `${PLUGIN_ID}-navigation`,
|
|
4156
|
-
to:
|
|
4157
|
-
Component:
|
|
4158
|
-
return await Promise.resolve().then(() => require(
|
|
4159
|
-
/* webpackChunkName: "webatlas-settings-navigation-page" */
|
|
4160
|
-
"./index-m2ivL3ht.js"
|
|
4161
|
-
));
|
|
4162
|
-
},
|
|
4320
|
+
to: `${PLUGIN_ID}/navigation`,
|
|
4321
|
+
Component: () => Promise.resolve().then(() => require("./index-D-vJE_K8.js")),
|
|
4163
4322
|
permissions: [
|
|
4164
4323
|
pluginPermissions["settings.navigation"][0]
|
|
4165
4324
|
]
|
|
@@ -4179,7 +4338,7 @@ const index = {
|
|
|
4179
4338
|
return Promise.all(
|
|
4180
4339
|
locales.map(async (locale) => {
|
|
4181
4340
|
try {
|
|
4182
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-
|
|
4341
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-CqU1FU8C.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-C7I90FwV.js")) }), `./translations/${locale}.json`, 3);
|
|
4183
4342
|
return { data, locale };
|
|
4184
4343
|
} catch {
|
|
4185
4344
|
return { data: {}, locale };
|
|
@@ -4198,7 +4357,6 @@ exports.duplicateCheck = duplicateCheck;
|
|
|
4198
4357
|
exports.getTranslation = getTranslation;
|
|
4199
4358
|
exports.index = index;
|
|
4200
4359
|
exports.pluginPermissions = pluginPermissions;
|
|
4201
|
-
exports.transformToUrl = transformToUrl;
|
|
4202
4360
|
exports.useAllContentTypes = useAllContentTypes;
|
|
4203
4361
|
exports.useApi = useApi;
|
|
4204
4362
|
exports.usePluginConfig = usePluginConfig;
|