@mattisvensson/strapi-plugin-webatlas 0.1.6 → 0.2.1

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 (29) hide show
  1. package/README.md +32 -5
  2. package/dist/_chunks/EmptyBox-7D4LrvdH.mjs +16 -0
  3. package/dist/_chunks/EmptyBox-DT6D5gcf.js +15 -0
  4. package/dist/_chunks/_baseConvert-B84_vf8X.js +864 -0
  5. package/dist/_chunks/_baseConvert-C2SW1VHq.mjs +865 -0
  6. package/dist/_chunks/{index-B3GOkpFO.js → index-B2j5uojM.js} +3140 -32
  7. package/dist/_chunks/{index-DWbEC3_A.mjs → index-BDU-lYsm.mjs} +14 -844
  8. package/dist/_chunks/{index-BoTOXEX8.mjs → index-BwErs0UT.mjs} +4 -7
  9. package/dist/_chunks/{index-DDVtOWSL.js → index-DC0vflKd.js} +4 -7
  10. package/dist/_chunks/{index-DfHrvxDY.js → index-DOVsVqnP.js} +39 -28
  11. package/dist/_chunks/{index-q4x-lnlr.js → index-DU_hn0uc.js} +30 -860
  12. package/dist/_chunks/{index-DL3LkD8O.mjs → index-Doc1ry3x.mjs} +3136 -28
  13. package/dist/_chunks/{index-lOv9Po4g.mjs → index-c7q9J79y.mjs} +39 -28
  14. package/dist/admin/index.js +1 -1
  15. package/dist/admin/index.mjs +1 -1
  16. package/dist/admin/src/{pages/Navigation/EmptyNav.d.ts → components/UI/EmptyBox.d.ts} +1 -1
  17. package/dist/admin/src/components/UI/index.d.ts +3 -0
  18. package/dist/admin/src/hooks/useApi.d.ts +1 -1
  19. package/dist/server/index.js +4246 -272
  20. package/dist/server/index.mjs +4246 -272
  21. package/dist/server/src/controllers/admin.d.ts +2 -1
  22. package/dist/server/src/controllers/index.d.ts +2 -1
  23. package/dist/server/src/index.d.ts +5 -3
  24. package/dist/server/src/services/admin.d.ts +2 -1
  25. package/dist/server/src/services/client.d.ts +1 -1
  26. package/dist/server/src/services/index.d.ts +3 -2
  27. package/package.json +1 -1
  28. package/dist/_chunks/_commonjsHelpers-BxmBWJD2.mjs +0 -33
  29. package/dist/_chunks/_commonjsHelpers-Cq6wktVC.js +0 -32
@@ -3,7 +3,8 @@ import { useState, useEffect } from "react";
3
3
  import { Layouts } from "@strapi/strapi/admin";
4
4
  import { Table, Thead, Tr, Th, Typography, VisuallyHidden, Tbody, Td, Flex, LinkButton } from "@strapi/design-system";
5
5
  import { Pencil } from "@strapi/icons";
6
- import { u as useApi } from "./index-lOv9Po4g.mjs";
6
+ import { u as useApi } from "./index-c7q9J79y.mjs";
7
+ import { C as Center, E as EmptyBox } from "./EmptyBox-7D4LrvdH.mjs";
7
8
  const Routes = () => {
8
9
  const { getRoutes } = useApi();
9
10
  const [routes, setRoutes] = useState([]);
@@ -22,22 +23,18 @@ const Routes = () => {
22
23
  subtitle: "Overview of all existing routes"
23
24
  }
24
25
  ),
25
- /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsxs(Table, { colCount: 6, rowCount: routes.length, children: [
26
+ /* @__PURE__ */ jsx(Layouts.Content, { children: routes.length === 0 ? /* @__PURE__ */ jsx(Center, { height: 400, children: /* @__PURE__ */ jsx(EmptyBox, { msg: "No routes found" }) }) : /* @__PURE__ */ jsxs(Table, { colCount: 4, rowCount: routes.length, children: [
26
27
  /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
27
28
  /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "ID" }) }),
28
29
  /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Title" }) }),
29
30
  /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Route" }) }),
30
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Internal" }) }),
31
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Active" }) }),
32
31
  /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: "Actions" }) })
33
32
  ] }) }),
34
33
  /* @__PURE__ */ jsx(Tbody, { children: routes.map((route) => /* @__PURE__ */ jsxs(Tr, { children: [
35
34
  /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.id }) }),
36
35
  /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.title }) }),
37
36
  /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.fullPath }) }),
38
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.internal ? "Yes" : "No" }) }),
39
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.active ? "Yes" : "No" }) }),
40
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { gap: 2, justifyContent: "end", children: /* @__PURE__ */ jsx(LinkButton, { variant: "secondary", startIcon: /* @__PURE__ */ jsx(Pencil, {}), href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedId}`, children: "Edit" }) }) })
37
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { gap: 2, justifyContent: "end", children: /* @__PURE__ */ jsx(LinkButton, { variant: "secondary", startIcon: /* @__PURE__ */ jsx(Pencil, {}), href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`, children: "Edit" }) }) })
41
38
  ] }, route.id)) })
42
39
  ] }) })
43
40
  ] });
@@ -5,7 +5,8 @@ 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-DfHrvxDY.js");
8
+ const index = require("./index-DOVsVqnP.js");
9
+ const EmptyBox = require("./EmptyBox-DT6D5gcf.js");
9
10
  const Routes = () => {
10
11
  const { getRoutes } = index.useApi();
11
12
  const [routes, setRoutes] = React.useState([]);
@@ -24,22 +25,18 @@ const Routes = () => {
24
25
  subtitle: "Overview of all existing routes"
25
26
  }
26
27
  ),
27
- /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 6, rowCount: routes.length, children: [
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: [
28
29
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
29
30
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "ID" }) }),
30
31
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Title" }) }),
31
32
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Route" }) }),
32
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Internal" }) }),
33
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Active" }) }),
34
33
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: "Actions" }) })
35
34
  ] }) }),
36
35
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: routes.map((route) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
37
36
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.id }) }),
38
37
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.title }) }),
39
38
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.fullPath }) }),
40
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.internal ? "Yes" : "No" }) }),
41
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.active ? "Yes" : "No" }) }),
42
- /* @__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.relatedId}`, children: "Edit" }) }) })
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" }) }) })
43
40
  ] }, route.id)) })
44
41
  ] }) })
45
42
  ] });
@@ -40,7 +40,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
40
40
  );
41
41
  });
42
42
  };
43
- const version = "0.1.5";
43
+ const version = "0.2.1";
44
44
  const keywords = [];
45
45
  const type = "commonjs";
46
46
  const exports$1 = {
@@ -207,10 +207,9 @@ function useApi() {
207
207
  throw err;
208
208
  }
209
209
  };
210
- const getRouteByRelated = async (relatedDocumentId, populate) => {
211
- const { data } = await get(`/content-manager/collection-types/plugin::webatlas.route?filters[relatedDocumentId][$eq]=${relatedDocumentId}${populate ? "&populate" + populate : ""}`);
212
- if (data?.results) return data.results[0];
213
- return null;
210
+ const getRelatedRoute = async (relatedDocumentId) => {
211
+ const { data } = await get(`/webatlas/route/related?documentId=${relatedDocumentId}`);
212
+ return data;
214
213
  };
215
214
  const createExternalRoute = async (body) => {
216
215
  const { data } = await post("/webatlas/route/external", {
@@ -266,7 +265,20 @@ function useApi() {
266
265
  });
267
266
  return data;
268
267
  };
269
- return { fetchAllContentTypes, fetchAllEntities, getRouteByRelated, createExternalRoute, getRoutes, updateRoute, createNavItem, updateNavItem, deleteNavItem, getStructuredNavigation, deleteNavigation, updateNavigation };
268
+ return {
269
+ fetchAllContentTypes,
270
+ fetchAllEntities,
271
+ getRelatedRoute,
272
+ createExternalRoute,
273
+ getRoutes,
274
+ updateRoute,
275
+ createNavItem,
276
+ updateNavItem,
277
+ deleteNavItem,
278
+ getStructuredNavigation,
279
+ deleteNavigation,
280
+ updateNavigation
281
+ };
270
282
  }
271
283
  const useAllContentTypes = () => {
272
284
  const { fetchAllContentTypes } = useApi();
@@ -3721,7 +3733,7 @@ function reducer(state, action) {
3721
3733
  const Alias = ({ config }) => {
3722
3734
  const { layout, form } = admin.unstable_useContentManagerContext();
3723
3735
  const { initialValues, values, onChange } = form;
3724
- const { getRouteByRelated } = useApi();
3736
+ const { getRelatedRoute } = useApi();
3725
3737
  const [routeId, setRouteId] = React.useState();
3726
3738
  const [isOverride, setIsOverride] = React.useState(false);
3727
3739
  const [validationState, setValidationState] = React.useState("initial");
@@ -3788,7 +3800,7 @@ const Alias = ({ config }) => {
3788
3800
  return;
3789
3801
  }
3790
3802
  try {
3791
- const route = await getRouteByRelated(initialValues.documentId);
3803
+ const route = await getRelatedRoute(initialValues.documentId);
3792
3804
  if (!route) return;
3793
3805
  initialPath.current = initialValues.webatlas_path || route.uIdPath;
3794
3806
  setRouteId(route.id);
@@ -3946,24 +3958,23 @@ const CMEditViewAside = () => {
3946
3958
  setIsLoading(false);
3947
3959
  }, [config]);
3948
3960
  React.useEffect(() => {
3949
- const label = Array.from(document.querySelectorAll("label")).find((l) => l.textContent?.startsWith("webatlas_path"));
3950
- if (label) {
3951
- let parentDiv = label.closest("div");
3952
- for (let i = 0; i < 2; i++) {
3953
- if (parentDiv) {
3954
- parentDiv = parentDiv.parentElement;
3955
- }
3956
- }
3957
- if (parentDiv) {
3958
- const grandParentDiv = parentDiv.parentElement;
3959
- if (grandParentDiv && grandParentDiv.children.length === 1) {
3960
- grandParentDiv.parentElement?.remove();
3961
- return;
3962
- } else {
3963
- parentDiv.remove();
3964
- }
3961
+ const isWebatlasLabel = (label) => label.textContent?.startsWith("webatlas_");
3962
+ document.querySelectorAll("label").forEach((label) => {
3963
+ if (!isWebatlasLabel(label)) return;
3964
+ const container = label.parentElement?.parentElement;
3965
+ const parent = container?.parentElement;
3966
+ const greatGrandParent = parent?.parentElement?.parentElement;
3967
+ if (!container || !parent) return;
3968
+ const parentWebatlasCount = Array.from(parent.querySelectorAll("label")).filter(isWebatlasLabel).length;
3969
+ const childrenCount = parent.children.length;
3970
+ if (greatGrandParent && greatGrandParent?.querySelectorAll("label").length === Array.from(greatGrandParent.querySelectorAll("label")).filter(isWebatlasLabel).length) {
3971
+ greatGrandParent.remove();
3972
+ } else if (childrenCount === 1 || childrenCount === 2 && parentWebatlasCount === 2) {
3973
+ parent.remove();
3974
+ } else {
3975
+ container.remove();
3965
3976
  }
3966
- }
3977
+ });
3967
3978
  }, []);
3968
3979
  if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: "Loading..." });
3969
3980
  if (!isAllowedContentType) return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { textColor: "neutral600", children: [
@@ -3990,7 +4001,7 @@ const index = {
3990
4001
  defaultMessage: "Routes"
3991
4002
  },
3992
4003
  Component: async () => {
3993
- const component = await Promise.resolve().then(() => require("./index-DDVtOWSL.js"));
4004
+ const component = await Promise.resolve().then(() => require("./index-DC0vflKd.js"));
3994
4005
  return { default: component.default };
3995
4006
  },
3996
4007
  permissions: [
@@ -4009,7 +4020,7 @@ const index = {
4009
4020
  defaultMessage: "Navigation"
4010
4021
  },
4011
4022
  Component: async () => {
4012
- const component = await Promise.resolve().then(() => require("./index-B3GOkpFO.js"));
4023
+ const component = await Promise.resolve().then(() => require("./index-B2j5uojM.js"));
4013
4024
  return { default: component.default };
4014
4025
  },
4015
4026
  permissions: [
@@ -4038,7 +4049,7 @@ const index = {
4038
4049
  Component: async () => {
4039
4050
  return await Promise.resolve().then(() => require(
4040
4051
  /* webpackChunkName: "webatlas-settings-page" */
4041
- "./index-q4x-lnlr.js"
4052
+ "./index-DU_hn0uc.js"
4042
4053
  ));
4043
4054
  },
4044
4055
  permissions: [