@griddo/ax 1.66.4 → 1.66.7

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 (70) hide show
  1. package/package.json +2 -2
  2. package/src/api/pages.tsx +3 -15
  3. package/src/api/redirects.tsx +2 -4
  4. package/src/api/sites.tsx +2 -4
  5. package/src/components/Browser/index.tsx +1 -3
  6. package/src/components/Browser/style.tsx +2 -2
  7. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +1 -0
  8. package/src/components/ErrorCenter/index.tsx +5 -8
  9. package/src/components/ErrorCenter/style.tsx +8 -21
  10. package/src/components/Fields/ColorPicker/index.tsx +0 -1
  11. package/src/components/Fields/ReferenceField/ItemList/index.tsx +1 -5
  12. package/src/components/Fields/ReferenceField/index.tsx +14 -18
  13. package/src/components/Fields/UrlField/index.tsx +1 -13
  14. package/src/components/Fields/index.tsx +0 -2
  15. package/src/components/FieldsBehavior/index.tsx +1 -14
  16. package/src/components/MainWrapper/AppBar/index.tsx +10 -21
  17. package/src/components/MainWrapper/AppBar/style.tsx +3 -11
  18. package/src/components/MainWrapper/index.tsx +0 -2
  19. package/src/components/Modal/style.tsx +1 -0
  20. package/src/components/SearchField/index.tsx +4 -36
  21. package/src/components/SearchField/style.tsx +10 -23
  22. package/src/components/SideModal/style.tsx +6 -6
  23. package/src/components/TableFilters/StatusFilter/index.tsx +2 -2
  24. package/src/components/index.tsx +0 -2
  25. package/src/containers/App/actions.tsx +7 -3
  26. package/src/containers/PageEditor/actions.tsx +22 -91
  27. package/src/containers/PageEditor/constants.tsx +1 -1
  28. package/src/containers/PageEditor/interfaces.tsx +6 -6
  29. package/src/containers/PageEditor/reducer.tsx +4 -4
  30. package/src/containers/PageEditor/utils.tsx +1 -2
  31. package/src/containers/Sites/actions.tsx +23 -35
  32. package/src/containers/Sites/constants.tsx +0 -1
  33. package/src/containers/Sites/interfaces.tsx +0 -6
  34. package/src/containers/Sites/reducer.tsx +0 -4
  35. package/src/forms/editor.tsx +1 -34
  36. package/src/forms/errors.tsx +0 -1
  37. package/src/forms/index.tsx +1 -15
  38. package/src/forms/validators.tsx +9 -168
  39. package/src/guards/error/index.tsx +1 -1
  40. package/src/helpers/dataPacks.tsx +1 -8
  41. package/src/helpers/index.tsx +1 -2
  42. package/src/modules/Content/PageItem/index.tsx +4 -54
  43. package/src/modules/Content/atoms.tsx +3 -41
  44. package/src/modules/Content/index.tsx +64 -111
  45. package/src/modules/Content/style.tsx +1 -8
  46. package/src/modules/GlobalEditor/Editor/index.tsx +1 -3
  47. package/src/modules/GlobalEditor/PageBrowser/index.tsx +0 -3
  48. package/src/modules/GlobalEditor/index.tsx +6 -8
  49. package/src/modules/PageEditor/Editor/index.tsx +2 -6
  50. package/src/modules/PageEditor/PageBrowser/index.tsx +0 -3
  51. package/src/modules/PageEditor/index.tsx +15 -29
  52. package/src/modules/Redirects/index.tsx +10 -40
  53. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +1 -1
  54. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/index.tsx +1 -1
  55. package/src/modules/Settings/ContentTypes/DataPacks/Config/index.tsx +1 -1
  56. package/src/modules/Settings/ContentTypes/DataPacks/index.tsx +1 -1
  57. package/src/modules/Sites/index.tsx +3 -3
  58. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +1 -1
  59. package/src/modules/StructuredData/StructuredDataList/atoms.tsx +1 -1
  60. package/src/modules/Users/Profile/index.tsx +4 -3
  61. package/src/modules/Users/UserCreate/SiteItem/index.tsx +1 -1
  62. package/src/modules/Users/UserCreate/SiteItem/style.tsx +1 -1
  63. package/src/modules/Users/UserForm/style.tsx +3 -3
  64. package/src/modules/Users/UserList/UserItem/index.tsx +1 -3
  65. package/src/modules/Users/UserList/hooks.tsx +1 -1
  66. package/src/modules/Users/UserList/index.tsx +2 -2
  67. package/src/types/index.tsx +3 -16
  68. package/src/components/Fields/LinkField/index.tsx +0 -85
  69. package/src/components/Icon/components/Copy.js +0 -14
  70. package/src/components/Icon/svgs/Copy2.svg +0 -3
@@ -15,7 +15,6 @@ import {
15
15
  IGetSitePagesParams,
16
16
  IColumn,
17
17
  ISite,
18
- IUser,
19
18
  } from "@ax/types";
20
19
  import { MainWrapper, Modal, TableList, ErrorToast, Toast, EmptyState, Notification } from "@ax/components";
21
20
  import { getFilteredStructuredData, isGlobalStructuredData, isStructuredDataFromPage } from "@ax/helpers";
@@ -84,14 +83,9 @@ const Content = (props: IProps): JSX.Element => {
84
83
  resetPageEditor,
85
84
  removePageFromSite,
86
85
  importPageFromGlobal,
86
+ restorePage,
87
87
  getDataPack,
88
- getSitesByLang,
89
88
  dataPacks,
90
- restorePage,
91
- getAvailableDataPacks,
92
- sitesByLang,
93
- user,
94
- setCurrentDataID,
95
89
  } = props;
96
90
 
97
91
  const itemsPerPage = 50;
@@ -112,12 +106,10 @@ const Content = (props: IProps): JSX.Element => {
112
106
  const isDataEditable = !isStructuredData || (currentStructuredData && currentStructuredData.editable);
113
107
 
114
108
  const pagesIds = currentSitePages && currentSitePages.map((page: any) => page.id);
115
- const currentSitePagesTemplatesIds = currentSitePages && currentSitePages.map((page: any) => page.templateId);
116
109
  const dataIds = currentDataContent && currentDataContent.map((data: any) => data.id);
117
110
  const contentIds = isStructuredData ? dataIds : pagesIds;
118
- const currentSitesByLang = sitesByLang?.filter(
119
- (site) => user?.sites?.includes("all") || user.sites.includes(site.id)
120
- );
111
+ const currentSitePagesTemplatesIds = currentSitePages && currentSitePages.map((page: any) => page.templateId);
112
+
121
113
  const categoryColumns =
122
114
  currentStructuredData && currentStructuredData.schema
123
115
  ? currentStructuredData.schema.fields.filter((field: any) => field.showList)
@@ -155,7 +147,6 @@ const Content = (props: IProps): JSX.Element => {
155
147
  const [deleteAllVersions, setDeleteAllVersions] = useState(false);
156
148
  const [arePagesTranslated, setArePagesTranslated] = useState(false);
157
149
  const [templateInstanceError, setTemplateInstanceError] = useState({ error: false, templateName: "" });
158
- const [pagesTemplatesIds, setPagesTemplatesIds] = useState<any[]>([]);
159
150
 
160
151
  const {
161
152
  resetBulkSelection,
@@ -179,12 +170,6 @@ const Content = (props: IProps): JSX.Element => {
179
170
  setIsVisible: setIsVisibleDeletedToast,
180
171
  } = useToast();
181
172
 
182
- const {
183
- isVisible: isVisibleCopiedToast,
184
- toggleToast: toggleCopiedToast,
185
- setIsVisible: setIsVisibleCopiedToast,
186
- } = useToast();
187
-
188
173
  const { categoryColors, addCategoryColors } = useCategoryColors();
189
174
 
190
175
  const getParams = useCallback(() => {
@@ -246,16 +231,11 @@ const Content = (props: IProps): JSX.Element => {
246
231
  // eslint-disable-next-line react-hooks/exhaustive-deps
247
232
  }, [filter]);
248
233
 
249
- const fetchSitesByLang = async () => await getSitesByLang(lang.id);
250
-
251
234
  useEffect(() => {
252
235
  if (!locationState || locationState.isFromEditor !== true) {
253
236
  setFilter("unique-pages");
254
237
  }
255
238
  resetPageEditor();
256
- fetchSitesByLang();
257
- setCurrentDataID(null);
258
- getAvailableDataPacks(null);
259
239
  // eslint-disable-next-line react-hooks/exhaustive-deps
260
240
  }, []);
261
241
 
@@ -282,12 +262,6 @@ const Content = (props: IProps): JSX.Element => {
282
262
  // eslint-disable-next-line react-hooks/exhaustive-deps
283
263
  }, [isLoading, currentSitePages]);
284
264
 
285
- useEffect(() => {
286
- if (pagesTemplatesIds?.length === 0) {
287
- setPagesTemplatesIds(currentSitePagesTemplatesIds);
288
- }
289
- }, [currentSitePagesTemplatesIds]);
290
-
291
265
  const bulkFilter = (bulkSelection: number[]) => filterByStatus(bulkSelection, currentSitePages);
292
266
 
293
267
  const handleAddToBulk = (item: ICheck) => addToBulkSelection(item, bulkFilter);
@@ -556,15 +530,13 @@ const Content = (props: IProps): JSX.Element => {
556
530
  duplicatePage,
557
531
  removePageFromSite,
558
532
  languageActions: pageLanguageActions,
533
+ deleteBulk: deleteCurrentPageBulk,
559
534
  getDataPack: getDataPack,
560
535
  setTemplateInstanceError,
561
- deleteBulk: deleteCurrentPageBulk,
562
- toggleCopiedToast,
563
536
  };
564
537
 
565
538
  return (
566
539
  <PageItem
567
- sites={currentSitesByLang}
568
540
  item={item}
569
541
  key={pageItem.id}
570
542
  functions={pageItemFunctions}
@@ -678,11 +650,6 @@ const Content = (props: IProps): JSX.Element => {
678
650
  message: "Page deleted.",
679
651
  };
680
652
 
681
- const copiedToastProps = {
682
- setIsVisible: setIsVisibleCopiedToast,
683
- message: "1 Page copied to another Site",
684
- };
685
-
686
653
  const addNewAction = filter === "unique-pages" || isGlobalPages ? toggleNewModal : addNewData;
687
654
 
688
655
  return (
@@ -694,74 +661,70 @@ const Content = (props: IProps): JSX.Element => {
694
661
  rightButton={{ label: "New", action: addNewAction }}
695
662
  searchAction={setSearchQuery}
696
663
  >
697
- <>
698
- <S.ContentListWrapper>
699
- <ContentFilters current={filter} dynamicValues={structuredData} resetFilter={resetFilter} />
700
- <S.TableWrapper>
701
- <ErrorToast />
702
- {templateInstanceError.error && (
703
- <Notification
704
- type="error"
705
- text={`There can be only one ${templateInstanceError.templateName} page and you already have it.`}
706
- />
664
+ <S.ContentListWrapper>
665
+ <ContentFilters current={filter} dynamicValues={structuredData} resetFilter={resetFilter} />
666
+ <S.TableWrapper>
667
+ <ErrorToast />
668
+ {templateInstanceError.error && (
669
+ <Notification
670
+ type="error"
671
+ text={`There can be only one ${templateInstanceError.templateName} page and you already have it.`}
672
+ />
673
+ )}
674
+ <TableList
675
+ tableHeader={Header}
676
+ pagination={pagination}
677
+ onScroll={onScroll}
678
+ hasFixedHeader={true}
679
+ tableRef={tableRef}
680
+ >
681
+ {!isEmpty ? (
682
+ content
683
+ ) : (
684
+ <S.EmptyWrapper>
685
+ <EmptyState {...emptyStateProps} />
686
+ </S.EmptyWrapper>
707
687
  )}
708
- <TableList
709
- tableHeader={Header}
710
- pagination={pagination}
711
- onScroll={onScroll}
712
- hasFixedHeader={true}
713
- tableRef={tableRef}
714
- >
715
- {!isEmpty ? (
716
- content
717
- ) : (
718
- <S.EmptyWrapper>
719
- <EmptyState {...emptyStateProps} />
720
- </S.EmptyWrapper>
721
- )}
722
- </TableList>
723
- </S.TableWrapper>
724
- </S.ContentListWrapper>
725
- <Modal isOpen={isNewOpen} hide={toggleNewModal} size="M" title="New content">
726
- <OptionTable
727
- selectPage={addTemplate}
728
- selectData={addNewStructuredData}
729
- filters={options.filters}
730
- values={options.values}
731
- selectedValue={selectedOption}
732
- theme={currentSiteInfo.theme}
733
- mainAction={createContentAction}
734
- secondaryAction={{ title: "Cancel", onClick: toggleNewModal }}
735
- />
736
- </Modal>
737
- <Modal
738
- isOpen={isImporterOpen}
739
- hide={toggleImporterModal}
740
- size="M"
741
- title="New content"
742
- mainAction={{ title: "Add Pages", onClick: importPage }}
743
- secondaryAction={{ title: "Cancel", onClick: toggleImporterModal }}
744
- >
745
- <PageImporter structuredData={selectedOptionType} {...{ setPagesToImport }} />
746
- </Modal>
747
- <DeleteModal
748
- isOpen={isDeleteOpen}
749
- toggleModal={toggleDeleteModal}
750
- mainModalAction={mainDeleteModalAction}
751
- secondaryModalAction={secondaryDeleteModalAction}
752
- {...{ isTranslated: arePagesTranslated, deleteAllVersions, setDeleteAllVersions }}
688
+ </TableList>
689
+ </S.TableWrapper>
690
+ </S.ContentListWrapper>
691
+ <Modal isOpen={isNewOpen} hide={toggleNewModal} size="M" title="New content">
692
+ <OptionTable
693
+ selectPage={addTemplate}
694
+ selectData={addNewStructuredData}
695
+ filters={options.filters}
696
+ values={options.values}
697
+ selectedValue={selectedOption}
698
+ theme={currentSiteInfo.theme}
699
+ mainAction={createContentAction}
700
+ secondaryAction={{ title: "Cancel", onClick: toggleNewModal }}
753
701
  />
754
- {isVisible && <Toast {...toastProps} />}
755
- {isVisibleRemovedToast && <Toast {...removedToastProps} />}
756
- {isVisibleDeletedToast && <Toast {...deletedToastProps} />}
757
- {isVisibleCopiedToast && <Toast {...copiedToastProps} />}
758
- </>
702
+ </Modal>
703
+ <Modal
704
+ isOpen={isImporterOpen}
705
+ hide={toggleImporterModal}
706
+ size="M"
707
+ title="New content"
708
+ mainAction={{ title: "Add Pages", onClick: importPage }}
709
+ secondaryAction={{ title: "Cancel", onClick: toggleImporterModal }}
710
+ >
711
+ <PageImporter structuredData={selectedOptionType} {...{ setPagesToImport }} />
712
+ </Modal>
713
+ <DeleteModal
714
+ isOpen={isDeleteOpen}
715
+ toggleModal={toggleDeleteModal}
716
+ mainModalAction={mainDeleteModalAction}
717
+ secondaryModalAction={secondaryDeleteModalAction}
718
+ {...{ isTranslated: arePagesTranslated, deleteAllVersions, setDeleteAllVersions }}
719
+ />
720
+ {isVisible && <Toast {...toastProps} />}
721
+ {isVisibleRemovedToast && <Toast {...removedToastProps} />}
722
+ {isVisibleDeletedToast && <Toast {...deletedToastProps} />}
759
723
  </MainWrapper>
760
724
  );
761
725
  };
762
726
 
763
727
  const mapStateToProps = (state: IRootState) => ({
764
- sitesByLang: state.sites.sitesByLang,
765
728
  currentSiteInfo: state.sites.currentSiteInfo,
766
729
  currentSitePages: state.sites.currentSitePages,
767
730
  filter: state.sites.currentFilter,
@@ -778,7 +741,6 @@ const mapStateToProps = (state: IRootState) => ({
778
741
  activatedTemplates: state.dataPacks.templates,
779
742
  isLoading: state.app.isLoading,
780
743
  dataPacks: state.dataPacks.activated,
781
- user: state.users.currentUser,
782
744
  });
783
745
 
784
746
  interface IDispatchProps {
@@ -798,7 +760,7 @@ interface IDispatchProps {
798
760
  getStructuredDataContents(params: any, siteID: number): Promise<void>;
799
761
  resetForm(): void;
800
762
  deleteBulk(ids: any): Promise<boolean>;
801
- duplicatePage(pageID: number, data?: any, siteID?: number): Promise<boolean>;
763
+ duplicatePage(pageID: number, data: any): Promise<void>;
802
764
  deleteDataContent(dataID: number[]): Promise<boolean>;
803
765
  restoreDataContent(catID: number | number[]): void;
804
766
  setFilter(value: string): void;
@@ -806,18 +768,14 @@ interface IDispatchProps {
806
768
  resetPageEditor(): Promise<void>;
807
769
  removePageFromSite(pageID: number | number[], refresh?: boolean): Promise<boolean>;
808
770
  importPageFromGlobal(pageID: number | number[]): Promise<boolean>;
809
- getDataPack: (id: string) => Promise<void>;
810
771
  restorePage(id: number | number[]): Promise<boolean>;
811
- getAvailableDataPacks: (queryParams: string | null) => void;
812
- getSitesByLang(language: number): Promise<void>;
813
- setCurrentDataID(id: number | null): void;
772
+ getDataPack: (id: string) => Promise<void>;
814
773
  }
815
774
 
816
775
  const mapDispatchToProps = {
817
776
  setHistoryPush: appActions.setHistoryPush,
818
777
  setLanguage: appActions.setLanguage,
819
778
  getSitePages: sitesActions.getSitePages,
820
- getSitesByLang: sitesActions.getSitesByLang,
821
779
  setCurrentPageID: pageEditorActions.setCurrentPageID,
822
780
  setCurrentPageStatus: pageEditorActions.setCurrentPageStatus,
823
781
  setCurrentPageName: pageEditorActions.setCurrentPageName,
@@ -838,10 +796,8 @@ const mapDispatchToProps = {
838
796
  resetPageEditor: pageEditorActions.resetPageEditor,
839
797
  removePageFromSite: sitesActions.removePageFromSite,
840
798
  importPageFromGlobal: sitesActions.importPageFromGlobal,
841
- getDataPack: dataPacksActions.getSiteDataPack,
842
799
  restorePage: pageEditorActions.restorePage,
843
- getAvailableDataPacks: dataPacksActions.getAvailableSiteDataPacks,
844
- setCurrentDataID: structuredDataActions.setCurrentDataID,
800
+ getDataPack: dataPacksActions.getSiteDataPack,
845
801
  };
846
802
 
847
803
  interface IPagesProps {
@@ -863,9 +819,6 @@ interface IPagesProps {
863
819
  activatedTemplates: any[];
864
820
  isLoading: boolean;
865
821
  dataPacks: IDataPack[];
866
- sites: ISite[];
867
- sitesByLang: ISite[];
868
- user: IUser;
869
822
  }
870
823
 
871
824
  type IProps = IPagesProps & IDispatchProps;
@@ -35,11 +35,4 @@ const ModalContent = styled.div`
35
35
  }
36
36
  `;
37
37
 
38
- const SelectWrapper = styled.div`
39
- & .react-select__control,
40
- .react-select__menu {
41
- min-width: 100%;
42
- }
43
- `;
44
-
45
- export { ContentListWrapper, TableWrapper, PaginationWrapper, EmptyWrapper, ModalContent, SelectWrapper };
38
+ export { ContentListWrapper, TableWrapper, PaginationWrapper, EmptyWrapper, ModalContent };
@@ -29,7 +29,6 @@ const Editor = (props: IProps) => {
29
29
  copyModule,
30
30
  pasteModule,
31
31
  theme,
32
- browserRef,
33
32
  setNotification,
34
33
  } = props;
35
34
 
@@ -48,7 +47,7 @@ const Editor = (props: IProps) => {
48
47
 
49
48
  return (
50
49
  <ResizePanel
51
- leftPanel={<PageBrowser isReadOnly={isReadOnly} theme={theme} browserRef={browserRef} />}
50
+ leftPanel={<PageBrowser isReadOnly={isReadOnly} theme={theme} />}
52
51
  rightPanel={
53
52
  <ConfigPanel
54
53
  schema={schema}
@@ -100,7 +99,6 @@ interface IPageBrowserDispatchProps {
100
99
  isEditable: boolean;
101
100
  isReadOnly: boolean;
102
101
  theme: string;
103
- browserRef: any;
104
102
  }
105
103
 
106
104
  type IProps = IEditorStateProps & IPageBrowserDispatchProps;
@@ -18,7 +18,6 @@ const PageBrowser = (props: IProps) => {
18
18
  theme,
19
19
  isReadOnly,
20
20
  isPreview,
21
- browserRef,
22
21
  } = props;
23
22
 
24
23
  const slugWithSlash = slug ? (slug.startsWith("/") ? slug : `/${slug}`) : "";
@@ -39,7 +38,6 @@ const PageBrowser = (props: IProps) => {
39
38
  disabled={isReadOnly}
40
39
  siteID={canonicalSite}
41
40
  isPreview={isPreview}
42
- browserRef={browserRef}
43
41
  />
44
42
  );
45
43
  };
@@ -62,7 +60,6 @@ interface IPageBrowserDispatchProps {
62
60
  theme: string;
63
61
  isReadOnly: boolean;
64
62
  isPreview?: boolean;
65
- browserRef?: any;
66
63
  }
67
64
 
68
65
  type IProps = IEditorStateProps & IPageBrowserDispatchProps;
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState, useRef } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import { connect } from "react-redux";
3
3
  import { RouteComponentProps } from "react-router-dom";
4
4
 
@@ -50,7 +50,6 @@ const GlobalEditor = (props: IProps) => {
50
50
  const [selectedTab, setSelectedTab] = useState("edit");
51
51
  const [notification, setNotification] = useState<INotification | null>(null);
52
52
  const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent.editorContent, isNewTranslation);
53
- const browserRef = useRef<HTMLDivElement>(null);
54
53
 
55
54
  const isPublished = props.pageStatus === pageStatus.PUBLISHED || props.pageStatus === pageStatus.UPLOAD_PENDING;
56
55
  const isDraft = props.pageStatus === pageStatus.MODIFIED;
@@ -115,7 +114,7 @@ const GlobalEditor = (props: IProps) => {
115
114
  const publishPage = async () => {
116
115
  const { updatePageStatus, savePage, pageID, validatePage } = props;
117
116
 
118
- const validated = await validatePage(true, browserRef);
117
+ const validated = await validatePage(true);
119
118
 
120
119
  if (validated) {
121
120
  const publishPage = {
@@ -135,7 +134,7 @@ const GlobalEditor = (props: IProps) => {
135
134
  const publishChanges = async () => {
136
135
  const { savePage, validatePage } = props;
137
136
 
138
- const validated = await validatePage(true, browserRef);
137
+ const validated = await validatePage(true);
139
138
 
140
139
  if (validated) {
141
140
  const publishPage = {
@@ -164,13 +163,13 @@ const GlobalEditor = (props: IProps) => {
164
163
 
165
164
  const reviewPage = () => {
166
165
  const { validatePage } = props;
167
- validatePage(false, browserRef);
166
+ validatePage();
168
167
  };
169
168
 
170
169
  const handlePublishDraft = async () => {
171
170
  const { savePage, validatePage } = props;
172
171
 
173
- const validated = await validatePage(true, browserRef);
172
+ const validated = await validatePage(true);
174
173
 
175
174
  if (validated) {
176
175
  const isSaved = await savePage(false, null, true);
@@ -463,7 +462,6 @@ const GlobalEditor = (props: IProps) => {
463
462
  isEditable={isEditable}
464
463
  isReadOnly={isReadOnly}
465
464
  theme={theme}
466
- browserRef={browserRef}
467
465
  setNotification={setNotification}
468
466
  />
469
467
  </S.Content>
@@ -569,7 +567,7 @@ interface IPageEditorDispatchProps {
569
567
  getPage(pageID?: number, global?: boolean): Promise<void>;
570
568
  savePage(createDraft: boolean, publishPage?: any, publishDraft?: boolean): Promise<boolean>;
571
569
  deletePage(params?: ISavePageParams): Promise<boolean>;
572
- validatePage(publish?: boolean, browserRef?: any): Promise<boolean>;
570
+ validatePage(publish?: boolean): Promise<boolean>;
573
571
  updatePageStatus(id: number[], status: string): Promise<boolean>;
574
572
  setHistoryPush(path: string, isEditor: boolean): void;
575
573
  setLanguage?(lang: { locale: string; id: number | null }): void;
@@ -35,11 +35,10 @@ const Editor = (props: IProps) => {
35
35
  isReadOnly,
36
36
  userEditing,
37
37
  site,
38
+ lastElementAddedId,
38
39
  copyModule,
39
40
  pasteModule,
40
41
  setNotification,
41
- lastElementAddedId,
42
- browserRef,
43
42
  } = props;
44
43
 
45
44
  const actions = {
@@ -59,9 +58,7 @@ const Editor = (props: IProps) => {
59
58
 
60
59
  return (
61
60
  <ResizePanel
62
- leftPanel={
63
- <PageBrowser isTemplateActivated={isTemplateActivated} isReadOnly={isReadOnly} browserRef={browserRef} />
64
- }
61
+ leftPanel={<PageBrowser isTemplateActivated={isTemplateActivated} isReadOnly={isReadOnly} />}
65
62
  rightPanel={
66
63
  <ConfigPanel
67
64
  schema={schema}
@@ -122,7 +119,6 @@ interface IPageBrowserDispatchProps {
122
119
  isEditable: boolean;
123
120
  pageTitle: string;
124
121
  isReadOnly: boolean;
125
- browserRef: any;
126
122
  }
127
123
 
128
124
  type IProps = IEditorStateProps & IPageBrowserDispatchProps;
@@ -21,7 +21,6 @@ const PageBrowser = (props: IProps) => {
21
21
  isTemplateActivated,
22
22
  isReadOnly,
23
23
  isPreview,
24
- browserRef,
25
24
  } = props;
26
25
 
27
26
  const slugWithSlash = slug ? (slug.startsWith("/") ? slug : `/${slug}`) : "";
@@ -45,7 +44,6 @@ const PageBrowser = (props: IProps) => {
45
44
  disabled={disabled}
46
45
  siteID={siteID}
47
46
  isPreview={isPreview}
48
- browserRef={browserRef}
49
47
  />
50
48
  );
51
49
  };
@@ -69,7 +67,6 @@ interface IPageBrowserDispatchProps {
69
67
  isTemplateActivated: boolean;
70
68
  isReadOnly: boolean;
71
69
  isPreview?: boolean;
72
- browserRef?: any;
73
70
  }
74
71
 
75
72
  type IProps = IEditorStateProps & IPageBrowserDispatchProps;
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState, useRef } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import { connect } from "react-redux";
3
3
  import { RouteComponentProps } from "react-router-dom";
4
4
 
@@ -10,11 +10,11 @@ import { navigationActions } from "@ax/containers/Navigation";
10
10
  import { pageStatus } from "@ax/containers/PageEditor/interfaces";
11
11
  import { RouteLeavingGuard } from "@ax/guards";
12
12
  import { useIsDirty, useModal } from "@ax/hooks";
13
- import { isModuleDisabled, getDeactivatedModules } from "@ax/helpers";
13
+ import { isModuleDisabled } from "@ax/helpers";
14
14
  import { dataPacksActions } from "@ax/containers/Settings/DataPacks";
15
+ import { DeleteModal } from "./atoms";
15
16
  import Editor from "./Editor";
16
17
  import Preview from "./Preview";
17
- import { DeleteModal } from "./atoms";
18
18
 
19
19
  import * as S from "./style";
20
20
 
@@ -46,15 +46,14 @@ const PageEditor = (props: IProps) => {
46
46
  isNewTranslation,
47
47
  } = props;
48
48
 
49
+ const [deleteAllVersions, setDeleteAllVersions] = useState(false);
49
50
  const [isReadOnly, setIsReadOnly] = useState(false);
50
51
  const [selectedTab, setSelectedTab] = useState("edit");
51
- const [deleteAllVersions, setDeleteAllVersions] = useState(false);
52
52
  const [notification, setNotification] = useState<INotification | null>(null);
53
53
  const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent.editorContent, isNewTranslation);
54
54
  const { isOpen, toggleModal } = useModal();
55
55
  const { isOpen: isUnpublishOpen, toggleModal: toggleUnpublishModal } = useModal();
56
56
  const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
57
- const browserRef = useRef<HTMLDivElement>(null);
58
57
 
59
58
  const isGlobal = editorContent.editorContent && editorContent.editorContent.origin === "GLOBAL";
60
59
  const isEditable = editorContent.editorContent && editorContent.editorContent.editable;
@@ -62,8 +61,8 @@ const PageEditor = (props: IProps) => {
62
61
  const isDraft = props.pageStatus === pageStatus.MODIFIED;
63
62
  const hasDraft = editorContent.editorContent && editorContent.editorContent.haveDraftPage;
64
63
  const isLivePageChanged = editorContent.editorContent && editorContent.editorContent.liveChanged;
65
- const structuredData = editorContent.editorContent ? editorContent.editorContent.structuredData : "";
66
64
  const isTranslated = pageLanguages.length > 1;
65
+ const structuredData = editorContent.editorContent ? editorContent.editorContent.structuredData : "";
67
66
 
68
67
  useEffect(() => {
69
68
  const { pageID, getPage, setTab, sendPagePing } = props;
@@ -119,7 +118,7 @@ const PageEditor = (props: IProps) => {
119
118
  const publishPage = async () => {
120
119
  const { updatePageStatus, savePage, pageID, validatePage } = props;
121
120
 
122
- const validated = await validatePage(true, browserRef);
121
+ const validated = await validatePage(true);
123
122
 
124
123
  if (validated) {
125
124
  const publishPage = {
@@ -139,7 +138,7 @@ const PageEditor = (props: IProps) => {
139
138
  const publishChanges = async () => {
140
139
  const { savePage, validatePage } = props;
141
140
 
142
- const validated = await validatePage(true, browserRef);
141
+ const validated = await validatePage(true);
143
142
 
144
143
  if (validated) {
145
144
  const publishPage = {
@@ -168,13 +167,13 @@ const PageEditor = (props: IProps) => {
168
167
 
169
168
  const reviewPage = () => {
170
169
  const { validatePage } = props;
171
- validatePage(false, browserRef);
170
+ validatePage();
172
171
  };
173
172
 
174
173
  const handlePublishDraft = async () => {
175
174
  const { savePage, validatePage } = props;
176
175
 
177
- const validated = await validatePage(true, browserRef);
176
+ const validated = await validatePage(true);
178
177
 
179
178
  if (validated) {
180
179
  const isSaved = await savePage(false, null, true);
@@ -296,12 +295,10 @@ const PageEditor = (props: IProps) => {
296
295
 
297
296
  const goToPages = (path: string) => setRoute(path);
298
297
 
299
- const goToError = (editorID: number | null, tab: string, template: boolean) => {
298
+ const goToError = (editorID: number, tab: string, template: boolean) => {
300
299
  const realEditorID = template ? 0 : editorID;
301
- if (realEditorID !== null) {
302
- setSelectedContent(realEditorID);
303
- setTab(tab);
304
- }
300
+ setSelectedContent(realEditorID);
301
+ setTab(tab);
305
302
  };
306
303
 
307
304
  const modalText = (
@@ -312,18 +309,9 @@ const PageEditor = (props: IProps) => {
312
309
 
313
310
  let isTemplateActivated = true;
314
311
  let hasDeactivatedModules = false;
315
- let deactivatedModules: string[] = [];
316
312
  if (editorContent.editorContent && editorContent.editorContent.template) {
317
313
  const editorTemplate = editorContent.editorContent.template;
318
- const mainContentModules = editorTemplate?.mainContent?.modules;
319
-
320
- if (mainContentModules) {
321
- deactivatedModules = getDeactivatedModules(activatedModules, mainContentModules);
322
- hasDeactivatedModules = deactivatedModules.length > 0;
323
- } else {
324
- hasDeactivatedModules = isModuleDisabled(selectedComponent, schema.schemaType, activatedModules);
325
- }
326
-
314
+ hasDeactivatedModules = isModuleDisabled(selectedComponent, schema.schemaType, activatedModules);
327
315
  isTemplateActivated = activatedTemplates.find((temp: any) => temp.id === editorTemplate.templateType)
328
316
  ? true
329
317
  : false;
@@ -407,8 +395,7 @@ const PageEditor = (props: IProps) => {
407
395
  if (!isTemplateActivated) {
408
396
  getSiteDataPackbyTemplate(editorTemplate.templateType);
409
397
  } else if (hasDeactivatedModules) {
410
- const currentModule = deactivatedModules.length === 1 ? deactivatedModules[0] : selectedComponent;
411
- getSiteDataPackbyModule(currentModule);
398
+ getSiteDataPackbyModule(selectedComponent);
412
399
  }
413
400
  setHistoryPush("/sites/settings/content-types", false);
414
401
  }
@@ -519,7 +506,6 @@ const PageEditor = (props: IProps) => {
519
506
  isEditable={isEditable}
520
507
  pageTitle={pageName}
521
508
  isReadOnly={isReadOnly}
522
- browserRef={browserRef}
523
509
  setNotification={setNotification}
524
510
  />
525
511
  </S.Content>
@@ -636,7 +622,7 @@ interface IPageEditorDispatchProps {
636
622
  getPage(pageID?: number): Promise<void>;
637
623
  savePage(createDraft: boolean, publishPage?: any, publishDraft?: boolean): Promise<boolean>;
638
624
  deletePage(params?: ISavePageParams): Promise<boolean>;
639
- validatePage(publish?: boolean, browserRef?: any): Promise<boolean>;
625
+ validatePage(publish?: boolean): Promise<boolean>;
640
626
  updatePageStatus(id: number[], status: string): Promise<boolean>;
641
627
  setHistoryPush(path: string, isEditor: boolean): void;
642
628
  setLanguage?(lang: { locale: string; id: number | null }): void;