@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.
Files changed (32) hide show
  1. package/README.md +46 -1
  2. package/dist/admin/{SettingTitle-DXGCUfum.js → ContentBox-D4PGQ8eh.js} +1 -5
  3. package/dist/admin/{SettingTitle-C1_2epDJ.mjs → ContentBox-KyQN2KGV.mjs} +2 -6
  4. package/dist/admin/{RoutePicker-C6LpgVMi.mjs → RoutePicker-CgndSXoF.mjs} +1 -1
  5. package/dist/admin/{RoutePicker-DvzQH2CX.js → RoutePicker-CwoMMhf_.js} +1 -1
  6. package/dist/admin/WarningBox-AyYq0Onj.mjs +18 -0
  7. package/dist/admin/{WarningBox-BHlYlKQ8.js → WarningBox-FF1yYDXP.js} +0 -24
  8. package/dist/admin/{de-BWUGdpM0.js → de-Cl0vM1wA.js} +51 -4
  9. package/dist/admin/{de-Dnk_hvMW.mjs → de-DWs5ckOd.mjs} +51 -4
  10. package/dist/admin/{en-D5EqZSGy.mjs → en-CyhISGZi.mjs} +51 -4
  11. package/dist/admin/{en-DOk8P6X5.js → en-DSmtmPYk.js} +51 -4
  12. package/dist/admin/{index-CVrufPeL.mjs → index-BKhrfzjO.mjs} +65 -26
  13. package/dist/admin/{index-DuSnxRbO.mjs → index-Bv5Ri-ri.mjs} +44 -12
  14. package/dist/admin/{index-D7zg69uM.js → index-BxGPKxr_.js} +50 -18
  15. package/dist/admin/index-Ctm4TBT5.mjs +5308 -0
  16. package/dist/admin/{index-Y4uwBSjP.mjs → index-D2O7sLKs.mjs} +1 -1
  17. package/dist/admin/{index-DHNPW0YT.js → index-DTrsl_uN.js} +65 -26
  18. package/dist/admin/index-FvaXwOH0.mjs +174 -0
  19. package/dist/admin/index-JBUU7dE6.js +5308 -0
  20. package/dist/admin/{index-Dp_eCRFS.js → index-jOCO4_-k.js} +1 -1
  21. package/dist/admin/index-uOC1Clyv.js +174 -0
  22. package/dist/admin/index.js +1 -1
  23. package/dist/admin/index.mjs +1 -1
  24. package/dist/server/index.js +314 -51
  25. package/dist/server/index.mjs +315 -52
  26. package/dist/server/src/index.d.ts +16 -3
  27. package/package.json +1 -1
  28. package/dist/admin/WarningBox-CfIVF0O-.mjs +0 -42
  29. package/dist/admin/index-DC-2-FsX.mjs +0 -9622
  30. package/dist/admin/index-Dx4gvFWK.mjs +0 -147
  31. package/dist/admin/index-FuvoHpAT.js +0 -147
  32. package/dist/admin/index-RmZ3LQPu.js +0 -9622
@@ -52,7 +52,7 @@ function transformToUrl(input, replaceSlash = true) {
52
52
  input = input.replace(/-+/g, "-");
53
53
  return input;
54
54
  }
55
- const version = "0.12.1";
55
+ const version = "0.12.2";
56
56
  const strapi = { "name": "webatlas", "displayName": "Webatlas" };
57
57
  const pluginPkg = {
58
58
  version,
@@ -158,6 +158,14 @@ function useApi() {
158
158
  });
159
159
  return data;
160
160
  };
161
+ const getNavigationDepths = async () => {
162
+ const { data } = await get(`/${PLUGIN_ID}/settings/navigation-depths`);
163
+ return data;
164
+ };
165
+ const updateNavigationDepths = async (depths) => {
166
+ const { data } = await put(`/${PLUGIN_ID}/settings/navigation-depths`, { data: depths });
167
+ return data;
168
+ };
161
169
  return {
162
170
  fetchAllContentTypes,
163
171
  fetchAllEntities,
@@ -169,7 +177,9 @@ function useApi() {
169
177
  createNavigation,
170
178
  deleteNavigation,
171
179
  updateNavigation,
172
- updateNavigationItemStructure
180
+ updateNavigationItemStructure,
181
+ getNavigationDepths,
182
+ updateNavigationDepths
173
183
  };
174
184
  }
175
185
  function debounce(func, wait) {
@@ -3665,7 +3675,14 @@ function Tooltip({ description }) {
3665
3675
  ) }) })
3666
3676
  ] }) });
3667
3677
  }
3668
- function PathInput({ path, dispatchPath, isOverride, config, hasUserInteracted }) {
3678
+ function PathInput({
3679
+ path,
3680
+ dispatchPath,
3681
+ isOverride,
3682
+ config,
3683
+ hasUserInteracted,
3684
+ disabled
3685
+ }) {
3669
3686
  const { formatMessage } = useIntl();
3670
3687
  const displayedPath = isOverride && path.overridePath !== void 0 ? path.overridePath : path.value ?? "";
3671
3688
  const inputBorder = path.replacement === null ? "" : path.replacement ? "1px solid #ee5e52" : "1px solid #5cb176";
@@ -3707,7 +3724,7 @@ function PathInput({ path, dispatchPath, isOverride, config, hasUserInteracted }
3707
3724
  hasUserInteracted.current = true;
3708
3725
  dispatchPath({ type: "SET_OVERRIDEPATH", payload: e.target.value });
3709
3726
  },
3710
- disabled: !isOverride,
3727
+ disabled: !isOverride || disabled,
3711
3728
  onBlur: (e) => {
3712
3729
  dispatchPath({
3713
3730
  type: "SET_OVERRIDEPATH",
@@ -3733,7 +3750,8 @@ function RouteStructure({
3733
3750
  canonicalPath,
3734
3751
  prohibitedRouteIds,
3735
3752
  defaultParentRoute,
3736
- isCreatingEntry
3753
+ isCreatingEntry,
3754
+ disabled
3737
3755
  }) {
3738
3756
  const { formatMessage } = useIntl();
3739
3757
  const handleSelectParent = (value) => {
@@ -3764,7 +3782,7 @@ function RouteStructure({
3764
3782
  id: getTranslation("components.CMEditViewAside.path.input.parentSelect.label"),
3765
3783
  defaultMessage: "Place under"
3766
3784
  }) }),
3767
- /* @__PURE__ */ jsxs(SingleSelect, { value: selectValue, onValueChange: handleSelectParent, children: [
3785
+ /* @__PURE__ */ jsxs(SingleSelect, { value: selectValue, onValueChange: handleSelectParent, disabled, children: [
3768
3786
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: formatMessage({
3769
3787
  id: getTranslation("components.CMEditViewAside.path.input.parentSelect.rootPath"),
3770
3788
  defaultMessage: "None (root path)"
@@ -3793,6 +3811,30 @@ function RouteStructure({
3793
3811
  ] })
3794
3812
  ] });
3795
3813
  }
3814
+ const pluginPermissions = {
3815
+ "cm.aside": [{ action: `plugin::${PLUGIN_ID}.cm.aside`, subject: null }],
3816
+ "cm.edit-path": [{ action: `plugin::${PLUGIN_ID}.cm.edit-path`, subject: null }],
3817
+ "navigation.read": [{ action: `plugin::${PLUGIN_ID}.navigation.read`, subject: null }],
3818
+ "navigation.create": [{ action: `plugin::${PLUGIN_ID}.navigation.create`, subject: null }],
3819
+ "navigation.update": [{ action: `plugin::${PLUGIN_ID}.navigation.update`, subject: null }],
3820
+ "navigation.delete": [{ action: `plugin::${PLUGIN_ID}.navigation.delete`, subject: null }],
3821
+ "navigation.edit-items": [
3822
+ { action: `plugin::${PLUGIN_ID}.navigation.edit-items`, subject: null }
3823
+ ],
3824
+ "page.routes": [{ action: `plugin::${PLUGIN_ID}.page.routes`, subject: null }],
3825
+ "settings.general.read": [
3826
+ { action: `plugin::${PLUGIN_ID}.settings.general.read`, subject: null }
3827
+ ],
3828
+ "settings.general.update": [
3829
+ { action: `plugin::${PLUGIN_ID}.settings.general.update`, subject: null }
3830
+ ],
3831
+ "settings.navigation.read": [
3832
+ { action: `plugin::${PLUGIN_ID}.settings.navigation.read`, subject: null }
3833
+ ],
3834
+ "settings.navigation.update": [
3835
+ { action: `plugin::${PLUGIN_ID}.settings.navigation.update`, subject: null }
3836
+ ]
3837
+ };
3796
3838
  function buildPath(type, slug, parent) {
3797
3839
  const parentSlug = type === "canonical" ? parent?.canonicalPath : parent?.path;
3798
3840
  const parentPath = parentSlug ? `${parentSlug}/` : "";
@@ -3844,8 +3886,9 @@ const Panel = ({ config }) => {
3844
3886
  const { formatMessage } = useIntl();
3845
3887
  const { get } = useFetchClient();
3846
3888
  const {
3847
- allowedActions: { canUpdate, canCreate }
3889
+ allowedActions: { canUpdate, canCreate, canEditPath }
3848
3890
  } = useRBAC([
3891
+ ...pluginPermissions["cm.edit-path"],
3849
3892
  {
3850
3893
  action: "plugin::content-manager.explorer.update",
3851
3894
  subject: model,
@@ -4115,7 +4158,8 @@ const Panel = ({ config }) => {
4115
4158
  },
4116
4159
  prohibitedRouteIds,
4117
4160
  defaultParentRoute: config.defaultParentRoute || "",
4118
- isCreatingEntry: !initialValues.documentId
4161
+ isCreatingEntry: !initialValues.documentId,
4162
+ disabled: !canEditPath
4119
4163
  }
4120
4164
  ),
4121
4165
  /* @__PURE__ */ jsx(Divider, { marginTop: 2, marginBottom: 2 }),
@@ -4127,7 +4171,8 @@ const Panel = ({ config }) => {
4127
4171
  dispatchPath,
4128
4172
  isOverride,
4129
4173
  config,
4130
- hasUserInteracted
4174
+ hasUserInteracted,
4175
+ disabled: !canEditPath
4131
4176
  }
4132
4177
  ),
4133
4178
  (validationState !== "initial" || isBlacklisted) && /* @__PURE__ */ jsx(
@@ -4149,7 +4194,7 @@ const Panel = ({ config }) => {
4149
4194
  dispatchPath({ type: "SET_URL_CHECK_FLAG", payload: true });
4150
4195
  setIsOverride(val);
4151
4196
  },
4152
- disabledCondition: !canCreate && !canUpdate
4197
+ disabledCondition: !canCreate && !canUpdate || !canEditPath
4153
4198
  }
4154
4199
  ),
4155
4200
  path.uidPath && /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -4158,13 +4203,6 @@ const Panel = ({ config }) => {
4158
4203
  ] })
4159
4204
  ] }) });
4160
4205
  };
4161
- const pluginPermissions = {
4162
- "cm.aside": [{ action: `plugin::${PLUGIN_ID}.cm.aside`, subject: null }],
4163
- "page.navigation": [{ action: `plugin::${PLUGIN_ID}.page.navigation`, subject: null }],
4164
- "page.routes": [{ action: `plugin::${PLUGIN_ID}.page.routes`, subject: null }],
4165
- "settings.general": [{ action: `plugin::${PLUGIN_ID}.settings.general`, subject: null }],
4166
- "settings.navigation": [{ action: `plugin::${PLUGIN_ID}.settings.navigation`, subject: null }]
4167
- };
4168
4206
  const CMEditViewAside = ({ model }) => {
4169
4207
  const { contentTypes } = useAllContentTypes();
4170
4208
  const { config } = usePluginConfig();
@@ -4221,7 +4259,7 @@ const index = {
4221
4259
  id: `${PLUGIN_ID}.link.paths`,
4222
4260
  defaultMessage: "Paths"
4223
4261
  },
4224
- Component: () => import("./index-Y4uwBSjP.mjs"),
4262
+ Component: () => import("./index-D2O7sLKs.mjs"),
4225
4263
  permissions: [pluginPermissions["page.routes"][0]]
4226
4264
  });
4227
4265
  app.addMenuLink({
@@ -4231,8 +4269,8 @@ const index = {
4231
4269
  id: `${PLUGIN_ID}.link.navigation`,
4232
4270
  defaultMessage: "Navigation"
4233
4271
  },
4234
- Component: () => import("./index-DC-2-FsX.mjs"),
4235
- permissions: [pluginPermissions["page.navigation"][0]]
4272
+ Component: () => import("./index-Ctm4TBT5.mjs"),
4273
+ permissions: [pluginPermissions["navigation.read"][0]]
4236
4274
  });
4237
4275
  app.addSettingsLink(
4238
4276
  {
@@ -4249,8 +4287,8 @@ const index = {
4249
4287
  },
4250
4288
  id: `${PLUGIN_ID}-general`,
4251
4289
  to: `${PLUGIN_ID}/general`,
4252
- Component: () => import("./index-DuSnxRbO.mjs"),
4253
- permissions: [pluginPermissions["settings.general"][0]]
4290
+ Component: () => import("./index-Bv5Ri-ri.mjs"),
4291
+ permissions: [pluginPermissions["settings.general.read"][0]]
4254
4292
  }
4255
4293
  );
4256
4294
  app.addSettingsLink(PLUGIN_ID, {
@@ -4260,8 +4298,8 @@ const index = {
4260
4298
  },
4261
4299
  id: `${PLUGIN_ID}-navigation`,
4262
4300
  to: `${PLUGIN_ID}/navigation`,
4263
- Component: () => import("./index-Dx4gvFWK.mjs"),
4264
- permissions: [pluginPermissions["settings.navigation"][0]]
4301
+ Component: () => import("./index-FvaXwOH0.mjs"),
4302
+ permissions: [pluginPermissions["settings.navigation.read"][0]]
4265
4303
  });
4266
4304
  app.customFields.register({
4267
4305
  name: "route-picker",
@@ -4276,7 +4314,7 @@ const index = {
4276
4314
  defaultMessage: "Select a route"
4277
4315
  },
4278
4316
  components: {
4279
- Input: async () => import("./RoutePicker-C6LpgVMi.mjs").then((module) => ({
4317
+ Input: async () => import("./RoutePicker-CgndSXoF.mjs").then((module) => ({
4280
4318
  default: module.default
4281
4319
  }))
4282
4320
  },
@@ -4319,7 +4357,7 @@ const index = {
4319
4357
  return Promise.all(
4320
4358
  locales.map(async (locale) => {
4321
4359
  try {
4322
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-Dnk_hvMW.mjs"), "./translations/en.json": () => import("./en-D5EqZSGy.mjs") }), `./translations/${locale}.json`, 3);
4360
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-DWs5ckOd.mjs"), "./translations/en.json": () => import("./en-CyhISGZi.mjs") }), `./translations/${locale}.json`, 3);
4323
4361
  return { data, locale };
4324
4362
  } catch {
4325
4363
  return { data: {}, locale };
@@ -4342,5 +4380,6 @@ export {
4342
4380
  isAbortError as i,
4343
4381
  index as j,
4344
4382
  pluginPermissions as p,
4383
+ transformToUrl as t,
4345
4384
  useApi as u
4346
4385
  };
@@ -1,26 +1,51 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useReducer, useRef, useMemo } from "react";
3
- import { Box, Accordion, Field, SingleSelect, SingleSelectOption, Grid, Typography, Link } from "@strapi/design-system";
4
- import { useNotification, Page } from "@strapi/strapi/admin";
5
- import { g as getTranslation, T as Tooltip, c as usePluginConfig, e as useAllContentTypes, p as pluginPermissions, f as PLUGIN_NAME, h as PLUGIN_VERSION } from "./index-CVrufPeL.mjs";
6
- import { W as WarningBox, u as useAllEntities } from "./WarningBox-CfIVF0O-.mjs";
3
+ import { Typography, Box, Accordion, Field, SingleSelect, SingleSelectOption, Grid, Link } from "@strapi/design-system";
4
+ import { useNotification, useRBAC, Page } from "@strapi/strapi/admin";
5
+ import { u as useApi, i as isAbortError, g as getTranslation, T as Tooltip, c as usePluginConfig, e as useAllContentTypes, p as pluginPermissions, f as PLUGIN_NAME, h as PLUGIN_VERSION } from "./index-BKhrfzjO.mjs";
7
6
  import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
8
7
  import { useIntl } from "react-intl";
9
8
  import "@strapi/icons/symbols";
10
9
  import { ExternalLink } from "@strapi/icons";
11
- import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-C1_2epDJ.mjs";
10
+ import { P as PageWrapper, C as ContentBox } from "./ContentBox-KyQN2KGV.mjs";
11
+ import { W as WarningBox } from "./WarningBox-AyYq0Onj.mjs";
12
12
  function getRouteSourceFields(contentType) {
13
13
  if (!contentType?.attributes) return [];
14
14
  return Object.entries(contentType.attributes).filter(
15
15
  ([key, attribute]) => attribute.type === "string" && key !== "documentId"
16
16
  );
17
17
  }
18
+ const useAllEntities = () => {
19
+ const { fetchAllEntities } = useApi();
20
+ const [entities, setEntities] = useState([]);
21
+ const [loading, setLoading] = useState(true);
22
+ const [error, setError] = useState(null);
23
+ useEffect(() => {
24
+ const fetchEntities = async () => {
25
+ try {
26
+ const result = await fetchAllEntities();
27
+ setEntities(result);
28
+ setLoading(false);
29
+ } catch (err) {
30
+ if (isAbortError(err)) return;
31
+ setError(err);
32
+ setLoading(false);
33
+ }
34
+ };
35
+ fetchEntities();
36
+ }, []);
37
+ return { entities, loading, error };
38
+ };
39
+ function SettingTitle({ children }) {
40
+ return /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children });
41
+ }
18
42
  function ContentTypeAccordion({
19
43
  contentType,
20
44
  contentTypeSettings,
21
45
  dispatch,
22
46
  allGroupedEntities,
23
- entitiesLoading
47
+ entitiesLoading,
48
+ disabled
24
49
  }) {
25
50
  const { formatMessage } = useIntl();
26
51
  const [selectedContentType, setSelectedContentType] = useState(null);
@@ -107,7 +132,7 @@ function ContentTypeAccordion({
107
132
  type: "SET_DEFAULT_FIELD",
108
133
  payload: { ctUid: contentType.uid, field: String(value) }
109
134
  }),
110
- disabled: filteredAttributes.length === 0,
135
+ disabled: disabled || filteredAttributes.length === 0,
111
136
  children: filteredAttributes.map(([key], index) => {
112
137
  return /* @__PURE__ */ jsx(SingleSelectOption, { value: key, children: key }, index);
113
138
  })
@@ -164,6 +189,7 @@ function ContentTypeAccordion({
164
189
  ),
165
190
  defaultMessage: "Select a content type"
166
191
  }),
192
+ disabled,
167
193
  children: allGroupedEntities.map((groupedEntity) => {
168
194
  return /* @__PURE__ */ jsx(
169
195
  SingleSelectOption,
@@ -196,7 +222,7 @@ function ContentTypeAccordion({
196
222
  type: "SET_DEFAULT_PARENT_ROUTE",
197
223
  payload: { ctUid: contentType.uid, parentRoute: String(value) }
198
224
  }),
199
- disabled: !selectedContentType || selectedContentType.entities.length === 0 || !selectedContentType.contentType.routeSourceField,
225
+ disabled: disabled || !selectedContentType || selectedContentType.entities.length === 0 || !selectedContentType.contentType.routeSourceField,
200
226
  children: selectedContentType?.entities.map((entity) => {
201
227
  if (!selectedContentType.contentType.routeSourceField) return null;
202
228
  return /* @__PURE__ */ jsx(SingleSelectOption, { value: entity.documentId, children: entity[selectedContentType.contentType.routeSourceField] }, entity.documentId);
@@ -251,6 +277,10 @@ const Settings = () => {
251
277
  const [blacklistInput, setBlacklistInput] = useState("");
252
278
  const initialConfig = useRef(fetchedConfig);
253
279
  const { entities, loading: entitiesLoading, error: entitiesError } = useAllEntities();
280
+ const {
281
+ isLoading: isLoadingPermissions,
282
+ allowedActions: { canUpdate }
283
+ } = useRBAC(pluginPermissions["settings.general.update"]);
254
284
  const selectableEntities = useMemo(
255
285
  () => entities.filter(
256
286
  (groupedEntity) => config?.selectedContentTypes.some(
@@ -329,7 +359,7 @@ const Settings = () => {
329
359
  console.error(err);
330
360
  }
331
361
  }
332
- if (loading) {
362
+ if (loading || isLoadingPermissions) {
333
363
  return /* @__PURE__ */ jsx(
334
364
  PageWrapper,
335
365
  {
@@ -343,10 +373,10 @@ const Settings = () => {
343
373
  }
344
374
  );
345
375
  }
346
- return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions["settings.general"], children: /* @__PURE__ */ jsxs(
376
+ return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions["settings.general.read"], children: /* @__PURE__ */ jsxs(
347
377
  PageWrapper,
348
378
  {
349
- save,
379
+ save: canUpdate ? save : void 0,
350
380
  isSaving,
351
381
  subtitle: formatMessage({
352
382
  id: getTranslation("settings.page.general.subtitle"),
@@ -378,7 +408,8 @@ const Settings = () => {
378
408
  contentTypeSettings,
379
409
  dispatch,
380
410
  allGroupedEntities: selectableEntities,
381
- entitiesLoading
411
+ entitiesLoading,
412
+ disabled: !canUpdate
382
413
  },
383
414
  contentTypeSettings.uid
384
415
  );
@@ -423,6 +454,7 @@ const Settings = () => {
423
454
  defaultMessage: "Enter comma-separated URL segments to block"
424
455
  }),
425
456
  value: blacklistInput,
457
+ disabled: !canUpdate,
426
458
  onChange: (e) => setBlacklistInput(e.target.value),
427
459
  onBlur: () => {
428
460
  const blacklist = blacklistInput.split(",").map((s) => s.trim().toLowerCase().replace(/^\/+/, "").replace(/\/+$/, "")).filter(Boolean);
@@ -4,25 +4,50 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const designSystem = require("@strapi/design-system");
6
6
  const admin = require("@strapi/strapi/admin");
7
- const index = require("./index-DHNPW0YT.js");
8
- const WarningBox = require("./WarningBox-BHlYlKQ8.js");
7
+ const index = require("./index-DTrsl_uN.js");
9
8
  const FullLoader = require("./FullLoader-C4hXFaLP.js");
10
9
  const reactIntl = require("react-intl");
11
10
  require("@strapi/icons/symbols");
12
11
  const icons = require("@strapi/icons");
13
- const SettingTitle = require("./SettingTitle-DXGCUfum.js");
12
+ const ContentBox = require("./ContentBox-D4PGQ8eh.js");
13
+ const WarningBox = require("./WarningBox-FF1yYDXP.js");
14
14
  function getRouteSourceFields(contentType) {
15
15
  if (!contentType?.attributes) return [];
16
16
  return Object.entries(contentType.attributes).filter(
17
17
  ([key, attribute]) => attribute.type === "string" && key !== "documentId"
18
18
  );
19
19
  }
20
+ const useAllEntities = () => {
21
+ const { fetchAllEntities } = index.useApi();
22
+ const [entities, setEntities] = React.useState([]);
23
+ const [loading, setLoading] = React.useState(true);
24
+ const [error, setError] = React.useState(null);
25
+ React.useEffect(() => {
26
+ const fetchEntities = async () => {
27
+ try {
28
+ const result = await fetchAllEntities();
29
+ setEntities(result);
30
+ setLoading(false);
31
+ } catch (err) {
32
+ if (index.isAbortError(err)) return;
33
+ setError(err);
34
+ setLoading(false);
35
+ }
36
+ };
37
+ fetchEntities();
38
+ }, []);
39
+ return { entities, loading, error };
40
+ };
41
+ function SettingTitle({ children }) {
42
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children });
43
+ }
20
44
  function ContentTypeAccordion({
21
45
  contentType,
22
46
  contentTypeSettings,
23
47
  dispatch,
24
48
  allGroupedEntities,
25
- entitiesLoading
49
+ entitiesLoading,
50
+ disabled
26
51
  }) {
27
52
  const { formatMessage } = reactIntl.useIntl();
28
53
  const [selectedContentType, setSelectedContentType] = React.useState(null);
@@ -109,7 +134,7 @@ function ContentTypeAccordion({
109
134
  type: "SET_DEFAULT_FIELD",
110
135
  payload: { ctUid: contentType.uid, field: String(value) }
111
136
  }),
112
- disabled: filteredAttributes.length === 0,
137
+ disabled: disabled || filteredAttributes.length === 0,
113
138
  children: filteredAttributes.map(([key], index2) => {
114
139
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: key, children: key }, index2);
115
140
  })
@@ -166,6 +191,7 @@ function ContentTypeAccordion({
166
191
  ),
167
192
  defaultMessage: "Select a content type"
168
193
  }),
194
+ disabled,
169
195
  children: allGroupedEntities.map((groupedEntity) => {
170
196
  return /* @__PURE__ */ jsxRuntime.jsx(
171
197
  designSystem.SingleSelectOption,
@@ -198,7 +224,7 @@ function ContentTypeAccordion({
198
224
  type: "SET_DEFAULT_PARENT_ROUTE",
199
225
  payload: { ctUid: contentType.uid, parentRoute: String(value) }
200
226
  }),
201
- disabled: !selectedContentType || selectedContentType.entities.length === 0 || !selectedContentType.contentType.routeSourceField,
227
+ disabled: disabled || !selectedContentType || selectedContentType.entities.length === 0 || !selectedContentType.contentType.routeSourceField,
202
228
  children: selectedContentType?.entities.map((entity) => {
203
229
  if (!selectedContentType.contentType.routeSourceField) return null;
204
230
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: entity.documentId, children: entity[selectedContentType.contentType.routeSourceField] }, entity.documentId);
@@ -252,7 +278,11 @@ const Settings = () => {
252
278
  const [isSaving, setIsSaving] = React.useState(false);
253
279
  const [blacklistInput, setBlacklistInput] = React.useState("");
254
280
  const initialConfig = React.useRef(fetchedConfig);
255
- const { entities, loading: entitiesLoading, error: entitiesError } = WarningBox.useAllEntities();
281
+ const { entities, loading: entitiesLoading, error: entitiesError } = useAllEntities();
282
+ const {
283
+ isLoading: isLoadingPermissions,
284
+ allowedActions: { canUpdate }
285
+ } = admin.useRBAC(index.pluginPermissions["settings.general.update"]);
256
286
  const selectableEntities = React.useMemo(
257
287
  () => entities.filter(
258
288
  (groupedEntity) => config?.selectedContentTypes.some(
@@ -331,9 +361,9 @@ const Settings = () => {
331
361
  console.error(err);
332
362
  }
333
363
  }
334
- if (loading) {
364
+ if (loading || isLoadingPermissions) {
335
365
  return /* @__PURE__ */ jsxRuntime.jsx(
336
- SettingTitle.PageWrapper,
366
+ ContentBox.PageWrapper,
337
367
  {
338
368
  isSaving,
339
369
  subtitle: formatMessage({
@@ -345,10 +375,10 @@ const Settings = () => {
345
375
  }
346
376
  );
347
377
  }
348
- return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.pluginPermissions["settings.general"], children: /* @__PURE__ */ jsxRuntime.jsxs(
349
- SettingTitle.PageWrapper,
378
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.pluginPermissions["settings.general.read"], children: /* @__PURE__ */ jsxRuntime.jsxs(
379
+ ContentBox.PageWrapper,
350
380
  {
351
- save,
381
+ save: canUpdate ? save : void 0,
352
382
  isSaving,
353
383
  subtitle: formatMessage({
354
384
  id: index.getTranslation("settings.page.general.subtitle"),
@@ -357,7 +387,7 @@ const Settings = () => {
357
387
  disabledCondition: JSON.stringify(config) === JSON.stringify(initialConfig.current) || hasMissingRouteSourceField,
358
388
  children: [
359
389
  /* @__PURE__ */ jsxRuntime.jsxs(
360
- SettingTitle.ContentBox,
390
+ ContentBox.ContentBox,
361
391
  {
362
392
  title: formatMessage({
363
393
  id: index.getTranslation("settings.page.general.contentTypes"),
@@ -365,7 +395,7 @@ const Settings = () => {
365
395
  }),
366
396
  children: [
367
397
  config?.selectedContentTypes && config.selectedContentTypes.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "selectedContentTypesAccordion", children: [
368
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingTitle.SettingTitle, { children: formatMessage({
398
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingTitle, { children: formatMessage({
369
399
  id: index.getTranslation("settings.page.contentTypeSettings"),
370
400
  defaultMessage: "Content Type settings"
371
401
  }) }) }),
@@ -380,7 +410,8 @@ const Settings = () => {
380
410
  contentTypeSettings,
381
411
  dispatch,
382
412
  allGroupedEntities: selectableEntities,
383
- entitiesLoading
413
+ entitiesLoading,
414
+ disabled: !canUpdate
384
415
  },
385
416
  contentTypeSettings.uid
386
417
  );
@@ -412,7 +443,7 @@ const Settings = () => {
412
443
  defaultMessage: 'Enter a comma-separated list of URL segments that should be blocked from being used in generated paths. For example, if you enter "admin, login", then any generated path that starts with "/admin" or "/login" will be blocked, while paths like "/admin-guide" stay allowed. The blacklist only applies to routes that are created or updated after saving — it does not affect existing routes.'
413
444
  }),
414
445
  children: [
415
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingTitle.SettingTitle, { children: formatMessage({
446
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingTitle, { children: formatMessage({
416
447
  id: index.getTranslation("settings.page.blacklist.label"),
417
448
  defaultMessage: "URL Blacklist"
418
449
  }) }) }),
@@ -425,6 +456,7 @@ const Settings = () => {
425
456
  defaultMessage: "Enter comma-separated URL segments to block"
426
457
  }),
427
458
  value: blacklistInput,
459
+ disabled: !canUpdate,
428
460
  onChange: (e) => setBlacklistInput(e.target.value),
429
461
  onBlur: () => {
430
462
  const blacklist = blacklistInput.split(",").map((s) => s.trim().toLowerCase().replace(/^\/+/, "").replace(/\/+$/, "")).filter(Boolean);
@@ -441,14 +473,14 @@ const Settings = () => {
441
473
  }
442
474
  ),
443
475
  /* @__PURE__ */ jsxRuntime.jsx(
444
- SettingTitle.ContentBox,
476
+ ContentBox.ContentBox,
445
477
  {
446
478
  title: formatMessage({
447
479
  id: index.getTranslation("settings.page.general.details"),
448
480
  defaultMessage: "Details"
449
481
  }),
450
482
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "selectedContentTypesAccordion", children: [
451
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsxs(SettingTitle.SettingTitle, { children: [
483
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: /* @__PURE__ */ jsxRuntime.jsxs(SettingTitle, { children: [
452
484
  index.PLUGIN_NAME,
453
485
  " ",
454
486
  formatMessage({