@mattisvensson/strapi-plugin-webatlas 0.12.0 → 0.12.2

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 (27) hide show
  1. package/README.md +13 -1
  2. package/dist/admin/{RoutePicker-h2yWGB6S.mjs → RoutePicker-C6LpgVMi.mjs} +1 -1
  3. package/dist/admin/{RoutePicker-mEHRtXQ9.js → RoutePicker-DvzQH2CX.js} +1 -1
  4. package/dist/admin/{SettingTitle-DTXdYICP.mjs → SettingTitle-C1_2epDJ.mjs} +1 -1
  5. package/dist/admin/{SettingTitle-CBcBCh1h.js → SettingTitle-DXGCUfum.js} +1 -1
  6. package/dist/admin/{WarningBox-DsBtzhs3.js → WarningBox-BHlYlKQ8.js} +1 -1
  7. package/dist/admin/{WarningBox-CMQuE_Ov.mjs → WarningBox-CfIVF0O-.mjs} +1 -1
  8. package/dist/admin/{de-DhwCZE_m.js → de-BWUGdpM0.js} +1 -0
  9. package/dist/admin/{de-BFjenpyN.mjs → de-Dnk_hvMW.mjs} +1 -0
  10. package/dist/admin/{en-CGCh9ld_.mjs → en-D5EqZSGy.mjs} +1 -0
  11. package/dist/admin/{en-C-rPCNd2.js → en-DOk8P6X5.js} +1 -0
  12. package/dist/admin/{index-Ckaev6xU.mjs → index-CVrufPeL.mjs} +47 -14
  13. package/dist/admin/{index-GZ_b2eve.js → index-D7zg69uM.js} +3 -3
  14. package/dist/admin/{index-Do9dOMP-.mjs → index-DC-2-FsX.mjs} +2 -2
  15. package/dist/admin/{index-BYytQZfK.js → index-DHNPW0YT.js} +47 -14
  16. package/dist/admin/{index-BZBUZWp1.js → index-Dp_eCRFS.js} +1 -1
  17. package/dist/admin/{index-aSdHc104.mjs → index-DuSnxRbO.mjs} +3 -3
  18. package/dist/admin/{index-DuwTQMlZ.mjs → index-Dx4gvFWK.mjs} +2 -2
  19. package/dist/admin/{index-CaFjiS4j.js → index-FuvoHpAT.js} +2 -2
  20. package/dist/admin/{index-Bn_SWdWd.js → index-RmZ3LQPu.js} +2 -2
  21. package/dist/admin/{index-l4-tTCw9.mjs → index-Y4uwBSjP.mjs} +1 -1
  22. package/dist/admin/index.js +1 -1
  23. package/dist/admin/index.mjs +1 -1
  24. package/dist/server/index.js +132 -47
  25. package/dist/server/index.mjs +132 -47
  26. package/dist/server/src/index.d.ts +1 -1
  27. package/package.json +3 -3
package/README.md CHANGED
@@ -114,6 +114,18 @@ The RoutePicker custom field allows you to select a route from the existing rout
114
114
 
115
115
  Webatlas provides two API endpoints. One to fetch routes and one to fetch navigations.
116
116
 
117
+ #### Permissions
118
+
119
+ The endpoints are protected like any other Strapi API endpoint. Grant the following permissions either to a role in **Settings → Users & Permissions plugin → Roles** (e.g. `Public`) or to an API token in **Settings → API Tokens**:
120
+
121
+ - Under **Webatlas**, enable `getEntityByPath` and/or `getNavigation`.
122
+ - Enable `findOne` (collection types) or `find` (single types) for every content type with webatlas enabled whose entries should be fetchable via `/api/webatlas/path`. Without this permission, the endpoint responds with `404`.
123
+ - Enable `find` for every content type that is referenced through a relation and should be included when using `populate`. Relations to content types without `find` permission are removed from the response, private fields are never returned.
124
+
125
+ Only enable `find` and `findOne` for content types whose entries are meant to be public, since they also expose the regular `/api/<content-type>` endpoints. Like with the Strapi REST API, anyone who can read a content type can also fetch its drafts by passing `status=draft`.
126
+
127
+ To keep your content types private, leave the `Public` role untouched and grant the permissions to an API token instead. Make sure to allow the `getEntityByPath` and `getNavigation` permissions for the API token.
128
+
117
129
  #### Fetch route
118
130
 
119
131
  `GET /api/webatlas/path`
@@ -122,7 +134,7 @@ Query parameters:
122
134
 
123
135
  - `slug` (string, required): The slug/path to fetch the route for. This can either be the generated path from webatlas, the uId path or the canonical path.
124
136
  - `populate` (string, optional): Comma-separated list of relations to populate. Use `deep` to populate all relations in any depth.
125
- - `populateDeepDepth` (string, optional): Depth for deep population.
137
+ - `populateDeepDepth` (string, optional): Depth for deep population, between `1` and `10`. Default is `5`.
126
138
  - `fields` (string, optional): Comma-separated list of fields to include in the response.
127
139
  - `status` (string, optional): `draft` or `published`. Default is `published`. Returns the draft or published version of the entity.
128
140
  - `breadcrumb` (string, optional): Pass `false` to omit the breadcrumb from the response. Enabled by default.
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useState, useEffect } from "react";
3
3
  import { Field, Combobox, ComboboxOption, Box } from "@strapi/design-system";
4
4
  import { ExternalLink, Link } from "@strapi/icons";
5
- import { u as useApi } from "./index-Ckaev6xU.mjs";
5
+ import { u as useApi } from "./index-CVrufPeL.mjs";
6
6
  import "@strapi/strapi/admin";
7
7
  const Input = forwardRef((props, ref) => {
8
8
  const { attribute, disabled, placeholder, label, name, onChange, required, value, hint } = props;
@@ -4,7 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const designSystem = require("@strapi/design-system");
6
6
  const icons = require("@strapi/icons");
7
- const index = require("./index-BYytQZfK.js");
7
+ const index = require("./index-DHNPW0YT.js");
8
8
  require("@strapi/strapi/admin");
9
9
  const Input = React.forwardRef((props, ref) => {
10
10
  const { attribute, disabled, placeholder, label, name, onChange, required, value, hint } = props;
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { Button, Flex, Typography, Box } from "@strapi/design-system";
3
3
  import { Page, Layouts } from "@strapi/strapi/admin";
4
- import { f as PLUGIN_NAME, g as getTranslation } from "./index-Ckaev6xU.mjs";
4
+ import { f as PLUGIN_NAME, g as getTranslation } from "./index-CVrufPeL.mjs";
5
5
  import { useIntl } from "react-intl";
6
6
  import { Check } from "@strapi/icons";
7
7
  function PageWrapper({
@@ -2,7 +2,7 @@
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
3
  const designSystem = require("@strapi/design-system");
4
4
  const admin = require("@strapi/strapi/admin");
5
- const index = require("./index-BYytQZfK.js");
5
+ const index = require("./index-DHNPW0YT.js");
6
6
  const reactIntl = require("react-intl");
7
7
  const icons = require("@strapi/icons");
8
8
  function PageWrapper({
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const React = require("react");
3
- const index = require("./index-BYytQZfK.js");
3
+ const index = require("./index-DHNPW0YT.js");
4
4
  const jsxRuntime = require("react/jsx-runtime");
5
5
  const designSystem = require("@strapi/design-system");
6
6
  const icons = require("@strapi/icons");
@@ -1,5 +1,5 @@
1
1
  import { useState, useEffect } from "react";
2
- import { u as useApi, i as isAbortError } from "./index-Ckaev6xU.mjs";
2
+ import { u as useApi, i as isAbortError } from "./index-CVrufPeL.mjs";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { Badge, Flex, Typography } from "@strapi/design-system";
5
5
  import { WarningCircle } from "@strapi/icons";
@@ -96,6 +96,7 @@ const de = {
96
96
  "webatlas.components.CMEditViewAside.path.overrideCheckbox": "Automatische Pfad-Generierung überschreiben",
97
97
  "webatlas.components.CMEditViewAside.path.uidPath.hint": "Permanenter UID-Pfad, kann nicht geändert werden",
98
98
  "webatlas.components.CMEditViewAside.path.newPathInfo": "Ein neuer Pfad wird beim Speichern dieses Eintrags erstellt.",
99
+ "webatlas.components.CMEditViewAside.path.noPathInfo": 'Es wird kein Pfad erstellt, solange das Feld "{field}" leer ist. Füllen Sie es aus oder verwenden Sie die Überschreibungsoption, um einen benutzerdefinierten Pfad festzulegen.',
99
100
  "webatlas.components.CMEditViewAside.path.input.noSourceField": "Verwenden Sie die Überschreibungsoption, um einen benutzerdefinierten Pfad festzulegen.",
100
101
  "webatlas.components.CMEditViewAside.path.input.parentSelect.label": "Platzieren unter",
101
102
  "webatlas.components.CMEditViewAside.path.input.parentSelect.rootPath": "Keine (Stammverzeichnis)",
@@ -94,6 +94,7 @@ const de = {
94
94
  "webatlas.components.CMEditViewAside.path.overrideCheckbox": "Automatische Pfad-Generierung überschreiben",
95
95
  "webatlas.components.CMEditViewAside.path.uidPath.hint": "Permanenter UID-Pfad, kann nicht geändert werden",
96
96
  "webatlas.components.CMEditViewAside.path.newPathInfo": "Ein neuer Pfad wird beim Speichern dieses Eintrags erstellt.",
97
+ "webatlas.components.CMEditViewAside.path.noPathInfo": 'Es wird kein Pfad erstellt, solange das Feld "{field}" leer ist. Füllen Sie es aus oder verwenden Sie die Überschreibungsoption, um einen benutzerdefinierten Pfad festzulegen.',
97
98
  "webatlas.components.CMEditViewAside.path.input.noSourceField": "Verwenden Sie die Überschreibungsoption, um einen benutzerdefinierten Pfad festzulegen.",
98
99
  "webatlas.components.CMEditViewAside.path.input.parentSelect.label": "Platzieren unter",
99
100
  "webatlas.components.CMEditViewAside.path.input.parentSelect.rootPath": "Keine (Stammverzeichnis)",
@@ -94,6 +94,7 @@ const en = {
94
94
  "webatlas.components.CMEditViewAside.path.overrideCheckbox": "Override automatic path generation",
95
95
  "webatlas.components.CMEditViewAside.path.uidPath.hint": "Permanent UID path, cannot be changed",
96
96
  "webatlas.components.CMEditViewAside.path.newPathInfo": "A new path will be created upon saving this entry.",
97
+ "webatlas.components.CMEditViewAside.path.noPathInfo": 'No path will be created while the "{field}" field is empty. Fill it in or use the override option to set a custom path.',
97
98
  "webatlas.components.CMEditViewAside.path.input.noSourceField": "Use the override option to set a custom Path.",
98
99
  "webatlas.components.CMEditViewAside.path.input.parentSelect.label": "Place under",
99
100
  "webatlas.components.CMEditViewAside.path.input.parentSelect.rootPath": "None (root path)",
@@ -96,6 +96,7 @@ const en = {
96
96
  "webatlas.components.CMEditViewAside.path.overrideCheckbox": "Override automatic path generation",
97
97
  "webatlas.components.CMEditViewAside.path.uidPath.hint": "Permanent UID path, cannot be changed",
98
98
  "webatlas.components.CMEditViewAside.path.newPathInfo": "A new path will be created upon saving this entry.",
99
+ "webatlas.components.CMEditViewAside.path.noPathInfo": 'No path will be created while the "{field}" field is empty. Fill it in or use the override option to set a custom path.',
99
100
  "webatlas.components.CMEditViewAside.path.input.noSourceField": "Use the override option to set a custom Path.",
100
101
  "webatlas.components.CMEditViewAside.path.input.parentSelect.label": "Place under",
101
102
  "webatlas.components.CMEditViewAside.path.input.parentSelect.rootPath": "None (root path)",
@@ -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.0";
55
+ const version = "0.12.1";
56
56
  const strapi = { "name": "webatlas", "displayName": "Webatlas" };
57
57
  const pluginPkg = {
58
58
  version,
@@ -332,8 +332,19 @@ function OverrideCheckbox({ isOverride, setIsOverride, disabledCondition }) {
332
332
  }
333
333
  ) });
334
334
  }
335
- function NewPathInfo() {
335
+ function NewPathInfo({
336
+ hasSlug,
337
+ routeSourceField
338
+ }) {
336
339
  const { formatMessage } = useIntl();
340
+ if (!hasSlug)
341
+ return /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: formatMessage(
342
+ {
343
+ id: getTranslation("components.CMEditViewAside.path.noPathInfo"),
344
+ 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.'
345
+ },
346
+ { field: routeSourceField }
347
+ ) });
337
348
  return /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
338
349
  id: getTranslation("components.CMEditViewAside.path.newPathInfo"),
339
350
  defaultMessage: "A new path will be created upon saving this entry."
@@ -3827,8 +3838,8 @@ function reducer(state, action) {
3827
3838
  }
3828
3839
  }
3829
3840
  const Panel = ({ config }) => {
3830
- const { form, model } = unstable_useContentManagerContext();
3831
- const { initialValues, values, onChange } = form;
3841
+ const { form, model, contentType } = unstable_useContentManagerContext();
3842
+ const { initialValues, values, onChange, isSubmitting } = form;
3832
3843
  const { getRelatedRoute, getAllRoutes, getProhibitedRouteIds } = useApi();
3833
3844
  const { formatMessage } = useIntl();
3834
3845
  const { get } = useFetchClient();
@@ -3866,6 +3877,8 @@ const Panel = ({ config }) => {
3866
3877
  slug: "",
3867
3878
  overridePath: ""
3868
3879
  });
3880
+ const [routeRefreshKey, setRouteRefreshKey] = useState(0);
3881
+ const wasSubmitting = useRef(false);
3869
3882
  const hasUserChangedField = useRef(false);
3870
3883
  const hasUserInteracted = useRef(false);
3871
3884
  const initialRouteData = useRef(null);
@@ -3873,6 +3886,7 @@ const Panel = ({ config }) => {
3873
3886
  const routeSourceField = config?.routeSourceField;
3874
3887
  const sourceFieldValue = routeSourceField ? values[routeSourceField] || "" : "";
3875
3888
  const initialSourceFieldValue = routeSourceField ? initialValues[routeSourceField] || "" : "";
3889
+ const isSourceFieldRequired = !!(routeSourceField && contentType?.attributes?.[routeSourceField]?.required);
3876
3890
  const latestCheckPathRef = useRef(checkPath);
3877
3891
  latestCheckPathRef.current = checkPath;
3878
3892
  const debouncedCheckPath = useRef(
@@ -3899,7 +3913,7 @@ const Panel = ({ config }) => {
3899
3913
  parentDocumentId: selectedParent?.documentId || null,
3900
3914
  slug: isOverride ? overridePath : slug
3901
3915
  };
3902
- if (initialRouteData.current?.isOverride === isOverride && data.path === initialRouteData.current?.path && data.parentDocumentId === (initialRouteData.current?.parent?.documentId ?? null)) {
3916
+ if (initialRouteData.current?.isOverride === isOverride && data.path === initialRouteData.current?.path && data.parentDocumentId === (initialRouteData.current?.parent?.documentId ?? null) && sourceFieldValue.trim() === (initialRouteData.current?.title ?? "")) {
3903
3917
  onChange("webatlas", void 0);
3904
3918
  return;
3905
3919
  }
@@ -3921,7 +3935,11 @@ const Panel = ({ config }) => {
3921
3935
  hasUserChangedField.current = true;
3922
3936
  }
3923
3937
  if (!sourceFieldValue) {
3924
- dispatchPath({ type: "NO_URL_CHECK", payload: "" });
3938
+ dispatchPath({ type: "NO_URL_CHECK", payload: initialRouteData.current?.path ?? "" });
3939
+ dispatchPath({
3940
+ type: "SET_CANONICALPATH",
3941
+ payload: initialRouteData.current?.canonicalPath ?? ""
3942
+ });
3925
3943
  return;
3926
3944
  }
3927
3945
  if (initialLoadComplete && (hasUserChangedField.current || !route) && prevSourceValueRef.current !== sourceFieldValue && !isOverride) {
@@ -3999,7 +4017,16 @@ const Panel = ({ config }) => {
3999
4017
  }
4000
4018
  }
4001
4019
  fetchRelatedRute();
4002
- }, [config]);
4020
+ }, [config, routeRefreshKey]);
4021
+ useEffect(() => {
4022
+ if (isSubmitting) {
4023
+ wasSubmitting.current = true;
4024
+ return;
4025
+ }
4026
+ if (!wasSubmitting.current) return;
4027
+ wasSubmitting.current = false;
4028
+ setRouteRefreshKey((key) => key + 1);
4029
+ }, [isSubmitting]);
4003
4030
  useEffect(() => {
4004
4031
  if (!route || !routes.length) return;
4005
4032
  const parentRoute = routes.find(
@@ -4067,7 +4094,13 @@ const Panel = ({ config }) => {
4067
4094
  }) });
4068
4095
  return /* @__PURE__ */ jsx(Box, { tag: "aside", "aria-labelledby": "URL Route", width: "100%", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
4069
4096
  !route && /* @__PURE__ */ jsxs(Fragment$1, { children: [
4070
- /* @__PURE__ */ jsx(NewPathInfo, {}),
4097
+ /* @__PURE__ */ jsx(
4098
+ NewPathInfo,
4099
+ {
4100
+ hasSlug: !!(isOverride ? path.overridePath : sourceFieldValue.trim()) || !isOverride && isSourceFieldRequired,
4101
+ routeSourceField
4102
+ }
4103
+ ),
4071
4104
  /* @__PURE__ */ jsx(Divider, { marginTop: 2, marginBottom: 2 })
4072
4105
  ] }),
4073
4106
  /* @__PURE__ */ jsx(
@@ -4188,7 +4221,7 @@ const index = {
4188
4221
  id: `${PLUGIN_ID}.link.paths`,
4189
4222
  defaultMessage: "Paths"
4190
4223
  },
4191
- Component: () => import("./index-l4-tTCw9.mjs"),
4224
+ Component: () => import("./index-Y4uwBSjP.mjs"),
4192
4225
  permissions: [pluginPermissions["page.routes"][0]]
4193
4226
  });
4194
4227
  app.addMenuLink({
@@ -4198,7 +4231,7 @@ const index = {
4198
4231
  id: `${PLUGIN_ID}.link.navigation`,
4199
4232
  defaultMessage: "Navigation"
4200
4233
  },
4201
- Component: () => import("./index-Do9dOMP-.mjs"),
4234
+ Component: () => import("./index-DC-2-FsX.mjs"),
4202
4235
  permissions: [pluginPermissions["page.navigation"][0]]
4203
4236
  });
4204
4237
  app.addSettingsLink(
@@ -4216,7 +4249,7 @@ const index = {
4216
4249
  },
4217
4250
  id: `${PLUGIN_ID}-general`,
4218
4251
  to: `${PLUGIN_ID}/general`,
4219
- Component: () => import("./index-aSdHc104.mjs"),
4252
+ Component: () => import("./index-DuSnxRbO.mjs"),
4220
4253
  permissions: [pluginPermissions["settings.general"][0]]
4221
4254
  }
4222
4255
  );
@@ -4227,7 +4260,7 @@ const index = {
4227
4260
  },
4228
4261
  id: `${PLUGIN_ID}-navigation`,
4229
4262
  to: `${PLUGIN_ID}/navigation`,
4230
- Component: () => import("./index-DuwTQMlZ.mjs"),
4263
+ Component: () => import("./index-Dx4gvFWK.mjs"),
4231
4264
  permissions: [pluginPermissions["settings.navigation"][0]]
4232
4265
  });
4233
4266
  app.customFields.register({
@@ -4243,7 +4276,7 @@ const index = {
4243
4276
  defaultMessage: "Select a route"
4244
4277
  },
4245
4278
  components: {
4246
- Input: async () => import("./RoutePicker-h2yWGB6S.mjs").then((module) => ({
4279
+ Input: async () => import("./RoutePicker-C6LpgVMi.mjs").then((module) => ({
4247
4280
  default: module.default
4248
4281
  }))
4249
4282
  },
@@ -4286,7 +4319,7 @@ const index = {
4286
4319
  return Promise.all(
4287
4320
  locales.map(async (locale) => {
4288
4321
  try {
4289
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-BFjenpyN.mjs"), "./translations/en.json": () => import("./en-CGCh9ld_.mjs") }), `./translations/${locale}.json`, 3);
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);
4290
4323
  return { data, locale };
4291
4324
  } catch {
4292
4325
  return { data: {}, locale };
@@ -4,13 +4,13 @@ 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-BYytQZfK.js");
8
- const WarningBox = require("./WarningBox-DsBtzhs3.js");
7
+ const index = require("./index-DHNPW0YT.js");
8
+ const WarningBox = require("./WarningBox-BHlYlKQ8.js");
9
9
  const FullLoader = require("./FullLoader-C4hXFaLP.js");
10
10
  const reactIntl = require("react-intl");
11
11
  require("@strapi/icons/symbols");
12
12
  const icons = require("@strapi/icons");
13
- const SettingTitle = require("./SettingTitle-CBcBCh1h.js");
13
+ const SettingTitle = require("./SettingTitle-DXGCUfum.js");
14
14
  function getRouteSourceFields(contentType) {
15
15
  if (!contentType?.attributes) return [];
16
16
  return Object.entries(contentType.attributes).filter(
@@ -5,11 +5,11 @@ import { Box, Typography, Dialog, Button, Modal, Flex, SingleSelect, SingleSelec
5
5
  import { createContext, useRef, useContext, useState, useMemo, useReducer, useCallback, useEffect, forwardRef } from "react";
6
6
  import { createPortal } from "react-dom";
7
7
  import { useIntl } from "react-intl";
8
- import { u as useApi, g as getTranslation, i as isAbortError, P as PLUGIN_ID, d as debounce, a as duplicateCheck, T as Tooltip, b as PathInfo, c as usePluginConfig, p as pluginPermissions } from "./index-Ckaev6xU.mjs";
8
+ import { u as useApi, g as getTranslation, i as isAbortError, P as PLUGIN_ID, d as debounce, a as duplicateCheck, T as Tooltip, b as PathInfo, c as usePluginConfig, p as pluginPermissions } from "./index-CVrufPeL.mjs";
9
9
  import { u as useErrorMessage, C as Center, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
10
10
  import { useNotification, useFetchClient, Page, Layouts } from "@strapi/strapi/admin";
11
11
  import { EmptyDocuments } from "@strapi/icons/symbols";
12
- import { u as useAllEntities, W as WarningBox } from "./WarningBox-CMQuE_Ov.mjs";
12
+ import { u as useAllEntities, W as WarningBox } from "./WarningBox-CfIVF0O-.mjs";
13
13
  import { MeasuringStrategy, DndContext, DragOverlay, closestCenter } from "@dnd-kit/core";
14
14
  import { arrayMove, useSortable, SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
15
15
  import { CSS } from "@dnd-kit/utilities";
@@ -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.0";
73
+ const version = "0.12.1";
74
74
  const strapi = { "name": "webatlas", "displayName": "Webatlas" };
75
75
  const pluginPkg = {
76
76
  version,
@@ -350,8 +350,19 @@ function OverrideCheckbox({ isOverride, setIsOverride, disabledCondition }) {
350
350
  }
351
351
  ) });
352
352
  }
353
- function NewPathInfo() {
353
+ function NewPathInfo({
354
+ hasSlug,
355
+ routeSourceField
356
+ }) {
354
357
  const { formatMessage } = reactIntl.useIntl();
358
+ if (!hasSlug)
359
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: formatMessage(
360
+ {
361
+ id: getTranslation("components.CMEditViewAside.path.noPathInfo"),
362
+ 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.'
363
+ },
364
+ { field: routeSourceField }
365
+ ) });
355
366
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
356
367
  id: getTranslation("components.CMEditViewAside.path.newPathInfo"),
357
368
  defaultMessage: "A new path will be created upon saving this entry."
@@ -3845,8 +3856,8 @@ function reducer(state, action) {
3845
3856
  }
3846
3857
  }
3847
3858
  const Panel = ({ config }) => {
3848
- const { form, model } = admin.unstable_useContentManagerContext();
3849
- const { initialValues, values, onChange } = form;
3859
+ const { form, model, contentType } = admin.unstable_useContentManagerContext();
3860
+ const { initialValues, values, onChange, isSubmitting } = form;
3850
3861
  const { getRelatedRoute, getAllRoutes, getProhibitedRouteIds } = useApi();
3851
3862
  const { formatMessage } = reactIntl.useIntl();
3852
3863
  const { get } = admin.useFetchClient();
@@ -3884,6 +3895,8 @@ const Panel = ({ config }) => {
3884
3895
  slug: "",
3885
3896
  overridePath: ""
3886
3897
  });
3898
+ const [routeRefreshKey, setRouteRefreshKey] = React.useState(0);
3899
+ const wasSubmitting = React.useRef(false);
3887
3900
  const hasUserChangedField = React.useRef(false);
3888
3901
  const hasUserInteracted = React.useRef(false);
3889
3902
  const initialRouteData = React.useRef(null);
@@ -3891,6 +3904,7 @@ const Panel = ({ config }) => {
3891
3904
  const routeSourceField = config?.routeSourceField;
3892
3905
  const sourceFieldValue = routeSourceField ? values[routeSourceField] || "" : "";
3893
3906
  const initialSourceFieldValue = routeSourceField ? initialValues[routeSourceField] || "" : "";
3907
+ const isSourceFieldRequired = !!(routeSourceField && contentType?.attributes?.[routeSourceField]?.required);
3894
3908
  const latestCheckPathRef = React.useRef(checkPath);
3895
3909
  latestCheckPathRef.current = checkPath;
3896
3910
  const debouncedCheckPath = React.useRef(
@@ -3917,7 +3931,7 @@ const Panel = ({ config }) => {
3917
3931
  parentDocumentId: selectedParent?.documentId || null,
3918
3932
  slug: isOverride ? overridePath : slug
3919
3933
  };
3920
- if (initialRouteData.current?.isOverride === isOverride && data.path === initialRouteData.current?.path && data.parentDocumentId === (initialRouteData.current?.parent?.documentId ?? null)) {
3934
+ if (initialRouteData.current?.isOverride === isOverride && data.path === initialRouteData.current?.path && data.parentDocumentId === (initialRouteData.current?.parent?.documentId ?? null) && sourceFieldValue.trim() === (initialRouteData.current?.title ?? "")) {
3921
3935
  onChange("webatlas", void 0);
3922
3936
  return;
3923
3937
  }
@@ -3939,7 +3953,11 @@ const Panel = ({ config }) => {
3939
3953
  hasUserChangedField.current = true;
3940
3954
  }
3941
3955
  if (!sourceFieldValue) {
3942
- dispatchPath({ type: "NO_URL_CHECK", payload: "" });
3956
+ dispatchPath({ type: "NO_URL_CHECK", payload: initialRouteData.current?.path ?? "" });
3957
+ dispatchPath({
3958
+ type: "SET_CANONICALPATH",
3959
+ payload: initialRouteData.current?.canonicalPath ?? ""
3960
+ });
3943
3961
  return;
3944
3962
  }
3945
3963
  if (initialLoadComplete && (hasUserChangedField.current || !route) && prevSourceValueRef.current !== sourceFieldValue && !isOverride) {
@@ -4017,7 +4035,16 @@ const Panel = ({ config }) => {
4017
4035
  }
4018
4036
  }
4019
4037
  fetchRelatedRute();
4020
- }, [config]);
4038
+ }, [config, routeRefreshKey]);
4039
+ React.useEffect(() => {
4040
+ if (isSubmitting) {
4041
+ wasSubmitting.current = true;
4042
+ return;
4043
+ }
4044
+ if (!wasSubmitting.current) return;
4045
+ wasSubmitting.current = false;
4046
+ setRouteRefreshKey((key) => key + 1);
4047
+ }, [isSubmitting]);
4021
4048
  React.useEffect(() => {
4022
4049
  if (!route || !routes.length) return;
4023
4050
  const parentRoute = routes.find(
@@ -4085,7 +4112,13 @@ const Panel = ({ config }) => {
4085
4112
  }) });
4086
4113
  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
4114
  !route && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4088
- /* @__PURE__ */ jsxRuntime.jsx(NewPathInfo, {}),
4115
+ /* @__PURE__ */ jsxRuntime.jsx(
4116
+ NewPathInfo,
4117
+ {
4118
+ hasSlug: !!(isOverride ? path.overridePath : sourceFieldValue.trim()) || !isOverride && isSourceFieldRequired,
4119
+ routeSourceField
4120
+ }
4121
+ ),
4089
4122
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, { marginTop: 2, marginBottom: 2 })
4090
4123
  ] }),
4091
4124
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -4206,7 +4239,7 @@ const index = {
4206
4239
  id: `${PLUGIN_ID}.link.paths`,
4207
4240
  defaultMessage: "Paths"
4208
4241
  },
4209
- Component: () => Promise.resolve().then(() => require("./index-BZBUZWp1.js")),
4242
+ Component: () => Promise.resolve().then(() => require("./index-Dp_eCRFS.js")),
4210
4243
  permissions: [pluginPermissions["page.routes"][0]]
4211
4244
  });
4212
4245
  app.addMenuLink({
@@ -4216,7 +4249,7 @@ const index = {
4216
4249
  id: `${PLUGIN_ID}.link.navigation`,
4217
4250
  defaultMessage: "Navigation"
4218
4251
  },
4219
- Component: () => Promise.resolve().then(() => require("./index-Bn_SWdWd.js")),
4252
+ Component: () => Promise.resolve().then(() => require("./index-RmZ3LQPu.js")),
4220
4253
  permissions: [pluginPermissions["page.navigation"][0]]
4221
4254
  });
4222
4255
  app.addSettingsLink(
@@ -4234,7 +4267,7 @@ const index = {
4234
4267
  },
4235
4268
  id: `${PLUGIN_ID}-general`,
4236
4269
  to: `${PLUGIN_ID}/general`,
4237
- Component: () => Promise.resolve().then(() => require("./index-GZ_b2eve.js")),
4270
+ Component: () => Promise.resolve().then(() => require("./index-D7zg69uM.js")),
4238
4271
  permissions: [pluginPermissions["settings.general"][0]]
4239
4272
  }
4240
4273
  );
@@ -4245,7 +4278,7 @@ const index = {
4245
4278
  },
4246
4279
  id: `${PLUGIN_ID}-navigation`,
4247
4280
  to: `${PLUGIN_ID}/navigation`,
4248
- Component: () => Promise.resolve().then(() => require("./index-CaFjiS4j.js")),
4281
+ Component: () => Promise.resolve().then(() => require("./index-FuvoHpAT.js")),
4249
4282
  permissions: [pluginPermissions["settings.navigation"][0]]
4250
4283
  });
4251
4284
  app.customFields.register({
@@ -4261,7 +4294,7 @@ const index = {
4261
4294
  defaultMessage: "Select a route"
4262
4295
  },
4263
4296
  components: {
4264
- Input: async () => Promise.resolve().then(() => require("./RoutePicker-mEHRtXQ9.js")).then((module2) => ({
4297
+ Input: async () => Promise.resolve().then(() => require("./RoutePicker-DvzQH2CX.js")).then((module2) => ({
4265
4298
  default: module2.default
4266
4299
  }))
4267
4300
  },
@@ -4304,7 +4337,7 @@ const index = {
4304
4337
  return Promise.all(
4305
4338
  locales.map(async (locale) => {
4306
4339
  try {
4307
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-DhwCZE_m.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-C-rPCNd2.js")) }), `./translations/${locale}.json`, 3);
4340
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-BWUGdpM0.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-DOk8P6X5.js")) }), `./translations/${locale}.json`, 3);
4308
4341
  return { data, locale };
4309
4342
  } catch {
4310
4343
  return { data: {}, locale };
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
- const index = require("./index-BYytQZfK.js");
5
+ const index = require("./index-DHNPW0YT.js");
6
6
  const FullLoader = require("./FullLoader-C4hXFaLP.js");
7
7
  const admin = require("@strapi/strapi/admin");
8
8
  const designSystem = require("@strapi/design-system");
@@ -2,13 +2,13 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useReducer, useRef, useMemo } from "react";
3
3
  import { Box, Accordion, Field, SingleSelect, SingleSelectOption, Grid, Typography, Link } from "@strapi/design-system";
4
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-Ckaev6xU.mjs";
6
- import { W as WarningBox, u as useAllEntities } from "./WarningBox-CMQuE_Ov.mjs";
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";
7
7
  import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
8
8
  import { useIntl } from "react-intl";
9
9
  import "@strapi/icons/symbols";
10
10
  import { ExternalLink } from "@strapi/icons";
11
- import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-DTXdYICP.mjs";
11
+ import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-C1_2epDJ.mjs";
12
12
  function getRouteSourceFields(contentType) {
13
13
  if (!contentType?.attributes) return [];
14
14
  return Object.entries(contentType.attributes).filter(
@@ -2,12 +2,12 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useReducer, useState, useRef, useEffect } from "react";
3
3
  import { Field } from "@strapi/design-system";
4
4
  import { useNotification, Page } from "@strapi/strapi/admin";
5
- import { c as usePluginConfig, g as getTranslation, p as pluginPermissions } from "./index-Ckaev6xU.mjs";
5
+ import { c as usePluginConfig, g as getTranslation, p as pluginPermissions } from "./index-CVrufPeL.mjs";
6
6
  import { u as useErrorMessage, F as FullLoader } from "./FullLoader-BTZzPY8g.mjs";
7
7
  import { useIntl } from "react-intl";
8
8
  import "@strapi/icons/symbols";
9
9
  import "@strapi/icons";
10
- import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-DTXdYICP.mjs";
10
+ import { P as PageWrapper, C as ContentBox, S as SettingTitle } from "./SettingTitle-C1_2epDJ.mjs";
11
11
  function reducer(newConfig, action) {
12
12
  switch (action.type) {
13
13
  case "SET_MAX_DEPTH":
@@ -4,12 +4,12 @@ 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-BYytQZfK.js");
7
+ const index = require("./index-DHNPW0YT.js");
8
8
  const FullLoader = require("./FullLoader-C4hXFaLP.js");
9
9
  const reactIntl = require("react-intl");
10
10
  require("@strapi/icons/symbols");
11
11
  require("@strapi/icons");
12
- const SettingTitle = require("./SettingTitle-CBcBCh1h.js");
12
+ const SettingTitle = require("./SettingTitle-DXGCUfum.js");
13
13
  function reducer(newConfig, action) {
14
14
  switch (action.type) {
15
15
  case "SET_MAX_DEPTH":
@@ -7,11 +7,11 @@ const designSystem = require("@strapi/design-system");
7
7
  const React = require("react");
8
8
  const ReactDOM = require("react-dom");
9
9
  const reactIntl = require("react-intl");
10
- const index = require("./index-BYytQZfK.js");
10
+ const index = require("./index-DHNPW0YT.js");
11
11
  const FullLoader = require("./FullLoader-C4hXFaLP.js");
12
12
  const admin = require("@strapi/strapi/admin");
13
13
  const symbols = require("@strapi/icons/symbols");
14
- const WarningBox = require("./WarningBox-DsBtzhs3.js");
14
+ const WarningBox = require("./WarningBox-BHlYlKQ8.js");
15
15
  const core = require("@dnd-kit/core");
16
16
  const sortable = require("@dnd-kit/sortable");
17
17
  const utilities = require("@dnd-kit/utilities");
@@ -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-Ckaev6xU.mjs";
3
+ import { g as getTranslation, u as useApi, d as debounce, p as pluginPermissions, i as isAbortError } from "./index-CVrufPeL.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";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("./index-BYytQZfK.js");
3
+ const index = require("./index-DHNPW0YT.js");
4
4
  exports.default = index.index;
@@ -1,4 +1,4 @@
1
- import { j } from "./index-Ckaev6xU.mjs";
1
+ import { j } from "./index-CVrufPeL.mjs";
2
2
  export {
3
3
  j as default
4
4
  };