@mattisvensson/strapi-plugin-webatlas 0.12.2 → 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 +46 -1
- package/dist/admin/{SettingTitle-DXGCUfum.js → ContentBox-D4PGQ8eh.js} +1 -5
- package/dist/admin/{SettingTitle-C1_2epDJ.mjs → ContentBox-KyQN2KGV.mjs} +2 -6
- package/dist/admin/{RoutePicker-C6LpgVMi.mjs → RoutePicker-CgndSXoF.mjs} +1 -1
- package/dist/admin/{RoutePicker-DvzQH2CX.js → RoutePicker-CwoMMhf_.js} +1 -1
- package/dist/admin/WarningBox-AyYq0Onj.mjs +18 -0
- package/dist/admin/{WarningBox-BHlYlKQ8.js → WarningBox-FF1yYDXP.js} +0 -24
- package/dist/admin/{de-BWUGdpM0.js → de-Cl0vM1wA.js} +51 -4
- package/dist/admin/{de-Dnk_hvMW.mjs → de-DWs5ckOd.mjs} +51 -4
- package/dist/admin/{en-D5EqZSGy.mjs → en-CyhISGZi.mjs} +51 -4
- package/dist/admin/{en-DOk8P6X5.js → en-DSmtmPYk.js} +51 -4
- package/dist/admin/{index-CVrufPeL.mjs → index-BKhrfzjO.mjs} +65 -26
- package/dist/admin/{index-DuSnxRbO.mjs → index-Bv5Ri-ri.mjs} +44 -12
- package/dist/admin/{index-D7zg69uM.js → index-BxGPKxr_.js} +50 -18
- package/dist/admin/index-Ctm4TBT5.mjs +5308 -0
- package/dist/admin/{index-Y4uwBSjP.mjs → index-D2O7sLKs.mjs} +1 -1
- package/dist/admin/{index-DHNPW0YT.js → index-DTrsl_uN.js} +65 -26
- package/dist/admin/index-FvaXwOH0.mjs +174 -0
- package/dist/admin/index-JBUU7dE6.js +5308 -0
- package/dist/admin/{index-Dp_eCRFS.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 +314 -51
- package/dist/server/index.mjs +315 -52
- package/dist/server/src/index.d.ts +16 -3
- package/package.json +1 -1
- package/dist/admin/WarningBox-CfIVF0O-.mjs +0 -42
- package/dist/admin/index-DC-2-FsX.mjs +0 -9622
- package/dist/admin/index-Dx4gvFWK.mjs +0 -147
- package/dist/admin/index-FuvoHpAT.js +0 -147
- package/dist/admin/index-RmZ3LQPu.js +0 -9622
|
@@ -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) {
|
|
@@ -3683,7 +3693,14 @@ function Tooltip({ description }) {
|
|
|
3683
3693
|
) }) })
|
|
3684
3694
|
] }) });
|
|
3685
3695
|
}
|
|
3686
|
-
function PathInput({
|
|
3696
|
+
function PathInput({
|
|
3697
|
+
path,
|
|
3698
|
+
dispatchPath,
|
|
3699
|
+
isOverride,
|
|
3700
|
+
config,
|
|
3701
|
+
hasUserInteracted,
|
|
3702
|
+
disabled
|
|
3703
|
+
}) {
|
|
3687
3704
|
const { formatMessage } = reactIntl.useIntl();
|
|
3688
3705
|
const displayedPath = isOverride && path.overridePath !== void 0 ? path.overridePath : path.value ?? "";
|
|
3689
3706
|
const inputBorder = path.replacement === null ? "" : path.replacement ? "1px solid #ee5e52" : "1px solid #5cb176";
|
|
@@ -3725,7 +3742,7 @@ function PathInput({ path, dispatchPath, isOverride, config, hasUserInteracted }
|
|
|
3725
3742
|
hasUserInteracted.current = true;
|
|
3726
3743
|
dispatchPath({ type: "SET_OVERRIDEPATH", payload: e.target.value });
|
|
3727
3744
|
},
|
|
3728
|
-
disabled: !isOverride,
|
|
3745
|
+
disabled: !isOverride || disabled,
|
|
3729
3746
|
onBlur: (e) => {
|
|
3730
3747
|
dispatchPath({
|
|
3731
3748
|
type: "SET_OVERRIDEPATH",
|
|
@@ -3751,7 +3768,8 @@ function RouteStructure({
|
|
|
3751
3768
|
canonicalPath,
|
|
3752
3769
|
prohibitedRouteIds,
|
|
3753
3770
|
defaultParentRoute,
|
|
3754
|
-
isCreatingEntry
|
|
3771
|
+
isCreatingEntry,
|
|
3772
|
+
disabled
|
|
3755
3773
|
}) {
|
|
3756
3774
|
const { formatMessage } = reactIntl.useIntl();
|
|
3757
3775
|
const handleSelectParent = (value) => {
|
|
@@ -3782,7 +3800,7 @@ function RouteStructure({
|
|
|
3782
3800
|
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.label"),
|
|
3783
3801
|
defaultMessage: "Place under"
|
|
3784
3802
|
}) }),
|
|
3785
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { value: selectValue, onValueChange: handleSelectParent, children: [
|
|
3803
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { value: selectValue, onValueChange: handleSelectParent, disabled, children: [
|
|
3786
3804
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "", children: formatMessage({
|
|
3787
3805
|
id: getTranslation("components.CMEditViewAside.path.input.parentSelect.rootPath"),
|
|
3788
3806
|
defaultMessage: "None (root path)"
|
|
@@ -3811,6 +3829,30 @@ function RouteStructure({
|
|
|
3811
3829
|
] })
|
|
3812
3830
|
] });
|
|
3813
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
|
+
};
|
|
3814
3856
|
function buildPath(type, slug, parent) {
|
|
3815
3857
|
const parentSlug = type === "canonical" ? parent?.canonicalPath : parent?.path;
|
|
3816
3858
|
const parentPath = parentSlug ? `${parentSlug}/` : "";
|
|
@@ -3862,8 +3904,9 @@ const Panel = ({ config }) => {
|
|
|
3862
3904
|
const { formatMessage } = reactIntl.useIntl();
|
|
3863
3905
|
const { get } = admin.useFetchClient();
|
|
3864
3906
|
const {
|
|
3865
|
-
allowedActions: { canUpdate, canCreate }
|
|
3907
|
+
allowedActions: { canUpdate, canCreate, canEditPath }
|
|
3866
3908
|
} = admin.useRBAC([
|
|
3909
|
+
...pluginPermissions["cm.edit-path"],
|
|
3867
3910
|
{
|
|
3868
3911
|
action: "plugin::content-manager.explorer.update",
|
|
3869
3912
|
subject: model,
|
|
@@ -4133,7 +4176,8 @@ const Panel = ({ config }) => {
|
|
|
4133
4176
|
},
|
|
4134
4177
|
prohibitedRouteIds,
|
|
4135
4178
|
defaultParentRoute: config.defaultParentRoute || "",
|
|
4136
|
-
isCreatingEntry: !initialValues.documentId
|
|
4179
|
+
isCreatingEntry: !initialValues.documentId,
|
|
4180
|
+
disabled: !canEditPath
|
|
4137
4181
|
}
|
|
4138
4182
|
),
|
|
4139
4183
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 }),
|
|
@@ -4145,7 +4189,8 @@ const Panel = ({ config }) => {
|
|
|
4145
4189
|
dispatchPath,
|
|
4146
4190
|
isOverride,
|
|
4147
4191
|
config,
|
|
4148
|
-
hasUserInteracted
|
|
4192
|
+
hasUserInteracted,
|
|
4193
|
+
disabled: !canEditPath
|
|
4149
4194
|
}
|
|
4150
4195
|
),
|
|
4151
4196
|
(validationState !== "initial" || isBlacklisted) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4167,7 +4212,7 @@ const Panel = ({ config }) => {
|
|
|
4167
4212
|
dispatchPath({ type: "SET_URL_CHECK_FLAG", payload: true });
|
|
4168
4213
|
setIsOverride(val);
|
|
4169
4214
|
},
|
|
4170
|
-
disabledCondition: !canCreate && !canUpdate
|
|
4215
|
+
disabledCondition: !canCreate && !canUpdate || !canEditPath
|
|
4171
4216
|
}
|
|
4172
4217
|
),
|
|
4173
4218
|
path.uidPath && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -4176,13 +4221,6 @@ const Panel = ({ config }) => {
|
|
|
4176
4221
|
] })
|
|
4177
4222
|
] }) });
|
|
4178
4223
|
};
|
|
4179
|
-
const pluginPermissions = {
|
|
4180
|
-
"cm.aside": [{ action: `plugin::${PLUGIN_ID}.cm.aside`, subject: null }],
|
|
4181
|
-
"page.navigation": [{ action: `plugin::${PLUGIN_ID}.page.navigation`, subject: null }],
|
|
4182
|
-
"page.routes": [{ action: `plugin::${PLUGIN_ID}.page.routes`, subject: null }],
|
|
4183
|
-
"settings.general": [{ action: `plugin::${PLUGIN_ID}.settings.general`, subject: null }],
|
|
4184
|
-
"settings.navigation": [{ action: `plugin::${PLUGIN_ID}.settings.navigation`, subject: null }]
|
|
4185
|
-
};
|
|
4186
4224
|
const CMEditViewAside = ({ model }) => {
|
|
4187
4225
|
const { contentTypes } = useAllContentTypes();
|
|
4188
4226
|
const { config } = usePluginConfig();
|
|
@@ -4239,7 +4277,7 @@ const index = {
|
|
|
4239
4277
|
id: `${PLUGIN_ID}.link.paths`,
|
|
4240
4278
|
defaultMessage: "Paths"
|
|
4241
4279
|
},
|
|
4242
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4280
|
+
Component: () => Promise.resolve().then(() => require("./index-jOCO4_-k.js")),
|
|
4243
4281
|
permissions: [pluginPermissions["page.routes"][0]]
|
|
4244
4282
|
});
|
|
4245
4283
|
app.addMenuLink({
|
|
@@ -4249,8 +4287,8 @@ const index = {
|
|
|
4249
4287
|
id: `${PLUGIN_ID}.link.navigation`,
|
|
4250
4288
|
defaultMessage: "Navigation"
|
|
4251
4289
|
},
|
|
4252
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4253
|
-
permissions: [pluginPermissions["
|
|
4290
|
+
Component: () => Promise.resolve().then(() => require("./index-JBUU7dE6.js")),
|
|
4291
|
+
permissions: [pluginPermissions["navigation.read"][0]]
|
|
4254
4292
|
});
|
|
4255
4293
|
app.addSettingsLink(
|
|
4256
4294
|
{
|
|
@@ -4267,8 +4305,8 @@ const index = {
|
|
|
4267
4305
|
},
|
|
4268
4306
|
id: `${PLUGIN_ID}-general`,
|
|
4269
4307
|
to: `${PLUGIN_ID}/general`,
|
|
4270
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4271
|
-
permissions: [pluginPermissions["settings.general"][0]]
|
|
4308
|
+
Component: () => Promise.resolve().then(() => require("./index-BxGPKxr_.js")),
|
|
4309
|
+
permissions: [pluginPermissions["settings.general.read"][0]]
|
|
4272
4310
|
}
|
|
4273
4311
|
);
|
|
4274
4312
|
app.addSettingsLink(PLUGIN_ID, {
|
|
@@ -4278,8 +4316,8 @@ const index = {
|
|
|
4278
4316
|
},
|
|
4279
4317
|
id: `${PLUGIN_ID}-navigation`,
|
|
4280
4318
|
to: `${PLUGIN_ID}/navigation`,
|
|
4281
|
-
Component: () => Promise.resolve().then(() => require("./index-
|
|
4282
|
-
permissions: [pluginPermissions["settings.navigation"][0]]
|
|
4319
|
+
Component: () => Promise.resolve().then(() => require("./index-uOC1Clyv.js")),
|
|
4320
|
+
permissions: [pluginPermissions["settings.navigation.read"][0]]
|
|
4283
4321
|
});
|
|
4284
4322
|
app.customFields.register({
|
|
4285
4323
|
name: "route-picker",
|
|
@@ -4294,7 +4332,7 @@ const index = {
|
|
|
4294
4332
|
defaultMessage: "Select a route"
|
|
4295
4333
|
},
|
|
4296
4334
|
components: {
|
|
4297
|
-
Input: async () => Promise.resolve().then(() => require("./RoutePicker-
|
|
4335
|
+
Input: async () => Promise.resolve().then(() => require("./RoutePicker-CwoMMhf_.js")).then((module2) => ({
|
|
4298
4336
|
default: module2.default
|
|
4299
4337
|
}))
|
|
4300
4338
|
},
|
|
@@ -4337,7 +4375,7 @@ const index = {
|
|
|
4337
4375
|
return Promise.all(
|
|
4338
4376
|
locales.map(async (locale) => {
|
|
4339
4377
|
try {
|
|
4340
|
-
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);
|
|
4341
4379
|
return { data, locale };
|
|
4342
4380
|
} catch {
|
|
4343
4381
|
return { data: {}, locale };
|
|
@@ -4357,6 +4395,7 @@ exports.getTranslation = getTranslation;
|
|
|
4357
4395
|
exports.index = index;
|
|
4358
4396
|
exports.isAbortError = isAbortError;
|
|
4359
4397
|
exports.pluginPermissions = pluginPermissions;
|
|
4398
|
+
exports.transformToUrl = transformToUrl;
|
|
4360
4399
|
exports.useAllContentTypes = useAllContentTypes;
|
|
4361
4400
|
exports.useApi = useApi;
|
|
4362
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
|
+
};
|