@griddo/ax 1.58.6 → 1.59.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 (120) hide show
  1. package/package.json +2 -2
  2. package/src/GlobalStore.tsx +3 -1
  3. package/src/api/checkgroups.tsx +1 -1
  4. package/src/api/domains.tsx +26 -0
  5. package/src/api/index.tsx +3 -1
  6. package/src/api/sites.tsx +25 -8
  7. package/src/api/utils.tsx +1 -1
  8. package/src/components/Browser/index.tsx +8 -3
  9. package/src/components/ElementsTooltip/index.tsx +23 -8
  10. package/src/components/ElementsTooltip/style.tsx +4 -5
  11. package/src/components/ErrorCenter/index.tsx +11 -1
  12. package/src/components/ErrorCenter/style.tsx +4 -3
  13. package/src/components/Fields/CheckGroup/index.tsx +5 -4
  14. package/src/components/Fields/ComponentArray/MixableComponentArray/AddItemButton/index.tsx +1 -0
  15. package/src/components/Fields/ReferenceField/Context/index.tsx +10 -6
  16. package/src/components/Fields/ReferenceField/ItemList/Item/index.tsx +2 -2
  17. package/src/components/Fields/ReferenceField/ItemList/index.tsx +15 -14
  18. package/src/components/FieldsBehavior/index.tsx +2 -1
  19. package/src/components/FloatingMenu/index.tsx +3 -1
  20. package/src/components/FloatingMenu/style.tsx +7 -5
  21. package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +17 -19
  22. package/src/components/Gallery/GalleryPanel/DetailPanel/style.tsx +32 -19
  23. package/src/components/Gallery/style.tsx +1 -1
  24. package/src/components/Icon/components/Category.js +5 -6
  25. package/src/components/Icon/components/Refresh.js +12 -0
  26. package/src/components/Icon/svgs/Category.svg +1 -1
  27. package/src/components/Icon/svgs/Refresh.svg +3 -0
  28. package/src/components/Lists/style.tsx +10 -9
  29. package/src/components/MainWrapper/AppBar/index.tsx +16 -5
  30. package/src/components/MainWrapper/AppBar/style.tsx +2 -1
  31. package/src/components/SideModal/index.tsx +10 -4
  32. package/src/components/TableCounter/style.tsx +1 -4
  33. package/src/components/TableFilters/CategoryFilter/index.tsx +92 -0
  34. package/src/{modules/Content/HeaderMenus/Translations → components/TableFilters/CategoryFilter}/style.tsx +4 -3
  35. package/src/components/TableFilters/CustomizeFilters/index.tsx +52 -0
  36. package/src/components/TableFilters/CustomizeFilters/style.tsx +28 -0
  37. package/src/{modules/StructuredData/StructuredDataList/HeaderMenus/Live → components/TableFilters/LiveFilter}/index.tsx +18 -6
  38. package/src/{modules/Content/HeaderMenus/Live → components/TableFilters/LiveFilter}/style.tsx +0 -0
  39. package/src/{modules/StructuredData/StructuredDataList/HeaderMenus/Name → components/TableFilters/NameFilter}/index.tsx +18 -9
  40. package/src/{modules/Content/HeaderMenus/Name → components/TableFilters/NameFilter}/style.tsx +0 -0
  41. package/src/{modules/StructuredData/StructuredDataList/HeaderMenus/Site → components/TableFilters/SiteFilter}/index.tsx +3 -3
  42. package/src/{modules/StructuredData/StructuredDataList/HeaderMenus/Site → components/TableFilters/SiteFilter}/style.tsx +1 -1
  43. package/src/{modules/Content/HeaderMenus/Status → components/TableFilters/StatusFilter}/index.tsx +7 -4
  44. package/src/{modules/Content/HeaderMenus/Status → components/TableFilters/StatusFilter}/style.tsx +0 -0
  45. package/src/{modules/StructuredData/StructuredDataList/HeaderMenus/Translations → components/TableFilters/TranslationsFilter}/index.tsx +4 -4
  46. package/src/{modules/StructuredData/StructuredDataList/HeaderMenus/Translations → components/TableFilters/TranslationsFilter}/style.tsx +0 -0
  47. package/src/{modules/StructuredData/StructuredDataList/HeaderMenus/Types → components/TableFilters/TypeFilter}/index.tsx +13 -9
  48. package/src/{modules/StructuredData/StructuredDataList/HeaderMenus/Types → components/TableFilters/TypeFilter}/style.tsx +1 -1
  49. package/src/components/TableFilters/index.tsx +19 -0
  50. package/src/components/Tag/index.tsx +1 -1
  51. package/src/components/Tag/style.tsx +10 -11
  52. package/src/components/index.tsx +19 -0
  53. package/src/containers/Domains/actions.tsx +51 -0
  54. package/src/containers/Domains/constants.tsx +5 -0
  55. package/src/containers/Domains/index.tsx +4 -0
  56. package/src/containers/Domains/interfaces.tsx +9 -0
  57. package/src/containers/Domains/reducer.tsx +22 -0
  58. package/src/containers/Gallery/actions.tsx +0 -1
  59. package/src/containers/PageEditor/actions.tsx +7 -0
  60. package/src/containers/PageEditor/utils.tsx +1 -1
  61. package/src/containers/Settings/Languages/constants.tsx +3 -3
  62. package/src/containers/Settings/Languages/index.tsx +2 -5
  63. package/src/containers/Sites/actions.tsx +3 -2
  64. package/src/containers/StructuredData/actions.tsx +62 -3
  65. package/src/containers/StructuredData/constants.tsx +4 -0
  66. package/src/containers/StructuredData/interfaces.tsx +13 -1
  67. package/src/containers/StructuredData/reducer.tsx +9 -1
  68. package/src/forms/editor.tsx +4 -0
  69. package/src/forms/elements.tsx +2 -5
  70. package/src/forms/index.tsx +2 -1
  71. package/src/forms/validators.tsx +12 -5
  72. package/src/helpers/arrays.tsx +12 -1
  73. package/src/helpers/index.tsx +4 -1
  74. package/src/helpers/strings.tsx +7 -0
  75. package/src/hooks/content.tsx +41 -0
  76. package/src/hooks/index.tsx +3 -1
  77. package/src/modules/Categories/CategoriesList/CategoryNav/NavItem/style.tsx +9 -9
  78. package/src/modules/Content/BulkHeader/TableHeader/index.tsx +95 -24
  79. package/src/modules/Content/BulkHeader/TableHeader/style.tsx +6 -19
  80. package/src/modules/Content/BulkHeader/index.tsx +16 -0
  81. package/src/modules/Content/ContentFilters/index.tsx +4 -4
  82. package/src/modules/Content/OptionTable/style.tsx +1 -1
  83. package/src/modules/Content/PageItem/atoms.tsx +28 -0
  84. package/src/modules/Content/PageItem/index.tsx +67 -24
  85. package/src/modules/Content/PageItem/style.tsx +14 -7
  86. package/src/modules/Content/hooks.tsx +27 -17
  87. package/src/modules/Content/index.tsx +53 -6
  88. package/src/modules/GlobalEditor/index.tsx +5 -11
  89. package/src/modules/GlobalSettings/Robots/Item/RobotsPanel/index.tsx +61 -0
  90. package/src/modules/GlobalSettings/Robots/Item/RobotsPanel/style.tsx +30 -0
  91. package/src/modules/GlobalSettings/Robots/Item/index.tsx +33 -0
  92. package/src/modules/GlobalSettings/Robots/Item/style.tsx +28 -0
  93. package/src/modules/GlobalSettings/Robots/index.tsx +120 -0
  94. package/src/modules/GlobalSettings/Robots/style.tsx +32 -0
  95. package/src/modules/GlobalSettings/index.tsx +26 -0
  96. package/src/modules/PageEditor/index.tsx +2 -5
  97. package/src/modules/Settings/Globals/style.tsx +1 -1
  98. package/src/modules/StructuredData/Form/ConnectedField/index.tsx +10 -2
  99. package/src/modules/StructuredData/Form/index.tsx +48 -9
  100. package/src/modules/StructuredData/Form/style.tsx +3 -6
  101. package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +84 -35
  102. package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/style.tsx +6 -25
  103. package/src/modules/StructuredData/StructuredDataList/BulkHeader/index.tsx +10 -1
  104. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +24 -3
  105. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +53 -22
  106. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/style.tsx +16 -9
  107. package/src/modules/StructuredData/StructuredDataList/OptionTable/style.tsx +1 -1
  108. package/src/modules/StructuredData/StructuredDataList/hooks.tsx +9 -2
  109. package/src/modules/StructuredData/StructuredDataList/index.tsx +45 -5
  110. package/src/routes/multisite.tsx +8 -0
  111. package/src/types/index.tsx +28 -11
  112. package/src/modules/Content/HeaderMenus/Live/index.tsx +0 -93
  113. package/src/modules/Content/HeaderMenus/Name/index.tsx +0 -52
  114. package/src/modules/Content/HeaderMenus/Translations/index.tsx +0 -62
  115. package/src/modules/Content/HeaderMenus/Types/index.tsx +0 -73
  116. package/src/modules/Content/HeaderMenus/Types/style.tsx +0 -34
  117. package/src/modules/StructuredData/StructuredDataList/HeaderMenus/Live/style.tsx +0 -37
  118. package/src/modules/StructuredData/StructuredDataList/HeaderMenus/Name/style.tsx +0 -29
  119. package/src/modules/StructuredData/StructuredDataList/HeaderMenus/Status/index.tsx +0 -47
  120. package/src/modules/StructuredData/StructuredDataList/HeaderMenus/Status/style.tsx +0 -30
@@ -4,9 +4,11 @@ import { Icon, FloatingMenu, ListTitle, ListItem } from "@ax/components";
4
4
 
5
5
  import * as S from "./style";
6
6
 
7
- const Status = ({ sortItems, sortedState }: IStatusProps) => {
7
+ const StatusFilter = (props: IStatusFilterProps) => {
8
+ const { sortItems, sortedState, isStructuredData } = props;
8
9
  const { isAscending, sortedByDate } = sortedState;
9
- const sortByModifiedDate = (isAscending: boolean) => sortItems("modified", isAscending);
10
+ const value = isStructuredData ? "date" : "modified";
11
+ const sortByModifiedDate = (isAscending: boolean) => sortItems(value, isAscending);
10
12
 
11
13
  const sortOldestModifiedDate = () => sortByModifiedDate(true);
12
14
  const sortMostRecentModifiedDate = () => sortByModifiedDate(false);
@@ -39,9 +41,10 @@ const Status = ({ sortItems, sortedState }: IStatusProps) => {
39
41
  );
40
42
  };
41
43
 
42
- interface IStatusProps {
44
+ interface IStatusFilterProps {
43
45
  sortedState: any;
44
46
  sortItems(orderPointer: string, isAscendent: boolean): any;
47
+ isStructuredData?: boolean;
45
48
  }
46
49
 
47
- export default Status;
50
+ export default StatusFilter;
@@ -5,7 +5,7 @@ import { areEquals, isNumber } from "@ax/helpers";
5
5
 
6
6
  import * as S from "./style";
7
7
 
8
- const Translations = (props: ITranslationsProps): JSX.Element => {
8
+ const TranslationsFilter = (props: ITranslationsFilterProps): JSX.Element => {
9
9
  const { filterItems, value } = props;
10
10
 
11
11
  const filters = [
@@ -52,15 +52,15 @@ const Translations = (props: ITranslationsProps): JSX.Element => {
52
52
  <FloatingMenu Button={Header} position="left" closeOnSelect={true} isCheckGroup={true}>
53
53
  <ListTitle>Filter by translations</ListTitle>
54
54
  <S.ChecksWrapper>
55
- <CheckGroup options={filters} value={selectedValue} onChange={setQuery} selectAllOption={selectAllOption} />
55
+ <CheckGroup options={filters} value={selectedValue} onChange={setQuery} multipleSelection={false} />
56
56
  </S.ChecksWrapper>
57
57
  </FloatingMenu>
58
58
  );
59
59
  };
60
60
 
61
- interface ITranslationsProps {
61
+ interface ITranslationsFilterProps {
62
62
  filterItems(pointer: string, filter: string): void;
63
63
  value: string;
64
64
  }
65
65
 
66
- export default Translations;
66
+ export default TranslationsFilter;
@@ -1,14 +1,11 @@
1
1
  import React, { useState } from "react";
2
2
  import { CheckGroup, FloatingMenu, Icon, ListTitle } from "@ax/components";
3
- import { areEquals, getGlobalPageTypes } from "@ax/helpers";
3
+ import { areEquals } from "@ax/helpers";
4
4
 
5
5
  import * as S from "./style";
6
6
 
7
- const Types = ({ filterItems }: ITypesProps): JSX.Element => {
8
- const globalPageTypes = getGlobalPageTypes();
9
- const filters = globalPageTypes.map(({ type, title }) => ({ name: type, value: type, title }));
10
- const allFilter = { name: "all", value: "all", title: "All types" };
11
- filters.unshift(allFilter);
7
+ const TypeFilter = (props: ITypeFilterProps): JSX.Element => {
8
+ const { filterItems, filters, pointer } = props;
12
9
 
13
10
  const initialState = ["all"];
14
11
  const selectAllOption = "all";
@@ -20,7 +17,6 @@ const Types = ({ filterItems }: ITypesProps): JSX.Element => {
20
17
  }
21
18
  setSelectedValue(selection);
22
19
  const queryFilters = selection.join("&");
23
- const pointer = "types";
24
20
  filterItems(pointer, queryFilters);
25
21
  };
26
22
 
@@ -51,8 +47,16 @@ const Types = ({ filterItems }: ITypesProps): JSX.Element => {
51
47
  );
52
48
  };
53
49
 
54
- interface ITypesProps {
50
+ interface IFilter {
51
+ name: string;
52
+ value: string;
53
+ title: string;
54
+ }
55
+
56
+ interface ITypeFilterProps {
55
57
  filterItems(pointer: string, filter: string): void;
58
+ filters: IFilter[];
59
+ pointer: string;
56
60
  }
57
61
 
58
- export default Types;
62
+ export default TypeFilter;
@@ -2,7 +2,7 @@ import styled from "styled-components";
2
2
  import { Header } from "@ax/components/TableList/style";
3
3
 
4
4
  const Types = styled(Header)<{ isActive: boolean }>`
5
- width: 230px;
5
+ width: 170px;
6
6
  justify-content: center;
7
7
  &:hover {
8
8
  color: ${(p) => p.theme.color.interactive01};
@@ -0,0 +1,19 @@
1
+ import CategoryFilter from "./CategoryFilter";
2
+ import CustomizeFilters from "./CustomizeFilters";
3
+ import LiveFilter from "./LiveFilter";
4
+ import NameFilter from "./NameFilter";
5
+ import SiteFilter from "./SiteFilter";
6
+ import StatusFilter from "./StatusFilter";
7
+ import TranslationsFilter from "./TranslationsFilter";
8
+ import TypeFilter from "./TypeFilter";
9
+
10
+ export {
11
+ CategoryFilter,
12
+ CustomizeFilters,
13
+ LiveFilter,
14
+ NameFilter,
15
+ SiteFilter,
16
+ StatusFilter,
17
+ TranslationsFilter,
18
+ TypeFilter,
19
+ };
@@ -28,7 +28,7 @@ const Tag = (props: ITagProps): JSX.Element => {
28
28
  );
29
29
  default:
30
30
  return (
31
- <S.TagFixed>
31
+ <S.TagFixed color={color}>
32
32
  <S.TagText>
33
33
  <S.Title>{text}</S.Title>
34
34
  {deleteIcon}
@@ -1,19 +1,19 @@
1
1
  import styled from "styled-components";
2
2
 
3
3
  export const TagStatus = styled.div`
4
- ${p => p.theme.textStyle.uiXS};
4
+ ${(p) => p.theme.textStyle.uiXS};
5
5
  background-color: #ffffff;
6
- border: 1px solid ${p => p.theme.color.uiLine};
6
+ border: 1px solid ${(p) => p.theme.color.uiLine};
7
7
  box-sizing: border-box;
8
8
  border-radius: ${(p) => p.theme.spacing.s};
9
- color: ${p => p.theme.color.textMediumEmphasis};
9
+ color: ${(p) => p.theme.color.textMediumEmphasis};
10
10
  display: inline-block;
11
11
  padding: 3px 8px;
12
12
  text-transform: capitalize;
13
13
  `;
14
14
 
15
15
  export const Bullet = styled.span<{ color: string | undefined }>`
16
- background-color: ${p => (p.color ? p.color : `#4096D6`)};
16
+ background-color: ${(p) => (p.color ? p.color : `#4096D6`)};
17
17
  display: inline-block;
18
18
  width: 8px;
19
19
  height: 8px;
@@ -21,20 +21,19 @@ export const Bullet = styled.span<{ color: string | undefined }>`
21
21
  margin-right: 4px;
22
22
  `;
23
23
 
24
- export const TagFixed = styled.div`
25
- ${p => p.theme.textStyle.uiS};
26
- background-color: ${p => p.theme.color.interactive02};
24
+ 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
27
  border-radius: ${(p) => p.theme.spacing.s};
28
28
  box-sizing: border-box;
29
- color: ${p => p.theme.color.textMediumEmphasis};
29
+ color: ${(p) => p.theme.color.textMediumEmphasis};
30
30
  display: inline-block;
31
31
  padding: 3px 8px;
32
32
  margin-right: ${(p) => p.theme.spacing.xxs};
33
33
  margin-bottom: ${(p) => p.theme.spacing.xxs};
34
34
  `;
35
35
 
36
- export const Title = styled.div`
37
- `;
36
+ export const Title = styled.div``;
38
37
 
39
38
  export const IconWrapper = styled.div`
40
39
  height: 16px;
@@ -42,7 +41,7 @@ export const IconWrapper = styled.div`
42
41
  cursor: pointer;
43
42
  svg {
44
43
  path {
45
- fill: ${p => p.theme.color.textMediumEmphasis};
44
+ fill: ${(p) => p.theme.color.textMediumEmphasis};
46
45
  }
47
46
  }
48
47
  `;
@@ -30,6 +30,16 @@ import {
30
30
  Wysiwyg,
31
31
  } from "./Fields";
32
32
  import { ListTitle, ListItem } from "./Lists";
33
+ import {
34
+ CategoryFilter,
35
+ CustomizeFilters,
36
+ LiveFilter,
37
+ NameFilter,
38
+ SiteFilter,
39
+ StatusFilter,
40
+ TranslationsFilter,
41
+ TypeFilter,
42
+ } from "./TableFilters";
33
43
 
34
44
  import ActionMenu from "./ActionMenu";
35
45
  import Avatar from "./Avatar";
@@ -110,6 +120,15 @@ export {
110
120
  //Lists
111
121
  ListTitle,
112
122
  ListItem,
123
+ //Filters
124
+ CategoryFilter,
125
+ CustomizeFilters,
126
+ LiveFilter,
127
+ NameFilter,
128
+ SiteFilter,
129
+ StatusFilter,
130
+ TranslationsFilter,
131
+ TypeFilter,
113
132
  // Components
114
133
  ActionMenu,
115
134
  Avatar,
@@ -0,0 +1,51 @@
1
+ import { domains } from "@ax/api";
2
+ import { appActions } from "@ax/containers/App";
3
+ import { handleRequest } from "@ax/helpers";
4
+ import { IDomainRobot } from "@ax/types";
5
+ import { SET_DOMAINS_ROBOTS } from "./constants";
6
+ import { ISetDomainsRobots } from "./interfaces";
7
+
8
+ function setDomainsRobots(robots: IDomainRobot[]): ISetDomainsRobots {
9
+ return { type: SET_DOMAINS_ROBOTS, payload: { robots } };
10
+ }
11
+
12
+ function getDomainsRobots(): (dispatch: any) => Promise<void> {
13
+ return async (dispatch) => {
14
+ try {
15
+ const callback = async () => domains.getDomainsRobots();
16
+
17
+ const responseActions = {
18
+ handleSuccess: (response: any) => {
19
+ dispatch(setDomainsRobots(response));
20
+ },
21
+ handleError: (response: any) => appActions.handleError(response)(dispatch),
22
+ };
23
+
24
+ await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
25
+ } catch (e) {
26
+ console.log(e);
27
+ }
28
+ };
29
+ }
30
+
31
+ function updateDomainsRobots(robots: IDomainRobot[]): (dispatch: any) => Promise<boolean> {
32
+ return async (dispatch) => {
33
+ try {
34
+ const callback = async () => domains.updateDomainsRobots(robots);
35
+
36
+ const responseActions = {
37
+ handleSuccess: () => {
38
+ dispatch(getDomainsRobots());
39
+ },
40
+ handleError: (response: any) => appActions.handleError(response)(dispatch),
41
+ };
42
+
43
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
44
+ } catch (e) {
45
+ console.log(e);
46
+ return false;
47
+ }
48
+ };
49
+ }
50
+
51
+ export { getDomainsRobots, updateDomainsRobots };
@@ -0,0 +1,5 @@
1
+ const NAME = "domains";
2
+
3
+ const SET_DOMAINS_ROBOTS = `${NAME}/SET_DOMAINS_ROBOTS`;
4
+
5
+ export { NAME, SET_DOMAINS_ROBOTS };
@@ -0,0 +1,4 @@
1
+ import * as domainsActions from "./actions";
2
+ import { domainsReducer } from "./reducer";
3
+
4
+ export { domainsActions, domainsReducer };
@@ -0,0 +1,9 @@
1
+ import { IDomainRobot } from "@ax/types";
2
+ import { SET_DOMAINS_ROBOTS } from "./constants";
3
+
4
+ export interface ISetDomainsRobots {
5
+ type: typeof SET_DOMAINS_ROBOTS;
6
+ payload: { robots: IDomainRobot[] };
7
+ }
8
+
9
+ export type DomainsActionsCreators = ISetDomainsRobots;
@@ -0,0 +1,22 @@
1
+ import { IDomainRobot } from "@ax/types";
2
+ import { SET_DOMAINS_ROBOTS } from "./constants";
3
+ import { DomainsActionsCreators } from "./interfaces";
4
+
5
+ export interface IDomainsState {
6
+ robots: IDomainRobot[];
7
+ }
8
+
9
+ export const initialState = {
10
+ robots: [],
11
+ };
12
+
13
+ export function reducer(state = initialState, action: DomainsActionsCreators): IDomainsState {
14
+ switch (action.type) {
15
+ case SET_DOMAINS_ROBOTS:
16
+ return { ...state, ...action.payload };
17
+ default:
18
+ return state;
19
+ }
20
+ }
21
+
22
+ export { initialState as domainsInitialState, reducer as domainsReducer };
@@ -137,7 +137,6 @@ function updateImage(
137
137
  try {
138
138
  const result = await images.updateImage(imageID, imageData);
139
139
  if (isReqOk(result.status)) {
140
- console.log(result.data, "data");
141
140
  dispatch(setData({ ...result.data, isImageSelected: false, imageSelected: null }));
142
141
  }
143
142
  } catch (e) {
@@ -779,6 +779,13 @@ function updateBreadcrumb(editorID: number): any {
779
779
  const isFiltered = true;
780
780
  const newBreadcrumb = getNewBreadcrumb(editorContent, editorID, isFiltered);
781
781
 
782
+ const { header, footer } = editorContent;
783
+ const navigationIds = [header?.editorID, footer?.editorID];
784
+ if (navigationIds.includes(editorID)) {
785
+ const rootBreadcrumb = { editorID: 0, displayName: 'Page', component: 'Page' };
786
+ newBreadcrumb.unshift(rootBreadcrumb);
787
+ }
788
+
782
789
  dispatch(setBreadcrumb(newBreadcrumb));
783
790
  };
784
791
  }
@@ -30,7 +30,7 @@ export const getPageData = (getState: any, deleted: boolean, params = getPagePar
30
30
 
31
31
  const getTemplateValues = (template: any) => {
32
32
  const sections = Object.keys(template)
33
- .map((key: string) => template[key])
33
+ .map((key: string) => ({ ...template[key], key }))
34
34
  .filter((value: any) => typeof value === "object" && value !== null && value.component === "Section");
35
35
 
36
36
  return sections;
@@ -1,6 +1,6 @@
1
- const NAME: string = "languages";
1
+ const NAME = "languages";
2
2
 
3
- const CREATE_FORM: string = `${NAME}/CREATE_FORM`;
4
- const UPDATE_FORM: string = `${NAME}/UPDATE_FORM`;
3
+ const CREATE_FORM = `${NAME}/CREATE_FORM`;
4
+ const UPDATE_FORM = `${NAME}/UPDATE_FORM`;
5
5
 
6
6
  export { NAME, CREATE_FORM, UPDATE_FORM };
@@ -1,7 +1,4 @@
1
1
  import * as languagesActions from "./actions";
2
- import { languagesReducer } from "./reducer";
2
+ import { languagesReducer } from "./reducer";
3
3
 
4
- export {
5
- languagesActions,
6
- languagesReducer
7
- };
4
+ export { languagesActions, languagesReducer };
@@ -261,13 +261,14 @@ function getFilteredContent(filter: any): (dispatch: any, getState: any) => Prom
261
261
 
262
262
  function getSitePages(
263
263
  params: IGetSitePagesParams,
264
- structuredData?: string | undefined
264
+ structuredData?: string,
265
+ filterQuery?: string
265
266
  ): (dispatch: any) => Promise<void> {
266
267
  return async (dispatch) => {
267
268
  try {
268
269
  dispatch(setIsLoading(true));
269
270
  const response: any = structuredData
270
- ? await sites.getStructuredSitePages(params, structuredData)
271
+ ? await sites.getStructuredSitePages(params, structuredData, filterQuery)
271
272
  : await sites.getSitePages(params);
272
273
 
273
274
  if (isReqOk(response.status)) {
@@ -13,6 +13,8 @@ import {
13
13
  DEFAULT_PARAMS,
14
14
  SET_FILTER,
15
15
  SET_SCHEMA_VERSION,
16
+ SET_ERRORS,
17
+ SET_VALIDATED,
16
18
  } from "./constants";
17
19
 
18
20
  import {
@@ -24,13 +26,16 @@ import {
24
26
  ISetCategory,
25
27
  ISetFilter,
26
28
  ISetSchemaVersion,
29
+ ISetErrors,
30
+ ISetValidated,
27
31
  } from "./interfaces";
28
32
  import { prepareStructuredDataContent, getTaxonomies, filterStructuredDataByID, getTypes } from "./utils";
29
- import { IStructuredData, IStructuredDataContent, ICategory, IGetStructuredDataParams } from "@ax/types";
33
+ import { IStructuredData, IStructuredDataContent, ICategory, IGetStructuredDataParams, IErrorItem } from "@ax/types";
30
34
  import { structuredData } from "@ax/api";
31
35
  import { setTotalItems } from "@ax/containers/Sites/actions";
32
36
  import { appActions } from "@ax/containers/App";
33
37
  import { handleRequest, isEmptyArray } from "@ax/helpers";
38
+ import { findMandatoryStructuredDataErrors } from "@ax/forms";
34
39
 
35
40
  const { setIsLoading, setIsSaving } = appActions;
36
41
 
@@ -83,6 +88,14 @@ function setSchemaVersion(schemaVersion: string): ISetSchemaVersion {
83
88
  return { type: SET_SCHEMA_VERSION, payload: { schemaVersion } };
84
89
  }
85
90
 
91
+ function setErrors(errors: IErrorItem[]): ISetErrors {
92
+ return { type: SET_ERRORS, payload: { errors } };
93
+ }
94
+
95
+ function setValidated(validated: boolean): ISetValidated {
96
+ return { type: SET_VALIDATED, payload: { validated } };
97
+ }
98
+
86
99
  function updateFormValue(valueObj: any): (dispatch: Dispatch, getState: any) => void {
87
100
  return (dispatch, getState) => {
88
101
  const {
@@ -109,6 +122,8 @@ function resetForm(): (dispatch: Dispatch, getState: any) => void {
109
122
  const updatedForm = { content: form.content };
110
123
  dispatch(setEntity(null));
111
124
  dispatch(updateForm(updatedForm));
125
+ dispatch(setErrors([]));
126
+ dispatch(setValidated(false));
112
127
  };
113
128
  }
114
129
 
@@ -320,7 +335,7 @@ function createStructuredDataContent(
320
335
 
321
336
  function updateStructuredDataContent(
322
337
  structuredDataContent: IStructuredDataContent
323
- ): (dispatch: Dispatch) => Promise<void> {
338
+ ): (dispatch: Dispatch) => Promise<boolean> {
324
339
  return async (dispatch) => {
325
340
  try {
326
341
  const dataContent = prepareStructuredDataContent(structuredDataContent);
@@ -332,9 +347,10 @@ function updateStructuredDataContent(
332
347
 
333
348
  const callback = async () => structuredData.updateDataContent(structuredDataContent.id, dataContent);
334
349
 
335
- await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
350
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
336
351
  } catch (e) {
337
352
  console.log(e); // TODO: capturar error bien
353
+ return false;
338
354
  }
339
355
  };
340
356
  }
@@ -467,6 +483,47 @@ function setStatusStructuredDataContent(
467
483
  };
468
484
  }
469
485
 
486
+ function validateForm(): (dispatch: Dispatch, getState: any) => Promise<boolean> {
487
+ return async (dispatch, getState) => {
488
+ try {
489
+ const {
490
+ structuredData: {
491
+ form: { content },
492
+ schema,
493
+ },
494
+ } = getState();
495
+
496
+ const errors = findMandatoryStructuredDataErrors(content, schema);
497
+ dispatch(setErrors(errors));
498
+ if (errors.length === 0) {
499
+ dispatch(setValidated(true));
500
+ } else {
501
+ dispatch(setValidated(false));
502
+ }
503
+ return true;
504
+ } catch (e) {
505
+ console.log(e);
506
+ return false;
507
+ }
508
+ };
509
+ }
510
+
511
+ function deleteError(error: IErrorItem): (dispatch: Dispatch, getState: any) => void {
512
+ return async (dispatch, getState) => {
513
+ try {
514
+ const {
515
+ structuredData: { errors },
516
+ } = getState();
517
+
518
+ const updatedErrors = errors.filter((err: IErrorItem) => error.key !== err.key);
519
+
520
+ dispatch(setErrors(updatedErrors));
521
+ } catch (e) {
522
+ console.log(e);
523
+ }
524
+ };
525
+ }
526
+
470
527
  export {
471
528
  setIsActive,
472
529
  setCategories,
@@ -495,4 +552,6 @@ export {
495
552
  setStatusStructuredDataContent,
496
553
  filterStructuredData,
497
554
  setFilter,
555
+ validateForm,
556
+ deleteError,
498
557
  };
@@ -12,6 +12,8 @@ const UPDATE_FORM = `${NAME}/UPDATE_FORM`;
12
12
  const SET_ENTITY = `${NAME}/SET_ENTITY`;
13
13
  const SET_FILTER: string | null = `${NAME}/SET_FILTER`;
14
14
  const SET_SCHEMA_VERSION: string | null = `${NAME}/SET_SCHEMA_VERSION`;
15
+ const SET_ERRORS = `${NAME}/SET_ERRORS`;
16
+ const SET_VALIDATED = `${NAME}/SET_VALIDATED`;
15
17
 
16
18
  const ITEMS_PER_PAGE = 50;
17
19
 
@@ -39,4 +41,6 @@ export {
39
41
  DEFAULT_PARAMS,
40
42
  SET_FILTER,
41
43
  SET_SCHEMA_VERSION,
44
+ SET_ERRORS,
45
+ SET_VALIDATED,
42
46
  };
@@ -9,9 +9,11 @@ import {
9
9
  SET_CATEGORY,
10
10
  SET_FILTER,
11
11
  SET_SCHEMA_VERSION,
12
+ SET_ERRORS,
13
+ SET_VALIDATED,
12
14
  } from "./constants";
13
15
 
14
- import { IStructuredData, IStructuredDataContent, ICategory } from "@ax/types";
16
+ import { IStructuredData, IStructuredDataContent, ICategory, IErrorItem } from "@ax/types";
15
17
 
16
18
  export interface ISetCategories {
17
19
  type: typeof SET_CATEGORIES;
@@ -62,6 +64,16 @@ export interface ISetSchemaVersion {
62
64
  payload: { schemaVersion: string };
63
65
  }
64
66
 
67
+ export interface ISetErrors {
68
+ type: typeof SET_ERRORS;
69
+ payload: { errors: IErrorItem[] };
70
+ }
71
+
72
+ export interface ISetValidated {
73
+ type: typeof SET_VALIDATED;
74
+ payload: { validated: boolean };
75
+ }
76
+
65
77
  export type CategoryActionsCreators = ISetCategories & ISetCurrentData;
66
78
 
67
79
  export type StructuredDataActionsCreators = CategoryActionsCreators &
@@ -1,4 +1,4 @@
1
- import { IStructuredData, IStructuredDataContent, ICategory } from "@ax/types";
1
+ import { IStructuredData, IStructuredDataContent, ICategory, IErrorItem } from "@ax/types";
2
2
  import {
3
3
  SET_CATEGORIES,
4
4
  SET_STRUCTURED_DATA,
@@ -12,6 +12,8 @@ import {
12
12
  SET_ENTITY,
13
13
  SET_FILTER,
14
14
  SET_SCHEMA_VERSION,
15
+ SET_ERRORS,
16
+ SET_VALIDATED,
15
17
  } from "./constants";
16
18
 
17
19
  import { StructuredDataActionsCreators } from "./interfaces";
@@ -28,6 +30,8 @@ export interface IStructuredDataState {
28
30
  entity: string | null;
29
31
  currentFilter: string;
30
32
  schemaVersion: string;
33
+ errors: IErrorItem[];
34
+ validated: boolean;
31
35
  }
32
36
 
33
37
  export const initialState = {
@@ -42,6 +46,8 @@ export const initialState = {
42
46
  entity: null,
43
47
  currentFilter: "all-pages",
44
48
  schemaVersion: "",
49
+ errors: [],
50
+ validated: false,
45
51
  };
46
52
 
47
53
  export function reducer(state = initialState, action: StructuredDataActionsCreators): IStructuredDataState {
@@ -58,6 +64,8 @@ export function reducer(state = initialState, action: StructuredDataActionsCreat
58
64
  case SET_ENTITY:
59
65
  case SET_FILTER:
60
66
  case SET_SCHEMA_VERSION:
67
+ case SET_ERRORS:
68
+ case SET_VALIDATED:
61
69
  return { ...state, ...action.payload };
62
70
  default:
63
71
  return state;
@@ -116,6 +116,8 @@ const cleanPageValues = (updatedValues: any, originalValues: any) => {
116
116
  delete updatedValues["hash"];
117
117
  delete updatedValues["editing"];
118
118
  delete updatedValues["pageLanguages"];
119
+ delete updatedValues["availableSites"];
120
+ delete updatedValues["fullUrl"];
119
121
 
120
122
  delete originalValues["setAsHome"];
121
123
  delete originalValues["modified"];
@@ -128,6 +130,8 @@ const cleanPageValues = (updatedValues: any, originalValues: any) => {
128
130
  delete originalValues["hash"];
129
131
  delete originalValues["editing"];
130
132
  delete originalValues["pageLanguages"];
133
+ delete originalValues["availableSites"];
134
+ delete originalValues["fullUrl"];
131
135
 
132
136
  return {
133
137
  cleanUpdatedValues: updatedValues,
@@ -68,7 +68,7 @@ const getUpdatedComponents = (sections: any, component: any, key: string) => {
68
68
  const getUpdatedSections = (sections: any[], id: number, moduleType: string) => {
69
69
  let selectedIndex = 0;
70
70
  const sectionEntries = sections.map((section: any, index: number) => {
71
- const { name, component, modules } = section;
71
+ const { modules, key } = section;
72
72
  if (isSelectedEditorID(section, id)) {
73
73
  selectedIndex = index;
74
74
  const newModule = getDefaultSchema(moduleType);
@@ -76,10 +76,7 @@ const getUpdatedSections = (sections: any[], id: number, moduleType: string) =>
76
76
  section.modules = [...updatedModules];
77
77
  }
78
78
 
79
- const text = name ? name : component;
80
- const sectionKey = camelize(text);
81
-
82
- return [sectionKey, section];
79
+ return [key, section];
83
80
  });
84
81
  const updatedSections = Object.fromEntries(sectionEntries);
85
82