@griddo/ax 11.11.8-rc.1 → 11.12.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 (99) hide show
  1. package/config/jest/componentsMock.js +5 -7
  2. package/package.json +2 -2
  3. package/src/__tests__/components/Browser/Browser.test.tsx +87 -438
  4. package/src/__tests__/components/ConfigPanel/ConfigPanel.test.tsx +3 -1
  5. package/src/__tests__/components/Fields/Button/Button.test.tsx +27 -29
  6. package/src/__tests__/components/ResizePanel/ResizePanel.test.tsx +1 -1
  7. package/src/components/Browser/index.tsx +149 -294
  8. package/src/components/Browser/style.tsx +6 -75
  9. package/src/components/Button/index.tsx +1 -2
  10. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +4 -2
  11. package/src/components/Fields/AsyncSelect/style.tsx +0 -13
  12. package/src/components/Fields/FieldGroup/index.tsx +2 -5
  13. package/src/components/Fields/FieldGroup/style.tsx +7 -32
  14. package/src/components/Fields/HeadingField/index.tsx +2 -2
  15. package/src/components/Fields/HiddenField/style.tsx +1 -1
  16. package/src/components/Fields/NumberField/index.tsx +16 -15
  17. package/src/components/Fields/NumberField/style.tsx +0 -2
  18. package/src/components/Fields/ReferenceField/index.tsx +1 -1
  19. package/src/components/Fields/Select/index.tsx +1 -5
  20. package/src/components/Fields/Select/style.tsx +0 -56
  21. package/src/components/Fields/SummaryButton/index.tsx +9 -18
  22. package/src/components/Fields/SummaryButton/style.tsx +2 -1
  23. package/src/components/Fields/TagsField/index.tsx +9 -8
  24. package/src/components/Fields/UrlField/index.tsx +27 -26
  25. package/src/components/Fields/index.tsx +0 -2
  26. package/src/components/FloatingPanel/index.tsx +2 -5
  27. package/src/components/FloatingPanel/style.tsx +1 -2
  28. package/src/components/IconAction/index.tsx +1 -1
  29. package/src/components/MainWrapper/AppBar/index.tsx +1 -8
  30. package/src/components/MainWrapper/index.tsx +1 -7
  31. package/src/components/Notification/index.tsx +2 -2
  32. package/src/components/PageFinder/index.tsx +1 -1
  33. package/src/components/ResizePanel/index.tsx +3 -4
  34. package/src/components/ResizePanel/style.tsx +1 -1
  35. package/src/components/SearchField/style.tsx +2 -2
  36. package/src/components/SideModal/index.tsx +1 -2
  37. package/src/components/Tabs/index.tsx +4 -13
  38. package/src/components/Tabs/style.tsx +8 -7
  39. package/src/components/Toast/index.tsx +2 -4
  40. package/src/components/Tooltip/index.tsx +3 -4
  41. package/src/components/index.tsx +0 -8
  42. package/src/forms/fields.tsx +68 -70
  43. package/src/hooks/forms.tsx +1 -22
  44. package/src/hooks/index.tsx +3 -13
  45. package/src/hooks/modals.tsx +15 -103
  46. package/src/hooks/users.tsx +8 -25
  47. package/src/modules/Forms/atoms.tsx +2 -2
  48. package/src/modules/FramePreview/index.tsx +16 -55
  49. package/src/modules/FramePreview/style.tsx +2 -34
  50. package/src/modules/GlobalEditor/Editor/index.tsx +3 -37
  51. package/src/modules/GlobalEditor/PageBrowser/index.tsx +2 -19
  52. package/src/modules/GlobalEditor/Preview/index.tsx +2 -0
  53. package/src/modules/GlobalEditor/Preview/style.tsx +1 -1
  54. package/src/modules/GlobalEditor/index.tsx +57 -119
  55. package/src/modules/PageEditor/Editor/index.tsx +2 -33
  56. package/src/modules/PageEditor/PageBrowser/index.tsx +2 -20
  57. package/src/modules/PageEditor/Preview/index.tsx +2 -0
  58. package/src/modules/PageEditor/Preview/style.tsx +1 -1
  59. package/src/modules/PageEditor/atoms.tsx +1 -1
  60. package/src/modules/PageEditor/index.tsx +66 -130
  61. package/src/modules/PublicPreview/index.tsx +2 -5
  62. package/src/schemas/pages/GlobalPage.ts +70 -87
  63. package/src/schemas/pages/Page.ts +70 -87
  64. package/src/types/index.tsx +0 -12
  65. package/src/__tests__/components/Browser/Browser.utils.test.ts +0 -55
  66. package/src/__tests__/components/HeadingsPreviewModal/ErrorsBanner/ErrorItem/ErrorItem.test.tsx +0 -158
  67. package/src/__tests__/components/HeadingsPreviewModal/ErrorsBanner/ErrorsBanner.test.tsx +0 -90
  68. package/src/__tests__/components/HeadingsPreviewModal/HeadingsPreviewModal.test.tsx +0 -178
  69. package/src/__tests__/components/HeadingsPreviewModal/HeadingsPreviewModal.utils.test.tsx +0 -150
  70. package/src/__tests__/components/KeywordsPreviewModal/KeywordItem/KeywordItem.test.tsx +0 -91
  71. package/src/__tests__/components/KeywordsPreviewModal/KeywordsPreviewModal.test.tsx +0 -122
  72. package/src/__tests__/components/KeywordsPreviewModal/KeywordsPreviewModal.utils.test.ts +0 -15
  73. package/src/__tests__/components/KeywordsPreviewModal/atoms.test.tsx +0 -101
  74. package/src/__tests__/modules/FramePreview/FramePreview.test.tsx +0 -318
  75. package/src/__tests__/modules/FramePreview/FramePreview.utils.test.ts +0 -242
  76. package/src/__tests__/modules/FramePreview/HeadingsOverlay/HeadingsOverlay.test.tsx +0 -185
  77. package/src/components/Browser/utils.tsx +0 -13
  78. package/src/components/Fields/SEOPreview/index.tsx +0 -36
  79. package/src/components/Fields/SEOPreview/style.tsx +0 -24
  80. package/src/components/FloatingNote/index.tsx +0 -35
  81. package/src/components/FloatingNote/style.tsx +0 -26
  82. package/src/components/HeadingsPreviewModal/ErrorsBanner/ErrorItem/index.tsx +0 -85
  83. package/src/components/HeadingsPreviewModal/ErrorsBanner/ErrorItem/style.tsx +0 -80
  84. package/src/components/HeadingsPreviewModal/ErrorsBanner/index.tsx +0 -57
  85. package/src/components/HeadingsPreviewModal/ErrorsBanner/style.tsx +0 -82
  86. package/src/components/HeadingsPreviewModal/HeadingItem/index.tsx +0 -71
  87. package/src/components/HeadingsPreviewModal/HeadingItem/style.tsx +0 -77
  88. package/src/components/HeadingsPreviewModal/index.tsx +0 -146
  89. package/src/components/HeadingsPreviewModal/style.tsx +0 -82
  90. package/src/components/HeadingsPreviewModal/utils.tsx +0 -257
  91. package/src/components/KeywordsPreviewModal/KeywordItem/index.tsx +0 -46
  92. package/src/components/KeywordsPreviewModal/KeywordItem/style.tsx +0 -64
  93. package/src/components/KeywordsPreviewModal/atoms.tsx +0 -96
  94. package/src/components/KeywordsPreviewModal/index.tsx +0 -99
  95. package/src/components/KeywordsPreviewModal/style.tsx +0 -87
  96. package/src/components/KeywordsPreviewModal/utils.tsx +0 -22
  97. package/src/modules/FramePreview/HeadingsOverlay/index.tsx +0 -113
  98. package/src/modules/FramePreview/HeadingsOverlay/style.tsx +0 -24
  99. package/src/modules/FramePreview/utils.tsx +0 -140
@@ -1,15 +1,8 @@
1
+ import React from "react";
1
2
  import { connect } from "react-redux";
2
3
  import { pageEditorActions } from "@ax/containers/PageEditor";
3
4
  import { ConfigPanel, ResizePanel } from "@ax/components";
4
- import type {
5
- HeadingFilter,
6
- IBreadcrumbItem,
7
- IModule,
8
- INotification,
9
- IRootState,
10
- ISchema,
11
- IUserEditing,
12
- } from "@ax/types";
5
+ import { IBreadcrumbItem, IModule, INotification, IRootState, ISchema, IUserEditing } from "@ax/types";
13
6
  import PageBrowser from "../PageBrowser";
14
7
 
15
8
  const Editor = (props: IProps) => {
@@ -40,12 +33,6 @@ const Editor = (props: IProps) => {
40
33
  setNotification,
41
34
  isEditLive,
42
35
  isDisabled,
43
- toggleHeadingsPreview,
44
- toggleKeywordsPreview,
45
- isHeadingsPreviewOpen,
46
- isKeywordsPreviewOpen,
47
- headingsFilter,
48
- keywordsFilter,
49
36
  } = props;
50
37
 
51
38
  const actions = {
@@ -59,26 +46,11 @@ const Editor = (props: IProps) => {
59
46
  copyModuleAction: copyModule,
60
47
  pasteModuleAction: pasteModule,
61
48
  setNotificationAction: setNotification,
62
- toggleHeadingsPreviewAction: toggleHeadingsPreview,
63
- toggleKeywordsPreviewAction: toggleKeywordsPreview,
64
49
  };
65
50
 
66
51
  return (
67
52
  <ResizePanel
68
- disabled={isHeadingsPreviewOpen || isKeywordsPreviewOpen}
69
- leftPanel={
70
- <PageBrowser
71
- isReadOnly={isReadOnly || isEditLive}
72
- theme={theme}
73
- browserRef={browserRef}
74
- isHeadingsPreviewOpen={isHeadingsPreviewOpen}
75
- toggleHeadingsPreview={toggleHeadingsPreview}
76
- headingsFilter={headingsFilter}
77
- toggleKeywordsPreview={toggleKeywordsPreview}
78
- isKeywordsPreviewOpen={isKeywordsPreviewOpen}
79
- keywordsFilter={keywordsFilter}
80
- />
81
- }
53
+ leftPanel={<PageBrowser isReadOnly={isReadOnly || isEditLive} theme={theme} browserRef={browserRef} />}
82
54
  rightPanel={
83
55
  <ConfigPanel
84
56
  schema={schema}
@@ -128,8 +100,6 @@ interface IPageBrowserDispatchProps {
128
100
  copyModule(editorID: number[]): boolean | number;
129
101
  pasteModule(editorID: number, key: string, modulesToPaste: IModule[]): Promise<{ error?: INotification }>;
130
102
  setNotification: (notification: INotification) => void;
131
- toggleHeadingsPreview: () => void;
132
- toggleKeywordsPreview: () => void;
133
103
  isGlobal: boolean;
134
104
  isEditable: boolean;
135
105
  isReadOnly: boolean;
@@ -137,10 +107,6 @@ interface IPageBrowserDispatchProps {
137
107
  browserRef: any;
138
108
  isEditLive: boolean;
139
109
  isDisabled: boolean;
140
- isHeadingsPreviewOpen: boolean;
141
- isKeywordsPreviewOpen: boolean;
142
- headingsFilter: HeadingFilter;
143
- keywordsFilter: string[];
144
110
  }
145
111
 
146
112
  type IProps = IEditorStateProps & IPageBrowserDispatchProps;
@@ -1,7 +1,8 @@
1
1
  import { connect } from "react-redux";
2
2
  import { pageEditorActions } from "@ax/containers/PageEditor";
3
+
3
4
  import { Browser } from "@ax/components";
4
- import type { HeadingFilter, ILanguage, IRootState, ISchema, ISocialState } from "@ax/types";
5
+ import type { ILanguage, IRootState, ISchema, ISocialState } from "@ax/types";
5
6
 
6
7
  const PageBrowser = (props: IProps) => {
7
8
  const {
@@ -14,22 +15,15 @@ const PageBrowser = (props: IProps) => {
14
15
  isReadOnly,
15
16
  isPreview,
16
17
  browserRef,
17
- isHeadingsPreviewOpen = false,
18
- isKeywordsPreviewOpen = false,
19
- headingsFilter,
20
- keywordsFilter,
21
18
  deleteModule,
22
19
  duplicateModule,
23
20
  copyModule,
24
21
  setScrollEditorID,
25
- toggleHeadingsPreview,
26
- toggleKeywordsPreview,
27
22
  } = props;
28
23
 
29
24
  const slugWithSlash = slug ? (slug.startsWith("/") ? slug : `/${slug}`) : "";
30
25
  const pathWithoutSlash = path ? (path.endsWith("/") ? path.slice(0, -1) : path) : "";
31
26
  const url = `${pathWithoutSlash}${slugWithSlash}`;
32
- const editorType = isHeadingsPreviewOpen ? "headings" : isKeywordsPreviewOpen ? "keywords" : "page";
33
27
 
34
28
  const actions = {
35
29
  deleteModuleAction: deleteModule,
@@ -54,11 +48,6 @@ const PageBrowser = (props: IProps) => {
54
48
  showIframe={true}
55
49
  browserRef={browserRef}
56
50
  actions={actions}
57
- editorType={editorType}
58
- toggleHeadingsPreview={toggleHeadingsPreview}
59
- headingFilter={headingsFilter}
60
- toggleKeywordsPreview={toggleKeywordsPreview}
61
- keywordsFilter={keywordsFilter}
62
51
  />
63
52
  );
64
53
  };
@@ -79,16 +68,10 @@ interface IPageBrowserDispatchProps {
79
68
  isReadOnly: boolean;
80
69
  isPreview?: boolean;
81
70
  browserRef?: any;
82
- isHeadingsPreviewOpen?: boolean;
83
- isKeywordsPreviewOpen?: boolean;
84
- headingsFilter?: HeadingFilter;
85
- keywordsFilter?: string[];
86
71
  deleteModule(editorID: number[]): void;
87
72
  duplicateModule(editorID: number[]): number;
88
73
  copyModule(editorID: number[]): number | boolean;
89
74
  setScrollEditorID(editorID: number | null): void;
90
- toggleHeadingsPreview?(): void;
91
- toggleKeywordsPreview?(): void;
92
75
  }
93
76
 
94
77
  type IProps = IPageBrowserStateProps & IPageBrowserDispatchProps;
@@ -1,3 +1,5 @@
1
+ import React from "react";
2
+
1
3
  import PageBrowser from "../PageBrowser";
2
4
  import * as S from "./style";
3
5
 
@@ -2,7 +2,7 @@ import styled from "styled-components";
2
2
 
3
3
  const BrowserWrapper = styled.div`
4
4
  background-color: ${(p) => p.theme.color.uiBackground01};
5
- height: 100%;
5
+ height: calc(100% - 44px);
6
6
  width: 100%;
7
7
  `;
8
8
 
@@ -7,8 +7,6 @@ import {
7
7
  CancelScheduleModal,
8
8
  ErrorPage,
9
9
  ErrorToast,
10
- HeadingsPreviewModal,
11
- KeywordsPreviewModal,
12
10
  Loading,
13
11
  MainWrapper,
14
12
  Modal,
@@ -25,9 +23,8 @@ import { structuredDataActions } from "@ax/containers/StructuredData";
25
23
  import { usersActions } from "@ax/containers/Users";
26
24
  import { RouteLeavingGuard } from "@ax/guards";
27
25
  import { dateToString, getDefaultTheme } from "@ax/helpers";
28
- import { useIsDirty, useModals, usePermissions } from "@ax/hooks";
26
+ import { useIsDirty, useModal, usePermission } from "@ax/hooks";
29
27
  import type {
30
- HeadingFilter,
31
28
  IErrorItem,
32
29
  ILanguage,
33
30
  INotification,
@@ -70,46 +67,35 @@ const GlobalEditor = (props: IProps) => {
70
67
  getUserCurrentPermissions,
71
68
  schedulePublication,
72
69
  restorePage,
73
- updateEditorContent,
74
70
  schemaVersion,
75
71
  } = props;
76
72
 
77
- const isAllowedTo = usePermissions({
78
- publishPages: "global.globalData.publishUnpublishAllGlobalData",
79
- createPages: "global.globalData.createAllGlobalData",
80
- deletePages: "global.globalData.deleteAllGlobalData",
81
- editContentPages: "global.globalData.editAllGlobalData",
82
- });
83
-
84
- const defaultTab = isAllowedTo.editContentPages ? "edit" : "view";
73
+ const isAllowedToPublishPages = usePermission("global.globalData.publishUnpublishAllGlobalData");
74
+ const isAllowedToCreatePages = usePermission("global.globalData.createAllGlobalData");
75
+ const isAllowedToDeletePage = usePermission("global.globalData.deleteAllGlobalData");
76
+ const isAllowedToEditContentPage = usePermission("global.globalData.editAllGlobalData");
77
+ //
78
+ const defaultTab = isAllowedToEditContentPage ? "edit" : "view";
85
79
 
80
+ const { isOpen, toggleModal } = useModal();
81
+ const { isOpen: isUnpublishOpen, toggleModal: toggleUnpublishModal } = useModal();
86
82
  const [isReadOnly, setIsReadOnly] = useState(false);
87
83
  const [selectedTab, setSelectedTab] = useState(defaultTab);
88
84
  const [notification, setNotification] = useState<INotification | null>(null);
89
85
  const [toastMsg, setToastMsg] = useState<string | null>(null);
86
+ const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent, isNewTranslation);
90
87
  const [errorPagesChecked, setErrorPagesChecked] = useState(false);
91
- const [headingsFilter, setHeadingsFilter] = useState<HeadingFilter>("all");
92
- const [keywordsFilter, setKeywordsFilter] = useState<string[]>([]);
93
88
  const [scheduleDate, setScheduleDate] = useState({
94
89
  date: dateToString(new Date(), "yyy/MM/dd"),
95
90
  time: "12:00 am",
96
91
  });
92
+ const { isOpen: isScheduleOpen, toggleModal: toggleScheduleModal } = useModal();
93
+ const { isOpen: isCancelScheduleOpen, toggleModal: toggleCancelScheduleModal } = useModal();
94
+ const { isOpen: isRestoreOpen, toggleModal: toggleRestoreModal } = useModal();
95
+ const { isOpen: isDirtyNavigateOpen, toggleModal: toggleDirtyNavigateModal } = useModal();
97
96
  const [pendingNavigateCallback, setPendingNavigateCallback] = useState<(() => void) | null>(null);
98
97
  const browserRef = useRef<HTMLDivElement>(null);
99
98
 
100
- const { isOpen, toggleModal } = useModals([
101
- "userEditing",
102
- "unpublish",
103
- "schedule",
104
- "cancelSchedule",
105
- "restore",
106
- "headingsPreview",
107
- "keywordsPreview",
108
- "dirtyNavigate",
109
- ]);
110
-
111
- const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent, isNewTranslation);
112
-
113
99
  const isPublished = props.pageStatus === pageStatus.PUBLISHED || props.pageStatus === pageStatus.UPLOAD_PENDING;
114
100
  const isDraft = props.pageStatus === pageStatus.MODIFIED || !!editorContent.draftFromPage;
115
101
  const hasDraft: boolean = editorContent && !!editorContent.haveDraftPage;
@@ -118,7 +104,6 @@ const GlobalEditor = (props: IProps) => {
118
104
  const isEditLive = isPublished && hasDraft;
119
105
  const isScheduled = props.pageStatus === pageStatus.SCHEDULED;
120
106
  const isDeleted = editorContent.deleted;
121
- const defaultContentTab = "content";
122
107
 
123
108
  const errorNotificationText =
124
109
  "There are some errors on the page so you can not publish yet. Please review them in the error panel.";
@@ -137,11 +122,12 @@ const GlobalEditor = (props: IProps) => {
137
122
 
138
123
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
139
124
  useEffect(() => {
140
- const { pageID, getPage, sendPagePing, setStructuredDataFilter } = props;
125
+ const { pageID, getPage, setTab, sendPagePing, setStructuredDataFilter } = props;
141
126
 
142
127
  editorContent?.structuredData && setStructuredDataFilter(editorContent.structuredData);
128
+ const defaultTab = "content";
143
129
  const handleGetPage = async () => await getPage(pageID, true);
144
- setTab(defaultContentTab);
130
+ setTab(defaultTab);
145
131
  setToastMsg(null);
146
132
  handleGetPage();
147
133
  if (!pageID) {
@@ -164,11 +150,11 @@ const GlobalEditor = (props: IProps) => {
164
150
  const { pageID, sendPagePing, currentUserID } = props;
165
151
  if (userEditing && userEditing.id !== currentUserID) {
166
152
  setIsReadOnly(true);
167
- !isOpen("userEditing") && toggleModal("userEditing");
153
+ !isOpen && toggleModal();
168
154
  } else {
169
155
  setIsReadOnly(false);
170
156
  pageID && sendPagePing(pageID);
171
- isOpen("userEditing") && toggleModal("userEditing");
157
+ isOpen && toggleModal();
172
158
  }
173
159
  }, [userEditing]);
174
160
 
@@ -294,7 +280,7 @@ const GlobalEditor = (props: IProps) => {
294
280
  const saved = await schedulePublication(dateString, isDraft);
295
281
  if (saved) {
296
282
  resetDirty();
297
- toggleModal("schedule");
283
+ toggleScheduleModal();
298
284
  }
299
285
  };
300
286
 
@@ -303,7 +289,7 @@ const GlobalEditor = (props: IProps) => {
303
289
  if (saved) {
304
290
  setScheduleDate({ date: "", time: "12:00 am" });
305
291
  resetDirty();
306
- toggleModal("cancelSchedule");
292
+ toggleCancelScheduleModal();
307
293
  }
308
294
  };
309
295
 
@@ -324,7 +310,7 @@ const GlobalEditor = (props: IProps) => {
324
310
  }
325
311
  : {
326
312
  label: status === pageStatus.UPLOAD_PENDING ? "Cancel publication" : "Unpublish",
327
- action: hasDraft ? () => toggleModal("unpublish") : unpublishPage,
313
+ action: hasDraft ? toggleUnpublishModal : unpublishPage,
328
314
  };
329
315
  case pageStatus.MODIFIED:
330
316
  case pageStatus.SCHEDULED:
@@ -339,24 +325,24 @@ const GlobalEditor = (props: IProps) => {
339
325
 
340
326
  const menuOptions = [];
341
327
 
342
- if (isAllowedTo.publishPages && !isScheduled && !isPublished && props.pageStatus !== pageStatus.OFFLINE_PENDING) {
328
+ if (isAllowedToPublishPages && !isScheduled && !isPublished && props.pageStatus !== pageStatus.OFFLINE_PENDING) {
343
329
  menuOptions.push({
344
330
  label: "Schedule",
345
331
  icon: "calendar",
346
- action: () => toggleModal("schedule"),
332
+ action: toggleScheduleModal,
347
333
  });
348
334
  }
349
335
 
350
- if (isAllowedTo.publishPages && isScheduled) {
336
+ if (isAllowedToPublishPages && isScheduled) {
351
337
  menuOptions.push({
352
338
  label: "Cancel Schedule",
353
339
  icon: "cancelEvent",
354
- action: () => toggleModal("cancelSchedule"),
340
+ action: toggleCancelScheduleModal,
355
341
  });
356
342
  }
357
343
 
358
344
  if (
359
- isAllowedTo.editContentPages &&
345
+ isAllowedToEditContentPage &&
360
346
  (props.pageStatus === pageStatus.PUBLISHED ||
361
347
  props.pageStatus === pageStatus.OFFLINE ||
362
348
  props.pageStatus === pageStatus.OFFLINE_PENDING ||
@@ -370,7 +356,7 @@ const GlobalEditor = (props: IProps) => {
370
356
  });
371
357
  }
372
358
 
373
- if (isAllowedTo.editContentPages && !isScheduled && (isDraft || (isPublished && isDirty))) {
359
+ if (isAllowedToEditContentPage && !isScheduled && (isDraft || (isPublished && isDirty))) {
374
360
  menuOptions.push({
375
361
  label: "Discard changes",
376
362
  icon: "close",
@@ -378,15 +364,15 @@ const GlobalEditor = (props: IProps) => {
378
364
  });
379
365
  }
380
366
 
381
- if (props.pageStatus === pageStatus.PUBLISHED && !hasDraft && isDirty && isAllowedTo.publishPages) {
367
+ if (props.pageStatus === pageStatus.PUBLISHED && !hasDraft && isDirty && isAllowedToPublishPages) {
382
368
  menuOptions.push({
383
369
  label: "Unpublish",
384
370
  icon: "offline",
385
- action: isDraft ? () => toggleModal("unpublish") : unpublishPage,
371
+ action: isDraft ? toggleUnpublishModal : unpublishPage,
386
372
  });
387
373
  }
388
374
 
389
- if (!isDraft && isAllowedTo.deletePages) {
375
+ if (!isDraft && isAllowedToDeletePage) {
390
376
  menuOptions.push({
391
377
  label: "Delete page",
392
378
  icon: "delete",
@@ -396,7 +382,7 @@ const GlobalEditor = (props: IProps) => {
396
382
 
397
383
  const downArrowMenu = {
398
384
  displayed: !isReadOnly && !isDeleted,
399
- button: isAllowedTo.publishPages ? getPublishButton(props.pageStatus) : undefined,
385
+ button: isAllowedToPublishPages ? getPublishButton(props.pageStatus) : undefined,
400
386
  options: menuOptions,
401
387
  };
402
388
 
@@ -444,7 +430,7 @@ const GlobalEditor = (props: IProps) => {
444
430
  }
445
431
  };
446
432
 
447
- const rightButtonProps = isAllowedTo.editContentPages
433
+ const rightButtonProps = isAllowedToEditContentPage
448
434
  ? {
449
435
  label: isSaving ? "Saving" : getSaveLabel(),
450
436
  disabled: (!isDirty && pageID !== null && !isNewTranslation) || isSaving || isReadOnly,
@@ -476,11 +462,11 @@ const GlobalEditor = (props: IProps) => {
476
462
 
477
463
  const onNavigateWithDirty = (navigateCallback: () => void) => {
478
464
  setPendingNavigateCallback(() => navigateCallback);
479
- toggleModal("dirtyNavigate");
465
+ toggleDirtyNavigateModal();
480
466
  };
481
467
 
482
468
  const handleConfirmDirtyNavigation = () => {
483
- toggleModal("dirtyNavigate");
469
+ toggleDirtyNavigateModal();
484
470
  if (pendingNavigateCallback) {
485
471
  pendingNavigateCallback();
486
472
  setPendingNavigateCallback(null);
@@ -488,7 +474,7 @@ const GlobalEditor = (props: IProps) => {
488
474
  };
489
475
 
490
476
  const handleCancelDirtyNavigation = () => {
491
- toggleModal("dirtyNavigate");
477
+ toggleDirtyNavigateModal();
492
478
  setPendingNavigateCallback(null);
493
479
  };
494
480
 
@@ -532,7 +518,7 @@ const GlobalEditor = (props: IProps) => {
532
518
  const mainAction = { title: "Preview Page", onClick: toggleModal };
533
519
  const secondaryAction = { title: "Ok, go back", onClick: handleGoBack };
534
520
 
535
- const mainUnpublishAction = { title: "Ok", onClick: () => toggleModal("unpublish") };
521
+ const mainUnpublishAction = { title: "Ok", onClick: toggleUnpublishModal };
536
522
 
537
523
  const mainScheduleModalAction = {
538
524
  title: "Schedule",
@@ -541,7 +527,7 @@ const GlobalEditor = (props: IProps) => {
541
527
 
542
528
  const secondaryScheduleModalAction = {
543
529
  title: "Cancel",
544
- onClick: () => toggleModal("schedule"),
530
+ onClick: toggleScheduleModal,
545
531
  };
546
532
 
547
533
  const mainCancelScheduleModalAction = {
@@ -551,10 +537,10 @@ const GlobalEditor = (props: IProps) => {
551
537
 
552
538
  const secondaryCancelScheduleModalAction = {
553
539
  title: "Back",
554
- onClick: () => toggleModal("cancelSchedule"),
540
+ onClick: toggleCancelScheduleModal,
555
541
  };
556
542
 
557
- const tabIcons = isAllowedTo.editContentPages
543
+ const tabIcons = isAllowedToEditContentPage
558
544
  ? [
559
545
  { name: "edit", text: "Edit mode" },
560
546
  { name: "view", text: "Preview mode" },
@@ -572,7 +558,6 @@ const GlobalEditor = (props: IProps) => {
572
558
  icons: tabIcons,
573
559
  selectedTab,
574
560
  action: (tab: string) => handleSelectedTab(tab),
575
- disabled: isOpen("headingsPreview") || isOpen("keywordsPreview"),
576
561
  };
577
562
 
578
563
  const filteredLanguages = globalLangs.filter((lang) =>
@@ -602,7 +587,7 @@ const GlobalEditor = (props: IProps) => {
602
587
  await getPage(selectedPageLanguage.pageId, true, isDraft);
603
588
  resetDirty();
604
589
  } else {
605
- isAllowedTo.editContentPages && setSelectedTab("edit");
590
+ isAllowedToEditContentPage && setSelectedTab("edit");
606
591
  createNewTranslation(true);
607
592
  await getPage(pageID, true);
608
593
  }
@@ -611,33 +596,11 @@ const GlobalEditor = (props: IProps) => {
611
596
  const handleRestorePage = async () => {
612
597
  const isRestored = await restorePage(pageID);
613
598
  if (isRestored) {
614
- isOpen("restore") && toggleModal("restore");
599
+ isRestoreOpen && toggleRestoreModal();
615
600
  await getPage(pageID);
616
601
  }
617
602
  };
618
603
 
619
- const handleAddKeywords = (newKeywords: string[]) => {
620
- const keywords: string[] = [...editorContent.metaKeywords, ...newKeywords];
621
- updateEditorContent(0, "metaKeywords", keywords);
622
- handleSavePage();
623
- };
624
-
625
- const handledeleteKeyword = (keyword: string) => {
626
- const newKeywords = (editorContent.metaKeywords as string[]).filter((key) => key !== keyword);
627
- updateEditorContent(0, "metaKeywords", newKeywords);
628
- handleSavePage();
629
- };
630
-
631
- const handleToggleHeadingsEditor = () => {
632
- toggleModal("headingsPreview");
633
- setTab(defaultContentTab);
634
- };
635
-
636
- const handleToggleKeywordsEditor = () => {
637
- toggleModal("keywordsPreview");
638
- setTab(defaultContentTab);
639
- };
640
-
641
604
  return isLoading ? (
642
605
  <Loading />
643
606
  ) : (
@@ -653,7 +616,7 @@ const GlobalEditor = (props: IProps) => {
653
616
  pageStatus={props.pageStatus}
654
617
  language={lang}
655
618
  languageAction={handleLanguage}
656
- availableLanguages={isAllowedTo.createPages && !isDeleted ? globalLangs : filteredLanguages}
619
+ availableLanguages={isAllowedToCreatePages && !isDeleted ? globalLangs : filteredLanguages}
657
620
  currentLanguages={contentLanguages}
658
621
  currentPageID={pageID}
659
622
  fullWidth={true}
@@ -680,7 +643,7 @@ const GlobalEditor = (props: IProps) => {
680
643
  type="error"
681
644
  text={deletedNotificationText}
682
645
  btnText="Restore page"
683
- onClick={() => toggleModal("restore")}
646
+ onClick={toggleRestoreModal}
684
647
  />
685
648
  </S.NotificationWrapper>
686
649
  )}
@@ -711,12 +674,6 @@ const GlobalEditor = (props: IProps) => {
711
674
  setNotification={setNotification}
712
675
  isEditLive={isEditLive}
713
676
  isDisabled={isDeleted}
714
- toggleHeadingsPreview={handleToggleHeadingsEditor}
715
- isHeadingsPreviewOpen={isOpen("headingsPreview")}
716
- headingsFilter={headingsFilter}
717
- toggleKeywordsPreview={handleToggleKeywordsEditor}
718
- isKeywordsPreviewOpen={isOpen("keywordsPreview")}
719
- keywordsFilter={keywordsFilter}
720
677
  />
721
678
  </S.Content>
722
679
  </>
@@ -727,14 +684,14 @@ const GlobalEditor = (props: IProps) => {
727
684
  </>
728
685
  )}
729
686
  <Modal
730
- isOpen={isOpen("userEditing")}
731
- hide={() => toggleModal("userEditing")}
687
+ isOpen={isOpen}
688
+ hide={toggleModal}
732
689
  size="S"
733
690
  title="This page is currently being edited"
734
691
  mainAction={mainAction}
735
692
  secondaryAction={secondaryAction}
736
693
  >
737
- {isOpen("userEditing") && (
694
+ {isOpen && (
738
695
  <S.ModalContent>
739
696
  <p>
740
697
  <strong>{userEditing?.name}</strong> is currently working on this page. You can preview the page but{" "}
@@ -744,13 +701,13 @@ const GlobalEditor = (props: IProps) => {
744
701
  )}
745
702
  </Modal>
746
703
  <Modal
747
- isOpen={isOpen("unpublish")}
748
- hide={() => toggleModal("unpublish")}
704
+ isOpen={isUnpublishOpen}
705
+ hide={toggleUnpublishModal}
749
706
  size="S"
750
707
  title="Unpublish Modified Page"
751
708
  mainAction={mainUnpublishAction}
752
709
  >
753
- {isOpen("unpublish") && (
710
+ {isUnpublishOpen && (
754
711
  <S.ModalContent>
755
712
  <p>
756
713
  There are some saved changes that are not published on this page. To Unpublish this page,{" "}
@@ -760,48 +717,31 @@ const GlobalEditor = (props: IProps) => {
760
717
  )}
761
718
  </Modal>
762
719
  <ScheduleModal
763
- isOpen={isOpen("schedule")}
764
- toggleModal={() => toggleModal("schedule")}
720
+ isOpen={isScheduleOpen}
721
+ toggleModal={toggleScheduleModal}
765
722
  mainModalAction={mainScheduleModalAction}
766
723
  secondaryModalAction={secondaryScheduleModalAction}
767
724
  scheduleDate={scheduleDate}
768
725
  setScheduleDate={setScheduleDate}
769
726
  />
770
727
  <CancelScheduleModal
771
- isOpen={isOpen("cancelSchedule")}
772
- toggleModal={() => toggleModal("cancelSchedule")}
728
+ isOpen={isCancelScheduleOpen}
729
+ toggleModal={toggleCancelScheduleModal}
773
730
  mainModalAction={mainCancelScheduleModalAction}
774
731
  secondaryModalAction={secondaryCancelScheduleModalAction}
775
732
  />
776
733
  <RestoreModal
777
- isOpen={isOpen("restore")}
778
- toggleModal={() => toggleModal("restore")}
734
+ isOpen={isRestoreOpen}
735
+ toggleModal={toggleRestoreModal}
779
736
  {...{
780
737
  isChild: false,
781
738
  hasIssues: schemaVersion !== editorContent.schemaVersionTimestamp,
782
739
  restorePage: handleRestorePage,
783
740
  }}
784
741
  />
785
- <HeadingsPreviewModal
786
- isOpen={isOpen("headingsPreview")}
787
- toggleModal={handleToggleHeadingsEditor}
788
- browserRef={browserRef}
789
- headingsFilter={headingsFilter}
790
- setHeadingsFilter={setHeadingsFilter}
791
- />
792
- <KeywordsPreviewModal
793
- isOpen={isOpen("keywordsPreview")}
794
- toggleModal={handleToggleKeywordsEditor}
795
- browserRef={browserRef}
796
- keywords={editorContent?.metaKeywords || []}
797
- keywordsFilter={keywordsFilter}
798
- setKeywordsFilter={setKeywordsFilter}
799
- addKeywords={handleAddKeywords}
800
- deleteKeyword={handledeleteKeyword}
801
- />
802
742
  </MainWrapper>
803
743
  <Modal
804
- isOpen={isOpen("dirtyNavigate")}
744
+ isOpen={isDirtyNavigateOpen}
805
745
  hide={handleCancelDirtyNavigation}
806
746
  size="S"
807
747
  title="Unsaved changes"
@@ -878,7 +818,6 @@ const mapDispatchToProps = {
878
818
  getUserCurrentPermissions: usersActions.getUserCurrentPermissions,
879
819
  schedulePublication: pageEditorActions.schedulePublication,
880
820
  restorePage: pageEditorActions.restorePage,
881
- updateEditorContent: pageEditorActions.updateEditorContent,
882
821
  };
883
822
 
884
823
  interface IPageEditorDispatchProps {
@@ -905,7 +844,6 @@ interface IPageEditorDispatchProps {
905
844
  getUserCurrentPermissions(): Promise<void>;
906
845
  schedulePublication(date: string | null, isDraft: boolean): Promise<boolean>;
907
846
  restorePage(id: number | number[]): Promise<boolean>;
908
- updateEditorContent(selectedEditorID: number, key: string, value: any): void;
909
847
  }
910
848
 
911
849
  type IProps = IPageEditorStateProps & IPageEditorDispatchProps & RouteComponentProps;
@@ -4,17 +4,7 @@ import { pageEditorActions } from "@ax/containers/PageEditor";
4
4
  import { sitesActions } from "@ax/containers/Sites";
5
5
  import { appActions } from "@ax/containers/App";
6
6
  import { ConfigPanel, ResizePanel } from "@ax/components";
7
- import type {
8
- HeadingFilter,
9
- IBreadcrumbItem,
10
- IModule,
11
- INotification,
12
- IRootState,
13
- ISchema,
14
- ISite,
15
- IUserEditing,
16
- } from "@ax/types";
17
-
7
+ import type { IBreadcrumbItem, IModule, INotification, IRootState, ISchema, ISite, IUserEditing } from "@ax/types";
18
8
  import PageBrowser from "../PageBrowser";
19
9
 
20
10
  const Editor = (props: IProps) => {
@@ -50,15 +40,9 @@ const Editor = (props: IProps) => {
50
40
  pasteModule,
51
41
  setNotification,
52
42
  restorePageNavigation,
53
- toggleHeadingsPreview,
54
- toggleKeywordsPreview,
55
43
  content,
56
44
  isEditLive,
57
45
  isDisabled,
58
- isHeadingsPreviewOpen,
59
- headingsFilter,
60
- isKeywordsPreviewOpen,
61
- keywordsFilter,
62
46
  isDirty,
63
47
  onNavigateWithDirty,
64
48
  } = props;
@@ -84,24 +68,15 @@ const Editor = (props: IProps) => {
84
68
  pasteModuleAction: pasteModule,
85
69
  setNotificationAction: setNotification,
86
70
  restorePageNavigationAction: restorePageNavigation,
87
- toggleHeadingsPreviewAction: toggleHeadingsPreview,
88
- toggleKeywordsPreviewAction: toggleKeywordsPreview,
89
71
  };
90
72
 
91
73
  return (
92
74
  <ResizePanel
93
- disabled={isHeadingsPreviewOpen || isKeywordsPreviewOpen}
94
75
  leftPanel={
95
76
  <PageBrowser
96
77
  isTemplateActivated={isTemplateActivated}
97
78
  isReadOnly={isReadOnly || isEditLive || isDisabled}
98
79
  browserRef={browserRef}
99
- isHeadingsPreviewOpen={isHeadingsPreviewOpen}
100
- toggleHeadingsPreview={toggleHeadingsPreview}
101
- headingsFilter={headingsFilter}
102
- toggleKeywordsPreview={toggleKeywordsPreview}
103
- isKeywordsPreviewOpen={isKeywordsPreviewOpen}
104
- keywordsFilter={keywordsFilter}
105
80
  />
106
81
  }
107
82
  rightPanel={
@@ -167,20 +142,14 @@ interface IPageBrowserDispatchProps {
167
142
  pasteModule(editorID: number, key: string, modulesToPaste: IModule[]): Promise<{ error?: INotification }>;
168
143
  setNotification: (notification: INotification) => void;
169
144
  restorePageNavigation: (key: string) => void;
170
- toggleHeadingsPreview: () => void;
171
- toggleKeywordsPreview: () => void;
172
145
  isTemplateActivated: boolean;
173
146
  isGlobal: boolean;
174
147
  isEditable: boolean;
175
148
  pageTitle: string;
176
149
  isReadOnly: boolean;
177
- browserRef: React.RefObject<HTMLDivElement>;
150
+ browserRef: any;
178
151
  isEditLive: boolean;
179
152
  isDisabled: boolean;
180
- isHeadingsPreviewOpen: boolean;
181
- headingsFilter: HeadingFilter;
182
- isKeywordsPreviewOpen: boolean;
183
- keywordsFilter: string[];
184
153
  isDirty?: boolean;
185
154
  onNavigateWithDirty?: (navigateCallback: () => void) => void;
186
155
  }