@griddo/ax 11.0.29-rc.0 → 11.0.30-rc.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 (141) hide show
  1. package/config/griddo-config/cx-polyfills/componentsBundle.js +1 -1
  2. package/package.json +2 -2
  3. package/scripts/griddo-sync-schemas.js +49 -42
  4. package/src/GlobalStore.tsx +3 -0
  5. package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +6 -0
  6. package/src/api/forms.tsx +191 -0
  7. package/src/api/index.tsx +2 -0
  8. package/src/components/Browser/index.tsx +42 -37
  9. package/src/components/Browser/style.tsx +3 -3
  10. package/src/components/BrowserContent/index.tsx +1 -1
  11. package/src/components/ConfigPanel/Form/index.tsx +6 -5
  12. package/src/components/ConfigPanel/GlobalPageForm/index.tsx +3 -1
  13. package/src/components/ConfigPanel/Header/index.tsx +1 -0
  14. package/src/components/Fields/ComponentArray/MixableComponentArray/AddItemButton/index.tsx +4 -5
  15. package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +4 -4
  16. package/src/components/Fields/ComponentArray/helpers.tsx +1 -1
  17. package/src/components/Fields/FormFieldArray/index.tsx +13 -0
  18. package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +1 -2
  19. package/src/components/Fields/ReferenceField/Context/index.tsx +0 -2
  20. package/src/components/Fields/ReferenceField/ItemList/index.tsx +1 -2
  21. package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +2 -2
  22. package/src/components/Fields/ReferenceField/index.tsx +1 -5
  23. package/src/components/Fields/TranslateButton/index.tsx +48 -10
  24. package/src/components/Fields/Wysiwyg/helpers.tsx +2 -2
  25. package/src/components/Fields/Wysiwyg/index.tsx +4 -11
  26. package/src/components/Fields/index.tsx +2 -0
  27. package/src/components/FieldsBehavior/index.tsx +8 -2
  28. package/src/components/Icon/components/Form.js +12 -0
  29. package/src/components/Icon/svgs/Form.svg +3 -0
  30. package/src/components/LanguageMenu/index.tsx +30 -27
  31. package/src/components/MainWrapper/AppBar/index.tsx +23 -68
  32. package/src/components/MainWrapper/index.tsx +4 -9
  33. package/src/components/MenuItem/index.tsx +2 -2
  34. package/src/components/ResizePanel/index.tsx +3 -2
  35. package/src/components/ResizePanel/style.tsx +11 -9
  36. package/src/components/SearchField/style.tsx +2 -2
  37. package/src/components/SideModal/SideModalOption/index.tsx +3 -2
  38. package/src/components/SideModal/SideModalOption/style.tsx +2 -2
  39. package/src/components/SideModal/index.tsx +11 -4
  40. package/src/components/SideModal/style.tsx +9 -7
  41. package/src/components/TableFilters/LiveFilter/index.tsx +4 -3
  42. package/src/components/index.tsx +4 -0
  43. package/src/containers/App/reducer.tsx +4 -1
  44. package/src/containers/Forms/actions.tsx +853 -0
  45. package/src/containers/Forms/constants.tsx +46 -0
  46. package/src/containers/Forms/index.tsx +4 -0
  47. package/src/containers/Forms/interfaces.tsx +95 -0
  48. package/src/containers/Forms/reducer.tsx +81 -0
  49. package/src/containers/Forms/utils.tsx +42 -0
  50. package/src/containers/Navigation/Menu/actions.tsx +6 -13
  51. package/src/containers/Navigation/Menu/reducer.tsx +0 -4
  52. package/src/containers/PageEditor/actions.tsx +3 -2
  53. package/src/containers/PageEditor/reducer.tsx +2 -2
  54. package/src/forms/editor.tsx +3 -1
  55. package/src/helpers/index.tsx +12 -1
  56. package/src/helpers/schemas.tsx +35 -9
  57. package/src/helpers/structuredData.tsx +3 -1
  58. package/src/helpers/themes.tsx +3 -1
  59. package/src/helpers/thumbnails.tsx +20 -2
  60. package/src/modules/Analytics/GroupPanel/utils.tsx +3 -1
  61. package/src/modules/App/Routing/NavMenu/index.tsx +16 -6
  62. package/src/modules/App/Routing/index.tsx +26 -9
  63. package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +4 -4
  64. package/src/modules/Categories/CategoriesList/index.tsx +16 -16
  65. package/src/modules/Content/BulkHeader/TableHeader/index.tsx +1 -5
  66. package/src/modules/Content/PageItem/index.tsx +34 -33
  67. package/src/modules/Content/index.tsx +23 -36
  68. package/src/modules/Content/utils.tsx +3 -1
  69. package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/index.tsx +42 -0
  70. package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/style.tsx +36 -0
  71. package/src/modules/Forms/FormCategoriesList/BulkHeader/index.tsx +37 -0
  72. package/src/modules/Forms/FormCategoriesList/BulkHeader/style.tsx +9 -0
  73. package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +125 -0
  74. package/src/modules/Forms/FormCategoriesList/CategoryItem/style.tsx +91 -0
  75. package/src/modules/Forms/FormCategoriesList/CategoryPanel/Form/index.tsx +50 -0
  76. package/src/modules/Forms/FormCategoriesList/CategoryPanel/index.tsx +112 -0
  77. package/src/modules/Forms/FormCategoriesList/CategoryPanel/style.tsx +31 -0
  78. package/src/modules/Forms/FormCategoriesList/atoms.tsx +33 -0
  79. package/src/modules/Forms/FormCategoriesList/hooks.tsx +61 -0
  80. package/src/modules/Forms/FormCategoriesList/index.tsx +245 -0
  81. package/src/modules/Forms/FormCategoriesList/style.tsx +82 -0
  82. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/Field/index.tsx +95 -0
  83. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/index.tsx +102 -0
  84. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/style.tsx +9 -0
  85. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/index.tsx +109 -0
  86. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/index.tsx +76 -0
  87. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/style.tsx +28 -0
  88. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/index.tsx +132 -0
  89. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/style.tsx +30 -0
  90. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/index.tsx +86 -0
  91. package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/style.tsx +7 -0
  92. package/src/modules/Forms/FormEditor/Editor/index.tsx +106 -0
  93. package/src/modules/Forms/FormEditor/PageBrowser/index.tsx +96 -0
  94. package/src/modules/Forms/FormEditor/index.tsx +295 -0
  95. package/src/modules/Forms/FormEditor/style.tsx +32 -0
  96. package/src/modules/Forms/FormList/BulkHeader/TableHeader/index.tsx +61 -0
  97. package/src/modules/Forms/FormList/BulkHeader/TableHeader/style.tsx +47 -0
  98. package/src/modules/Forms/FormList/BulkHeader/index.tsx +60 -0
  99. package/src/modules/Forms/FormList/FormItem/index.tsx +218 -0
  100. package/src/modules/Forms/FormList/FormItem/style.tsx +87 -0
  101. package/src/modules/Forms/FormList/Summary/index.tsx +51 -0
  102. package/src/modules/Forms/FormList/Summary/style.tsx +46 -0
  103. package/src/modules/Forms/FormList/TemplateModal/index.tsx +67 -0
  104. package/src/modules/Forms/FormList/TemplateModal/style.tsx +54 -0
  105. package/src/modules/Forms/FormList/index.tsx +266 -0
  106. package/src/modules/Forms/FormList/style.tsx +31 -0
  107. package/src/modules/Forms/FormsMenu/MenuGroup/index.tsx +57 -0
  108. package/src/modules/Forms/FormsMenu/MenuGroup/style.tsx +55 -0
  109. package/src/modules/Forms/FormsMenu/index.tsx +78 -0
  110. package/src/modules/Forms/FormsMenu/style.tsx +9 -0
  111. package/src/modules/Forms/atoms.tsx +111 -0
  112. package/src/modules/Forms/style.tsx +11 -0
  113. package/src/modules/FramePreview/index.tsx +26 -12
  114. package/src/modules/GlobalEditor/index.tsx +52 -21
  115. package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +32 -15
  116. package/src/modules/Navigation/Defaults/Item/atoms.tsx +6 -5
  117. package/src/modules/Navigation/Defaults/Item/index.tsx +10 -10
  118. package/src/modules/Navigation/Defaults/index.tsx +7 -6
  119. package/src/modules/Navigation/Menus/List/Nav/index.tsx +2 -10
  120. package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/index.tsx +14 -11
  121. package/src/modules/Navigation/Menus/List/index.tsx +15 -16
  122. package/src/modules/Navigation/Menus/index.tsx +9 -17
  123. package/src/modules/PageEditor/index.tsx +54 -31
  124. package/src/modules/Settings/Globals/index.tsx +3 -1
  125. package/src/modules/Settings/Languages/Table/Item/index.tsx +11 -9
  126. package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/index.tsx +1 -1
  127. package/src/modules/StructuredData/Form/index.tsx +41 -28
  128. package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +1 -5
  129. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +6 -8
  130. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +5 -7
  131. package/src/modules/StructuredData/StructuredDataList/index.tsx +13 -10
  132. package/src/modules/StructuredData/StructuredDataList/utils.tsx +2 -1
  133. package/src/routes/multisite.tsx +53 -16
  134. package/src/routes/site.tsx +1 -0
  135. package/src/schemas/pages/FormPage.tsx +49 -0
  136. package/src/schemas/pages/GlobalPage.tsx +1 -0
  137. package/src/schemas/pages/Page.tsx +4 -1
  138. package/src/schemas/pages/index.tsx +2 -1
  139. package/src/types/forms.tsx +87 -0
  140. package/src/types/index.tsx +43 -7
  141. /package/src/modules/Navigation/Menus/{helpers.tsx → List/helpers.tsx} +0 -0
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect } from "react";
2
2
  import { connect } from "react-redux";
3
- import { Switch, Route } from "react-router-dom";
3
+ import { Switch, Route, matchPath } from "react-router-dom";
4
4
 
5
5
  import { ErrorGuard } from "@ax/guards";
6
6
  import { IRootState, IUser } from "@ax/types";
@@ -9,6 +9,7 @@ import { publicRoutes, privateRoutes, routes, IRouter } from "@ax/routes";
9
9
  import { ILogoutAction } from "@ax/containers/App/interfaces";
10
10
  import { ErrorPage } from "@ax/components";
11
11
  import { usePermission } from "@ax/hooks";
12
+ import { IGlobalSettings } from "@ax/containers/App/reducer";
12
13
  import NavMenu from "./NavMenu";
13
14
  import PrivateRoute from "./PrivateRoute";
14
15
  import Logout from "./Logout";
@@ -16,7 +17,9 @@ import Logout from "./Logout";
16
17
  import * as S from "./style";
17
18
 
18
19
  const Routing = (props: IProps) => {
19
- const { path, token, currentUser, setHistoryPush, logout } = props;
20
+ const { path, token, currentUser, globalSettings, setHistoryPush, logout } = props;
21
+
22
+ const { useForms } = globalSettings;
20
23
 
21
24
  useEffect(() => {
22
25
  path === "/" && setHistoryPush("/login");
@@ -34,8 +37,17 @@ const Routing = (props: IProps) => {
34
37
 
35
38
  const route: IRouter | undefined = routes.find((item: IRouter) => {
36
39
  const cleanPath = path && path.replace(/\/$/, "");
40
+
41
+ const match = cleanPath
42
+ ? matchPath(cleanPath, {
43
+ path: item.path,
44
+ exact: true,
45
+ strict: false,
46
+ })
47
+ : null;
48
+
37
49
  return (
38
- item.path === cleanPath ||
50
+ !!match ||
39
51
  (item.routesGroups &&
40
52
  item.routesGroups.find((subitem) => {
41
53
  return subitem.routes.find((subroute) => subroute.path === path);
@@ -72,12 +84,15 @@ const Routing = (props: IProps) => {
72
84
  };
73
85
 
74
86
  const mapRoutes = (routeArr: IRouter[], isPrivate: boolean) =>
75
- routeArr.map((singleRoute: IRouter, i) => (
76
- <React.Fragment key={i}>
77
- {getRoute(singleRoute.component, singleRoute.path, isPrivate, singleRoute.permission)}
78
- {singleRoute.routesGroups && singleRoute.routesGroups.map((subgroup: any) => mapSubroutes(subgroup, isPrivate))}
79
- </React.Fragment>
80
- ));
87
+ routeArr
88
+ .filter((singleRoute: IRouter) => useForms || (!useForms && !singleRoute.path.includes("/forms")))
89
+ .map((singleRoute: IRouter, i) => (
90
+ <React.Fragment key={i}>
91
+ {getRoute(singleRoute.component, singleRoute.path, isPrivate, singleRoute.permission)}
92
+ {singleRoute.routesGroups &&
93
+ singleRoute.routesGroups.map((subgroup: any) => mapSubroutes(subgroup, isPrivate))}
94
+ </React.Fragment>
95
+ ));
81
96
 
82
97
  return (
83
98
  <>
@@ -102,6 +117,7 @@ const mapStateToProps = (state: IRootState) => ({
102
117
  path: state.router.location.pathname,
103
118
  token: state.app.token,
104
119
  currentUser: state.users.currentUser,
120
+ globalSettings: state.app.globalSettings,
105
121
  });
106
122
 
107
123
  interface IDispatchProps {
@@ -113,6 +129,7 @@ interface IStateProps {
113
129
  path?: string;
114
130
  token: string;
115
131
  currentUser: IUser | null;
132
+ globalSettings: IGlobalSettings;
116
133
  }
117
134
 
118
135
  const mapDispatchToProps = {
@@ -98,11 +98,11 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
98
98
  : [];
99
99
 
100
100
  const getCurrentLanguages = () => {
101
- const availables: any[] = [];
101
+ const availables: ILanguage[] = [];
102
102
 
103
103
  dataLanguages &&
104
104
  dataLanguages.forEach(
105
- (dataLang: any) =>
105
+ (dataLang) =>
106
106
  languages &&
107
107
  languages.forEach((language) => {
108
108
  if (language.id === dataLang.language) {
@@ -131,7 +131,7 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
131
131
  }
132
132
  };
133
133
 
134
- const handleLanguage = (language: ILanguage) => async () => {
134
+ const handleLanguage = async (language: ILanguage) => {
135
135
  const lang = {
136
136
  locale: language.locale,
137
137
  id: language.id,
@@ -257,7 +257,7 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
257
257
 
258
258
  interface IProps {
259
259
  category: IStructuredDataCategory | ICategoryGroup;
260
- languages: any[];
260
+ languages: ILanguage[];
261
261
  lang: { locale: string; id: number | null };
262
262
  isTranslatable: boolean;
263
263
  isSelected: boolean;
@@ -22,6 +22,7 @@ import {
22
22
  ICategoryGroup,
23
23
  IOrderCategoryParams,
24
24
  IQueryValue,
25
+ ILanguage,
25
26
  } from "@ax/types";
26
27
  import { useBulkSelection, useModal, usePermission, useToast } from "@ax/hooks";
27
28
  import {
@@ -95,6 +96,11 @@ const CategoriesList = (props: IProps): JSX.Element => {
95
96
 
96
97
  const scope = currentSiteID ? "site" : "global";
97
98
  const currentCategories = categories[scope].sort(sortBy("title", false));
99
+ const isEmpty = currentDataContent && currentDataContent.length === 0;
100
+ const hasCategories = currentCategories.length > 0;
101
+ const categoryName = currentStructuredData && currentStructuredData.title;
102
+ const availableLanguages = currentSiteID ? siteLanguages : globalLangs;
103
+ const isTranslatable = currentStructuredData ? currentStructuredData.translate : true;
98
104
 
99
105
  const catIds = getIDsFromTree(currentDataContent);
100
106
 
@@ -227,14 +233,6 @@ const CategoriesList = (props: IProps): JSX.Element => {
227
233
  />
228
234
  );
229
235
 
230
- const availableLanguages = currentSiteID ? siteLanguages : globalLangs;
231
-
232
- const isTranslatable = currentStructuredData ? currentStructuredData.translate : true;
233
-
234
- const languageActions = {
235
- setLanguage,
236
- };
237
-
238
236
  const getIcon = (item: TreeItem, onExpand: (itemId: ItemId) => void, onCollapse: (itemId: ItemId) => void) => {
239
237
  const handleCollapse = (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent) => {
240
238
  e.stopPropagation();
@@ -335,8 +333,8 @@ const CategoriesList = (props: IProps): JSX.Element => {
335
333
  destination.index !== undefined
336
334
  ? destination.index - (isGoingUp ? 1 : 0)
337
335
  : parent
338
- ? parent.children.length - 1
339
- : 0;
336
+ ? parent.children.length - 1
337
+ : 0;
340
338
 
341
339
  const itemDestination = findChildByIndex(tree, parentId, index);
342
340
 
@@ -355,9 +353,11 @@ const CategoriesList = (props: IProps): JSX.Element => {
355
353
  }
356
354
  };
357
355
 
358
- const isEmpty = currentDataContent && currentDataContent.length === 0;
359
- const hasCategories = currentCategories.length > 0;
360
- const categoryName = currentStructuredData && currentStructuredData.title;
356
+ const handleLanguage = (language: ILanguage) => {
357
+ const { locale, id } = language;
358
+ setLanguage({ locale, id });
359
+ };
360
+
361
361
  const emptyStateProps = {
362
362
  message: hasCategories
363
363
  ? `To start using ${categoryName} categories, create as many of them as yo need.`
@@ -386,7 +386,7 @@ const CategoriesList = (props: IProps): JSX.Element => {
386
386
  rightButton={rightButtonProps}
387
387
  language={lang}
388
388
  availableLanguages={availableLanguages}
389
- languageActions={languageActions}
389
+ languageAction={handleLanguage}
390
390
  searchAction={setSearchQuery}
391
391
  searchValue={searchQuery}
392
392
  >
@@ -494,8 +494,8 @@ interface ICategoriesProps {
494
494
  currentDataContent: (IStructuredDataCategory | ICategoryGroup)[];
495
495
  currentStructuredData: IStructuredData | null;
496
496
  lang: { locale: string; id: number };
497
- siteLanguages: any[];
498
- globalLangs: any[];
497
+ siteLanguages: ILanguage[];
498
+ globalLangs: ILanguage[];
499
499
  totalItems: number;
500
500
  categories: { global: IStructuredData[]; site: IStructuredData[] };
501
501
  activatedDataPacks: IDataPack[];
@@ -76,11 +76,7 @@ const TableHeader = (props: IProps): JSX.Element => {
76
76
  </S.NameWrapper>
77
77
  {activeColumns.includes("live") && (
78
78
  <S.HeaderWrapper>
79
- <LiveFilter
80
- filterItems={filterItems}
81
- value={filterValues.liveStatus}
82
- statusOptions={["offline", "active", "scheduled"]}
83
- />
79
+ <LiveFilter filterItems={filterItems} value={filterValues.liveStatus} hasBasicStatus={true} />
84
80
  </S.HeaderWrapper>
85
81
  )}
86
82
  {CategoryColumns}
@@ -1,10 +1,11 @@
1
- import React, { memo, useRef, useState } from "react";
2
- import { schemas } from "components";
1
+ import React, { useRef, useState } from "react";
2
+ import { connect } from "react-redux";
3
+ import { config } from "components";
3
4
  import { useTheme } from "styled-components";
4
5
 
5
6
  import { useAdaptiveText, useModal, usePermission } from "@ax/hooks";
6
7
  import { getHumanLastModifiedDate, getScheduleFormatDate, getTemplateDisplayName, slugify } from "@ax/helpers";
7
- import { IPage, ISite, ISavePageParams, ICheck, IColumn, IPageLanguage, IDataPack } from "@ax/types";
8
+ import { IPage, ISite, ISavePageParams, ICheck, IColumn, IPageLanguage, IDataPack, ILanguage } from "@ax/types";
8
9
  import { pageStatus, ISetCurrentPageIDAction } from "@ax/containers/PageEditor/interfaces";
9
10
  import {
10
11
  CheckField,
@@ -18,11 +19,15 @@ import {
18
19
  Tooltip,
19
20
  CategoryCell,
20
21
  } from "@ax/components";
22
+ import { pageEditorActions } from "@ax/containers/PageEditor";
23
+ import { appActions } from "@ax/containers/App";
21
24
 
22
25
  import { DeleteModal, CopyModal } from "../atoms";
23
26
 
24
27
  import * as S from "./style";
25
28
 
29
+ const schemas = config.schemas.ui;
30
+
26
31
  const PageItem = (props: IPageItemProps): JSX.Element => {
27
32
  const {
28
33
  functions,
@@ -38,6 +43,8 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
38
43
  sites,
39
44
  skipReview,
40
45
  hoverCheck,
46
+ createNewTranslation,
47
+ setLanguage,
41
48
  } = props;
42
49
  const { isSelected, siteLanguages, page, lang, isDuplicable } = item;
43
50
  const {
@@ -48,7 +55,6 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
48
55
  setHistoryPush,
49
56
  updatePageStatus,
50
57
  setCurrentPageID,
51
- languageActions,
52
58
  duplicatePage,
53
59
  validatePage,
54
60
  getPage,
@@ -227,34 +233,27 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
227
233
  await getSiteContent();
228
234
  };
229
235
 
230
- const getSelectedPageLanguage = (language: any) => pageLanguages.find((lang: any) => lang.languageId === language.id);
231
-
232
- const handleLanguage = (language: any) => () => {
233
- if (!languageActions || !languageActions.setLanguage) return;
236
+ const getSelectedPageLanguage = (language: ILanguage) =>
237
+ pageLanguages.find((lang: IPageLanguage) => lang.languageId === language.id);
234
238
 
239
+ const handleLanguage = (language: ILanguage) => {
235
240
  const { locale, id } = language;
236
241
 
237
- const lang = {
242
+ setLanguage({
238
243
  locale,
239
244
  id,
240
- };
241
-
242
- languageActions.setLanguage(lang);
245
+ });
243
246
 
244
247
  const selectedPageLanguage = getSelectedPageLanguage(language);
245
-
246
- selectedPageLanguage
247
- ? setCurrentPageID(selectedPageLanguage.pageId)
248
- : languageActions.createNewTranslation && languageActions.createNewTranslation(true);
249
-
248
+ selectedPageLanguage ? setCurrentPageID(selectedPageLanguage.pageId) : createNewTranslation(true);
250
249
  setHistoryPush("pages/editor", true);
251
250
  };
252
251
 
253
252
  const getCurrentPageLanguages = () => {
254
- const languages: any[] = [];
253
+ const languages: ILanguage[] = [];
255
254
 
256
255
  pageLanguages.forEach(
257
- (pageLang: any) =>
256
+ (pageLang: IPageLanguage) =>
258
257
  siteLanguages &&
259
258
  siteLanguages.forEach((siteLang) => {
260
259
  if (siteLang.id === pageLang.languageId) {
@@ -294,14 +293,14 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
294
293
  let availableLanguages = siteLanguages;
295
294
 
296
295
  if (!isTemplateActivated || isGlobal || !isAllowedToCreatePages) {
297
- const pageLanguagesIDs = pageLanguages.map((language: any) => language.languageId);
296
+ const pageLanguagesIDs = pageLanguages.map((language: IPageLanguage) => language.languageId);
298
297
  availableLanguages = siteLanguages && siteLanguages.filter((language) => pageLanguagesIDs.includes(language.id));
299
298
  }
300
299
 
301
300
  const languageMenu = () => (
302
301
  <LanguageMenu
303
302
  language={locale}
304
- availableLanguages={availableLanguages}
303
+ availableLanguages={availableLanguages || []}
305
304
  setLanguage={handleLanguage}
306
305
  currentLanguages={currentLanguages}
307
306
  />
@@ -309,7 +308,7 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
309
308
 
310
309
  const FlagsButton = () => (
311
310
  <S.FlagsWrapper onClick={onClick}>
312
- {currentLanguages.slice(0, 2).map((pageLanguage: any, i: number) => (
311
+ {currentLanguages.slice(0, 2).map((pageLanguage: ILanguage, i: number) => (
313
312
  <Flag key={`${pageLanguage.language}${i}`} name={pageLanguage.locale} size="15" />
314
313
  ))}
315
314
  <span>({currentLanguages.length})</span>
@@ -329,8 +328,8 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
329
328
  isGlobal && !manuallyImported
330
329
  ? "This page has been provided by subscription. You cannot remove it."
331
330
  : canBeUnpublished === false
332
- ? "This is the canonical site of the page. You cannot remove it."
333
- : null;
331
+ ? "This is the canonical site of the page. You cannot remove it."
332
+ : null;
334
333
 
335
334
  let menuOptions: IPageOption[] = [];
336
335
 
@@ -477,8 +476,8 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
477
476
  const categories: string[] = !type
478
477
  ? []
479
478
  : Array.isArray(type)
480
- ? type.map((cat: any) => cat.label || cat.title)
481
- : [type.label || type.title];
479
+ ? type.map((cat: any) => cat.label || cat.title)
480
+ : [type.label || type.title];
482
481
 
483
482
  return (
484
483
  activeColumns.includes(col.key) && (
@@ -656,18 +655,13 @@ interface IPageOption {
656
655
  interface IPageItemProps {
657
656
  item: {
658
657
  isSelected: boolean;
659
- siteLanguages?: any[];
658
+ siteLanguages?: ILanguage[];
660
659
  page: IPage;
661
660
  site: ISite;
662
661
  lang: { locale: string; id: number };
663
662
  isDuplicable: boolean;
664
663
  };
665
664
  functions: {
666
- languageActions?: {
667
- setLanguage?(lang: { locale: string; id: number | null }): void;
668
- createNewTranslation?(isNewTranslation: boolean): void;
669
- getContent?(id?: number): void;
670
- };
671
665
  onClick: (e: any) => void;
672
666
  onCheck: (e: any) => void;
673
667
  deletePage(params?: ISavePageParams, currentLanguage?: string): void;
@@ -695,6 +689,13 @@ interface IPageItemProps {
695
689
  sites: ISite[];
696
690
  skipReview?: boolean;
697
691
  hoverCheck?: boolean;
692
+ createNewTranslation(isNewTranslation: boolean): void;
693
+ setLanguage(lang: { locale: string; id: number | null }): void;
698
694
  }
699
695
 
700
- export default memo(PageItem);
696
+ const mapDispatchToProps = {
697
+ createNewTranslation: pageEditorActions.createNewTranslation,
698
+ setLanguage: appActions.setLanguage,
699
+ };
700
+
701
+ export default connect(null, mapDispatchToProps)(PageItem);
@@ -1,7 +1,9 @@
1
1
  import React, { useEffect, useCallback, useState, useRef, useLayoutEffect } from "react";
2
2
  import { connect } from "react-redux";
3
3
  import { useHistory, useLocation } from "react-router-dom";
4
- import { schemas } from "components";
4
+ import { config } from "components";
5
+
6
+ const schemas = config.schemas.ui;
5
7
 
6
8
  import { useModal, useBulkSelection, useToast, useCategoryColors, usePermission, useWindowSize } from "@ax/hooks";
7
9
  import {
@@ -23,6 +25,7 @@ import {
23
25
  IStructuredData,
24
26
  ISchemaField,
25
27
  IExportDataParams,
28
+ ILanguage,
26
29
  } from "@ax/types";
27
30
  import {
28
31
  MainWrapper,
@@ -100,7 +103,6 @@ const Content = (props: IProps): JSX.Element => {
100
103
  currentDataContent,
101
104
  isData,
102
105
  setSelectedStructuredData,
103
- createNewTranslation,
104
106
  resetForm,
105
107
  deleteBulk,
106
108
  getPage,
@@ -199,7 +201,7 @@ const Content = (props: IProps): JSX.Element => {
199
201
  const [pagesSelected, setPagesSelected] = useState<any[]>([]);
200
202
  const history = useHistory();
201
203
 
202
- const [windowWidth, windowHeight] = useWindowSize();
204
+ const [windowWidth] = useWindowSize();
203
205
  const maxColumns = getMaxColumns(windowWidth, isStructuredData);
204
206
 
205
207
  const initialColumns = getColumns(categoryColumns, isStructuredData, isGlobalPages, maxColumns.value);
@@ -292,7 +294,7 @@ const Content = (props: IProps): JSX.Element => {
292
294
  tableRef.current.scrollTo(0, 0);
293
295
  }
294
296
  // eslint-disable-next-line
295
- }, [page, filter, currentFilterQuery, currentSearch]);
297
+ }, [page, filter, currentFilterQuery, currentSearch, lang]);
296
298
 
297
299
  useLayoutEffect(() => {
298
300
  setPage(firstPage);
@@ -344,13 +346,13 @@ const Content = (props: IProps): JSX.Element => {
344
346
  emptyState.message = isContentType
345
347
  ? "You don’t have pages with this content type yet."
346
348
  : isAllowedToCreatePages
347
- ? "To start using pages in your site, create as many pages as you need."
348
- : undefined;
349
+ ? "To start using pages in your site, create as many pages as you need."
350
+ : undefined;
349
351
  emptyState.button = isContentType
350
352
  ? "View all content"
351
353
  : isAllowedToCreatePages
352
- ? "Create the first page"
353
- : undefined;
354
+ ? "Create the first page"
355
+ : undefined;
354
356
  emptyState.action = isContentType ? () => setFilter("unique-pages") : toggleNewModal;
355
357
  }
356
358
  setIsEmpty(!content.length);
@@ -432,7 +434,7 @@ const Content = (props: IProps): JSX.Element => {
432
434
 
433
435
  const createContent = isData ? addNewData : addNewPage;
434
436
 
435
- const goToPage = (page: IPage) => (e: React.MouseEvent<HTMLElement>) => {
437
+ const goToPage = (page: IPage) => () => {
436
438
  const pageID = page.haveDraftPage ? page.haveDraftPage : page.id;
437
439
  setCurrentPageID(pageID);
438
440
  };
@@ -488,8 +490,8 @@ const Content = (props: IProps): JSX.Element => {
488
490
  }
489
491
  })
490
492
  : deleteAllVersions
491
- ? await handleBulkDelete(allPageVersions)
492
- : await handleBulkDelete(selectedItems.all);
493
+ ? await handleBulkDelete(allPageVersions)
494
+ : await handleBulkDelete(selectedItems.all);
493
495
  toggleDeleteModal();
494
496
  const allPageItemsSelected = selectedItems.all.length >= currentSitePages.length;
495
497
  const previousPage = page - 1;
@@ -606,17 +608,6 @@ const Content = (props: IProps): JSX.Element => {
606
608
  setHistoryPush(path, isFromPage);
607
609
  };
608
610
 
609
- const changeLanguage = (language: { locale: string; id: number | null }) => {
610
- setPage(firstPage);
611
- resetBulkSelection();
612
- return setLanguage(language);
613
- };
614
-
615
- const dataLanguageActions = {
616
- setLanguage: changeLanguage,
617
- getSiteContent,
618
- };
619
-
620
611
  const mapStructuredData = () =>
621
612
  currentDataContent &&
622
613
  currentDataContent.map((item: any) => {
@@ -644,12 +635,6 @@ const Content = (props: IProps): JSX.Element => {
644
635
  );
645
636
  });
646
637
 
647
- const pageLanguageActions = {
648
- setLanguage: changeLanguage,
649
- createNewTranslation,
650
- getSiteContent,
651
- };
652
-
653
638
  const mapPages = () =>
654
639
  currentSitePages &&
655
640
  currentSitePages.map((pageItem: IPage) => {
@@ -705,7 +690,6 @@ const Content = (props: IProps): JSX.Element => {
705
690
  setCurrentPageID,
706
691
  duplicatePage,
707
692
  removePageFromSite,
708
- languageActions: pageLanguageActions,
709
693
  deleteBulk: deleteCurrentPageBulk,
710
694
  getDataPack: getDataPack,
711
695
  setTemplateInstanceError,
@@ -762,8 +746,6 @@ const Content = (props: IProps): JSX.Element => {
762
746
 
763
747
  const content = isStructuredData ? mapStructuredData() : mapPages();
764
748
 
765
- const languageActions = isStructuredData ? dataLanguageActions : pageLanguageActions;
766
-
767
749
  const title = currentSiteInfo ? currentSiteInfo.name : `Site Content`;
768
750
 
769
751
  const options = {
@@ -800,6 +782,13 @@ const Content = (props: IProps): JSX.Element => {
800
782
  }
801
783
  };
802
784
 
785
+ const handleLanguage = (language: ILanguage) => {
786
+ const { locale, id } = language;
787
+ setLanguage({ locale, id });
788
+ setPage(firstPage);
789
+ resetBulkSelection();
790
+ };
791
+
803
792
  const createContentAction = isOptionImportable
804
793
  ? { onClick: handleImport, title: "NEXT" }
805
794
  : { onClick: createContent, title: "Create new" };
@@ -863,7 +852,7 @@ const Content = (props: IProps): JSX.Element => {
863
852
  <MainWrapper
864
853
  title={title}
865
854
  language={lang}
866
- languageActions={languageActions}
855
+ languageAction={handleLanguage}
867
856
  availableLanguages={siteLanguages}
868
857
  rightButton={rightButtonProps}
869
858
  searchAction={updateCurrentSearch}
@@ -1012,7 +1001,6 @@ interface IDispatchProps {
1012
1001
  deletePage(params?: ISavePageParams): Promise<boolean>;
1013
1002
  setHistoryPush(page: string, isEditor: boolean): Promise<void>;
1014
1003
  setLanguage(lang: { locale: string; id: number | null }): void;
1015
- createNewTranslation(isNewTranslation: boolean): void;
1016
1004
  getFilteredContent(filter: string | null): void;
1017
1005
  getStructuredDataContents(params: any, siteID: number): Promise<void>;
1018
1006
  resetForm(setDefault?: boolean): void;
@@ -1052,7 +1040,6 @@ const mapDispatchToProps = {
1052
1040
  addTemplate: pageEditorActions.addTemplate,
1053
1041
  updatePageStatus: pageEditorActions.updatePageStatus,
1054
1042
  deletePage: pageEditorActions.deletePage,
1055
- createNewTranslation: pageEditorActions.createNewTranslation,
1056
1043
  deleteBulk: pageEditorActions.deleteBulk,
1057
1044
  duplicatePage: pageEditorActions.duplicatePage,
1058
1045
  getPage: pageEditorActions.getPage,
@@ -1092,9 +1079,9 @@ interface IPagesProps {
1092
1079
  totalItems: number;
1093
1080
  lang: { locale: string; id: number };
1094
1081
  langID?: number;
1095
- pageLanguages: any[];
1082
+ pageLanguages: IPageLanguage[];
1096
1083
  errors: IErrorItem[];
1097
- siteLanguages: any[];
1084
+ siteLanguages: ILanguage[];
1098
1085
  structuredData: IStructuredData[];
1099
1086
  currentStructuredData: IStructuredData | null;
1100
1087
  currentDataContent: IStructuredDataContent[];
@@ -1,8 +1,10 @@
1
- import { schemas } from "components";
1
+ import { config } from "components";
2
2
  import { arrayInsert, getActivatedDataPacksIds } from "@ax/helpers";
3
3
  import { pageStatus } from "@ax/containers/PageEditor/interfaces";
4
4
  import { IColumn, IDataPack, IPage, ISchemaField, IStructuredData } from "@ax/types";
5
5
 
6
+ const schemas = config.schemas.ui;
7
+
6
8
  const getTemplatesFilters = (activatedDataPacks: IDataPack[]) => {
7
9
  const activatedDataPacksIds = getActivatedDataPacksIds(activatedDataPacks);
8
10
  const { templates } = schemas;
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+
3
+ import { CheckField, TableCounter, Tooltip } from "@ax/components";
4
+
5
+ import * as S from "./style";
6
+
7
+ const TableHeader = (props: IProps): JSX.Element => {
8
+ const { totalItems, selectAllItems, isScrolling, setHoverCheck, checkState } = props;
9
+ return (
10
+ <S.TableHeader isScrolling={isScrolling}>
11
+ <S.CheckHeader>
12
+ <Tooltip content="Select All Items">
13
+ <CheckField
14
+ key="selectAll"
15
+ name="selectAll"
16
+ value="selectAll"
17
+ onChange={selectAllItems}
18
+ checked={checkState.isAllSelected || checkState.hoverCheck}
19
+ disabled={false}
20
+ error={false}
21
+ setHoverCheck={setHoverCheck}
22
+ />
23
+ </Tooltip>
24
+ </S.CheckHeader>
25
+ <S.NameHeader>Name</S.NameHeader>
26
+ <S.CodeHeader>Code</S.CodeHeader>
27
+ <S.ActionsHeader>
28
+ <TableCounter totalItems={totalItems} />
29
+ </S.ActionsHeader>
30
+ </S.TableHeader>
31
+ );
32
+ };
33
+
34
+ interface IProps {
35
+ totalItems: number;
36
+ isScrolling: boolean;
37
+ selectAllItems: () => void;
38
+ setHoverCheck: (state: boolean) => void;
39
+ checkState: Record<string, boolean>;
40
+ }
41
+
42
+ export default TableHeader;
@@ -0,0 +1,36 @@
1
+ import styled from "styled-components";
2
+ import { Header } from "@ax/components/TableList/style";
3
+
4
+ const TableHeader = styled.div<{ isScrolling?: boolean }>`
5
+ width: 100%;
6
+ display: flex;
7
+ flex-direction: row;
8
+ padding: ${(p) => `${p.theme.spacing.s} ${p.theme.spacing.m}`};
9
+ border-bottom: ${(p) => (p.isScrolling ? `1px solid ${p.theme.color.uiLine};` : "")};
10
+ `;
11
+
12
+ const CheckHeader = styled(Header)`
13
+ padding-left: ${(p) => p.theme.spacing.m};
14
+ width: 32px;
15
+ `;
16
+
17
+ const NameHeader = styled(Header)`
18
+ flex-grow: 1;
19
+ `;
20
+
21
+ const CodeHeader = styled(Header)`
22
+ flex: 0 0 250px;
23
+ `;
24
+
25
+ const SelectHeader = styled(Header)`
26
+ flex: 0 0 115px;
27
+ justify-content: center;
28
+ `;
29
+
30
+ const ActionsHeader = styled(Header)`
31
+ flex: 0 0 80px;
32
+ padding-right: 0;
33
+ justify-content: flex-end;
34
+ `;
35
+
36
+ export { TableHeader, CheckHeader, NameHeader, CodeHeader, ActionsHeader, SelectHeader };
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+ import TableHeader from "./TableHeader";
3
+
4
+ import * as S from "./style";
5
+
6
+ const BulkHeader = (props: IProps): JSX.Element => {
7
+ const { showBulk, checkState, selectItems, totalItems, isScrolling, bulkActions, setHoverCheck } = props;
8
+
9
+ return showBulk ? (
10
+ <S.StyledBulkSelectionOptions
11
+ checkState={checkState}
12
+ actions={bulkActions}
13
+ selectItems={selectItems}
14
+ totalItems={totalItems}
15
+ />
16
+ ) : (
17
+ <TableHeader
18
+ totalItems={totalItems}
19
+ selectAllItems={selectItems}
20
+ isScrolling={isScrolling}
21
+ setHoverCheck={setHoverCheck}
22
+ checkState={checkState}
23
+ />
24
+ );
25
+ };
26
+
27
+ interface IProps {
28
+ showBulk: boolean;
29
+ checkState: Record<string, boolean>;
30
+ selectItems: () => void;
31
+ totalItems: number;
32
+ isScrolling: boolean;
33
+ bulkActions: { icon: string; text: string; action: () => void }[];
34
+ setHoverCheck: (state: boolean) => void;
35
+ }
36
+
37
+ export default BulkHeader;