@griddo/ax 1.63.5 → 1.64.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/config/griddo-config/cx-polyfills/builder.ssr.js +6 -0
  2. package/config/griddo-config/cx-polyfills/componentsBundle.js +4 -0
  3. package/config/{griddo-config.js → griddo-config/index.js} +36 -15
  4. package/config/griddo-config/ssrHelpers.js +47 -0
  5. package/config/jest/componentsMock.js +29 -0
  6. package/config/jest/fileMock.js +1 -0
  7. package/config/jest/setup.js +5 -0
  8. package/config/jest/styleMock.js +1 -0
  9. package/config/jest/test-utils.js +17 -0
  10. package/config/paths.js +36 -5
  11. package/config/webpack.config.js +1 -1
  12. package/config/webpackDevServer.config.js +4 -1
  13. package/config/webpackSchemas.config.js +4 -1
  14. package/package.json +33 -59
  15. package/scripts/build.js +9 -2
  16. package/src/__mocks__/reducers/analyticsState.tsx +14 -0
  17. package/src/__mocks__/reducers/pageEditor.tsx +30 -0
  18. package/src/api/sites.tsx +28 -6
  19. package/src/api/structuredData.tsx +1 -1
  20. package/src/api/users.tsx +5 -4
  21. package/src/components/ActionMenu/style.tsx +2 -0
  22. package/src/components/Browser/index.tsx +9 -5
  23. package/src/{modules/Content/PageItem/atoms.tsx → components/CategoryCell/index.tsx} +4 -6
  24. package/src/components/CategoryCell/style.tsx +11 -0
  25. package/src/components/Fields/AnalyticsField/PageAnalytics/index.tsx +19 -19
  26. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/atoms.tsx +26 -16
  27. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/index.tsx +8 -13
  28. package/src/components/Fields/AnalyticsField/index.test.tsx +100 -0
  29. package/src/components/Fields/AnalyticsField/index.tsx +9 -2
  30. package/src/components/Fields/AnalyticsField/utils.tsx +2 -2
  31. package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/style.tsx +2 -1
  32. package/src/components/Fields/CheckField/index.test.tsx +95 -0
  33. package/src/components/Fields/CheckField/index.tsx +9 -3
  34. package/src/components/Fields/CheckField/style.tsx +32 -24
  35. package/src/components/Fields/CheckGroup/index.test.tsx +274 -0
  36. package/src/components/Fields/CheckGroup/index.tsx +2 -1
  37. package/src/components/Fields/FileField/FileDragAndDrop/style.tsx +3 -2
  38. package/src/components/Fields/FileField/style.tsx +2 -1
  39. package/src/components/Fields/MultiCheckSelect/style.tsx +18 -18
  40. package/src/components/Fields/NoteField/style.tsx +9 -9
  41. package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +1 -1
  42. package/src/components/Fields/Select/style.tsx +41 -37
  43. package/src/components/Fields/TagField/index.test.tsx +136 -0
  44. package/src/components/Fields/TagField/index.tsx +8 -12
  45. package/src/components/Fields/TextArea/index.test.tsx +69 -0
  46. package/src/components/Fields/TextArea/index.tsx +4 -13
  47. package/src/components/Fields/TextArea/style.tsx +2 -2
  48. package/src/components/Fields/TextField/index.test.tsx +144 -0
  49. package/src/components/Fields/TextField/index.tsx +23 -19
  50. package/src/components/Fields/TextField/style.tsx +16 -7
  51. package/src/components/Fields/UniqueCheck/index.test.tsx +43 -0
  52. package/src/components/Fields/UrlField/utils.tsx +8 -6
  53. package/src/components/FieldsBehavior/index.tsx +0 -2
  54. package/src/components/FieldsBehavior/style.tsx +21 -21
  55. package/src/components/Gallery/GalleryFilters/Orientation/style.tsx +2 -1
  56. package/src/components/Gallery/GalleryFilters/SortBy/style.tsx +2 -1
  57. package/src/components/Icon/index.tsx +12 -10
  58. package/src/components/IconAction/index.tsx +7 -1
  59. package/src/components/IconAction/style.tsx +10 -10
  60. package/src/components/SearchField/index.tsx +11 -8
  61. package/src/components/SearchField/style.tsx +21 -12
  62. package/src/components/TableFilters/CategoryFilter/index.tsx +1 -1
  63. package/src/components/TableFilters/CategoryFilter/style.tsx +2 -1
  64. package/src/components/TableFilters/DateFilter/style.tsx +2 -1
  65. package/src/components/TableFilters/LiveFilter/index.tsx +2 -2
  66. package/src/components/TableFilters/LiveFilter/style.tsx +2 -1
  67. package/src/components/TableFilters/NameFilter/style.tsx +2 -1
  68. package/src/components/TableFilters/SiteFilter/index.tsx +38 -24
  69. package/src/components/TableFilters/SiteFilter/style.tsx +2 -1
  70. package/src/components/TableFilters/StatusFilter/style.tsx +2 -1
  71. package/src/components/TableFilters/TranslationsFilter/style.tsx +2 -1
  72. package/src/components/TableFilters/TypeFilter/style.tsx +2 -1
  73. package/src/components/Tag/index.tsx +9 -7
  74. package/src/components/Tag/style.tsx +20 -8
  75. package/src/components/index.tsx +4 -2
  76. package/src/containers/App/reducer.tsx +0 -2
  77. package/src/containers/PageEditor/actions.tsx +2 -2
  78. package/src/containers/Sites/actions.tsx +30 -19
  79. package/src/containers/Users/actions.tsx +10 -2
  80. package/src/containers/Users/reducer.tsx +3 -1
  81. package/src/helpers/fields.tsx +2 -4
  82. package/src/helpers/index.tsx +3 -0
  83. package/src/helpers/themes.tsx +9 -0
  84. package/src/modules/Analytics/GroupPanel/utils.tsx +3 -3
  85. package/src/modules/App/Routing/NavMenu/index.tsx +13 -12
  86. package/src/modules/Content/PageItem/index.tsx +31 -9
  87. package/src/modules/Content/PageItem/style.tsx +0 -7
  88. package/src/modules/Content/atoms.tsx +78 -0
  89. package/src/modules/Content/index.tsx +104 -33
  90. package/src/modules/Content/style.tsx +10 -7
  91. package/src/modules/GlobalEditor/PageBrowser/index.tsx +0 -4
  92. package/src/modules/GlobalEditor/index.tsx +3 -3
  93. package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/DefaultsBrowser/index.tsx +0 -4
  94. package/src/modules/PageEditor/PageBrowser/index.tsx +0 -4
  95. package/src/modules/PageEditor/atoms.tsx +74 -0
  96. package/src/modules/PageEditor/index.tsx +30 -9
  97. package/src/modules/PageEditor/style.tsx +4 -0
  98. package/src/modules/PublicPreview/index.tsx +3 -5
  99. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/TemplateBrowser/index.tsx +0 -4
  100. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +2 -3
  101. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +1 -1
  102. package/src/modules/Settings/Globals/index.tsx +3 -3
  103. package/src/modules/StructuredData/Form/index.tsx +2 -4
  104. package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +22 -18
  105. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +3 -24
  106. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +2 -2
  107. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/style.tsx +0 -7
  108. package/src/modules/StructuredData/StructuredDataList/OptionTable/index.tsx +2 -4
  109. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +46 -14
  110. package/src/modules/StructuredData/StructuredDataList/hooks.tsx +21 -9
  111. package/src/modules/StructuredData/StructuredDataList/index.tsx +48 -20
  112. package/src/modules/Users/Profile/index.tsx +12 -7
  113. package/src/modules/Users/UserCreate/SiteItem/index.tsx +44 -0
  114. package/src/modules/Users/UserCreate/SiteItem/style.tsx +30 -0
  115. package/src/modules/Users/UserCreate/index.tsx +120 -10
  116. package/src/modules/Users/UserCreate/style.tsx +54 -1
  117. package/src/modules/Users/UserEdit/index.tsx +53 -15
  118. package/src/modules/Users/UserForm/index.tsx +152 -5
  119. package/src/modules/Users/UserForm/style.tsx +40 -2
  120. package/src/modules/Users/UserList/BulkHeader/TableHeader/index.tsx +40 -2
  121. package/src/modules/Users/UserList/BulkHeader/TableHeader/style.tsx +0 -1
  122. package/src/modules/Users/UserList/BulkHeader/index.tsx +10 -1
  123. package/src/modules/Users/UserList/UserItem/index.tsx +70 -15
  124. package/src/modules/Users/UserList/hooks.tsx +58 -1
  125. package/src/modules/Users/UserList/index.tsx +80 -34
  126. package/src/modules/Users/index.tsx +18 -11
  127. package/src/routes/site.tsx +8 -0
  128. package/src/types/index.tsx +7 -0
  129. package/tsconfig.json +2 -0
  130. package/scripts/test.js +0 -45
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const Site = styled(Header)<{ isActive: boolean; center: boolean }>`
5
+ const Site = styled((props) => <Header {...props} />)<{ isActive: boolean; center: boolean }>`
5
6
  width: 170px;
6
7
  justify-content: ${(p) => (p.center ? "center" : "flex-start")};
7
8
  &:hover {
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const Status = styled(Header)<{ isActive: boolean }>`
5
+ const Status = styled((props) => <Header {...props} />)<{ isActive: boolean }>`
5
6
  width: 170px;
6
7
  justify-content: center;
7
8
  &:hover {
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const Translations = styled(Header)<{ isActive: boolean }>`
5
+ const Translations = styled((props) => <Header {...props} />)<{ isActive: boolean }>`
5
6
  width: 115px;
6
7
  justify-content: center;
7
8
  &:hover {
@@ -1,7 +1,8 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
  import { Header } from "@ax/components/TableList/style";
3
4
 
4
- const Types = styled(Header)<{ isActive: boolean }>`
5
+ const Types = styled((props) => <Header {...props} />)<{ isActive: boolean }>`
5
6
  width: 170px;
6
7
  justify-content: center;
7
8
  &:hover {
@@ -4,16 +4,16 @@ import { Icon } from "@ax/components";
4
4
  import * as S from "./style";
5
5
 
6
6
  const Tag = (props: ITagProps): JSX.Element => {
7
- const { type, text, color, deleteAction } = props;
7
+ const { type, text, color, onDeleteAction } = props;
8
8
 
9
9
  const handleClick = () => {
10
- if (deleteAction) {
11
- deleteAction();
10
+ if (onDeleteAction) {
11
+ onDeleteAction();
12
12
  }
13
13
  };
14
14
 
15
- const deleteIcon = deleteAction ? (
16
- <S.IconWrapper onClick={handleClick}>
15
+ const deleteIcon = onDeleteAction ? (
16
+ <S.IconWrapper onClick={handleClick} data-testid="tagComponent">
17
17
  <Icon name="close" size="16" />
18
18
  </S.IconWrapper>
19
19
  ) : null;
@@ -26,6 +26,8 @@ const Tag = (props: ITagProps): JSX.Element => {
26
26
  {text}
27
27
  </S.TagStatus>
28
28
  );
29
+ case "square":
30
+ return <S.TagSquare color={color}>{text}</S.TagSquare>;
29
31
  default:
30
32
  return (
31
33
  <S.TagFixed color={color}>
@@ -39,10 +41,10 @@ const Tag = (props: ITagProps): JSX.Element => {
39
41
  };
40
42
 
41
43
  interface ITagProps {
42
- type?: "status" | "fixed" | "interactive" | undefined;
44
+ type?: "status" | "fixed" | "interactive" | "square" | undefined;
43
45
  text: string;
44
46
  color?: string;
45
- deleteAction?: () => void;
47
+ onDeleteAction?: () => void;
46
48
  }
47
49
 
48
50
  export default Tag;
@@ -12,6 +12,18 @@ export const TagStatus = styled.div`
12
12
  text-transform: capitalize;
13
13
  `;
14
14
 
15
+ export const TagSquare = styled.div<{ color: string | undefined }>`
16
+ ${(p) => p.theme.textStyle.uiXS};
17
+ background-color: ${(p) => (p.color ? p.color : p.theme.colors.uiBackground01)};
18
+ box-sizing: border-box;
19
+ border-radius: ${(p) => p.theme.radii.xs};
20
+ color: ${(p) => (p.color ? p.theme.color.textMediumEmphasisInverse : p.theme.color.textMediumEmphasis)};
21
+ white-space: nowrap;
22
+ display: inline-block;
23
+ padding: 3px 8px;
24
+ text-transform: capitalize;
25
+ `;
26
+
15
27
  export const Bullet = styled.span<{ color: string | undefined }>`
16
28
  background-color: ${(p) => (p.color ? p.color : `#4096D6`)};
17
29
  display: inline-block;
@@ -22,26 +34,26 @@ export const Bullet = styled.span<{ color: string | undefined }>`
22
34
  `;
23
35
 
24
36
  export const TagFixed = styled.div<{ color: string | undefined }>`
25
- ${(p) => p.theme.textStyle.uiS};
26
- background-color: ${(p) => (p.color ? p.color : p.theme.color.interactive02)};
27
- border-radius: ${(p) => p.theme.spacing.s};
37
+ ${(p) => p.theme.textStyle?.uiS};
38
+ background-color: ${(p) => (p.color ? p.color : p.theme.color?.interactive02)};
39
+ border-radius: ${(p) => p.theme.spacing?.s};
28
40
  box-sizing: border-box;
29
- color: ${(p) => p.theme.color.textMediumEmphasis};
41
+ color: ${(p) => p.theme.color?.textMediumEmphasis};
30
42
  display: inline-block;
31
43
  padding: 3px 8px;
32
- margin-right: ${(p) => p.theme.spacing.xxs};
33
- margin-bottom: ${(p) => p.theme.spacing.xxs};
44
+ margin-right: ${(p) => p.theme.spacing?.xxs};
45
+ margin-bottom: ${(p) => p.theme.spacing?.xxs};
34
46
  `;
35
47
 
36
48
  export const Title = styled.div``;
37
49
 
38
50
  export const IconWrapper = styled.div`
39
51
  height: 16px;
40
- margin-left: ${(p) => p.theme.spacing.xxs};
52
+ margin-left: ${(p) => p.theme.spacing?.xxs};
41
53
  cursor: pointer;
42
54
  svg {
43
55
  path {
44
- fill: ${(p) => p.theme.color.textMediumEmphasis};
56
+ fill: ${(p) => p.theme.color?.textMediumEmphasis};
45
57
  }
46
58
  }
47
59
  `;
@@ -48,8 +48,10 @@ import Breadcrumb from "./Breadcrumb";
48
48
  import Browser from "./Browser";
49
49
  import BulkSelectionOptions from "./BulkSelectionOptions";
50
50
  import Button from "./Button";
51
+ import CategoryCell from "./CategoryCell";
51
52
  import ConfigPanel from "./ConfigPanel";
52
53
  import DragAndDrop from "./DragAndDrop";
54
+ import ElementsTooltip from "./ElementsTooltip";
53
55
  import EmptyState from "./EmptyState";
54
56
  import ErrorCenter from "./ErrorCenter";
55
57
  import ErrorToast from "./ErrorToast";
@@ -85,7 +87,6 @@ import Tabs from "./Tabs";
85
87
  import Tag from "./Tag";
86
88
  import Tooltip from "./Tooltip";
87
89
  import Toast from "./Toast";
88
- import ElementsTooltip from "./ElementsTooltip";
89
90
 
90
91
  export {
91
92
  //Fields
@@ -138,8 +139,10 @@ export {
138
139
  Browser,
139
140
  BulkSelectionOptions,
140
141
  Button,
142
+ CategoryCell,
141
143
  ConfigPanel,
142
144
  DragAndDrop,
145
+ ElementsTooltip,
143
146
  EmptyState,
144
147
  ErrorCenter,
145
148
  ErrorToast,
@@ -175,5 +178,4 @@ export {
175
178
  Tag,
176
179
  Tooltip,
177
180
  Toast,
178
- ElementsTooltip,
179
181
  };
@@ -38,7 +38,6 @@ export interface IUser {
38
38
 
39
39
  export interface IGlobalSettings {
40
40
  cloudinaryName: string | null;
41
- damDomain: string | null;
42
41
  globalLogoBig: string;
43
42
  globalLogoMini: string;
44
43
  siteLogoBig: string;
@@ -67,7 +66,6 @@ export const initialState = {
67
66
  globalLangs: [],
68
67
  globalSettings: {
69
68
  cloudinaryName: "",
70
- damDomain: "",
71
69
  globalLogoBig: "",
72
70
  globalLogoMini: "",
73
71
  siteLogoBig: "",
@@ -457,7 +457,7 @@ function deleteBulk(ids: any): (dispatch: Dispatch) => Promise<boolean> {
457
457
 
458
458
  return await handleRequest(callback, responseActions, [])(dispatch);
459
459
  } catch (e) {
460
- console.log(e); // TODO: capturar error bien
460
+ console.log(e);
461
461
  return false;
462
462
  }
463
463
  };
@@ -473,7 +473,7 @@ function restorePage(id: number | number[]): (dispatch: Dispatch) => Promise<boo
473
473
 
474
474
  const callback = async () => (Array.isArray(id) ? pages.bulkRestore(id) : pages.restorePage(id));
475
475
 
476
- return await handleRequest(callback, responseActions, [setIsLoading])(dispatch);
476
+ return await handleRequest(callback, responseActions, [])(dispatch);
477
477
  } catch (e) {
478
478
  console.log(e); // TODO: capturar error bien
479
479
  return false;
@@ -20,7 +20,6 @@ import {
20
20
  } from "./interfaces";
21
21
 
22
22
  import { ISite, IGetSitePagesParams, ISettingsForm, IGetGlobalPagesParams, IPage } from "@ax/types";
23
-
24
23
  import { sites, languages, dataPack, social, structuredData, analytics } from "@ax/api";
25
24
  import { appActions } from "@ax/containers/App";
26
25
  import { structuredDataActions } from "@ax/containers/StructuredData";
@@ -29,13 +28,15 @@ import { pageEditorActions } from "@ax/containers/PageEditor";
29
28
  import { analyticsActions } from "@ax/containers/Analytics";
30
29
  import { dataPacksActions } from "@ax/containers/Settings/DataPacks";
31
30
  import { socialActions } from "@ax/containers/Settings/Social";
32
- import { handleRequest, isReqOk, sortBy } from "@ax/helpers";
31
+ import { getDefaultTheme, handleRequest, isReqOk, sortBy } from "@ax/helpers";
32
+ import { usersActions } from "@ax/containers/Users";
33
33
 
34
34
  const { setIsLoading, setIsSaving, setLanguage } = appActions;
35
35
  const { resetDefaultsValues } = navigationActions;
36
36
  const { resetPageEditor } = pageEditorActions;
37
37
  const { resetMenuValues } = menuActions;
38
38
  const { getAnalytics } = analyticsActions;
39
+ const { getUsers } = usersActions;
39
40
 
40
41
  function setSites(sitesList: ISite[]): ISetSitesAction {
41
42
  return { type: SET_SITES, payload: { sites: sitesList } };
@@ -87,25 +88,23 @@ function getSites(token: string): (dispatch: Dispatch) => Promise<void> {
87
88
  function saveSettings(form: ISettingsForm): (dispatch: Dispatch, getState: any) => Promise<boolean> {
88
89
  return async (dispatch, getState) => {
89
90
  try {
90
- dispatch(setIsSaving(true));
91
91
  const {
92
92
  sites: { currentSiteInfo },
93
93
  } = getState();
94
94
 
95
- const saveResponse = currentSiteInfo
96
- ? await sites.updateSite(currentSiteInfo.id, form)
97
- : await sites.createSite(form);
95
+ const isNewSite = !currentSiteInfo;
98
96
 
99
- // TODO: refactor con handleRequest
100
- if (isReqOk(saveResponse.status)) {
101
- const { data } = saveResponse;
97
+ const theme = getDefaultTheme();
102
98
 
103
- await setSiteInfo(data)(dispatch, getState);
104
- dispatch(setIsSaving(false));
105
- return true;
106
- } else {
107
- appActions.handleError(saveResponse)(dispatch);
108
- }
99
+ const responseActions = {
100
+ handleSuccess: (response: any) => setSiteInfo(response)(dispatch, getState),
101
+ handleError: (response: any) => appActions.handleError(response)(dispatch),
102
+ };
103
+
104
+ const callback = async () =>
105
+ isNewSite ? sites.createSite({ ...form, theme }) : sites.updateSite(currentSiteInfo.id, form);
106
+
107
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
109
108
  } catch (e) {
110
109
  console.log(e); // TODO: capturar error bien
111
110
  }
@@ -378,10 +377,7 @@ function importPageFromGlobal(pageID: number | number[]): (dispatch: any, getSta
378
377
  return async (dispatch, getState) => {
379
378
  try {
380
379
  const {
381
- sites: {
382
- currentSiteInfo,
383
- currentFilter
384
- },
380
+ sites: { currentSiteInfo, currentFilter },
385
381
  } = getState();
386
382
 
387
383
  const responseActions = {
@@ -409,6 +405,20 @@ function importPageFromGlobal(pageID: number | number[]): (dispatch: any, getSta
409
405
  };
410
406
  }
411
407
 
408
+ function removeUsersBulk(siteId: number, users: number[]): (dispatch: Dispatch, getState: any) => Promise<void> {
409
+ return async (dispatch, getState) => {
410
+ try {
411
+ const response = await sites.removeUsersBulk(siteId, users);
412
+ if (isReqOk(response.status)) {
413
+ const params = { filterQuery: "?order=dateCreated" };
414
+ getUsers(params)(dispatch);
415
+ }
416
+ } catch (e) {
417
+ console.log(e); // TODO: capturar error bien
418
+ }
419
+ };
420
+ }
421
+
412
422
  function removePageFromSite(
413
423
  pageID: number | number[],
414
424
  refresh = true
@@ -467,4 +477,5 @@ export {
467
477
  saveCurrentSiteInfo,
468
478
  importPageFromGlobal,
469
479
  removePageFromSite,
480
+ removeUsersBulk,
470
481
  };
@@ -64,7 +64,12 @@ function getUser(id: string | number, token?: string): (dispatch: Dispatch) => P
64
64
  };
65
65
  }
66
66
 
67
- function updateUser(id: number, data: any, isProfile: boolean): (dispatch: Dispatch, getState: any) => Promise<void> {
67
+ function updateUser(
68
+ id: number,
69
+ data: any,
70
+ isProfile: boolean,
71
+ isList?: boolean
72
+ ): (dispatch: Dispatch, getState: any) => Promise<void> {
68
73
  return async (dispatch) => {
69
74
  try {
70
75
  const callback = async () => users.updateUser(id, data);
@@ -73,6 +78,9 @@ function updateUser(id: number, data: any, isProfile: boolean): (dispatch: Dispa
73
78
  handleSuccess: (response: any) => {
74
79
  if (isProfile) {
75
80
  dispatch(setCurrentUser(response));
81
+ } else if (isList) {
82
+ const params = { filterQuery: "?order=dateCreated" };
83
+ getUsers(params)(dispatch);
76
84
  } else {
77
85
  dispatch(setUserForm(response));
78
86
  }
@@ -125,7 +133,7 @@ function createUser(data: { name: string; email: string; sites: any[] }): (dispa
125
133
  function deleteUser(id: number | number[]): (dispatch: Dispatch) => Promise<boolean> {
126
134
  return async (dispatch) => {
127
135
  try {
128
- const params = { order: "dateCreated" };
136
+ const params = { filterQuery: "?order=dateCreated" };
129
137
 
130
138
  const responseActions = {
131
139
  handleSuccess: () => getUsers(params)(dispatch),
@@ -16,6 +16,7 @@ export const initialState = {
16
16
  name: "",
17
17
  email: "",
18
18
  failed: 0,
19
+ sites: ["all"],
19
20
  },
20
21
  currentUser: {
21
22
  id: null,
@@ -23,6 +24,7 @@ export const initialState = {
23
24
  name: "",
24
25
  email: "",
25
26
  failed: 0,
27
+ sites: ["all"],
26
28
  },
27
29
  };
28
30
 
@@ -37,4 +39,4 @@ export function reducer(state = initialState, action: UsersActionsCreators): IUs
37
39
  }
38
40
  }
39
41
 
40
- export { initialState as usersInitialState, reducer as usersReducer };
42
+ export { initialState as usersInitialState, reducer as usersReducer };
@@ -1,7 +1,5 @@
1
1
  const fields = require.context("./../components/Fields", true);
2
2
 
3
- const getFieldByPath = (name: string) => fields(`./${name}`).default;
3
+ const getFieldByPath = (name: string) => fields(`./${name}/index.tsx`).default;
4
4
 
5
- export {
6
- getFieldByPath
7
- };
5
+ export { getFieldByPath };
@@ -92,6 +92,8 @@ import { getActivatedDataPacksIds, isModuleDisabled } from "./dataPacks";
92
92
 
93
93
  import { isDevelopment } from "./environment";
94
94
 
95
+ import { getDefaultTheme } from "./themes";
96
+
95
97
  export {
96
98
  isComponentEmpty,
97
99
  setAsContainedComponent,
@@ -165,5 +167,6 @@ export {
165
167
  getDataPackSchema,
166
168
  splitAndJoin,
167
169
  splitAndTrim,
170
+ getDefaultTheme,
168
171
  copyTextToClipboard,
169
172
  };
@@ -0,0 +1,9 @@
1
+ import { themes } from "components";
2
+
3
+ const getDefaultTheme = (): string => {
4
+ const defaultTheme = themes.find((theme: any) => theme.default);
5
+ const theme = defaultTheme ? defaultTheme.value : themes[0].value;
6
+ return theme;
7
+ }
8
+
9
+ export { getDefaultTheme }
@@ -21,9 +21,9 @@ const getTemplateOptions = (): ITemplateOption[] => {
21
21
  };
22
22
 
23
23
  interface ITemplateOption {
24
- name: string,
25
- title: string,
26
- value: string,
24
+ name: string;
25
+ title: string;
26
+ value: string;
27
27
  }
28
28
 
29
29
  export { getTemplateOptions };
@@ -1,16 +1,17 @@
1
1
  import React, { useState } from "react";
2
2
  import { connect } from "react-redux";
3
3
  import { RouteComponentProps, withRouter } from "react-router-dom";
4
+ import { version } from "./../../../../../package.json";
4
5
 
5
6
  import { IRouter, multisite, site } from "@ax/routes";
6
7
 
7
8
  import { IRootState } from "@ax/types";
8
9
  import { appActions } from "@ax/containers/App";
10
+ import { Icon, Tag } from "@ax/components";
9
11
 
10
12
  import NavItem from "./NavItem";
11
13
  import { NavProvider } from "./context";
12
14
 
13
- import { Icon } from "@ax/components";
14
15
  import * as S from "./style";
15
16
 
16
17
  const NavMenu = (props: IProps) => {
@@ -52,7 +53,8 @@ const NavMenu = (props: IProps) => {
52
53
  };
53
54
 
54
55
  const goToProfile = () => {
55
- setHistoryPush("/profile");
56
+ const profileRoute = isSite ? "/sites/profile" : "profile";
57
+ setHistoryPush(profileRoute);
56
58
  };
57
59
 
58
60
  const config: IConfig = isSite
@@ -97,7 +99,7 @@ const NavMenu = (props: IProps) => {
97
99
  component: "",
98
100
  name: "Profile",
99
101
  icon: "User",
100
- path: "/profile",
102
+ path: isSite ? "/site/profile" : "/profile",
101
103
  onClick: goToProfile,
102
104
  };
103
105
 
@@ -124,6 +126,7 @@ const NavMenu = (props: IProps) => {
124
126
  </S.GoBack>
125
127
  )}
126
128
  <S.NavLink>{config.logo}</S.NavLink>
129
+ {isOpened && !isSite ? <Tag type="square" text={`V ${version}`} color="rgba(80, 87, 255, 0.16)" /> : null}
127
130
  </S.Home>
128
131
  <S.Lists>
129
132
  <S.List>
@@ -150,15 +153,13 @@ const NavMenu = (props: IProps) => {
150
153
  <S.Separator />
151
154
  </>
152
155
  )}
153
- {!isSite && (
154
- <NavItem
155
- setHistoryPush={setHistoryPush}
156
- route={profileRoute}
157
- type={config.type}
158
- isOpened={isOpened}
159
- location={location}
160
- />
161
- )}
156
+ <NavItem
157
+ setHistoryPush={setHistoryPush}
158
+ route={profileRoute}
159
+ type={config.type}
160
+ isOpened={isOpened}
161
+ location={location}
162
+ />
162
163
  <NavItem setHistoryPush={setHistoryPush} route={logoutRoute} type={config.type} isOpened={isOpened} />
163
164
  <S.Separator />
164
165
  <NavItem setHistoryPush={setHistoryPush} route={collapseRoute} type={config.type} isOpened={isOpened} />
@@ -2,7 +2,7 @@ import React, { memo, useState } from "react";
2
2
 
3
3
  import { useModal } from "@ax/hooks";
4
4
  import { getHumanLastModifiedDate, getTemplateDisplayName, slugify } from "@ax/helpers";
5
- import { IPage, ISite, ISavePageParams, ICheck, IColumn, IDataPack } from "@ax/types";
5
+ import { IPage, ISite, ISavePageParams, ICheck, IColumn, IPageLanguage, IDataPack } from "@ax/types";
6
6
  import { pageStatus, ISetCurrentPageIDAction } from "@ax/containers/PageEditor/interfaces";
7
7
 
8
8
  import {
@@ -15,9 +15,10 @@ import {
15
15
  Modal,
16
16
  Tag,
17
17
  Tooltip,
18
+ CategoryCell,
18
19
  } from "@ax/components";
19
20
 
20
- import { CategoryCell } from "./atoms";
21
+ import { DeleteModal } from "../atoms";
21
22
 
22
23
  import * as S from "./style";
23
24
 
@@ -46,6 +47,7 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
46
47
  languageActions,
47
48
  duplicatePage,
48
49
  removePageFromSite,
50
+ deleteBulk,
49
51
  getDataPack,
50
52
  } = functions;
51
53
  const { locale } = lang;
@@ -63,11 +65,14 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
63
65
 
64
66
  const initValue = { title: "", slug: "" };
65
67
  const [modalState, setModalState] = useState(initValue);
68
+ const [deleteAllVersions, setDeleteAllVersions] = useState(false);
66
69
  const { isOpen, toggleModal } = useModal();
67
70
  const { isOpen: isRemoveOpen, toggleModal: toggleRemoveModal } = useModal();
68
71
  const { isOpen: isUnpublishOpen, toggleModal: toggleUnpublishModal } = useModal();
72
+ const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
69
73
 
70
74
  const isGlobal = origin === "GLOBAL";
75
+ const isTranslated = pageLanguages.length > 1;
71
76
  const activeColumns = Object.keys(columns).filter((col: string) => columns[col].show);
72
77
 
73
78
  const publishedTooltip: any = {
@@ -86,7 +91,7 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
86
91
 
87
92
  const { templateId } = item.page;
88
93
  const dataPack = dataPacks.find((pack) => pack.templates.some((template) => template.id === templateId));
89
- dataPack && await getDataPack(dataPack.id);
94
+ dataPack && (await getDataPack(dataPack.id));
90
95
 
91
96
  setRoute("pages/editor");
92
97
  };
@@ -151,7 +156,9 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
151
156
  };
152
157
 
153
158
  const handleDeleteItem = async () => {
154
- await deletePage();
159
+ const allPageVersions = pageLanguages.map((lang: IPageLanguage) => lang.pageId);
160
+ deleteAllVersions ? await deleteBulk(allPageVersions) : await deletePage();
161
+ toggleDeleteModal();
155
162
  };
156
163
 
157
164
  const handleRemoveItemFromSite = async () => {
@@ -277,14 +284,14 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
277
284
  isGlobal && !manuallyImported
278
285
  ? "This page has been provided by subscription. You cannot remove it."
279
286
  : canBeUnpublished === false
280
- ? "This is the canonical site of the page. You cannot remove it."
281
- : null;
287
+ ? "This is the canonical site of the page. You cannot remove it."
288
+ : null;
282
289
 
283
290
  let menuOptions: IPageOption[] = [
284
291
  {
285
292
  label: isGlobal ? "Remove from site" : "delete",
286
293
  icon: "delete",
287
- action: isGlobal ? toggleRemoveModal : handleDeleteItem,
294
+ action: isGlobal ? toggleRemoveModal : toggleDeleteModal,
288
295
  disabled: deleteDisabled,
289
296
  helpText: deleteHelpText,
290
297
  },
@@ -382,6 +389,13 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
382
389
 
383
390
  const mainUnpublishAction = { title: "Ok", onClick: toggleUnpublishModal };
384
391
 
392
+ const mainDeleteModalAction = {
393
+ title: "Delete page",
394
+ onClick: handleDeleteItem,
395
+ };
396
+
397
+ const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
398
+
385
399
  const CategoryColumns =
386
400
  isGlobal &&
387
401
  categoryColumns.map((col: any) => {
@@ -511,6 +525,13 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
511
525
  </S.ModalContent>
512
526
  )}
513
527
  </Modal>
528
+ <DeleteModal
529
+ isOpen={isDeleteOpen}
530
+ toggleModal={toggleDeleteModal}
531
+ mainModalAction={mainDeleteModalAction}
532
+ secondaryModalAction={secondaryDeleteModalAction}
533
+ {...{ isTranslated, deleteAllVersions, setDeleteAllVersions, title: page.title }}
534
+ />
514
535
  </>
515
536
  );
516
537
  };
@@ -540,13 +561,14 @@ interface IPageItemProps {
540
561
  };
541
562
  onClick: (e: any) => void;
542
563
  onCheck: (e: any) => void;
543
- deletePage(params?: ISavePageParams, currentLanguage?: string): any;
564
+ deletePage(params?: ISavePageParams, currentLanguage?: string): void;
544
565
  getSiteContent(): any;
545
566
  setHistoryPush(path: string, isEditor: boolean): void;
546
- updatePageStatus(ids: number[], status: string, updatedFromList: boolean): any;
567
+ updatePageStatus(ids: number[], status: string, updatedFromList: boolean): Promise<boolean>;
547
568
  setCurrentPageID(currentPageID: number | null): ISetCurrentPageIDAction;
548
569
  duplicatePage(pageID: number, data: any): Promise<void>;
549
570
  removePageFromSite(pageID: number): Promise<boolean>;
571
+ deleteBulk(ids: number[]): void;
550
572
  getDataPack: (id: string) => Promise<void>;
551
573
  };
552
574
  activatedTemplates: any[];
@@ -93,12 +93,6 @@ const ActionsCell = styled(Cell)`
93
93
  text-align: center;
94
94
  `;
95
95
 
96
- const CategoryCell = styled(Cell)`
97
- flex: 0 0 150px;
98
- align-items: center;
99
- position: relative;
100
- `;
101
-
102
96
  const StyledActionMenu = styled(ActionMenu)`
103
97
  opacity: 0;
104
98
  width: 32px;
@@ -197,5 +191,4 @@ export {
197
191
  ModalContent,
198
192
  GlobalCell,
199
193
  Mark,
200
- CategoryCell,
201
194
  };