@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
@@ -22,7 +22,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
22
22
  );
23
23
  });
24
24
  };
25
- const version = "0.1.5";
25
+ const version = "0.2.1";
26
26
  const keywords = [];
27
27
  const type = "commonjs";
28
28
  const exports = {
@@ -189,10 +189,9 @@ function useApi() {
189
189
  throw err;
190
190
  }
191
191
  };
192
- const getRouteByRelated = async (relatedDocumentId, populate) => {
193
- const { data } = await get(`/content-manager/collection-types/plugin::webatlas.route?filters[relatedDocumentId][$eq]=${relatedDocumentId}${populate ? "&populate" + populate : ""}`);
194
- if (data?.results) return data.results[0];
195
- return null;
192
+ const getRelatedRoute = async (relatedDocumentId) => {
193
+ const { data } = await get(`/webatlas/route/related?documentId=${relatedDocumentId}`);
194
+ return data;
196
195
  };
197
196
  const createExternalRoute = async (body) => {
198
197
  const { data } = await post("/webatlas/route/external", {
@@ -248,7 +247,20 @@ function useApi() {
248
247
  });
249
248
  return data;
250
249
  };
251
- return { fetchAllContentTypes, fetchAllEntities, getRouteByRelated, createExternalRoute, getRoutes, updateRoute, createNavItem, updateNavItem, deleteNavItem, getStructuredNavigation, deleteNavigation, updateNavigation };
250
+ return {
251
+ fetchAllContentTypes,
252
+ fetchAllEntities,
253
+ getRelatedRoute,
254
+ createExternalRoute,
255
+ getRoutes,
256
+ updateRoute,
257
+ createNavItem,
258
+ updateNavItem,
259
+ deleteNavItem,
260
+ getStructuredNavigation,
261
+ deleteNavigation,
262
+ updateNavigation
263
+ };
252
264
  }
253
265
  const useAllContentTypes = () => {
254
266
  const { fetchAllContentTypes } = useApi();
@@ -3703,7 +3715,7 @@ function reducer(state, action) {
3703
3715
  const Alias = ({ config }) => {
3704
3716
  const { layout, form } = unstable_useContentManagerContext();
3705
3717
  const { initialValues, values, onChange } = form;
3706
- const { getRouteByRelated } = useApi();
3718
+ const { getRelatedRoute } = useApi();
3707
3719
  const [routeId, setRouteId] = useState();
3708
3720
  const [isOverride, setIsOverride] = useState(false);
3709
3721
  const [validationState, setValidationState] = useState("initial");
@@ -3770,7 +3782,7 @@ const Alias = ({ config }) => {
3770
3782
  return;
3771
3783
  }
3772
3784
  try {
3773
- const route = await getRouteByRelated(initialValues.documentId);
3785
+ const route = await getRelatedRoute(initialValues.documentId);
3774
3786
  if (!route) return;
3775
3787
  initialPath.current = initialValues.webatlas_path || route.uIdPath;
3776
3788
  setRouteId(route.id);
@@ -3928,24 +3940,23 @@ const CMEditViewAside = () => {
3928
3940
  setIsLoading(false);
3929
3941
  }, [config]);
3930
3942
  useEffect(() => {
3931
- const label = Array.from(document.querySelectorAll("label")).find((l) => l.textContent?.startsWith("webatlas_path"));
3932
- if (label) {
3933
- let parentDiv = label.closest("div");
3934
- for (let i = 0; i < 2; i++) {
3935
- if (parentDiv) {
3936
- parentDiv = parentDiv.parentElement;
3937
- }
3938
- }
3939
- if (parentDiv) {
3940
- const grandParentDiv = parentDiv.parentElement;
3941
- if (grandParentDiv && grandParentDiv.children.length === 1) {
3942
- grandParentDiv.parentElement?.remove();
3943
- return;
3944
- } else {
3945
- parentDiv.remove();
3946
- }
3943
+ const isWebatlasLabel = (label) => label.textContent?.startsWith("webatlas_");
3944
+ document.querySelectorAll("label").forEach((label) => {
3945
+ if (!isWebatlasLabel(label)) return;
3946
+ const container = label.parentElement?.parentElement;
3947
+ const parent = container?.parentElement;
3948
+ const greatGrandParent = parent?.parentElement?.parentElement;
3949
+ if (!container || !parent) return;
3950
+ const parentWebatlasCount = Array.from(parent.querySelectorAll("label")).filter(isWebatlasLabel).length;
3951
+ const childrenCount = parent.children.length;
3952
+ if (greatGrandParent && greatGrandParent?.querySelectorAll("label").length === Array.from(greatGrandParent.querySelectorAll("label")).filter(isWebatlasLabel).length) {
3953
+ greatGrandParent.remove();
3954
+ } else if (childrenCount === 1 || childrenCount === 2 && parentWebatlasCount === 2) {
3955
+ parent.remove();
3956
+ } else {
3957
+ container.remove();
3947
3958
  }
3948
- }
3959
+ });
3949
3960
  }, []);
3950
3961
  if (isLoading) return /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: "Loading..." });
3951
3962
  if (!isAllowedContentType) return /* @__PURE__ */ jsxs(Typography, { textColor: "neutral600", children: [
@@ -3972,7 +3983,7 @@ const index = {
3972
3983
  defaultMessage: "Routes"
3973
3984
  },
3974
3985
  Component: async () => {
3975
- const component = await import("./index-BoTOXEX8.mjs");
3986
+ const component = await import("./index-BwErs0UT.mjs");
3976
3987
  return { default: component.default };
3977
3988
  },
3978
3989
  permissions: [
@@ -3991,7 +4002,7 @@ const index = {
3991
4002
  defaultMessage: "Navigation"
3992
4003
  },
3993
4004
  Component: async () => {
3994
- const component = await import("./index-DL3LkD8O.mjs");
4005
+ const component = await import("./index-Doc1ry3x.mjs");
3995
4006
  return { default: component.default };
3996
4007
  },
3997
4008
  permissions: [
@@ -4020,7 +4031,7 @@ const index = {
4020
4031
  Component: async () => {
4021
4032
  return await import(
4022
4033
  /* webpackChunkName: "webatlas-settings-page" */
4023
- "./index-DWbEC3_A.mjs"
4034
+ "./index-BDU-lYsm.mjs"
4024
4035
  );
4025
4036
  },
4026
4037
  permissions: [
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-DfHrvxDY.js");
2
+ const index = require("../_chunks/index-DOVsVqnP.js");
3
3
  require("react/jsx-runtime");
4
4
  module.exports = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "../_chunks/index-lOv9Po4g.mjs";
1
+ import { i } from "../_chunks/index-c7q9J79y.mjs";
2
2
  import "react/jsx-runtime";
3
3
  export {
4
4
  i as default
@@ -1,5 +1,5 @@
1
1
  type EmptyNavProps = {
2
2
  msg: string;
3
3
  };
4
- export default function EmptyNav({ msg }: EmptyNavProps): import("react/jsx-runtime").JSX.Element;
4
+ export default function EmptyBox({ msg }: EmptyNavProps): import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -0,0 +1,3 @@
1
+ import Center from "./Center";
2
+ import EmptyBox from "./EmptyBox";
3
+ export { Center, EmptyBox, };
@@ -2,7 +2,7 @@ import { GroupedEntities, RouteSettings, NavItemSettings, ConfigContentType, Str
2
2
  export default function useApi(): {
3
3
  fetchAllContentTypes: () => Promise<any>;
4
4
  fetchAllEntities: (contentTypes?: ConfigContentType[]) => Promise<GroupedEntities[]>;
5
- getRouteByRelated: (relatedDocumentId: string, populate?: string) => Promise<any>;
5
+ getRelatedRoute: (relatedDocumentId: string) => Promise<any>;
6
6
  createExternalRoute: (body: RouteSettings) => Promise<any>;
7
7
  getRoutes: () => Promise<any>;
8
8
  updateRoute: (body: RouteSettings, documentId: string) => Promise<any>;