@webiny/app-website-builder 6.4.12-beta.0 → 6.4.12-beta.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.
@@ -2,10 +2,14 @@ import react from "react";
2
2
  import { Layout } from "./components/Layout/index.js";
3
3
  import { Main } from "./components/Main/index.js";
4
4
  import { Sidebar } from "./components/Sidebar/index.js";
5
- const PagesList = ()=>/*#__PURE__*/ react.createElement(Layout, {
5
+ import { useDocumentListController } from "./useDocumentList.js";
6
+ const PagesList = ()=>{
7
+ useDocumentListController();
8
+ return /*#__PURE__*/ react.createElement(Layout, {
6
9
  main: /*#__PURE__*/ react.createElement(Main, null),
7
10
  sidebar: /*#__PURE__*/ react.createElement(Sidebar, null)
8
11
  });
12
+ };
9
13
  export { PagesList };
10
14
 
11
15
  //# sourceMappingURL=PagesList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modules/pages/PagesList/PagesList.js","sources":["../../../../src/modules/pages/PagesList/PagesList.tsx"],"sourcesContent":["import React from \"react\";\nimport { Layout } from \"~/modules/pages/PagesList/components/Layout/index.js\";\nimport { Main } from \"~/modules/pages/PagesList/components/Main/index.js\";\nimport { Sidebar } from \"~/modules/pages/PagesList/components/Sidebar/index.js\";\n\nexport const PagesList = () => {\n return <Layout main={<Main />} sidebar={<Sidebar />} />;\n};\n"],"names":["PagesList","Layout","Main","Sidebar"],"mappings":";;;;AAKO,MAAMA,YAAY,IACd,WAAP,GAAO,oBAACC,QAAMA;QAAC,oBAAM,oBAACC,MAAIA;QAAK,uBAAS,oBAACC,SAAOA"}
1
+ {"version":3,"file":"modules/pages/PagesList/PagesList.js","sources":["../../../../src/modules/pages/PagesList/PagesList.tsx"],"sourcesContent":["import React from \"react\";\nimport { Layout } from \"~/modules/pages/PagesList/components/Layout/index.js\";\nimport { Main } from \"~/modules/pages/PagesList/components/Main/index.js\";\nimport { Sidebar } from \"~/modules/pages/PagesList/components/Sidebar/index.js\";\nimport { useDocumentListController } from \"~/modules/pages/PagesList/useDocumentList.js\";\n\nexport const PagesList = () => {\n useDocumentListController();\n\n return <Layout main={<Main />} sidebar={<Sidebar />} />;\n};\n"],"names":["PagesList","useDocumentListController","Layout","Main","Sidebar"],"mappings":";;;;;AAMO,MAAMA,YAAY;IACrBC;IAEA,OAAO,WAAP,GAAO,oBAACC,QAAMA;QAAC,oBAAM,oBAACC,MAAIA;QAAK,uBAAS,oBAACC,SAAOA;;AACpD"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Reads the list view model. Safe to call from any number of components: it performs no data
3
+ * loading, so an extra consumer costs nothing.
4
+ *
5
+ * Loading belongs to `useDocumentListController`, which the list root calls exactly once. Keeping it
6
+ * here would mean every consumer issued its own `listPages` request on mount.
7
+ */
1
8
  export declare const useDocumentList: import("@webiny/react-composition").GenericHook<unknown, {
2
9
  vm: import("../../../presentation/pages/PageList").IDocumentListVm;
3
10
  showFilters: (show: boolean) => void;
@@ -13,3 +20,8 @@ export declare const useDocumentList: import("@webiny/react-composition").Generi
13
20
  showFilters: (show: boolean) => void;
14
21
  }>) => () => React.JSX.Element;
15
22
  };
23
+ /**
24
+ * Owns the loading of the current folder. Must be called exactly once, by the list root - every call
25
+ * site runs its own copy of the effect below, and each copy issues a `listPages` request.
26
+ */
27
+ export declare const useDocumentListController: () => void;
@@ -7,13 +7,8 @@ import { makeDecoratableHook } from "@webiny/react-composition";
7
7
  import { useFeature } from "@webiny/app";
8
8
  import { PageListFeature } from "../../../presentation/pages/PageList/feature.js";
9
9
  const useDocumentList = makeDecoratableHook(()=>{
10
- const isFirstLoad = useRef(true);
11
- const { folders, loadFolderHierarchy } = useLoadFolderHierarchy();
12
- const { listFoldersByParentIds } = useListFoldersByParentIds();
13
10
  const { currentFolderId } = useNavigateFolder();
14
- const { loadPages: listDocuments } = useLoadPages();
15
11
  const { filterPages: filterDocuments } = useFilterPages();
16
- const { selectPages: selectDocuments } = useSelectPages();
17
12
  const { presenter } = useFeature(PageListFeature);
18
13
  const params = useMemo(()=>({
19
14
  folderId: currentFolderId
@@ -38,6 +33,19 @@ const useDocumentList = makeDecoratableHook(()=>{
38
33
  }, [
39
34
  presenter
40
35
  ]);
36
+ return {
37
+ vm,
38
+ showFilters
39
+ };
40
+ });
41
+ const useDocumentListController = ()=>{
42
+ const isFirstLoad = useRef(true);
43
+ const { folders, loadFolderHierarchy } = useLoadFolderHierarchy();
44
+ const { listFoldersByParentIds } = useListFoldersByParentIds();
45
+ const { loadPages: listDocuments } = useLoadPages();
46
+ const { selectPages: selectDocuments } = useSelectPages();
47
+ const { presenter } = useFeature(PageListFeature);
48
+ const { vm } = useDocumentList();
41
49
  useEffect(()=>{
42
50
  if (0 === folders.length) loadFolderHierarchy(vm.folderId);
43
51
  else listFoldersByParentIds([
@@ -53,11 +61,7 @@ const useDocumentList = makeDecoratableHook(()=>{
53
61
  }, [
54
62
  vm.folderId
55
63
  ]);
56
- return {
57
- vm,
58
- showFilters
59
- };
60
- });
61
- export { useDocumentList };
64
+ };
65
+ export { useDocumentList, useDocumentListController };
62
66
 
63
67
  //# sourceMappingURL=useDocumentList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modules/pages/PagesList/useDocumentList.js","sources":["../../../../src/modules/pages/PagesList/useDocumentList.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport {\n useListFoldersByParentIds,\n useLoadFolderHierarchy,\n useNavigateFolder\n} from \"@webiny/app-aco\";\nimport { useFilterPages, useLoadPages } from \"~/features/pages/index.js\";\nimport { useSelectPages } from \"~/features/pages/selectPages/useSelectPages.js\";\nimport { makeDecoratableHook } from \"@webiny/react-composition\";\nimport { useFeature } from \"@webiny/app\";\nimport { PageListFeature } from \"~/presentation/pages/PageList/feature.js\";\n\nexport const useDocumentList = makeDecoratableHook(() => {\n const isFirstLoad = useRef(true);\n const { folders, loadFolderHierarchy } = useLoadFolderHierarchy();\n const { listFoldersByParentIds } = useListFoldersByParentIds();\n const { currentFolderId } = useNavigateFolder();\n const { loadPages: listDocuments } = useLoadPages();\n const { filterPages: filterDocuments } = useFilterPages();\n const { selectPages: selectDocuments } = useSelectPages();\n const { presenter } = useFeature(PageListFeature);\n\n const params = useMemo(\n () => ({\n folderId: currentFolderId\n }),\n [currentFolderId]\n );\n\n useEffect(() => {\n presenter.init(params);\n }, [params, presenter]);\n\n const [vm, setVm] = useState(presenter.vm);\n\n useEffect(() => {\n return autorun(() => {\n setVm(presenter.vm);\n });\n }, [presenter]);\n\n const showFilters = useCallback(\n (show: boolean) => {\n presenter.showFilters(show);\n\n // When set to false, it will also clear any applied document filters for the current folder.\n if (!show) {\n filterDocuments({}, currentFolderId);\n }\n },\n [presenter]\n );\n\n useEffect(() => {\n // The folders collection is empty, it must be the first render, let's load the full hierarchy.\n if (folders.length === 0) {\n loadFolderHierarchy(vm.folderId);\n } else {\n // Otherwise let's load only the current folder sub-tree\n listFoldersByParentIds([vm.folderId]);\n }\n\n // Close the filter list\n presenter.showFilters(false);\n\n // Unselect any selected items\n selectDocuments([]);\n\n // List all documents when the current folder changes.\n listDocuments({\n folderId: vm.folderId,\n resetSearch: !isFirstLoad.current\n });\n isFirstLoad.current = false;\n }, [vm.folderId]);\n\n return {\n vm,\n showFilters\n };\n});\n"],"names":["useDocumentList","makeDecoratableHook","isFirstLoad","useRef","folders","loadFolderHierarchy","useLoadFolderHierarchy","listFoldersByParentIds","useListFoldersByParentIds","currentFolderId","useNavigateFolder","listDocuments","useLoadPages","filterDocuments","useFilterPages","selectDocuments","useSelectPages","presenter","useFeature","PageListFeature","params","useMemo","useEffect","vm","setVm","useState","autorun","showFilters","useCallback","show"],"mappings":";;;;;;;;AAaO,MAAMA,kBAAkBC,oBAAoB;IAC/C,MAAMC,cAAcC,OAAO;IAC3B,MAAM,EAAEC,OAAO,EAAEC,mBAAmB,EAAE,GAAGC;IACzC,MAAM,EAAEC,sBAAsB,EAAE,GAAGC;IACnC,MAAM,EAAEC,eAAe,EAAE,GAAGC;IAC5B,MAAM,EAAE,WAAWC,aAAa,EAAE,GAAGC;IACrC,MAAM,EAAE,aAAaC,eAAe,EAAE,GAAGC;IACzC,MAAM,EAAE,aAAaC,eAAe,EAAE,GAAGC;IACzC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IAEjC,MAAMC,SAASC,QACX,IAAO;YACH,UAAUZ;QACd,IACA;QAACA;KAAgB;IAGrBa,UAAU;QACNL,UAAU,IAAI,CAACG;IACnB,GAAG;QAACA;QAAQH;KAAU;IAEtB,MAAM,CAACM,IAAIC,MAAM,GAAGC,SAASR,UAAU,EAAE;IAEzCK,UAAU,IACCI,QAAQ;YACXF,MAAMP,UAAU,EAAE;QACtB,IACD;QAACA;KAAU;IAEd,MAAMU,cAAcC,YAChB,CAACC;QACGZ,UAAU,WAAW,CAACY;QAGtB,IAAI,CAACA,MACDhB,gBAAgB,CAAC,GAAGJ;IAE5B,GACA;QAACQ;KAAU;IAGfK,UAAU;QAEN,IAAIlB,AAAmB,MAAnBA,QAAQ,MAAM,EACdC,oBAAoBkB,GAAG,QAAQ;aAG/BhB,uBAAuB;YAACgB,GAAG,QAAQ;SAAC;QAIxCN,UAAU,WAAW,CAAC;QAGtBF,gBAAgB,EAAE;QAGlBJ,cAAc;YACV,UAAUY,GAAG,QAAQ;YACrB,aAAa,CAACrB,YAAY,OAAO;QACrC;QACAA,YAAY,OAAO,GAAG;IAC1B,GAAG;QAACqB,GAAG,QAAQ;KAAC;IAEhB,OAAO;QACHA;QACAI;IACJ;AACJ"}
1
+ {"version":3,"file":"modules/pages/PagesList/useDocumentList.js","sources":["../../../../src/modules/pages/PagesList/useDocumentList.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport {\n useListFoldersByParentIds,\n useLoadFolderHierarchy,\n useNavigateFolder\n} from \"@webiny/app-aco\";\nimport { useFilterPages, useLoadPages } from \"~/features/pages/index.js\";\nimport { useSelectPages } from \"~/features/pages/selectPages/useSelectPages.js\";\nimport { makeDecoratableHook } from \"@webiny/react-composition\";\nimport { useFeature } from \"@webiny/app\";\nimport { PageListFeature } from \"~/presentation/pages/PageList/feature.js\";\n\n/**\n * Reads the list view model. Safe to call from any number of components: it performs no data\n * loading, so an extra consumer costs nothing.\n *\n * Loading belongs to `useDocumentListController`, which the list root calls exactly once. Keeping it\n * here would mean every consumer issued its own `listPages` request on mount.\n */\nexport const useDocumentList = makeDecoratableHook(() => {\n const { currentFolderId } = useNavigateFolder();\n const { filterPages: filterDocuments } = useFilterPages();\n const { presenter } = useFeature(PageListFeature);\n\n const params = useMemo(\n () => ({\n folderId: currentFolderId\n }),\n [currentFolderId]\n );\n\n /**\n * Stays here rather than in the controller: it is idempotent and makes no request, and child\n * effects run before the parent's - so a consumer would otherwise render one frame against an\n * uninitialized view model.\n */\n useEffect(() => {\n presenter.init(params);\n }, [params, presenter]);\n\n const [vm, setVm] = useState(presenter.vm);\n\n useEffect(() => {\n return autorun(() => {\n setVm(presenter.vm);\n });\n }, [presenter]);\n\n const showFilters = useCallback(\n (show: boolean) => {\n presenter.showFilters(show);\n\n // When set to false, it will also clear any applied document filters for the current folder.\n if (!show) {\n filterDocuments({}, currentFolderId);\n }\n },\n [presenter]\n );\n\n return {\n vm,\n showFilters\n };\n});\n\n/**\n * Owns the loading of the current folder. Must be called exactly once, by the list root - every call\n * site runs its own copy of the effect below, and each copy issues a `listPages` request.\n */\nexport const useDocumentListController = () => {\n const isFirstLoad = useRef(true);\n const { folders, loadFolderHierarchy } = useLoadFolderHierarchy();\n const { listFoldersByParentIds } = useListFoldersByParentIds();\n const { loadPages: listDocuments } = useLoadPages();\n const { selectPages: selectDocuments } = useSelectPages();\n const { presenter } = useFeature(PageListFeature);\n const { vm } = useDocumentList();\n\n useEffect(() => {\n // The folders collection is empty, it must be the first render, let's load the full hierarchy.\n if (folders.length === 0) {\n loadFolderHierarchy(vm.folderId);\n } else {\n // Otherwise let's load only the current folder sub-tree\n listFoldersByParentIds([vm.folderId]);\n }\n\n // Close the filter list\n presenter.showFilters(false);\n\n // Unselect any selected items\n selectDocuments([]);\n\n // List all documents when the current folder changes.\n listDocuments({\n folderId: vm.folderId,\n resetSearch: !isFirstLoad.current\n });\n isFirstLoad.current = false;\n }, [vm.folderId]);\n};\n"],"names":["useDocumentList","makeDecoratableHook","currentFolderId","useNavigateFolder","filterDocuments","useFilterPages","presenter","useFeature","PageListFeature","params","useMemo","useEffect","vm","setVm","useState","autorun","showFilters","useCallback","show","useDocumentListController","isFirstLoad","useRef","folders","loadFolderHierarchy","useLoadFolderHierarchy","listFoldersByParentIds","useListFoldersByParentIds","listDocuments","useLoadPages","selectDocuments","useSelectPages"],"mappings":";;;;;;;;AAoBO,MAAMA,kBAAkBC,oBAAoB;IAC/C,MAAM,EAAEC,eAAe,EAAE,GAAGC;IAC5B,MAAM,EAAE,aAAaC,eAAe,EAAE,GAAGC;IACzC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IAEjC,MAAMC,SAASC,QACX,IAAO;YACH,UAAUR;QACd,IACA;QAACA;KAAgB;IAQrBS,UAAU;QACNL,UAAU,IAAI,CAACG;IACnB,GAAG;QAACA;QAAQH;KAAU;IAEtB,MAAM,CAACM,IAAIC,MAAM,GAAGC,SAASR,UAAU,EAAE;IAEzCK,UAAU,IACCI,QAAQ;YACXF,MAAMP,UAAU,EAAE;QACtB,IACD;QAACA;KAAU;IAEd,MAAMU,cAAcC,YAChB,CAACC;QACGZ,UAAU,WAAW,CAACY;QAGtB,IAAI,CAACA,MACDd,gBAAgB,CAAC,GAAGF;IAE5B,GACA;QAACI;KAAU;IAGf,OAAO;QACHM;QACAI;IACJ;AACJ;AAMO,MAAMG,4BAA4B;IACrC,MAAMC,cAAcC,OAAO;IAC3B,MAAM,EAAEC,OAAO,EAAEC,mBAAmB,EAAE,GAAGC;IACzC,MAAM,EAAEC,sBAAsB,EAAE,GAAGC;IACnC,MAAM,EAAE,WAAWC,aAAa,EAAE,GAAGC;IACrC,MAAM,EAAE,aAAaC,eAAe,EAAE,GAAGC;IACzC,MAAM,EAAExB,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAM,EAAEI,EAAE,EAAE,GAAGZ;IAEfW,UAAU;QAEN,IAAIW,AAAmB,MAAnBA,QAAQ,MAAM,EACdC,oBAAoBX,GAAG,QAAQ;aAG/Ba,uBAAuB;YAACb,GAAG,QAAQ;SAAC;QAIxCN,UAAU,WAAW,CAAC;QAGtBuB,gBAAgB,EAAE;QAGlBF,cAAc;YACV,UAAUf,GAAG,QAAQ;YACrB,aAAa,CAACQ,YAAY,OAAO;QACrC;QACAA,YAAY,OAAO,GAAG;IAC1B,GAAG;QAACR,GAAG,QAAQ;KAAC;AACpB"}
@@ -3,10 +3,15 @@ import { Layout } from "./components/Layout/index.js";
3
3
  import { Main } from "./components/Main/index.js";
4
4
  import { Sidebar } from "./components/Sidebar/index.js";
5
5
  import { DocumentListPresenterProvider } from "./presenters/DocumentListPresenterContext.js";
6
- const DocumentList = ()=>/*#__PURE__*/ react.createElement(DocumentListPresenterProvider, null, /*#__PURE__*/ react.createElement(Layout, {
6
+ import { useDocumentListController } from "./useDocumentList.js";
7
+ const DocumentListContent = ()=>{
8
+ useDocumentListController();
9
+ return /*#__PURE__*/ react.createElement(Layout, {
7
10
  main: /*#__PURE__*/ react.createElement(Main, null),
8
11
  sidebar: /*#__PURE__*/ react.createElement(Sidebar, null)
9
- }));
12
+ });
13
+ };
14
+ const DocumentList = ()=>/*#__PURE__*/ react.createElement(DocumentListPresenterProvider, null, /*#__PURE__*/ react.createElement(DocumentListContent, null));
10
15
  export { DocumentList };
11
16
 
12
17
  //# sourceMappingURL=DocumentList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modules/redirects/RedirectsList/DocumentList.js","sources":["../../../../src/modules/redirects/RedirectsList/DocumentList.tsx"],"sourcesContent":["import React from \"react\";\nimport { Layout } from \"~/modules/redirects/RedirectsList/components/Layout/index.js\";\nimport { Main } from \"~/modules/redirects/RedirectsList/components/Main/index.js\";\nimport { Sidebar } from \"~/modules/redirects/RedirectsList/components/Sidebar/index.js\";\nimport { DocumentListPresenterProvider } from \"~/modules/redirects/RedirectsList/presenters/DocumentListPresenterContext.js\";\n\nexport const DocumentList = () => {\n return (\n <DocumentListPresenterProvider>\n <Layout main={<Main />} sidebar={<Sidebar />} />\n </DocumentListPresenterProvider>\n );\n};\n"],"names":["DocumentList","DocumentListPresenterProvider","Layout","Main","Sidebar"],"mappings":";;;;;AAMO,MAAMA,eAAe,IACjB,WAAP,GACI,oBAACC,+BAA6BA,MAAAA,WAAAA,GAC1B,oBAACC,QAAMA;QAAC,oBAAM,oBAACC,MAAIA;QAAK,uBAAS,oBAACC,SAAOA"}
1
+ {"version":3,"file":"modules/redirects/RedirectsList/DocumentList.js","sources":["../../../../src/modules/redirects/RedirectsList/DocumentList.tsx"],"sourcesContent":["import React from \"react\";\nimport { Layout } from \"~/modules/redirects/RedirectsList/components/Layout/index.js\";\nimport { Main } from \"~/modules/redirects/RedirectsList/components/Main/index.js\";\nimport { Sidebar } from \"~/modules/redirects/RedirectsList/components/Sidebar/index.js\";\nimport { DocumentListPresenterProvider } from \"~/modules/redirects/RedirectsList/presenters/DocumentListPresenterContext.js\";\nimport { useDocumentListController } from \"~/modules/redirects/RedirectsList/useDocumentList.js\";\n\n/**\n * Separate component because the controller reads the presenter from context, so it has to run\n * below the provider.\n */\nconst DocumentListContent = () => {\n useDocumentListController();\n\n return <Layout main={<Main />} sidebar={<Sidebar />} />;\n};\n\nexport const DocumentList = () => {\n return (\n <DocumentListPresenterProvider>\n <DocumentListContent />\n </DocumentListPresenterProvider>\n );\n};\n"],"names":["DocumentListContent","useDocumentListController","Layout","Main","Sidebar","DocumentList","DocumentListPresenterProvider"],"mappings":";;;;;;AAWA,MAAMA,sBAAsB;IACxBC;IAEA,OAAO,WAAP,GAAO,oBAACC,QAAMA;QAAC,oBAAM,oBAACC,MAAIA;QAAK,uBAAS,oBAACC,SAAOA;;AACpD;AAEO,MAAMC,eAAe,IACjB,WAAP,GACI,oBAACC,+BAA6BA,MAAAA,WAAAA,GAC1B,oBAACN,qBAAmBA"}
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Reads the list view model. Safe to call from any number of components: it performs no data
3
+ * loading, so an extra consumer costs nothing.
4
+ *
5
+ * Loading belongs to `useDocumentListController`, which the list root calls exactly once. Keeping it
6
+ * here would mean every consumer issued its own `listRedirects` request on mount - Apollo's query
7
+ * deduplication collapses those into a single network request, so the cost is invisible rather than
8
+ * absent.
9
+ */
1
10
  export declare const useDocumentList: () => {
2
11
  vm: {
3
12
  folderId: string;
@@ -20,3 +29,8 @@ export declare const useDocumentList: () => {
20
29
  };
21
30
  showFilters: (show: boolean) => void;
22
31
  };
32
+ /**
33
+ * Owns the loading of the current folder. Must be called exactly once, by the list root - every call
34
+ * site runs its own copy of the effect below, and each copy issues a `listRedirects` request.
35
+ */
36
+ export declare const useDocumentListController: () => void;
@@ -5,13 +5,8 @@ import { useDocumentListPresenter } from "./presenters/DocumentListPresenterCont
5
5
  import { useFilterRedirects, useLoadRedirects } from "../../../features/redirects/index.js";
6
6
  import { useSelectRedirects } from "../../../features/redirects/selectRedirects/useSelectRedirects.js";
7
7
  const useDocumentList = ()=>{
8
- const isFirstLoad = useRef(true);
9
- const { folders, loadFolderHierarchy } = useLoadFolderHierarchy();
10
- const { listFoldersByParentIds } = useListFoldersByParentIds();
11
8
  const { currentFolderId } = useNavigateFolder();
12
- const { loadRedirects: listDocuments } = useLoadRedirects();
13
9
  const { filterRedirects: filterDocuments } = useFilterRedirects();
14
- const { selectRedirects: selectDocuments } = useSelectRedirects();
15
10
  const presenter = useDocumentListPresenter();
16
11
  const params = useMemo(()=>({
17
12
  folderId: currentFolderId
@@ -36,6 +31,19 @@ const useDocumentList = ()=>{
36
31
  }, [
37
32
  presenter
38
33
  ]);
34
+ return {
35
+ vm,
36
+ showFilters
37
+ };
38
+ };
39
+ const useDocumentListController = ()=>{
40
+ const isFirstLoad = useRef(true);
41
+ const { folders, loadFolderHierarchy } = useLoadFolderHierarchy();
42
+ const { listFoldersByParentIds } = useListFoldersByParentIds();
43
+ const { loadRedirects: listDocuments } = useLoadRedirects();
44
+ const { selectRedirects: selectDocuments } = useSelectRedirects();
45
+ const presenter = useDocumentListPresenter();
46
+ const { vm } = useDocumentList();
39
47
  useEffect(()=>{
40
48
  if (0 === folders.length) loadFolderHierarchy(vm.folderId);
41
49
  else listFoldersByParentIds([
@@ -51,11 +59,7 @@ const useDocumentList = ()=>{
51
59
  }, [
52
60
  vm.folderId
53
61
  ]);
54
- return {
55
- vm,
56
- showFilters
57
- };
58
62
  };
59
- export { useDocumentList };
63
+ export { useDocumentList, useDocumentListController };
60
64
 
61
65
  //# sourceMappingURL=useDocumentList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modules/redirects/RedirectsList/useDocumentList.js","sources":["../../../../src/modules/redirects/RedirectsList/useDocumentList.ts"],"sourcesContent":["import { useCallback, useState, useMemo, useEffect, useRef } from \"react\";\nimport { autorun } from \"mobx\";\nimport { useListFoldersByParentIds } from \"@webiny/app-aco\";\nimport { useLoadFolderHierarchy } from \"@webiny/app-aco\";\nimport { useNavigateFolder } from \"@webiny/app-aco\";\nimport { useDocumentListPresenter } from \"./presenters/DocumentListPresenterContext.js\";\nimport { useFilterRedirects, useLoadRedirects } from \"~/features/redirects/index.js\";\nimport { useSelectRedirects } from \"~/features/redirects/selectRedirects/useSelectRedirects.js\";\n\nexport const useDocumentList = () => {\n const isFirstLoad = useRef(true);\n const { folders, loadFolderHierarchy } = useLoadFolderHierarchy();\n const { listFoldersByParentIds } = useListFoldersByParentIds();\n const { currentFolderId } = useNavigateFolder();\n const { loadRedirects: listDocuments } = useLoadRedirects();\n const { filterRedirects: filterDocuments } = useFilterRedirects();\n const { selectRedirects: selectDocuments } = useSelectRedirects();\n const presenter = useDocumentListPresenter();\n\n const params = useMemo(\n () => ({\n folderId: currentFolderId\n }),\n [currentFolderId]\n );\n\n useEffect(() => {\n presenter.init(params);\n }, [params, presenter]);\n\n const [vm, setVm] = useState(presenter.vm);\n\n useEffect(() => {\n return autorun(() => {\n setVm(presenter.vm);\n });\n }, [presenter]);\n\n const showFilters = useCallback(\n (show: boolean) => {\n presenter.showFilters(show);\n\n // When set to false, it will also clear any applied document filters for the current folder.\n if (!show) {\n filterDocuments({}, currentFolderId);\n }\n },\n [presenter]\n );\n\n useEffect(() => {\n // The folders collection is empty, it must be the first render, let's load the full hierarchy.\n if (folders.length === 0) {\n loadFolderHierarchy(vm.folderId);\n } else {\n // Otherwise let's load only the current folder sub-tree\n listFoldersByParentIds([vm.folderId]);\n }\n\n // Close the filter list\n presenter.showFilters(false);\n\n // Unselect any selected items\n selectDocuments([]);\n\n // List all documents when the current folder changes.\n listDocuments({\n folderId: vm.folderId,\n resetSearch: !isFirstLoad.current\n });\n isFirstLoad.current = false;\n }, [vm.folderId]);\n\n return {\n vm,\n showFilters\n };\n};\n"],"names":["useDocumentList","isFirstLoad","useRef","folders","loadFolderHierarchy","useLoadFolderHierarchy","listFoldersByParentIds","useListFoldersByParentIds","currentFolderId","useNavigateFolder","listDocuments","useLoadRedirects","filterDocuments","useFilterRedirects","selectDocuments","useSelectRedirects","presenter","useDocumentListPresenter","params","useMemo","useEffect","vm","setVm","useState","autorun","showFilters","useCallback","show"],"mappings":";;;;;;AASO,MAAMA,kBAAkB;IAC3B,MAAMC,cAAcC,OAAO;IAC3B,MAAM,EAAEC,OAAO,EAAEC,mBAAmB,EAAE,GAAGC;IACzC,MAAM,EAAEC,sBAAsB,EAAE,GAAGC;IACnC,MAAM,EAAEC,eAAe,EAAE,GAAGC;IAC5B,MAAM,EAAE,eAAeC,aAAa,EAAE,GAAGC;IACzC,MAAM,EAAE,iBAAiBC,eAAe,EAAE,GAAGC;IAC7C,MAAM,EAAE,iBAAiBC,eAAe,EAAE,GAAGC;IAC7C,MAAMC,YAAYC;IAElB,MAAMC,SAASC,QACX,IAAO;YACH,UAAUX;QACd,IACA;QAACA;KAAgB;IAGrBY,UAAU;QACNJ,UAAU,IAAI,CAACE;IACnB,GAAG;QAACA;QAAQF;KAAU;IAEtB,MAAM,CAACK,IAAIC,MAAM,GAAGC,SAASP,UAAU,EAAE;IAEzCI,UAAU,IACCI,QAAQ;YACXF,MAAMN,UAAU,EAAE;QACtB,IACD;QAACA;KAAU;IAEd,MAAMS,cAAcC,YAChB,CAACC;QACGX,UAAU,WAAW,CAACW;QAGtB,IAAI,CAACA,MACDf,gBAAgB,CAAC,GAAGJ;IAE5B,GACA;QAACQ;KAAU;IAGfI,UAAU;QAEN,IAAIjB,AAAmB,MAAnBA,QAAQ,MAAM,EACdC,oBAAoBiB,GAAG,QAAQ;aAG/Bf,uBAAuB;YAACe,GAAG,QAAQ;SAAC;QAIxCL,UAAU,WAAW,CAAC;QAGtBF,gBAAgB,EAAE;QAGlBJ,cAAc;YACV,UAAUW,GAAG,QAAQ;YACrB,aAAa,CAACpB,YAAY,OAAO;QACrC;QACAA,YAAY,OAAO,GAAG;IAC1B,GAAG;QAACoB,GAAG,QAAQ;KAAC;IAEhB,OAAO;QACHA;QACAI;IACJ;AACJ"}
1
+ {"version":3,"file":"modules/redirects/RedirectsList/useDocumentList.js","sources":["../../../../src/modules/redirects/RedirectsList/useDocumentList.ts"],"sourcesContent":["import { useCallback, useState, useMemo, useEffect, useRef } from \"react\";\nimport { autorun } from \"mobx\";\nimport { useListFoldersByParentIds } from \"@webiny/app-aco\";\nimport { useLoadFolderHierarchy } from \"@webiny/app-aco\";\nimport { useNavigateFolder } from \"@webiny/app-aco\";\nimport { useDocumentListPresenter } from \"./presenters/DocumentListPresenterContext.js\";\nimport { useFilterRedirects, useLoadRedirects } from \"~/features/redirects/index.js\";\nimport { useSelectRedirects } from \"~/features/redirects/selectRedirects/useSelectRedirects.js\";\n\n/**\n * Reads the list view model. Safe to call from any number of components: it performs no data\n * loading, so an extra consumer costs nothing.\n *\n * Loading belongs to `useDocumentListController`, which the list root calls exactly once. Keeping it\n * here would mean every consumer issued its own `listRedirects` request on mount - Apollo's query\n * deduplication collapses those into a single network request, so the cost is invisible rather than\n * absent.\n */\nexport const useDocumentList = () => {\n const { currentFolderId } = useNavigateFolder();\n const { filterRedirects: filterDocuments } = useFilterRedirects();\n const presenter = useDocumentListPresenter();\n\n const params = useMemo(\n () => ({\n folderId: currentFolderId\n }),\n [currentFolderId]\n );\n\n /**\n * Stays here rather than in the controller: it is idempotent and makes no request, and child\n * effects run before the parent's - so a consumer would otherwise render one frame against an\n * uninitialized view model.\n */\n useEffect(() => {\n presenter.init(params);\n }, [params, presenter]);\n\n const [vm, setVm] = useState(presenter.vm);\n\n useEffect(() => {\n return autorun(() => {\n setVm(presenter.vm);\n });\n }, [presenter]);\n\n const showFilters = useCallback(\n (show: boolean) => {\n presenter.showFilters(show);\n\n // When set to false, it will also clear any applied document filters for the current folder.\n if (!show) {\n filterDocuments({}, currentFolderId);\n }\n },\n [presenter]\n );\n\n return {\n vm,\n showFilters\n };\n};\n\n/**\n * Owns the loading of the current folder. Must be called exactly once, by the list root - every call\n * site runs its own copy of the effect below, and each copy issues a `listRedirects` request.\n */\nexport const useDocumentListController = () => {\n const isFirstLoad = useRef(true);\n const { folders, loadFolderHierarchy } = useLoadFolderHierarchy();\n const { listFoldersByParentIds } = useListFoldersByParentIds();\n const { loadRedirects: listDocuments } = useLoadRedirects();\n const { selectRedirects: selectDocuments } = useSelectRedirects();\n const presenter = useDocumentListPresenter();\n const { vm } = useDocumentList();\n\n useEffect(() => {\n // The folders collection is empty, it must be the first render, let's load the full hierarchy.\n if (folders.length === 0) {\n loadFolderHierarchy(vm.folderId);\n } else {\n // Otherwise let's load only the current folder sub-tree\n listFoldersByParentIds([vm.folderId]);\n }\n\n // Close the filter list\n presenter.showFilters(false);\n\n // Unselect any selected items\n selectDocuments([]);\n\n // List all documents when the current folder changes.\n listDocuments({\n folderId: vm.folderId,\n resetSearch: !isFirstLoad.current\n });\n isFirstLoad.current = false;\n }, [vm.folderId]);\n};\n"],"names":["useDocumentList","currentFolderId","useNavigateFolder","filterDocuments","useFilterRedirects","presenter","useDocumentListPresenter","params","useMemo","useEffect","vm","setVm","useState","autorun","showFilters","useCallback","show","useDocumentListController","isFirstLoad","useRef","folders","loadFolderHierarchy","useLoadFolderHierarchy","listFoldersByParentIds","useListFoldersByParentIds","listDocuments","useLoadRedirects","selectDocuments","useSelectRedirects"],"mappings":";;;;;;AAkBO,MAAMA,kBAAkB;IAC3B,MAAM,EAAEC,eAAe,EAAE,GAAGC;IAC5B,MAAM,EAAE,iBAAiBC,eAAe,EAAE,GAAGC;IAC7C,MAAMC,YAAYC;IAElB,MAAMC,SAASC,QACX,IAAO;YACH,UAAUP;QACd,IACA;QAACA;KAAgB;IAQrBQ,UAAU;QACNJ,UAAU,IAAI,CAACE;IACnB,GAAG;QAACA;QAAQF;KAAU;IAEtB,MAAM,CAACK,IAAIC,MAAM,GAAGC,SAASP,UAAU,EAAE;IAEzCI,UAAU,IACCI,QAAQ;YACXF,MAAMN,UAAU,EAAE;QACtB,IACD;QAACA;KAAU;IAEd,MAAMS,cAAcC,YAChB,CAACC;QACGX,UAAU,WAAW,CAACW;QAGtB,IAAI,CAACA,MACDb,gBAAgB,CAAC,GAAGF;IAE5B,GACA;QAACI;KAAU;IAGf,OAAO;QACHK;QACAI;IACJ;AACJ;AAMO,MAAMG,4BAA4B;IACrC,MAAMC,cAAcC,OAAO;IAC3B,MAAM,EAAEC,OAAO,EAAEC,mBAAmB,EAAE,GAAGC;IACzC,MAAM,EAAEC,sBAAsB,EAAE,GAAGC;IACnC,MAAM,EAAE,eAAeC,aAAa,EAAE,GAAGC;IACzC,MAAM,EAAE,iBAAiBC,eAAe,EAAE,GAAGC;IAC7C,MAAMvB,YAAYC;IAClB,MAAM,EAAEI,EAAE,EAAE,GAAGV;IAEfS,UAAU;QAEN,IAAIW,AAAmB,MAAnBA,QAAQ,MAAM,EACdC,oBAAoBX,GAAG,QAAQ;aAG/Ba,uBAAuB;YAACb,GAAG,QAAQ;SAAC;QAIxCL,UAAU,WAAW,CAAC;QAGtBsB,gBAAgB,EAAE;QAGlBF,cAAc;YACV,UAAUf,GAAG,QAAQ;YACrB,aAAa,CAACQ,YAAY,OAAO;QACrC;QACAA,YAAY,OAAO,GAAG;IAC1B,GAAG;QAACR,GAAG,QAAQ;KAAC;AACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-website-builder",
3
- "version": "6.4.12-beta.0",
3
+ "version": "6.4.12-beta.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -21,28 +21,28 @@
21
21
  "@monaco-editor/react": "4.7.0",
22
22
  "@svgr/webpack": "8.1.0",
23
23
  "@types/react": "18.3.31",
24
- "@webiny/admin-ui": "6.4.12-beta.0",
25
- "@webiny/app": "6.4.12-beta.0",
26
- "@webiny/app-aco": "6.4.12-beta.0",
27
- "@webiny/app-admin": "6.4.12-beta.0",
28
- "@webiny/app-headless-cms-common": "6.4.12-beta.0",
29
- "@webiny/app-trash-bin": "6.4.12-beta.0",
30
- "@webiny/app-utils": "6.4.12-beta.0",
24
+ "@webiny/admin-ui": "6.4.12-beta.2",
25
+ "@webiny/app": "6.4.12-beta.2",
26
+ "@webiny/app-aco": "6.4.12-beta.2",
27
+ "@webiny/app-admin": "6.4.12-beta.2",
28
+ "@webiny/app-headless-cms-common": "6.4.12-beta.2",
29
+ "@webiny/app-trash-bin": "6.4.12-beta.2",
30
+ "@webiny/app-utils": "6.4.12-beta.2",
31
31
  "@webiny/di": "1.1.0",
32
- "@webiny/error": "6.4.12-beta.0",
33
- "@webiny/feature": "6.4.12-beta.0",
34
- "@webiny/form": "6.4.12-beta.0",
35
- "@webiny/icons": "6.4.12-beta.0",
36
- "@webiny/languages": "6.4.12-beta.0",
37
- "@webiny/lexical-converter": "6.4.12-beta.0",
38
- "@webiny/lexical-editor": "6.4.12-beta.0",
39
- "@webiny/lexical-nodes": "6.4.12-beta.0",
40
- "@webiny/lexical-theme": "6.4.12-beta.0",
41
- "@webiny/react-composition": "6.4.12-beta.0",
42
- "@webiny/react-properties": "6.4.12-beta.0",
43
- "@webiny/utils": "6.4.12-beta.0",
44
- "@webiny/validation": "6.4.12-beta.0",
45
- "@webiny/website-builder-sdk": "6.4.12-beta.0",
32
+ "@webiny/error": "6.4.12-beta.2",
33
+ "@webiny/feature": "6.4.12-beta.2",
34
+ "@webiny/form": "6.4.12-beta.2",
35
+ "@webiny/icons": "6.4.12-beta.2",
36
+ "@webiny/languages": "6.4.12-beta.2",
37
+ "@webiny/lexical-converter": "6.4.12-beta.2",
38
+ "@webiny/lexical-editor": "6.4.12-beta.2",
39
+ "@webiny/lexical-nodes": "6.4.12-beta.2",
40
+ "@webiny/lexical-theme": "6.4.12-beta.2",
41
+ "@webiny/react-composition": "6.4.12-beta.2",
42
+ "@webiny/react-properties": "6.4.12-beta.2",
43
+ "@webiny/utils": "6.4.12-beta.2",
44
+ "@webiny/validation": "6.4.12-beta.2",
45
+ "@webiny/website-builder-sdk": "6.4.12-beta.2",
46
46
  "apollo-cache": "1.3.5",
47
47
  "apollo-client": "2.6.10",
48
48
  "apollo-link": "1.2.14",
@@ -69,7 +69,7 @@
69
69
  "devDependencies": {
70
70
  "@types/deep-equal": "1.0.4",
71
71
  "@types/is-hotkey": "0.1.10",
72
- "@webiny/build-tools": "6.4.12-beta.0",
72
+ "@webiny/build-tools": "6.4.12-beta.2",
73
73
  "execa": "5.1.1",
74
74
  "rimraf": "6.1.3",
75
75
  "typescript": "6.0.3",