@mattisvensson/strapi-plugin-webatlas 0.2.5 → 0.3.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 (69) hide show
  1. package/README.md +2 -3
  2. package/dist/_chunks/{_baseConvert-DVIhGQH6.js.map → _baseConvert-B84_vf8X.js.map} +1 -1
  3. package/dist/_chunks/{_baseConvert-CDjccxdO.mjs.map → _baseConvert-C2SW1VHq.mjs.map} +1 -1
  4. package/dist/_chunks/de-4tL_cJTC.js +104 -0
  5. package/dist/_chunks/de-4tL_cJTC.js.map +1 -0
  6. package/dist/_chunks/de-C8PE3n3B.mjs +104 -0
  7. package/dist/_chunks/de-C8PE3n3B.mjs.map +1 -0
  8. package/dist/_chunks/en-Bg4z3fR7.js +104 -0
  9. package/dist/_chunks/en-Bg4z3fR7.js.map +1 -0
  10. package/dist/_chunks/en-CR1YZvJo.mjs +104 -0
  11. package/dist/_chunks/en-CR1YZvJo.mjs.map +1 -0
  12. package/dist/_chunks/{index-B-ABW-o6.js → index-B0XE_zRP.js} +298 -91
  13. package/dist/_chunks/index-B2Tiv3EK.mjs +92 -0
  14. package/dist/_chunks/{index-HHBjOGX5.mjs → index-B48CGofU.mjs} +70 -30
  15. package/dist/_chunks/{index-HHBjOGX5.mjs.map → index-B48CGofU.mjs.map} +1 -1
  16. package/dist/_chunks/{index-CAjBRbaH.js → index-B85fJxGa.js} +170 -77
  17. package/dist/_chunks/{index-Cs_oxZfX.js → index-BbM9Sn1t.js} +169 -108
  18. package/dist/_chunks/{index-BxuR805w.mjs → index-BocSkZOu.mjs} +57 -17
  19. package/dist/_chunks/{index-D_OdzeaU.mjs → index-C7B8QHDT.mjs} +296 -89
  20. package/dist/_chunks/{index-BjbgWZrg.mjs → index-CCiDvLAC.mjs} +171 -78
  21. package/dist/_chunks/index-CXzNr2cH.mjs +93 -0
  22. package/dist/_chunks/index-CXzNr2cH.mjs.map +1 -0
  23. package/dist/_chunks/{index-kz3NL7uv.js → index-Cd6y6nuf.js} +57 -8
  24. package/dist/_chunks/index-Cd6y6nuf.js.map +1 -0
  25. package/dist/_chunks/{index-CPE1Ne_e.js → index-Cf9ZIBLd.js} +171 -78
  26. package/dist/_chunks/index-Cf9ZIBLd.js.map +1 -0
  27. package/dist/_chunks/{index-yLrZAFVv.mjs → index-D981K4TK.mjs} +172 -79
  28. package/dist/_chunks/index-D981K4TK.mjs.map +1 -0
  29. package/dist/_chunks/{index-Djk_-mU6.js → index-DGb8ESH-.js} +56 -9
  30. package/dist/_chunks/{index-CuMn96qA.js → index-DYiJBXKE.js} +300 -93
  31. package/dist/_chunks/index-DYiJBXKE.js.map +1 -0
  32. package/dist/_chunks/{index-B7vKSyAn.js → index-DjZ3ZaVB.js} +60 -20
  33. package/dist/_chunks/{index-B7vKSyAn.js.map → index-DjZ3ZaVB.js.map} +1 -1
  34. package/dist/_chunks/{index-ChOgKZGK.mjs → index-DkhJl5mF.mjs} +298 -91
  35. package/dist/_chunks/index-DkhJl5mF.mjs.map +1 -0
  36. package/dist/admin/index.js +1 -1
  37. package/dist/admin/index.mjs +1 -1
  38. package/dist/admin/src/components/CMEditViewAside/Alias.d.ts +1 -1
  39. package/dist/admin/src/components/URLInfo.d.ts +2 -1
  40. package/dist/admin/src/components/modals/NavModal.d.ts +2 -1
  41. package/dist/admin/src/utils/getRouteType.d.ts +2 -0
  42. package/dist/admin/src/utils/index.d.ts +2 -1
  43. package/dist/server/index.js +23 -12
  44. package/dist/server/index.js.map +1 -1
  45. package/dist/server/index.mjs +23 -12
  46. package/dist/server/index.mjs.map +1 -1
  47. package/dist/server/src/content-types/index.d.ts +5 -5
  48. package/dist/server/src/content-types/navigation/index.d.ts +1 -1
  49. package/dist/server/src/content-types/navigation/schema.d.ts +1 -1
  50. package/dist/server/src/content-types/navitem/index.d.ts +3 -3
  51. package/dist/server/src/content-types/navitem/schema.d.ts +3 -3
  52. package/dist/server/src/content-types/route/index.d.ts +1 -1
  53. package/dist/server/src/content-types/route/schema.d.ts +1 -1
  54. package/dist/server/src/index.d.ts +5 -5
  55. package/package.json +1 -1
  56. package/dist/_chunks/_baseConvert-CDjccxdO.mjs +0 -859
  57. package/dist/_chunks/_baseConvert-DVIhGQH6.js +0 -858
  58. package/dist/_chunks/en-B4KWt_jN.js +0 -4
  59. package/dist/_chunks/en-B4KWt_jN.js.map +0 -1
  60. package/dist/_chunks/en-Byx4XI2L.mjs +0 -4
  61. package/dist/_chunks/en-Byx4XI2L.mjs.map +0 -1
  62. package/dist/_chunks/index-1VNPebOd.mjs +0 -45
  63. package/dist/_chunks/index-1VNPebOd.mjs.map +0 -1
  64. package/dist/_chunks/index-B5ilx6DT.mjs +0 -44
  65. package/dist/_chunks/index-CPE1Ne_e.js.map +0 -1
  66. package/dist/_chunks/index-ChOgKZGK.mjs.map +0 -1
  67. package/dist/_chunks/index-CuMn96qA.js.map +0 -1
  68. package/dist/_chunks/index-Djk_-mU6.js.map +0 -1
  69. package/dist/_chunks/index-yLrZAFVv.mjs.map +0 -1
@@ -3,9 +3,10 @@ import * as React from "react";
3
3
  import { useRef, useEffect, useState, useCallback, createContext, useMemo, createElement, useContext, Fragment, forwardRef, Children, isValidElement, cloneElement, useLayoutEffect, useReducer } from "react";
4
4
  import { Link, List, Information } from "@strapi/icons";
5
5
  import { useFetchClient, unstable_useContentManagerContext } from "@strapi/strapi/admin";
6
- import { Box, Typography, Flex, Field, Checkbox, Divider, Link as Link$1 } from "@strapi/design-system";
6
+ import { Box, Typography, Flex, Divider, Field, Checkbox, Link as Link$1 } from "@strapi/design-system";
7
7
  import * as ReactDOM from "react-dom";
8
8
  import ReactDOM__default, { flushSync } from "react-dom";
9
+ import { useIntl } from "react-intl";
9
10
  const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
10
11
  const v = glob[path];
11
12
  if (v) {
@@ -22,7 +23,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
22
23
  );
23
24
  });
24
25
  };
25
- const version = "0.2.4";
26
+ const version = "0.2.6";
26
27
  const keywords = [];
27
28
  const type = "commonjs";
28
29
  const exports = {
@@ -146,6 +147,7 @@ const pluginPkg = {
146
147
  packageManager
147
148
  };
148
149
  const PLUGIN_ID = pluginPkg.strapi.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, "") || "webatlas";
150
+ const PLUGIN_NAME = pluginPkg.strapi.displayName;
149
151
  const Initializer = ({ setPlugin }) => {
150
152
  const ref = useRef(setPlugin);
151
153
  useEffect(() => {
@@ -3641,6 +3643,7 @@ function Tooltip({ description: description2 }) {
3641
3643
  background: "neutral1000",
3642
3644
  hasRadius: true,
3643
3645
  shadow: "filterShadow",
3646
+ maxWidth: "300px",
3644
3647
  children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral0", children: description2 })
3645
3648
  }
3646
3649
  ) }) })
@@ -3657,19 +3660,6 @@ function debounce(func, wait) {
3657
3660
  timeout = setTimeout(later, wait);
3658
3661
  };
3659
3662
  }
3660
- function URLInfo({ validationState, replacement }) {
3661
- if (validationState === "initial") return null;
3662
- let color = "neutral800";
3663
- let text = "Checking if URL is available...";
3664
- if (validationState === "checking") {
3665
- color = "neutral800";
3666
- text = "Checking if URL is available...";
3667
- } else if (validationState === "done") {
3668
- color = replacement ? "danger500" : "success500";
3669
- text = replacement ? `URL is not available. Replaced with "${replacement}".` : "URL is available";
3670
- }
3671
- return /* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(Typography, { textColor: color, children: text }) });
3672
- }
3673
3663
  async function duplicateCheck(url, routeDocumentId) {
3674
3664
  if (!url) throw new Error("URL is required");
3675
3665
  try {
@@ -3681,6 +3671,33 @@ async function duplicateCheck(url, routeDocumentId) {
3681
3671
  throw new Error("Failed to check URL uniqueness");
3682
3672
  }
3683
3673
  }
3674
+ const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
3675
+ function URLInfo({ validationState, replacement, setUrlStatus }) {
3676
+ const [color, setColor] = useState(null);
3677
+ const [text, setText] = useState(null);
3678
+ const { formatMessage } = useIntl();
3679
+ useEffect(() => {
3680
+ if (validationState === "initial") return;
3681
+ if (validationState === "checking") {
3682
+ setColor("neutral800");
3683
+ setText(formatMessage({
3684
+ id: getTranslation("components.URLInfo.checking"),
3685
+ defaultMessage: "Checking if URL is available..."
3686
+ }));
3687
+ } else if (validationState === "done") {
3688
+ setColor(replacement ? "danger500" : "success500");
3689
+ setText(replacement ? `${formatMessage({
3690
+ id: getTranslation("components.URLInfo.notAvailable"),
3691
+ defaultMessage: "URL is not available. Replaced with"
3692
+ })} "${replacement}".` : formatMessage({
3693
+ id: getTranslation("components.URLInfo.available"),
3694
+ defaultMessage: "URL is available."
3695
+ }));
3696
+ if (setUrlStatus) setUrlStatus(replacement ? "invalid" : "valid");
3697
+ }
3698
+ }, [validationState, replacement, formatMessage, setUrlStatus]);
3699
+ return /* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(Typography, { textColor: color, children: text }) });
3700
+ }
3684
3701
  function reducer(state, action) {
3685
3702
  switch (action.type) {
3686
3703
  case "DEFAULT":
@@ -3715,14 +3732,16 @@ function reducer(state, action) {
3715
3732
  }
3716
3733
  }
3717
3734
  const Alias = ({ config }) => {
3718
- const { layout, form } = unstable_useContentManagerContext();
3735
+ const { form } = unstable_useContentManagerContext();
3719
3736
  const { initialValues, values, onChange } = form;
3720
3737
  const { getRelatedRoute } = useApi();
3738
+ const { formatMessage } = useIntl();
3721
3739
  const [routeId, setRouteId] = useState();
3722
3740
  const [isOverride, setIsOverride] = useState(false);
3723
3741
  const [validationState, setValidationState] = useState("initial");
3724
3742
  const [replacement, setReplacement] = useState("");
3725
3743
  const [initialLoadComplete, setInitialLoadComplete] = useState(false);
3744
+ const [urlIsValid, setUrlIsValid] = useState(null);
3726
3745
  const [path, dispatchPath] = useReducer(reducer, {
3727
3746
  needsUrlCheck: false,
3728
3747
  value: "",
@@ -3732,39 +3751,39 @@ const Alias = ({ config }) => {
3732
3751
  const hasUserChangedField = useRef(false);
3733
3752
  const initialPath = useRef("");
3734
3753
  const prevValueRef = useRef(null);
3735
- if (!config) return null;
3736
- const debouncedCheckUrl = useCallback(debounce(checkUrl, 500), []);
3754
+ const debouncedCheckUrl = useCallback(debounce(checkUrl, 250), []);
3737
3755
  useEffect(() => {
3738
3756
  onChange("webatlas_path", path.value);
3739
3757
  onChange("webatlas_override", isOverride);
3740
- }, [path.value, routeId, isOverride]);
3741
- const debouncedValueEffect = useMemo(
3742
- () => debounce((currentValues) => {
3743
- const key = config?.default;
3744
- if (!key) return;
3745
- const currentValue = currentValues[key];
3746
- if (!currentValue) {
3747
- dispatchPath({ type: "NO_URL_CHECK", payload: "" });
3748
- return;
3749
- }
3750
- if (initialLoadComplete && (hasUserChangedField.current || !routeId) && prevValueRef.current !== currentValue && !isOverride) {
3751
- const path2 = config.pattern ? `${config.pattern}/${currentValue}` : `${currentValue}`;
3752
- if (currentValue === initialValues[key]) {
3753
- dispatchPath({ type: "NO_URL_CHECK", payload: path2 });
3754
- } else {
3755
- dispatchPath({ type: "DEFAULT", payload: path2 });
3756
- }
3757
- prevValueRef.current = currentValue;
3758
+ }, [path.value, isOverride]);
3759
+ const debouncedValueEffect = useMemo(() => debounce((currentValues) => {
3760
+ const key = config?.default;
3761
+ if (!key) return;
3762
+ const currentValue = currentValues[key];
3763
+ if (!currentValue) {
3764
+ dispatchPath({ type: "NO_URL_CHECK", payload: "" });
3765
+ return;
3766
+ }
3767
+ if (initialLoadComplete && (hasUserChangedField.current || !routeId) && prevValueRef.current !== currentValue && !isOverride) {
3768
+ const path2 = config.pattern ? `${config.pattern}/${currentValue}` : `${currentValue}`;
3769
+ if (currentValue === initialValues[key]) {
3770
+ dispatchPath({ type: "NO_URL_CHECK", payload: path2 });
3771
+ } else {
3772
+ dispatchPath({ type: "DEFAULT", payload: path2 });
3758
3773
  }
3759
- }, 500),
3760
- [config?.default, config?.pattern, initialValues, isOverride, initialLoadComplete, routeId]
3761
- );
3774
+ prevValueRef.current = currentValue;
3775
+ }
3776
+ }, 500), [config?.default, config?.pattern, initialValues, isOverride, initialLoadComplete, routeId]);
3762
3777
  useEffect(() => {
3763
- if (!initialLoadComplete) return;
3764
3778
  const key = config?.default;
3765
3779
  if (!key) return;
3766
3780
  const currentValue = values[key];
3767
3781
  const initialValue = initialValues[key];
3782
+ if (currentValue && !isOverride) {
3783
+ const path2 = config.pattern ? `${config.pattern}/${currentValue}` : `${currentValue}`;
3784
+ onChange("webatlas_path", path2);
3785
+ }
3786
+ if (!initialLoadComplete) return;
3768
3787
  if (currentValue !== initialValue) {
3769
3788
  hasUserChangedField.current = true;
3770
3789
  }
@@ -3820,9 +3839,14 @@ const Alias = ({ config }) => {
3820
3839
  } catch (err) {
3821
3840
  console.log(err);
3822
3841
  } finally {
3842
+ setUrlIsValid(null);
3823
3843
  setValidationState("done");
3824
3844
  }
3825
3845
  }
3846
+ if (!initialLoadComplete) return /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
3847
+ id: getTranslation("components.CMEditViewAside.loading"),
3848
+ defaultMessage: "Loading..."
3849
+ }) });
3826
3850
  return /* @__PURE__ */ jsx(
3827
3851
  Box,
3828
3852
  {
@@ -3837,28 +3861,53 @@ const Alias = ({ config }) => {
3837
3861
  gap: 4,
3838
3862
  children: [
3839
3863
  /* @__PURE__ */ jsxs(Box, { children: [
3840
- /* @__PURE__ */ jsxs(Field.Root, { hint: !initialValues.id && !config.default ? "[id] will be replaced with the entry ID" : "", children: [
3841
- /* @__PURE__ */ jsxs(Field.Label, { children: [
3842
- "URL",
3843
- /* @__PURE__ */ jsx(Tooltip, { description: "The following characters are valid: A-Z, a-z, 0-9, /, -, _, $, ., +, !, *, ', (, )" })
3844
- ] }),
3845
- /* @__PURE__ */ jsx(
3846
- Field.Input,
3847
- {
3848
- id: "url-input",
3849
- value: path.value,
3850
- placeholder: config.default ? `Edit the "${config.default}" field to generate a URL` : `${layout.list.settings.displayName?.toLowerCase()}/[id]`,
3851
- onChange: (e) => dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: e.target.value }),
3852
- disabled: !isOverride,
3853
- onBlur: (e) => {
3854
- if (e.target.value === path.prevValue) return;
3855
- dispatchPath({ type: "DEFAULT", payload: e.target.value });
3856
- }
3857
- }
3858
- ),
3859
- /* @__PURE__ */ jsx(Field.Hint, {})
3864
+ !routeId && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3865
+ /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", marginBottom: 2, children: formatMessage({
3866
+ id: getTranslation("components.CMEditViewAside.alias.newRouteInfo"),
3867
+ defaultMessage: "A new URL route will be created upon saving this entry."
3868
+ }) }),
3869
+ /* @__PURE__ */ jsx(Box, { paddingBottom: 2, paddingTop: 2, children: /* @__PURE__ */ jsx(Divider, {}) })
3860
3870
  ] }),
3861
- /* @__PURE__ */ jsx(URLInfo, { validationState, replacement }),
3871
+ /* @__PURE__ */ jsxs(
3872
+ Field.Root,
3873
+ {
3874
+ hint: formatMessage({
3875
+ id: getTranslation("components.CMEditViewAside.alias.urlInput.start"),
3876
+ defaultMessage: "Edit the"
3877
+ }) + ' "' + config.default + '" ' + formatMessage({
3878
+ id: getTranslation("components.CMEditViewAside.alias.urlInput.end"),
3879
+ defaultMessage: "field to generate a URL"
3880
+ }),
3881
+ children: [
3882
+ /* @__PURE__ */ jsxs(Field.Label, { children: [
3883
+ formatMessage({
3884
+ id: getTranslation("components.CMEditViewAside.alias.urlInput.label"),
3885
+ defaultMessage: "URL"
3886
+ }),
3887
+ /* @__PURE__ */ jsx(Tooltip, { description: formatMessage({
3888
+ id: getTranslation("components.CMEditViewAside.alias.urlInput.tooltip"),
3889
+ defaultMessage: "The following characters are valid: A-Z, a-z, 0-9, /, -, _, $, ., +, !, *, ', (, )"
3890
+ }) })
3891
+ ] }),
3892
+ /* @__PURE__ */ jsx(
3893
+ Field.Input,
3894
+ {
3895
+ id: "url-input",
3896
+ value: path.value,
3897
+ onChange: (e) => dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: e.target.value }),
3898
+ disabled: !isOverride,
3899
+ onBlur: (e) => {
3900
+ if (e.target.value === path.prevValue) return;
3901
+ dispatchPath({ type: "DEFAULT", payload: e.target.value });
3902
+ },
3903
+ style: { outline: urlIsValid !== null ? urlIsValid === "valid" ? "1px solid #5cb176" : "1px solid #ee5e52" : void 0 }
3904
+ }
3905
+ ),
3906
+ /* @__PURE__ */ jsx(Field.Hint, {})
3907
+ ]
3908
+ }
3909
+ ),
3910
+ /* @__PURE__ */ jsx(URLInfo, { validationState, replacement, setUrlStatus: setUrlIsValid }),
3862
3911
  /* @__PURE__ */ jsx(
3863
3912
  Flex,
3864
3913
  {
@@ -3870,7 +3919,10 @@ const Alias = ({ config }) => {
3870
3919
  id: "override-url",
3871
3920
  checked: isOverride,
3872
3921
  onCheckedChange: () => setIsOverride((prev) => !prev),
3873
- children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: "Override generated URL" })
3922
+ children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
3923
+ id: getTranslation("components.CMEditViewAside.alias.overrideCheckbox"),
3924
+ defaultMessage: "Override automatic URL generation"
3925
+ }) })
3874
3926
  }
3875
3927
  )
3876
3928
  }
@@ -3881,8 +3933,14 @@ const Alias = ({ config }) => {
3881
3933
  /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
3882
3934
  Field.Root,
3883
3935
  {
3884
- hint: "Permanent UID path, cannot be changed.",
3885
- label: "UID path",
3936
+ hint: formatMessage({
3937
+ id: getTranslation("components.CMEditViewAside.alias.uidRoute.hint"),
3938
+ defaultMessage: "Permanent UID route, cannot be changed"
3939
+ }),
3940
+ label: formatMessage({
3941
+ id: getTranslation("components.CMEditViewAside.alias.uidRoute.label"),
3942
+ defaultMessage: "UID route"
3943
+ }),
3886
3944
  children: [
3887
3945
  /* @__PURE__ */ jsx(Field.Label, {}),
3888
3946
  /* @__PURE__ */ jsx(
@@ -3899,8 +3957,14 @@ const Alias = ({ config }) => {
3899
3957
  /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
3900
3958
  Field.Root,
3901
3959
  {
3902
- hint: "Permanent DocumentID path, cannot be changed.",
3903
- label: "DocumentID path",
3960
+ hint: formatMessage({
3961
+ id: getTranslation("components.CMEditViewAside.alias.documentIdRoute.hint"),
3962
+ defaultMessage: "Permanent Document ID route, cannot be changed"
3963
+ }),
3964
+ label: formatMessage({
3965
+ id: getTranslation("components.CMEditViewAside.alias.documentIdRoute.label"),
3966
+ defaultMessage: "Document ID route"
3967
+ }),
3904
3968
  children: [
3905
3969
  /* @__PURE__ */ jsx(Field.Label, {}),
3906
3970
  /* @__PURE__ */ jsx(
@@ -3929,6 +3993,7 @@ const CMEditViewAside = () => {
3929
3993
  const [isAllowedContentType, setIsAllowedContentType] = useState(false);
3930
3994
  const [isActiveContentType, setIsActiveContentType] = useState(false);
3931
3995
  const [isLoading, setIsLoading] = useState(true);
3996
+ const { formatMessage } = useIntl();
3932
3997
  useEffect(() => {
3933
3998
  if (!config) return;
3934
3999
  const contentType = contentTypes?.find((ct) => ct.uid === model);
@@ -3960,17 +4025,43 @@ const CMEditViewAside = () => {
3960
4025
  }
3961
4026
  });
3962
4027
  }, []);
3963
- if (isLoading) return /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: "Loading..." });
4028
+ if (isLoading || !config) return /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
4029
+ id: getTranslation("components.CMEditViewAside.loading"),
4030
+ defaultMessage: "Loading..."
4031
+ }) });
3964
4032
  if (!isAllowedContentType) return /* @__PURE__ */ jsxs(Typography, { textColor: "neutral600", children: [
3965
- "This content type is not allowed for ",
3966
- /* @__PURE__ */ jsx("strong", { children: "WebAtlas" }),
3967
- ". If you wish to use it, please contact your administrator."
4033
+ formatMessage({
4034
+ id: getTranslation("components.CMEditViewAside.notAllowed.start"),
4035
+ defaultMessage: "This content type is not allowed for"
4036
+ }),
4037
+ " ",
4038
+ /* @__PURE__ */ jsx("strong", { children: PLUGIN_NAME }),
4039
+ ".",
4040
+ " ",
4041
+ formatMessage({
4042
+ id: getTranslation("components.CMEditViewAside.notAllowed.end"),
4043
+ defaultMessage: "If you wish to use it, please contact your administrator"
4044
+ }),
4045
+ "."
3968
4046
  ] });
3969
4047
  if (!isActiveContentType || !contentTypeConfig) return /* @__PURE__ */ jsxs(Typography, { textColor: "neutral600", children: [
3970
- "This content type is not configured for ",
3971
- /* @__PURE__ */ jsx("strong", { children: "WebAtlas" }),
3972
- ". If you wish to use it, please configure it in the",
3973
- /* @__PURE__ */ jsx(Link$1, { href: "/admin/settings/webatlas/configuration", marginLeft: 1, children: "settings" }),
4048
+ formatMessage({
4049
+ id: getTranslation("components.CMEditViewAside.notConfigured.start"),
4050
+ defaultMessage: "This content type is not configured for"
4051
+ }),
4052
+ " ",
4053
+ /* @__PURE__ */ jsx("strong", { children: PLUGIN_NAME }),
4054
+ ".",
4055
+ " ",
4056
+ formatMessage({
4057
+ id: getTranslation("components.CMEditViewAside.notConfigured.middle"),
4058
+ defaultMessage: "If you wish to use it, please configure it in the"
4059
+ }),
4060
+ " ",
4061
+ /* @__PURE__ */ jsx(Link$1, { href: "/admin/settings/webatlas/configuration", children: formatMessage({
4062
+ id: getTranslation("components.CMEditViewAside.notConfigured.end"),
4063
+ defaultMessage: "settings"
4064
+ }) }),
3974
4065
  "."
3975
4066
  ] });
3976
4067
  return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Alias, { config: contentTypeConfig }) });
@@ -3985,7 +4076,7 @@ const index = {
3985
4076
  defaultMessage: "Routes"
3986
4077
  },
3987
4078
  Component: async () => {
3988
- const component = await import("./index-B5ilx6DT.mjs");
4079
+ const component = await import("./index-B2Tiv3EK.mjs");
3989
4080
  return { default: component.default };
3990
4081
  },
3991
4082
  permissions: [
@@ -4004,7 +4095,7 @@ const index = {
4004
4095
  defaultMessage: "Navigation"
4005
4096
  },
4006
4097
  Component: async () => {
4007
- const component = await import("./index-D_OdzeaU.mjs");
4098
+ const component = await import("./index-C7B8QHDT.mjs");
4008
4099
  return { default: component.default };
4009
4100
  },
4010
4101
  permissions: [
@@ -4033,7 +4124,7 @@ const index = {
4033
4124
  Component: async () => {
4034
4125
  return await import(
4035
4126
  /* webpackChunkName: "webatlas-settings-page" */
4036
- "./index-BxuR805w.mjs"
4127
+ "./index-BocSkZOu.mjs"
4037
4128
  );
4038
4129
  },
4039
4130
  permissions: [
@@ -4062,7 +4153,7 @@ const index = {
4062
4153
  return Promise.all(
4063
4154
  locales.map(async (locale) => {
4064
4155
  try {
4065
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-Byx4XI2L.mjs") }), `./translations/${locale}.json`, 3);
4156
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-C8PE3n3B.mjs"), "./translations/en.json": () => import("./en-CR1YZvJo.mjs") }), `./translations/${locale}.json`, 3);
4066
4157
  return { data, locale };
4067
4158
  } catch {
4068
4159
  return { data: {}, locale };
@@ -4072,6 +4163,7 @@ const index = {
4072
4163
  }
4073
4164
  };
4074
4165
  export {
4166
+ PLUGIN_NAME as P,
4075
4167
  Tooltip as T,
4076
4168
  URLInfo as U,
4077
4169
  _extends as _,
@@ -4079,6 +4171,7 @@ export {
4079
4171
  usePluginConfig as b,
4080
4172
  useAllContentTypes as c,
4081
4173
  debounce as d,
4174
+ getTranslation as g,
4082
4175
  index as i,
4083
4176
  transformToUrl as t,
4084
4177
  useApi as u
@@ -0,0 +1,93 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ import { Layouts } from "@strapi/strapi/admin";
4
+ import { Table, Thead, Tr, Th, Typography, VisuallyHidden, Tbody, Td, Flex, LinkButton } from "@strapi/design-system";
5
+ import { Pencil } from "@strapi/icons";
6
+ import { u as useApi, g as getTranslation } from "./index-D981K4TK.mjs";
7
+ import { C as Center, E as EmptyBox } from "./EmptyBox-7D4LrvdH.mjs";
8
+ import { useIntl } from "react-intl";
9
+ function getRouteType(route) {
10
+ if (route.wrapper) {
11
+ return "wrapper";
12
+ } else if (!route.internal) {
13
+ return "external";
14
+ } else {
15
+ return "internal";
16
+ }
17
+ }
18
+ const Routes = () => {
19
+ const { getRoutes } = useApi();
20
+ const { formatMessage } = useIntl();
21
+ const [routes, setRoutes] = useState([]);
22
+ useEffect(() => {
23
+ async function fetchRoutes() {
24
+ const data = await getRoutes();
25
+ setRoutes(data);
26
+ }
27
+ fetchRoutes();
28
+ }, []);
29
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ /* @__PURE__ */ jsx(
31
+ Layouts.Header,
32
+ {
33
+ title: formatMessage({
34
+ id: getTranslation("routes.page.title"),
35
+ defaultMessage: "Routes"
36
+ }),
37
+ subtitle: formatMessage({
38
+ id: getTranslation("routes.page.subtitle"),
39
+ defaultMessage: "Overview of all existing routes"
40
+ })
41
+ }
42
+ ),
43
+ /* @__PURE__ */ jsx(Layouts.Content, { children: routes.length === 0 ? /* @__PURE__ */ jsx(Center, { height: 400, children: /* @__PURE__ */ jsx(EmptyBox, { msg: formatMessage({
44
+ id: getTranslation("routes.page.emptyRoutes"),
45
+ defaultMessage: "No routes found"
46
+ }) }) }) : /* @__PURE__ */ jsxs(Table, { colCount: 4, rowCount: routes.length, children: [
47
+ /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
48
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "ID" }) }),
49
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
50
+ id: getTranslation("title"),
51
+ defaultMessage: "Title"
52
+ }) }) }),
53
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
54
+ id: getTranslation("route"),
55
+ defaultMessage: "Route"
56
+ }) }) }),
57
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
58
+ id: getTranslation("routes.page.column.type"),
59
+ defaultMessage: "Type"
60
+ }) }) }),
61
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: formatMessage({
62
+ id: getTranslation("actions"),
63
+ defaultMessage: "Actions"
64
+ }) }) })
65
+ ] }) }),
66
+ /* @__PURE__ */ jsx(Tbody, { children: routes.map((route) => /* @__PURE__ */ jsxs(Tr, { children: [
67
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.id }) }),
68
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.title }) }),
69
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.fullPath }) }),
70
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
71
+ id: getTranslation(`route.type.${getRouteType(route)}`),
72
+ defaultMessage: "-"
73
+ }) }) }),
74
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { gap: 2, justifyContent: "end", children: route.internal && /* @__PURE__ */ jsx(
75
+ LinkButton,
76
+ {
77
+ variant: "secondary",
78
+ startIcon: /* @__PURE__ */ jsx(Pencil, {}),
79
+ href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`,
80
+ children: formatMessage({
81
+ id: getTranslation("edit"),
82
+ defaultMessage: "Edit"
83
+ })
84
+ }
85
+ ) }) })
86
+ ] }, route.id)) })
87
+ ] }) })
88
+ ] });
89
+ };
90
+ export {
91
+ Routes as default
92
+ };
93
+ //# sourceMappingURL=index-CXzNr2cH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CXzNr2cH.mjs","sources":["../../admin/src/utils/getRouteType.ts","../../admin/src/pages/Routes/index.tsx"],"sourcesContent":["import type { Route } from \"../../../types\";\n\nexport default function getRouteType(route: Route): 'internal' | 'external' | 'wrapper' {\n if (route.wrapper) {\n return 'wrapper';\n } else if (!route.internal) {\n return 'external';\n } else {\n return 'internal';\n }\n}","/*\n *\n * Routes\n * This file contains the Routes page of the Webatlas plugin for Strapi.\n * It displays a table of all existing routes with their details and allows editing.\n *\n*/\n\nimport { useState, useEffect } from 'react';\nimport { Layouts } from '@strapi/strapi/admin';\nimport { Flex, Typography, Table, Thead, Tbody, Tr, Td, Th, VisuallyHidden, LinkButton } from '@strapi/design-system';\nimport { Pencil } from '@strapi/icons';\nimport { Route } from '../../../../types';\nimport { useApi } from '../../hooks';\nimport { EmptyBox, Center } from '../../components/UI';\nimport { getTranslation, getRouteType } from '../../utils';\nimport { useIntl } from 'react-intl';\n\nconst Routes = () => {\n const { getRoutes } = useApi();\n const { formatMessage } = useIntl();\n\n const [routes, setRoutes] = useState<Route[]>([]);\n\n useEffect(() => {\n async function fetchRoutes() {\n const data = await getRoutes();\n setRoutes(data);\n }\n fetchRoutes();\n }, [])\n\n return (\n <>\n <Layouts.Header\n title={formatMessage({\n id: getTranslation('routes.page.title'),\n defaultMessage: 'Routes',\n })}\n subtitle={formatMessage({\n id: getTranslation('routes.page.subtitle'),\n defaultMessage: 'Overview of all existing routes',\n })}\n />\n <Layouts.Content>\n {routes.length === 0 ? (\n <Center height={400}>\n <EmptyBox msg={formatMessage({\n id: getTranslation('routes.page.emptyRoutes'),\n defaultMessage: 'No routes found',\n })} />\n </Center>\n ) : (\n <Table colCount={4} rowCount={routes.length}>\n <Thead>\n <Tr>\n <Th>\n <Typography variant=\"sigma\">ID</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('title'),\n defaultMessage: 'Title',\n })}\n </Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('route'),\n defaultMessage: 'Route',\n })}\n </Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('routes.page.column.type'),\n defaultMessage: 'Type',\n })}\n </Typography>\n </Th>\n <Th>\n <VisuallyHidden>\n {formatMessage({\n id: getTranslation('actions'),\n defaultMessage: 'Actions',\n })}\n </VisuallyHidden>\n </Th>\n </Tr>\n </Thead>\n <Tbody>\n {routes.map((route: Route) => (\n <Tr key={route.id}>\n <Td>\n <Typography textColor=\"neutral800\">{route.id}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{route.title}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{route.fullPath}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">\n {formatMessage({\n id: getTranslation(`route.type.${getRouteType(route)}`),\n defaultMessage: '-',\n })}\n </Typography>\n </Td>\n <Td>\n <Flex gap={2} justifyContent=\"end\">\n {route.internal && \n <LinkButton\n variant=\"secondary\"\n startIcon={<Pencil />} \n href={`/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`}\n >\n {formatMessage({\n id: getTranslation('edit'),\n defaultMessage: 'Edit',\n })}\n </LinkButton>\n }\n </Flex>\n </Td>\n </Tr>\n ))}\n </Tbody>\n </Table>\n )}\n </Layouts.Content>\n </>\n );\n};\n\nexport default Routes;"],"names":[],"mappings":";;;;;;;;AAEA,SAAwB,aAAa,OAAmD;AACtF,MAAI,MAAM,SAAS;AACV,WAAA;AAAA,EAAA,WACE,CAAC,MAAM,UAAU;AACnB,WAAA;AAAA,EAAA,OACF;AACE,WAAA;AAAA,EAAA;AAEX;ACQA,MAAM,SAAS,MAAM;AACb,QAAA,EAAE,UAAU,IAAI,OAAO;AACvB,QAAA,EAAE,cAAc,IAAI,QAAQ;AAElC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAkB,CAAA,CAAE;AAEhD,Y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ACF;AAEJ;"}
@@ -5,10 +5,21 @@ const React = require("react");
5
5
  const admin = require("@strapi/strapi/admin");
6
6
  const designSystem = require("@strapi/design-system");
7
7
  const icons = require("@strapi/icons");
8
- const index = require("./index-CAjBRbaH.js");
8
+ const index = require("./index-Cf9ZIBLd.js");
9
9
  const EmptyBox = require("./EmptyBox-DT6D5gcf.js");
10
+ const reactIntl = require("react-intl");
11
+ function getRouteType(route) {
12
+ if (route.wrapper) {
13
+ return "wrapper";
14
+ } else if (!route.internal) {
15
+ return "external";
16
+ } else {
17
+ return "internal";
18
+ }
19
+ }
10
20
  const Routes = () => {
11
21
  const { getRoutes } = index.useApi();
22
+ const { formatMessage } = reactIntl.useIntl();
12
23
  const [routes, setRoutes] = React.useState([]);
13
24
  React.useEffect(() => {
14
25
  async function fetchRoutes() {
@@ -21,24 +32,62 @@ const Routes = () => {
21
32
  /* @__PURE__ */ jsxRuntime.jsx(
22
33
  admin.Layouts.Header,
23
34
  {
24
- title: "Routes",
25
- subtitle: "Overview of all existing routes"
35
+ title: formatMessage({
36
+ id: index.getTranslation("routes.page.title"),
37
+ defaultMessage: "Routes"
38
+ }),
39
+ subtitle: formatMessage({
40
+ id: index.getTranslation("routes.page.subtitle"),
41
+ defaultMessage: "Overview of all existing routes"
42
+ })
26
43
  }
27
44
  ),
28
- /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: routes.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.Center, { height: 400, children: /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.EmptyBox, { msg: "No routes found" }) }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 4, rowCount: routes.length, children: [
45
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: routes.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.Center, { height: 400, children: /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.EmptyBox, { msg: formatMessage({
46
+ id: index.getTranslation("routes.page.emptyRoutes"),
47
+ defaultMessage: "No routes found"
48
+ }) }) }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 4, rowCount: routes.length, children: [
29
49
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
30
50
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "ID" }) }),
31
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Title" }) }),
32
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Route" }) }),
33
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: "Actions" }) })
51
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
52
+ id: index.getTranslation("title"),
53
+ defaultMessage: "Title"
54
+ }) }) }),
55
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
56
+ id: index.getTranslation("route"),
57
+ defaultMessage: "Route"
58
+ }) }) }),
59
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
60
+ id: index.getTranslation("routes.page.column.type"),
61
+ defaultMessage: "Type"
62
+ }) }) }),
63
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({
64
+ id: index.getTranslation("actions"),
65
+ defaultMessage: "Actions"
66
+ }) }) })
34
67
  ] }) }),
35
68
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: routes.map((route) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
36
69
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.id }) }),
37
70
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.title }) }),
38
71
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.fullPath }) }),
39
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, justifyContent: "end", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { variant: "secondary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}), href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`, children: "Edit" }) }) })
72
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: formatMessage({
73
+ id: index.getTranslation(`route.type.${getRouteType(route)}`),
74
+ defaultMessage: "-"
75
+ }) }) }),
76
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, justifyContent: "end", children: route.internal && /* @__PURE__ */ jsxRuntime.jsx(
77
+ designSystem.LinkButton,
78
+ {
79
+ variant: "secondary",
80
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}),
81
+ href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`,
82
+ children: formatMessage({
83
+ id: index.getTranslation("edit"),
84
+ defaultMessage: "Edit"
85
+ })
86
+ }
87
+ ) }) })
40
88
  ] }, route.id)) })
41
89
  ] }) })
42
90
  ] });
43
91
  };
44
92
  exports.default = Routes;
93
+ //# sourceMappingURL=index-Cd6y6nuf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Cd6y6nuf.js","sources":["../../admin/src/utils/getRouteType.ts","../../admin/src/pages/Routes/index.tsx"],"sourcesContent":["import type { Route } from \"../../../types\";\n\nexport default function getRouteType(route: Route): 'internal' | 'external' | 'wrapper' {\n if (route.wrapper) {\n return 'wrapper';\n } else if (!route.internal) {\n return 'external';\n } else {\n return 'internal';\n }\n}","/*\n *\n * Routes\n * This file contains the Routes page of the Webatlas plugin for Strapi.\n * It displays a table of all existing routes with their details and allows editing.\n *\n*/\n\nimport { useState, useEffect } from 'react';\nimport { Layouts } from '@strapi/strapi/admin';\nimport { Flex, Typography, Table, Thead, Tbody, Tr, Td, Th, VisuallyHidden, LinkButton } from '@strapi/design-system';\nimport { Pencil } from '@strapi/icons';\nimport { Route } from '../../../../types';\nimport { useApi } from '../../hooks';\nimport { EmptyBox, Center } from '../../components/UI';\nimport { getTranslation, getRouteType } from '../../utils';\nimport { useIntl } from 'react-intl';\n\nconst Routes = () => {\n const { getRoutes } = useApi();\n const { formatMessage } = useIntl();\n\n const [routes, setRoutes] = useState<Route[]>([]);\n\n useEffect(() => {\n async function fetchRoutes() {\n const data = await getRoutes();\n setRoutes(data);\n }\n fetchRoutes();\n }, [])\n\n return (\n <>\n <Layouts.Header\n title={formatMessage({\n id: getTranslation('routes.page.title'),\n defaultMessage: 'Routes',\n })}\n subtitle={formatMessage({\n id: getTranslation('routes.page.subtitle'),\n defaultMessage: 'Overview of all existing routes',\n })}\n />\n <Layouts.Content>\n {routes.length === 0 ? (\n <Center height={400}>\n <EmptyBox msg={formatMessage({\n id: getTranslation('routes.page.emptyRoutes'),\n defaultMessage: 'No routes found',\n })} />\n </Center>\n ) : (\n <Table colCount={4} rowCount={routes.length}>\n <Thead>\n <Tr>\n <Th>\n <Typography variant=\"sigma\">ID</Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('title'),\n defaultMessage: 'Title',\n })}\n </Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('route'),\n defaultMessage: 'Route',\n })}\n </Typography>\n </Th>\n <Th>\n <Typography variant=\"sigma\">\n {formatMessage({\n id: getTranslation('routes.page.column.type'),\n defaultMessage: 'Type',\n })}\n </Typography>\n </Th>\n <Th>\n <VisuallyHidden>\n {formatMessage({\n id: getTranslation('actions'),\n defaultMessage: 'Actions',\n })}\n </VisuallyHidden>\n </Th>\n </Tr>\n </Thead>\n <Tbody>\n {routes.map((route: Route) => (\n <Tr key={route.id}>\n <Td>\n <Typography textColor=\"neutral800\">{route.id}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{route.title}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">{route.fullPath}</Typography>\n </Td>\n <Td>\n <Typography textColor=\"neutral800\">\n {formatMessage({\n id: getTranslation(`route.type.${getRouteType(route)}`),\n defaultMessage: '-',\n })}\n </Typography>\n </Td>\n <Td>\n <Flex gap={2} justifyContent=\"end\">\n {route.internal && \n <LinkButton\n variant=\"secondary\"\n startIcon={<Pencil />} \n href={`/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`}\n >\n {formatMessage({\n id: getTranslation('edit'),\n defaultMessage: 'Edit',\n })}\n </LinkButton>\n }\n </Flex>\n </Td>\n </Tr>\n ))}\n </Tbody>\n </Table>\n )}\n </Layouts.Content>\n </>\n );\n};\n\nexport default Routes;"],"names":["useApi","useIntl","useState","useEffect","jsxs","Fragment","jsx","Layouts","getTranslation","Center","EmptyBox","Table","Thead","Tr","Th","Typography","VisuallyHidden","Tbody","Td","Flex","LinkButton","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