@mattisvensson/strapi-plugin-webatlas 0.12.1 → 0.13.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 +59 -2
- package/dist/admin/{SettingTitle-Ib_0AvoZ.js → ContentBox-D4PGQ8eh.js} +1 -5
- package/dist/admin/{SettingTitle-0mKlA80i.mjs → ContentBox-KyQN2KGV.mjs} +2 -6
- package/dist/admin/{RoutePicker-IRZiHKFi.mjs → RoutePicker-CgndSXoF.mjs} +1 -1
- package/dist/admin/{RoutePicker-C3_tzz9U.js → RoutePicker-CwoMMhf_.js} +1 -1
- package/dist/admin/WarningBox-AyYq0Onj.mjs +18 -0
- package/dist/admin/{WarningBox-BZ3BZ5fR.js → WarningBox-FF1yYDXP.js} +0 -24
- package/dist/admin/{de-DhwCZE_m.js → de-Cl0vM1wA.js} +52 -4
- package/dist/admin/{de-BFjenpyN.mjs → de-DWs5ckOd.mjs} +52 -4
- package/dist/admin/{en-CGCh9ld_.mjs → en-CyhISGZi.mjs} +52 -4
- package/dist/admin/{en-C-rPCNd2.js → en-DSmtmPYk.js} +52 -4
- package/dist/admin/{index-ByxM39aL.mjs → index-BKhrfzjO.mjs} +105 -33
- package/dist/admin/{index-Bym1mXg1.mjs → index-Bv5Ri-ri.mjs} +44 -12
- package/dist/admin/{index-88JTX1Mj.js → index-BxGPKxr_.js} +50 -18
- package/dist/admin/index-Ctm4TBT5.mjs +5308 -0
- package/dist/admin/{index-PD3gcnXA.mjs → index-D2O7sLKs.mjs} +1 -1
- package/dist/admin/{index-CsKnBzp6.js → index-DTrsl_uN.js} +105 -33
- package/dist/admin/index-FvaXwOH0.mjs +174 -0
- package/dist/admin/index-JBUU7dE6.js +5308 -0
- package/dist/admin/{index-DNBXz42q.js → index-jOCO4_-k.js} +1 -1
- package/dist/admin/index-uOC1Clyv.js +174 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +443 -96
- package/dist/server/index.mjs +444 -97
- package/dist/server/src/index.d.ts +17 -4
- package/package.json +3 -3
- package/dist/admin/WarningBox-CXEmXfVx.mjs +0 -42
- package/dist/admin/index-BPUJTNed.js +0 -9622
- package/dist/admin/index-BY6JLZrD.mjs +0 -9622
- package/dist/admin/index-CEJBltoJ.js +0 -147
- package/dist/admin/index-CNCyng5O.mjs +0 -147
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect, useMemo } from "react";
|
|
3
|
-
import { g as getTranslation, u as useApi, d as debounce, p as pluginPermissions, i as isAbortError } from "./index-
|
|
3
|
+
import { g as getTranslation, u as useApi, d as debounce, p as pluginPermissions, i as isAbortError } from "./index-BKhrfzjO.mjs";
|
|
4
4
|
import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
|
|
5
5
|
import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
|
|
6
6
|
import { Grid, Box, Field, Thead, Tr, Th, Typography, VisuallyHidden, Td, Flex, LinkButton, Table, Tbody, EmptyStateLayout } from "@strapi/design-system";
|
|
@@ -70,7 +70,7 @@ function transformToUrl(input, replaceSlash = true) {
|
|
|
70
70
|
input = input.replace(/-+/g, "-");
|
|
71
71
|
return input;
|
|
72
72
|
}
|
|
73
|
-
const version = "0.12.
|
|
73
|
+
const version = "0.12.2";
|
|
74
74
|
const strapi = { "name": "webatlas", "displayName": "Webatlas" };
|
|
75
75
|
const pluginPkg = {
|
|
76
76
|
version,
|
|
@@ -176,6 +176,14 @@ function useApi() {
|
|
|
176
176
|
});
|
|
177
177
|
return data;
|
|
178
178
|
};
|
|
179
|
+
const getNavigationDepths = async () => {
|
|
180
|
+
const { data } = await get(`/${PLUGIN_ID}/settings/navigation-depths`);
|
|
181
|
+
return data;
|
|
182
|
+
};
|
|
183
|
+
const updateNavigationDepths = async (depths) => {
|
|
184
|
+
const { data } = await put(`/${PLUGIN_ID}/settings/navigation-depths`, { data: depths });
|
|
185
|
+
return data;
|
|
186
|
+
};
|
|
179
187
|
return {
|
|
180
188
|
fetchAllContentTypes,
|
|
181
189
|
fetchAllEntities,
|
|
@@ -187,7 +195,9 @@ function useApi() {
|
|
|
187
195
|
createNavigation,
|
|
188
196
|
deleteNavigation,
|
|
189
197
|
updateNavigation,
|
|
190
|
-
updateNavigationItemStructure
|
|
198
|
+
updateNavigationItemStructure,
|
|
199
|
+
getNavigationDepths,
|
|
200
|
+
updateNavigationDepths
|
|
191
201
|
};
|
|
192
202
|
}
|
|
193
203
|
function debounce(func, wait) {
|
|
@@ -350,8 +360,19 @@ function OverrideCheckbox({ isOverride, setIsOverride, disabledCondition }) {
|
|
|
350
360
|
}
|
|
351
361
|
) });
|
|
352
362
|
}
|
|
353
|
-
function NewPathInfo(
|
|
363
|
+
function NewPathInfo({
|
|
364
|
+
hasSlug,
|
|
365
|
+
routeSourceField
|
|
366
|
+
}) {
|
|
354
367
|
const { formatMessage } = reactIntl.useIntl();
|
|
368
|
+
if (!hasSlug)
|
|
369
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: formatMessage(
|
|
370
|
+
{
|
|
371
|
+
id: getTranslation("components.CMEditViewAside.path.noPathInfo"),
|
|
372
|
+
defaultMessage: 'No path will be created while the "{field}" field is empty. Fill it in or use the override option to set a custom path.'
|
|
373
|
+
},
|
|
374
|
+
{ field: routeSourceField }
|
|
375
|
+
) });
|
|
355
376
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
|
|
356
377
|
id: getTranslation("components.CMEditViewAside.path.newPathInfo"),
|
|
357
378
|
defaultMessage: "A new path will be created upon saving this entry."
|
|
@@ -3672,7 +3693,14 @@ function Tooltip({ description }) {
|
|
|
3672
3693
|
) }) })
|
|
3673
3694
|
] }) });
|
|
3674
3695
|
}
|
|
3675
|
-
function PathInput({
|
|
3696
|
+
function PathInput({
|
|
3697
|
+
path,
|
|
3698
|
+
dispatchPath,
|
|
3699
|
+
isOverride,
|
|
3700
|
+
config,
|
|
3701
|
+
hasUserInteracted,
|
|
3702
|
+
disabled
|
|
3703
|
+
}) {
|
|
3676
3704
|
const { formatMessage } = reactIntl.useIntl();
|
|
3677
3705
|
const displayedPath = isOverride && path.overridePath !== void 0 ? path.overridePath : path.value ?? "";
|
|
3678
3706
|
const inputBorder = path.replacement === null ? "" : path.replacement ? "1px solid #ee5e52" : "1px solid #5cb176";
|
|
@@ -3714,7 +3742,7 @@ function PathInput({ path, dispatchPath, isOverride, config, hasUserInteracted }
|
|
|
3714
3742
|
hasUserInteracted.current = true;
|
|
3715
3743
|
dispatchPath({ type: "SET_OVERRIDEPATH", payload: e.target.value });
|
|
3716
3744
|
},
|
|
3717
|
-
disabled: !isOverride,
|
|
3745
|
+
disabled: !isOverride || disabled,
|
|
3718
3746
|
onBlur: (e) => {
|
|
3719
3747
|
dispatchPath({
|
|
3720
3748
|
type: "SET_OVERRIDEPATH",
|
|
@@ -3740,7 +3768,8 @@ function RouteStructure({
|
|
|
3740
3768
|
canonicalPath,
|
|
3741
3769
|
prohibitedRouteIds,
|
|
3742
3770
|
defaultParentRoute,
|
|
3743
|
-
isCreatingEntry
|
|
3771
|
+
isCreatingEntry,
|
|
3772
|
+
disabled
|
|
3744
3773
|
}) {
|
|
3745
3774
|
const { formatMessage } = reactIntl.useIntl();
|
|
3746
3775
|
const handleSelectParent = (value) => {
|
|
@@ -3771,7 +3800,7 @@ function RouteStructure({
|
|
|
3771
3800
|
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.label"),
|
|
3772
3801
|
defaultMessage: "Place under"
|
|
3773
3802
|
}) }),
|
|
3774
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { value: selectValue, onValueChange: handleSelectParent, children: [
|
|
3803
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { value: selectValue, onValueChange: handleSelectParent, disabled, children: [
|
|
3775
3804
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "", children: formatMessage({
|
|
3776
3805
|
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.rootPath"),
|
|
3777
3806
|
defaultMessage: "None (root path)"
|
|
@@ -3800,6 +3829,30 @@ function RouteStructure({
|
|
|
3800
3829
|
] })
|
|
3801
3830
|
] });
|
|
3802
3831
|
}
|
|
3832
|
+
const pluginPermissions = {
|
|
3833
|
+
"cm.aside": [{ action: `plugin::${PLUGIN_ID}.cm.aside`, subject: null }],
|
|
3834
|
+
"cm.edit-path": [{ action: `plugin::${PLUGIN_ID}.cm.edit-path`, subject: null }],
|
|
3835
|
+
"navigation.read": [{ action: `plugin::${PLUGIN_ID}.navigation.read`, subject: null }],
|
|
3836
|
+
"navigation.create": [{ action: `plugin::${PLUGIN_ID}.navigation.create`, subject: null }],
|
|
3837
|
+
"navigation.update": [{ action: `plugin::${PLUGIN_ID}.navigation.update`, subject: null }],
|
|
3838
|
+
"navigation.delete": [{ action: `plugin::${PLUGIN_ID}.navigation.delete`, subject: null }],
|
|
3839
|
+
"navigation.edit-items": [
|
|
3840
|
+
{ action: `plugin::${PLUGIN_ID}.navigation.edit-items`, subject: null }
|
|
3841
|
+
],
|
|
3842
|
+
"page.routes": [{ action: `plugin::${PLUGIN_ID}.page.routes`, subject: null }],
|
|
3843
|
+
"settings.general.read": [
|
|
3844
|
+
{ action: `plugin::${PLUGIN_ID}.settings.general.read`, subject: null }
|
|
3845
|
+
],
|
|
3846
|
+
"settings.general.update": [
|
|
3847
|
+
{ action: `plugin::${PLUGIN_ID}.settings.general.update`, subject: null }
|
|
3848
|
+
],
|
|
3849
|
+
"settings.navigation.read": [
|
|
3850
|
+
{ action: `plugin::${PLUGIN_ID}.settings.navigation.read`, subject: null }
|
|
3851
|
+
],
|
|
3852
|
+
"settings.navigation.update": [
|
|
3853
|
+
{ action: `plugin::${PLUGIN_ID}.settings.navigation.update`, subject: null }
|
|
3854
|
+
]
|
|
3855
|
+
};
|
|
3803
3856
|
function buildPath(type, slug, parent) {
|
|
3804
3857
|
const parentSlug = type === "canonical" ? parent?.canonicalPath : parent?.path;
|
|
3805
3858
|
const parentPath = parentSlug ? `${parentSlug}/` : "";
|
|
@@ -3845,14 +3898,15 @@ function reducer(state, action) {
|
|
|
3845
3898
|
}
|
|
3846
3899
|
}
|
|
3847
3900
|
const Panel = ({ config }) => {
|
|
3848
|
-
const { form, model } = admin.unstable_useContentManagerContext();
|
|
3849
|
-
const { initialValues, values, onChange } = form;
|
|
3901
|
+
const { form, model, contentType } = admin.unstable_useContentManagerContext();
|
|
3902
|
+
const { initialValues, values, onChange, isSubmitting } = form;
|
|
3850
3903
|
const { getRelatedRoute, getAllRoutes, getProhibitedRouteIds } = useApi();
|
|
3851
3904
|
const { formatMessage } = reactIntl.useIntl();
|
|
3852
3905
|
const { get } = admin.useFetchClient();
|
|
3853
3906
|
const {
|
|
3854
|
-
allowedActions: { canUpdate, canCreate }
|
|
3907
|
+
allowedActions: { canUpdate, canCreate, canEditPath }
|
|
3855
3908
|
} = admin.useRBAC([
|
|
3909
|
+
...pluginPermissions["cm.edit-path"],
|
|
3856
3910
|
{
|
|
3857
3911
|
action: "plugin::content-manager.explorer.update",
|
|
3858
3912
|
subject: model,
|
|
@@ -3884,6 +3938,8 @@ const Panel = ({ config }) => {
|
|
|
3884
3938
|
slug: "",
|
|
3885
3939
|
overridePath: ""
|
|
3886
3940
|
});
|
|
3941
|
+
const [routeRefreshKey, setRouteRefreshKey] = React.useState(0);
|
|
3942
|
+
const wasSubmitting = React.useRef(false);
|
|
3887
3943
|
const hasUserChangedField = React.useRef(false);
|
|
3888
3944
|
const hasUserInteracted = React.useRef(false);
|
|
3889
3945
|
const initialRouteData = React.useRef(null);
|
|
@@ -3891,6 +3947,7 @@ const Panel = ({ config }) => {
|
|
|
3891
3947
|
const routeSourceField = config?.routeSourceField;
|
|
3892
3948
|
const sourceFieldValue = routeSourceField ? values[routeSourceField] || "" : "";
|
|
3893
3949
|
const initialSourceFieldValue = routeSourceField ? initialValues[routeSourceField] || "" : "";
|
|
3950
|
+
const isSourceFieldRequired = !!(routeSourceField && contentType?.attributes?.[routeSourceField]?.required);
|
|
3894
3951
|
const latestCheckPathRef = React.useRef(checkPath);
|
|
3895
3952
|
latestCheckPathRef.current = checkPath;
|
|
3896
3953
|
const debouncedCheckPath = React.useRef(
|
|
@@ -3917,7 +3974,7 @@ const Panel = ({ config }) => {
|
|
|
3917
3974
|
parentDocumentId: selectedParent?.documentId || null,
|
|
3918
3975
|
slug: isOverride ? overridePath : slug
|
|
3919
3976
|
};
|
|
3920
|
-
if (initialRouteData.current?.isOverride === isOverride && data.path === initialRouteData.current?.path && data.parentDocumentId === (initialRouteData.current?.parent?.documentId ?? null)) {
|
|
3977
|
+
if (initialRouteData.current?.isOverride === isOverride && data.path === initialRouteData.current?.path && data.parentDocumentId === (initialRouteData.current?.parent?.documentId ?? null) && sourceFieldValue.trim() === (initialRouteData.current?.title ?? "")) {
|
|
3921
3978
|
onChange("webatlas", void 0);
|
|
3922
3979
|
return;
|
|
3923
3980
|
}
|
|
@@ -3939,7 +3996,11 @@ const Panel = ({ config }) => {
|
|
|
3939
3996
|
hasUserChangedField.current = true;
|
|
3940
3997
|
}
|
|
3941
3998
|
if (!sourceFieldValue) {
|
|
3942
|
-
dispatchPath({ type: "NO_URL_CHECK", payload: "" });
|
|
3999
|
+
dispatchPath({ type: "NO_URL_CHECK", payload: initialRouteData.current?.path ?? "" });
|
|
4000
|
+
dispatchPath({
|
|
4001
|
+
type: "SET_CANONICALPATH",
|
|
4002
|
+
payload: initialRouteData.current?.canonicalPath ?? ""
|
|
4003
|
+
});
|
|
3943
4004
|
return;
|
|
3944
4005
|
}
|
|
3945
4006
|
if (initialLoadComplete && (hasUserChangedField.current || !route) && prevSourceValueRef.current !== sourceFieldValue && !isOverride) {
|
|
@@ -4017,7 +4078,16 @@ const Panel = ({ config }) => {
|
|
|
4017
4078
|
}
|
|
4018
4079
|
}
|
|
4019
4080
|
fetchRelatedRute();
|
|
4020
|
-
}, [config]);
|
|
4081
|
+
}, [config, routeRefreshKey]);
|
|
4082
|
+
React.useEffect(() => {
|
|
4083
|
+
if (isSubmitting) {
|
|
4084
|
+
wasSubmitting.current = true;
|
|
4085
|
+
return;
|
|
4086
|
+
}
|
|
4087
|
+
if (!wasSubmitting.current) return;
|
|
4088
|
+
wasSubmitting.current = false;
|
|
4089
|
+
setRouteRefreshKey((key) => key + 1);
|
|
4090
|
+
}, [isSubmitting]);
|
|
4021
4091
|
React.useEffect(() => {
|
|
4022
4092
|
if (!route || !routes.length) return;
|
|
4023
4093
|
const parentRoute = routes.find(
|
|
@@ -4085,7 +4155,13 @@ const Panel = ({ config }) => {
|
|
|
4085
4155
|
}) });
|
|
4086
4156
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "aside", "aria-labelledby": "URL Route", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
|
4087
4157
|
!route && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4088
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4158
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4159
|
+
NewPathInfo,
|
|
4160
|
+
{
|
|
4161
|
+
hasSlug: !!(isOverride ? path.overridePath : sourceFieldValue.trim()) || !isOverride && isSourceFieldRequired,
|
|
4162
|
+
routeSourceField
|
|
4163
|
+
}
|
|
4164
|
+
),
|
|
4089
4165
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 })
|
|
4090
4166
|
] }),
|
|
4091
4167
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4100,7 +4176,8 @@ const Panel = ({ config }) => {
|
|
|
4100
4176
|
},
|
|
4101
4177
|
prohibitedRouteIds,
|
|
4102
4178
|
defaultParentRoute: config.defaultParentRoute || "",
|
|
4103
|
-
isCreatingEntry: !initialValues.documentId
|
|
4179
|
+
isCreatingEntry: !initialValues.documentId,
|
|
4180
|
+
disabled: !canEditPath
|
|
4104
4181
|
}
|
|
4105
4182
|
),
|
|
4106
4183
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 }),
|
|
@@ -4112,7 +4189,8 @@ const Panel = ({ config }) => {
|
|
|
4112
4189
|
dispatchPath,
|
|
4113
4190
|
isOverride,
|
|
4114
4191
|
config,
|
|
4115
|
-
hasUserInteracted
|
|
4192
|
+
hasUserInteracted,
|
|
4193
|
+
disabled: !canEditPath
|
|
4116
4194
|
}
|
|
4117
4195
|
),
|
|
4118
4196
|
(validationState !== "initial" || isBlacklisted) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4134,7 +4212,7 @@ const Panel = ({ config }) => {
|
|
|
4134
4212
|
dispatchPath({ type: "SET_URL_CHECK_FLAG", payload: true });
|
|
4135
4213
|
setIsOverride(val);
|
|
4136
4214
|
},
|
|
4137
|
-
disabledCondition: !canCreate && !canUpdate
|
|
4215
|
+
disabledCondition: !canCreate && !canUpdate || !canEditPath
|
|
4138
4216
|
}
|
|
4139
4217
|
),
|
|
4140
4218
|
path.uidPath && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -4143,13 +4221,6 @@ const Panel = ({ config }) => {
|
|
|
4143
4221
|
] })
|
|
4144
4222
|
] }) });
|
|
4145
4223
|
};
|
|
4146
|
-
const pluginPermissions = {
|
|
4147
|
-
"cm.aside": [{ action: `plugin::${PLUGIN_ID}.cm.aside`, subject: null }],
|
|
4148
|
-
"page.navigation": [{ action: `plugin::${PLUGIN_ID}.page.navigation`, subject: null }],
|
|
4149
|
-
"page.routes": [{ action: `plugin::${PLUGIN_ID}.page.routes`, subject: null }],
|
|
4150
|
-
"settings.general": [{ action: `plugin::${PLUGIN_ID}.settings.general`, subject: null }],
|
|
4151
|
-
"settings.navigation": [{ action: `plugin::${PLUGIN_ID}.settings.navigation`, subject: null }]
|
|
4152
|
-
};
|
|
4153
4224
|
const CMEditViewAside = ({ model }) => {
|
|
4154
4225
|
const { contentTypes } = useAllContentTypes();
|
|
4155
4226
|
const { config } = usePluginConfig();
|
|
@@ -4206,7 +4277,7 @@ const index = {
|
|
|
4206
4277
|
id: `${PLUGIN_ID}.link.paths`,
|
|
4207
4278
|
defaultMessage: "Paths"
|
|
4208
4279
|
},
|
|
4209
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4280
|
+
Component: () => Promise.resolve().then(() => require("./index-jOCO4_-k.js")),
|
|
4210
4281
|
permissions: [pluginPermissions["page.routes"][0]]
|
|
4211
4282
|
});
|
|
4212
4283
|
app.addMenuLink({
|
|
@@ -4216,8 +4287,8 @@ const index = {
|
|
|
4216
4287
|
id: `${PLUGIN_ID}.link.navigation`,
|
|
4217
4288
|
defaultMessage: "Navigation"
|
|
4218
4289
|
},
|
|
4219
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4220
|
-
permissions: [pluginPermissions["
|
|
4290
|
+
Component: () => Promise.resolve().then(() => require("./index-JBUU7dE6.js")),
|
|
4291
|
+
permissions: [pluginPermissions["navigation.read"][0]]
|
|
4221
4292
|
});
|
|
4222
4293
|
app.addSettingsLink(
|
|
4223
4294
|
{
|
|
@@ -4234,8 +4305,8 @@ const index = {
|
|
|
4234
4305
|
},
|
|
4235
4306
|
id: `${PLUGIN_ID}-general`,
|
|
4236
4307
|
to: `${PLUGIN_ID}/general`,
|
|
4237
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4238
|
-
permissions: [pluginPermissions["settings.general"][0]]
|
|
4308
|
+
Component: () => Promise.resolve().then(() => require("./index-BxGPKxr_.js")),
|
|
4309
|
+
permissions: [pluginPermissions["settings.general.read"][0]]
|
|
4239
4310
|
}
|
|
4240
4311
|
);
|
|
4241
4312
|
app.addSettingsLink(PLUGIN_ID, {
|
|
@@ -4245,8 +4316,8 @@ const index = {
|
|
|
4245
4316
|
},
|
|
4246
4317
|
id: `${PLUGIN_ID}-navigation`,
|
|
4247
4318
|
to: `${PLUGIN_ID}/navigation`,
|
|
4248
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4249
|
-
permissions: [pluginPermissions["settings.navigation"][0]]
|
|
4319
|
+
Component: () => Promise.resolve().then(() => require("./index-uOC1Clyv.js")),
|
|
4320
|
+
permissions: [pluginPermissions["settings.navigation.read"][0]]
|
|
4250
4321
|
});
|
|
4251
4322
|
app.customFields.register({
|
|
4252
4323
|
name: "route-picker",
|
|
@@ -4261,7 +4332,7 @@ const index = {
|
|
|
4261
4332
|
defaultMessage: "Select a route"
|
|
4262
4333
|
},
|
|
4263
4334
|
components: {
|
|
4264
|
-
Input: async () => Promise.resolve().then(() => require("./RoutePicker-
|
|
4335
|
+
Input: async () => Promise.resolve().then(() => require("./RoutePicker-CwoMMhf_.js")).then((module2) => ({
|
|
4265
4336
|
default: module2.default
|
|
4266
4337
|
}))
|
|
4267
4338
|
},
|
|
@@ -4304,7 +4375,7 @@ const index = {
|
|
|
4304
4375
|
return Promise.all(
|
|
4305
4376
|
locales.map(async (locale) => {
|
|
4306
4377
|
try {
|
|
4307
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-
|
|
4378
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-Cl0vM1wA.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-DSmtmPYk.js")) }), `./translations/${locale}.json`, 3);
|
|
4308
4379
|
return { data, locale };
|
|
4309
4380
|
} catch {
|
|
4310
4381
|
return { data: {}, locale };
|
|
@@ -4324,6 +4395,7 @@ exports.getTranslation = getTranslation;
|
|
|
4324
4395
|
exports.index = index;
|
|
4325
4396
|
exports.isAbortError = isAbortError;
|
|
4326
4397
|
exports.pluginPermissions = pluginPermissions;
|
|
4398
|
+
exports.transformToUrl = transformToUrl;
|
|
4327
4399
|
exports.useAllContentTypes = useAllContentTypes;
|
|
4328
4400
|
exports.useApi = useApi;
|
|
4329
4401
|
exports.usePluginConfig = usePluginConfig;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useMemo } from "react";
|
|
3
|
+
import { Typography, RawTable, Thead, Tr, Th, Tbody, Td, Field } from "@strapi/design-system";
|
|
4
|
+
import { useNotification, useRBAC, Page } from "@strapi/strapi/admin";
|
|
5
|
+
import { u as useApi, p as pluginPermissions, i as isAbortError, g as getTranslation } from "./index-BKhrfzjO.mjs";
|
|
6
|
+
import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
|
|
7
|
+
import { useIntl } from "react-intl";
|
|
8
|
+
import "@strapi/icons/symbols";
|
|
9
|
+
import "@strapi/icons";
|
|
10
|
+
import { P as PageWrapper, C as ContentBox } from "./ContentBox-KyQN2KGV.mjs";
|
|
11
|
+
const toLevels = (maxDepth) => String(maxDepth + 1);
|
|
12
|
+
const Settings = () => {
|
|
13
|
+
const { getNavigationDepths, updateNavigationDepths } = useApi();
|
|
14
|
+
const { toggleNotification } = useNotification();
|
|
15
|
+
const getErrorMessage = useErrorMessage();
|
|
16
|
+
const { formatMessage } = useIntl();
|
|
17
|
+
const [depths, setDepths] = useState([]);
|
|
18
|
+
const [levels, setLevels] = useState({});
|
|
19
|
+
const [loading, setLoading] = useState(true);
|
|
20
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
21
|
+
const {
|
|
22
|
+
isLoading: isLoadingPermissions,
|
|
23
|
+
allowedActions: { canUpdate }
|
|
24
|
+
} = useRBAC(pluginPermissions["settings.navigation.update"]);
|
|
25
|
+
const applyDepths = (nextDepths) => {
|
|
26
|
+
setDepths(nextDepths);
|
|
27
|
+
setLevels(
|
|
28
|
+
Object.fromEntries(nextDepths.map((depth) => [depth.documentId, toLevels(depth.maxDepth)]))
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
const showError = (error) => toggleNotification({
|
|
32
|
+
type: "danger",
|
|
33
|
+
message: getErrorMessage(
|
|
34
|
+
error,
|
|
35
|
+
formatMessage({
|
|
36
|
+
id: getTranslation("notification.error"),
|
|
37
|
+
defaultMessage: "An error occurred"
|
|
38
|
+
})
|
|
39
|
+
)
|
|
40
|
+
});
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
getNavigationDepths().then(applyDepths).catch((error) => {
|
|
43
|
+
if (isAbortError(error)) return;
|
|
44
|
+
console.error(error);
|
|
45
|
+
showError(error);
|
|
46
|
+
}).finally(() => setLoading(false));
|
|
47
|
+
}, []);
|
|
48
|
+
const errors = useMemo(() => {
|
|
49
|
+
const result = {};
|
|
50
|
+
depths.forEach(({ documentId, deepestDepth }) => {
|
|
51
|
+
const value = Number(levels[documentId]);
|
|
52
|
+
const minLevels = Math.max(1, deepestDepth + 1);
|
|
53
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
54
|
+
result[documentId] = formatMessage({
|
|
55
|
+
id: getTranslation("settings.page.navigation.maxDepth.invalid"),
|
|
56
|
+
defaultMessage: "At least 1"
|
|
57
|
+
});
|
|
58
|
+
} else if (value < minLevels) {
|
|
59
|
+
result[documentId] = formatMessage(
|
|
60
|
+
{
|
|
61
|
+
id: getTranslation("settings.page.navigation.maxDepth.tooLow"),
|
|
62
|
+
defaultMessage: "At least {count}, the navigation already has items on level {count}"
|
|
63
|
+
},
|
|
64
|
+
{ count: minLevels }
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return result;
|
|
69
|
+
}, [depths, levels, formatMessage]);
|
|
70
|
+
const changedDepths = depths.filter(({ documentId, maxDepth }) => levels[documentId] !== toLevels(maxDepth)).map(({ documentId }) => ({ documentId, maxDepth: Number(levels[documentId]) - 1 }));
|
|
71
|
+
async function save() {
|
|
72
|
+
setIsSaving(true);
|
|
73
|
+
try {
|
|
74
|
+
applyDepths(await updateNavigationDepths(changedDepths));
|
|
75
|
+
toggleNotification({
|
|
76
|
+
type: "success",
|
|
77
|
+
message: formatMessage({
|
|
78
|
+
id: getTranslation("notification.settings.saved"),
|
|
79
|
+
defaultMessage: "Settings saved successfully"
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error(error);
|
|
84
|
+
showError(error);
|
|
85
|
+
} finally {
|
|
86
|
+
setIsSaving(false);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (loading || isLoadingPermissions) {
|
|
90
|
+
return /* @__PURE__ */ jsx(
|
|
91
|
+
PageWrapper,
|
|
92
|
+
{
|
|
93
|
+
isSaving,
|
|
94
|
+
subtitle: formatMessage({
|
|
95
|
+
id: getTranslation("loading"),
|
|
96
|
+
defaultMessage: "Loading..."
|
|
97
|
+
}),
|
|
98
|
+
disabledCondition: true,
|
|
99
|
+
children: /* @__PURE__ */ jsx(FullLoader, { height: 200 })
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions["settings.navigation.read"], children: /* @__PURE__ */ jsx(
|
|
104
|
+
PageWrapper,
|
|
105
|
+
{
|
|
106
|
+
save: canUpdate ? save : void 0,
|
|
107
|
+
isSaving,
|
|
108
|
+
subtitle: formatMessage({
|
|
109
|
+
id: getTranslation("settings.page.navigation.subtitle"),
|
|
110
|
+
defaultMessage: "Configure navigation settings"
|
|
111
|
+
}),
|
|
112
|
+
disabledCondition: changedDepths.length === 0 || Object.keys(errors).length > 0,
|
|
113
|
+
children: /* @__PURE__ */ jsxs(
|
|
114
|
+
ContentBox,
|
|
115
|
+
{
|
|
116
|
+
title: formatMessage({
|
|
117
|
+
id: getTranslation("settings.page.navigation.maxDepth.title"),
|
|
118
|
+
defaultMessage: "Maximum depth"
|
|
119
|
+
}),
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral600", tag: "p", children: formatMessage({
|
|
122
|
+
id: getTranslation("settings.page.navigation.maxDepth.description"),
|
|
123
|
+
defaultMessage: "Sets how many levels a navigation may have. It cannot be lower than the deepest existing level."
|
|
124
|
+
}) }),
|
|
125
|
+
depths.length === 0 ? /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", tag: "p", children: formatMessage({
|
|
126
|
+
id: getTranslation("settings.page.navigation.maxDepth.empty"),
|
|
127
|
+
defaultMessage: "There are no navigations yet."
|
|
128
|
+
}) }) : /* @__PURE__ */ jsxs(RawTable, { colCount: 3, rowCount: depths.length + 1, style: { width: "100%" }, children: [
|
|
129
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
130
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
|
|
131
|
+
id: getTranslation("settings.page.navigation.navigation"),
|
|
132
|
+
defaultMessage: "Navigation"
|
|
133
|
+
}) }) }),
|
|
134
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
|
|
135
|
+
id: getTranslation("settings.page.navigation.maxDepth.levels"),
|
|
136
|
+
defaultMessage: "Maximum levels"
|
|
137
|
+
}) }) }),
|
|
138
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
|
|
139
|
+
id: getTranslation("settings.page.navigation.maxDepth.deepest"),
|
|
140
|
+
defaultMessage: "Current deepest level"
|
|
141
|
+
}) }) })
|
|
142
|
+
] }) }),
|
|
143
|
+
/* @__PURE__ */ jsx(Tbody, { children: depths.map(({ documentId, name, deepestDepth }) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
144
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: name }) }),
|
|
145
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Field.Root, { error: errors[documentId], children: [
|
|
146
|
+
/* @__PURE__ */ jsx(
|
|
147
|
+
Field.Input,
|
|
148
|
+
{
|
|
149
|
+
type: "number",
|
|
150
|
+
min: 1,
|
|
151
|
+
step: 1,
|
|
152
|
+
"aria-label": formatMessage({
|
|
153
|
+
id: getTranslation("settings.page.navigation.maxDepth.levels"),
|
|
154
|
+
defaultMessage: "Maximum levels"
|
|
155
|
+
}),
|
|
156
|
+
value: levels[documentId] ?? "",
|
|
157
|
+
disabled: !canUpdate,
|
|
158
|
+
onChange: (e) => setLevels((current) => ({ ...current, [documentId]: e.target.value }))
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
162
|
+
] }) }),
|
|
163
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: deepestDepth < 0 ? "–" : deepestDepth + 1 }) })
|
|
164
|
+
] }, documentId)) })
|
|
165
|
+
] })
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
) });
|
|
171
|
+
};
|
|
172
|
+
export {
|
|
173
|
+
Settings as default
|
|
174
|
+
};
|