@griddo/ax 1.66.4 → 1.66.5
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.
- package/package.json +2 -2
- package/src/api/pages.tsx +3 -15
- package/src/api/redirects.tsx +2 -4
- package/src/api/sites.tsx +2 -4
- package/src/components/Browser/index.tsx +1 -3
- package/src/components/Browser/style.tsx +2 -2
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +1 -0
- package/src/components/ErrorCenter/index.tsx +5 -8
- package/src/components/ErrorCenter/style.tsx +8 -21
- package/src/components/Fields/ColorPicker/index.tsx +0 -1
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +1 -5
- package/src/components/Fields/ReferenceField/index.tsx +14 -18
- package/src/components/Fields/UrlField/index.tsx +1 -13
- package/src/components/Fields/index.tsx +0 -2
- package/src/components/FieldsBehavior/index.tsx +1 -14
- package/src/components/MainWrapper/AppBar/index.tsx +10 -21
- package/src/components/MainWrapper/AppBar/style.tsx +3 -11
- package/src/components/MainWrapper/index.tsx +0 -2
- package/src/components/Modal/style.tsx +1 -0
- package/src/components/SearchField/index.tsx +4 -36
- package/src/components/SearchField/style.tsx +10 -23
- package/src/components/SideModal/style.tsx +6 -6
- package/src/components/TableFilters/StatusFilter/index.tsx +2 -2
- package/src/components/index.tsx +0 -2
- package/src/containers/App/actions.tsx +7 -3
- package/src/containers/PageEditor/actions.tsx +22 -91
- package/src/containers/PageEditor/constants.tsx +1 -1
- package/src/containers/PageEditor/interfaces.tsx +6 -6
- package/src/containers/PageEditor/reducer.tsx +4 -4
- package/src/containers/PageEditor/utils.tsx +1 -2
- package/src/containers/Sites/actions.tsx +23 -35
- package/src/containers/Sites/constants.tsx +0 -1
- package/src/containers/Sites/interfaces.tsx +0 -6
- package/src/containers/Sites/reducer.tsx +0 -4
- package/src/forms/editor.tsx +1 -34
- package/src/forms/errors.tsx +0 -1
- package/src/forms/index.tsx +1 -15
- package/src/forms/validators.tsx +9 -168
- package/src/guards/error/index.tsx +1 -1
- package/src/helpers/dataPacks.tsx +1 -8
- package/src/helpers/index.tsx +1 -2
- package/src/modules/Content/PageItem/index.tsx +4 -54
- package/src/modules/Content/atoms.tsx +3 -41
- package/src/modules/Content/index.tsx +64 -111
- package/src/modules/Content/style.tsx +1 -8
- package/src/modules/GlobalEditor/Editor/index.tsx +1 -3
- package/src/modules/GlobalEditor/PageBrowser/index.tsx +0 -3
- package/src/modules/GlobalEditor/index.tsx +6 -8
- package/src/modules/PageEditor/Editor/index.tsx +2 -6
- package/src/modules/PageEditor/PageBrowser/index.tsx +0 -3
- package/src/modules/PageEditor/index.tsx +15 -29
- package/src/modules/Redirects/index.tsx +10 -40
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +1 -1
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/index.tsx +1 -1
- package/src/modules/Settings/ContentTypes/DataPacks/Config/index.tsx +1 -1
- package/src/modules/Settings/ContentTypes/DataPacks/index.tsx +1 -1
- package/src/modules/Sites/index.tsx +3 -3
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +1 -1
- package/src/modules/StructuredData/StructuredDataList/atoms.tsx +1 -1
- package/src/modules/Users/Profile/index.tsx +4 -3
- package/src/modules/Users/UserCreate/SiteItem/index.tsx +1 -1
- package/src/modules/Users/UserCreate/SiteItem/style.tsx +1 -1
- package/src/modules/Users/UserForm/style.tsx +3 -3
- package/src/modules/Users/UserList/UserItem/index.tsx +1 -3
- package/src/modules/Users/UserList/hooks.tsx +1 -1
- package/src/modules/Users/UserList/index.tsx +2 -2
- package/src/types/index.tsx +3 -16
- package/src/components/Fields/LinkField/index.tsx +0 -85
- package/src/components/Icon/components/Copy.js +0 -14
- package/src/components/Icon/svgs/Copy2.svg +0 -3
|
@@ -11,8 +11,7 @@ const Wrapper = styled.div<{ optionsType?: string }>`
|
|
|
11
11
|
|
|
12
12
|
height: 100vh;
|
|
13
13
|
background: ${(p) => p.theme.colors.uiBackground01};
|
|
14
|
-
box-shadow: ${(p) =>
|
|
15
|
-
p.optionsType && placeRight.includes(p.optionsType) ? p.theme.shadow.rightPanel : p.theme.shadow.leftPanel};
|
|
14
|
+
box-shadow: ${(p) => (p.optionsType && placeRight.includes(p.optionsType) ? p.theme.shadow.rightPanel : p.theme.shadow.leftPanel)};
|
|
16
15
|
padding-bottom: calc(${(p) => p.theme.spacing.m} * 2);
|
|
17
16
|
`;
|
|
18
17
|
|
|
@@ -32,10 +31,11 @@ const Header = styled.div`
|
|
|
32
31
|
}
|
|
33
32
|
`;
|
|
34
33
|
|
|
35
|
-
const Title = styled.h6
|
|
34
|
+
const Title = styled.h6`
|
|
35
|
+
`;
|
|
36
36
|
|
|
37
37
|
const ColumnsWrapper = styled.div`
|
|
38
|
-
display:
|
|
38
|
+
display:flex;
|
|
39
39
|
`;
|
|
40
40
|
|
|
41
41
|
const Content = styled.div`
|
|
@@ -64,11 +64,11 @@ const FeaturedWrapper = styled.div`
|
|
|
64
64
|
`;
|
|
65
65
|
|
|
66
66
|
const SearchWrapper = styled.div`
|
|
67
|
-
width: ${
|
|
67
|
+
width: ${p => `calc(${p.theme.spacing.xl} * 4)`};
|
|
68
68
|
`;
|
|
69
69
|
|
|
70
70
|
const Link = styled.div<{ active: boolean }>`
|
|
71
|
-
color: ${
|
|
71
|
+
color: ${p => p.active ? p.theme.color.textHighEmphasis : p.theme.color.textMediumEmphasis};
|
|
72
72
|
`;
|
|
73
73
|
|
|
74
74
|
const ButtonWrapper = styled.div`
|
|
@@ -4,7 +4,7 @@ import { Icon, FloatingMenu, ListTitle, ListItem } from "@ax/components";
|
|
|
4
4
|
|
|
5
5
|
import * as S from "./style";
|
|
6
6
|
|
|
7
|
-
const StatusFilter = (props: IStatusFilterProps)
|
|
7
|
+
const StatusFilter = (props: IStatusFilterProps) => {
|
|
8
8
|
const { sortItems, sortedState, isStructuredData } = props;
|
|
9
9
|
const { isAscending, sortedByDate } = sortedState;
|
|
10
10
|
const value = isStructuredData ? "date" : "modified";
|
|
@@ -46,7 +46,7 @@ const StatusFilter = (props: IStatusFilterProps): JSX.Element => {
|
|
|
46
46
|
|
|
47
47
|
interface IStatusFilterProps {
|
|
48
48
|
sortedState: any;
|
|
49
|
-
sortItems(orderPointer: string, isAscendent: boolean):
|
|
49
|
+
sortItems(orderPointer: string, isAscendent: boolean): any;
|
|
50
50
|
isStructuredData?: boolean;
|
|
51
51
|
}
|
|
52
52
|
|
package/src/components/index.tsx
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
HeadingField,
|
|
14
14
|
HiddenField,
|
|
15
15
|
ImageField,
|
|
16
|
-
LinkField,
|
|
17
16
|
NoteField,
|
|
18
17
|
NumberField,
|
|
19
18
|
RadioField,
|
|
@@ -106,7 +105,6 @@ export {
|
|
|
106
105
|
HeadingField,
|
|
107
106
|
HiddenField,
|
|
108
107
|
ImageField,
|
|
109
|
-
LinkField,
|
|
110
108
|
NoteField,
|
|
111
109
|
NumberField,
|
|
112
110
|
RadioField,
|
|
@@ -99,10 +99,14 @@ function resetError(): ISetErrorAction {
|
|
|
99
99
|
|
|
100
100
|
function handleError(response: any): (dispatch: Dispatch) => Promise<void> {
|
|
101
101
|
return async (dispatch) => {
|
|
102
|
-
const {
|
|
102
|
+
const {
|
|
103
|
+
data: { code, message },
|
|
104
|
+
btnText,
|
|
105
|
+
actionsBelow,
|
|
106
|
+
} = response;
|
|
103
107
|
const error = {
|
|
104
|
-
code
|
|
105
|
-
text:
|
|
108
|
+
code,
|
|
109
|
+
text: message,
|
|
106
110
|
btnText,
|
|
107
111
|
actionsBelow,
|
|
108
112
|
};
|
|
@@ -26,10 +26,6 @@ import {
|
|
|
26
26
|
replaceElements,
|
|
27
27
|
findFieldsErrors,
|
|
28
28
|
getParentKey,
|
|
29
|
-
checkMaxModules,
|
|
30
|
-
checkH1content,
|
|
31
|
-
parseValidationErrors,
|
|
32
|
-
findPackagesActivationErrors,
|
|
33
29
|
} from "@ax/forms";
|
|
34
30
|
import { appActions } from "@ax/containers/App";
|
|
35
31
|
import { navigationActions } from "@ax/containers/Navigation";
|
|
@@ -54,8 +50,8 @@ import {
|
|
|
54
50
|
SET_VALIDATED,
|
|
55
51
|
SET_SITE_PAGE_ID,
|
|
56
52
|
SET_USER_EDITING,
|
|
57
|
-
SET_COPY_MODULE,
|
|
58
53
|
SET_LAST_ELEMENT_ADDED_ID,
|
|
54
|
+
SET_COPY_MODULE,
|
|
59
55
|
} from "./constants";
|
|
60
56
|
|
|
61
57
|
import {
|
|
@@ -89,11 +85,11 @@ import {
|
|
|
89
85
|
ISetSitePageID,
|
|
90
86
|
ISetUserEditing,
|
|
91
87
|
pageStatus,
|
|
92
|
-
ISetCopyModule,
|
|
93
88
|
ISetLastElementAddedId,
|
|
89
|
+
ISetCopyModule,
|
|
94
90
|
} from "./interfaces";
|
|
95
91
|
|
|
96
|
-
const { setIsLoading, setIsSaving
|
|
92
|
+
const { setIsLoading, setIsSaving } = appActions;
|
|
97
93
|
const { getSiteDefaults, getDefaults } = navigationActions;
|
|
98
94
|
|
|
99
95
|
// AUDIT: THIS FILE IS WAY TOO LONG - LOOK FOR A REFACTOR SOLUTION
|
|
@@ -171,14 +167,14 @@ function setUserEditing(userEditing: IUserEditing | null): ISetUserEditing {
|
|
|
171
167
|
return { type: SET_USER_EDITING, payload: { userEditing } };
|
|
172
168
|
}
|
|
173
169
|
|
|
174
|
-
function setCopyModule(moduleCopy: Record<string, unknown> | null): ISetCopyModule {
|
|
175
|
-
return { type: SET_COPY_MODULE, payload: { moduleCopy } };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
170
|
function setLastElementAddedId(lastElementAddedId: null | number): ISetLastElementAddedId {
|
|
179
171
|
return { type: SET_LAST_ELEMENT_ADDED_ID, payload: { lastElementAddedId } };
|
|
180
172
|
}
|
|
181
173
|
|
|
174
|
+
function setCopyModule(moduleCopy: Record<string, unknown> | null): ISetCopyModule {
|
|
175
|
+
return { type: SET_COPY_MODULE, payload: { moduleCopy } };
|
|
176
|
+
}
|
|
177
|
+
|
|
182
178
|
function setTranslatedParent(): (dispatch: Dispatch, getState: any) => void {
|
|
183
179
|
return async (dispatch, getState) => {
|
|
184
180
|
try {
|
|
@@ -201,7 +197,7 @@ function setTranslatedParent(): (dispatch: Dispatch, getState: any) => void {
|
|
|
201
197
|
const translatedParentId = translatedParent && translatedParent[0] ? translatedParent[0].pageId : null;
|
|
202
198
|
updateEditorContent(selectedEditorID, "parent", translatedParentId)(dispatch, getState);
|
|
203
199
|
},
|
|
204
|
-
handleError: (response: any) => handleError(response)(dispatch),
|
|
200
|
+
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
205
201
|
};
|
|
206
202
|
|
|
207
203
|
const callback = async () => pages.getPageLanguages(parent, site, entity);
|
|
@@ -555,29 +551,18 @@ function getPageLanguages(pageID: number, siteID: number | null, entity?: string
|
|
|
555
551
|
};
|
|
556
552
|
}
|
|
557
553
|
|
|
558
|
-
function duplicatePage(pageID: number, data: any
|
|
554
|
+
function duplicatePage(pageID: number, data: any): (dispatch: any) => Promise<void> {
|
|
559
555
|
return async (dispatch) => {
|
|
560
556
|
try {
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
},
|
|
569
|
-
handleError: (response: any) => {
|
|
570
|
-
appActions.handleError(response)(dispatch);
|
|
571
|
-
return false;
|
|
572
|
-
},
|
|
573
|
-
};
|
|
574
|
-
|
|
575
|
-
const callback = async () => pages.duplicatePage(pageID, data, siteID);
|
|
576
|
-
|
|
577
|
-
return await handleRequest(callback, responseActions, [])(dispatch);
|
|
557
|
+
const response: { status: number; data: IPage } = await pages.duplicatePage(pageID, data);
|
|
558
|
+
if (isReqOk(response.status)) {
|
|
559
|
+
dispatch(setCurrentPageID(response.data.id));
|
|
560
|
+
dispatch(setCurrentPageStatus("offline"));
|
|
561
|
+
} else {
|
|
562
|
+
console.log("Error en duplicate Page"); // FIXME: capturar errores mejor
|
|
563
|
+
}
|
|
578
564
|
} catch (e) {
|
|
579
|
-
console.log(e);
|
|
580
|
-
return false;
|
|
565
|
+
console.log(e); // FIXME: capturar errores mejor
|
|
581
566
|
}
|
|
582
567
|
};
|
|
583
568
|
}
|
|
@@ -632,13 +617,6 @@ function addModule(
|
|
|
632
617
|
): (dispatch: Dispatch, getState: any) => void {
|
|
633
618
|
return (dispatch, getState) => {
|
|
634
619
|
const { editorContent, sections, editorID } = getStateValues(getState);
|
|
635
|
-
|
|
636
|
-
const { isMaxModules, errorMessage } = checkMaxModules(editorContent, type);
|
|
637
|
-
if (isMaxModules) {
|
|
638
|
-
handleError({ text: errorMessage })(dispatch);
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
620
|
const componentModule = {
|
|
643
621
|
editorID,
|
|
644
622
|
type,
|
|
@@ -713,7 +691,7 @@ function replaceElementsInCollection(newValue: string, reference: string): (disp
|
|
|
713
691
|
|
|
714
692
|
function deleteModule(editorID: number, key?: string): (dispatch: Dispatch, getState: any) => void {
|
|
715
693
|
return (dispatch, getState) => {
|
|
716
|
-
const { sections, editorContent
|
|
694
|
+
const { sections, editorContent } = getStateValues(getState);
|
|
717
695
|
|
|
718
696
|
const updatedSections: any = [...sections];
|
|
719
697
|
const { parent, grandParent } = findByEditorID(updatedSections, editorID);
|
|
@@ -729,10 +707,6 @@ function deleteModule(editorID: number, key?: string): (dispatch: Dispatch, getS
|
|
|
729
707
|
...editorContent,
|
|
730
708
|
};
|
|
731
709
|
|
|
732
|
-
if (errors.length) {
|
|
733
|
-
validatePage()(dispatch, getState);
|
|
734
|
-
}
|
|
735
|
-
|
|
736
710
|
generatePageContent(updatedPageContent, dispatch, getState);
|
|
737
711
|
|
|
738
712
|
dispatch(setLastElementAddedId(null));
|
|
@@ -745,13 +719,6 @@ function duplicateModule(editorID: number, key?: string): (dispatch: Dispatch, g
|
|
|
745
719
|
|
|
746
720
|
const updatedSections: any = [...sections];
|
|
747
721
|
const { element: originalItem, parent, grandParent } = findByEditorID(updatedSections, editorID);
|
|
748
|
-
|
|
749
|
-
const { isMaxModules, errorMessage } = checkMaxModules(editorContent, originalItem.component);
|
|
750
|
-
if (isMaxModules) {
|
|
751
|
-
handleError({ text: errorMessage })(dispatch);
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
722
|
const parentModule = Array.isArray(parent) ? grandParent : parent;
|
|
756
723
|
|
|
757
724
|
const parentKey = key ? key : getParentKey(parentModule, editorID);
|
|
@@ -1058,52 +1025,16 @@ function getTemplateConfig(template: string): (dispatch: Dispatch, getState: any
|
|
|
1058
1025
|
};
|
|
1059
1026
|
}
|
|
1060
1027
|
|
|
1061
|
-
function validatePage(publish
|
|
1028
|
+
function validatePage(publish: boolean): (dispatch: Dispatch, getState: any) => Promise<boolean> {
|
|
1062
1029
|
return async (dispatch, getState) => {
|
|
1063
1030
|
try {
|
|
1064
1031
|
const { editorContent } = getStateValues(getState);
|
|
1065
1032
|
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
} = getState();
|
|
1070
|
-
|
|
1071
|
-
const page = getPageData(getState, false);
|
|
1072
|
-
const { values } = parseData(page, false);
|
|
1073
|
-
|
|
1074
|
-
let errors: IErrorItem[] = [];
|
|
1075
|
-
|
|
1076
|
-
const responseActions = {
|
|
1077
|
-
handleSuccess: (data: any) => {
|
|
1078
|
-
const apiErrors = parseValidationErrors(data, editorContent);
|
|
1079
|
-
errors = [...errors, ...apiErrors];
|
|
1080
|
-
},
|
|
1081
|
-
handleError: () => console.log("Error en page check"),
|
|
1082
|
-
};
|
|
1083
|
-
|
|
1084
|
-
const callback = async () => pages.pageCheck(values);
|
|
1085
|
-
|
|
1086
|
-
await handleRequest(callback, responseActions, [])(dispatch);
|
|
1087
|
-
|
|
1088
|
-
const fieldErrors = findFieldsErrors(editorContent);
|
|
1089
|
-
errors = [...errors, ...fieldErrors];
|
|
1090
|
-
const packagesActivationErrors = findPackagesActivationErrors(pageEditor, modules, templates);
|
|
1091
|
-
errors = packagesActivationErrors ? [...errors, packagesActivationErrors] : errors;
|
|
1092
|
-
|
|
1093
|
-
let warnings: IErrorItem[] = [];
|
|
1094
|
-
if (browserRef && browserRef.current) {
|
|
1095
|
-
const h1Warning = checkH1content(browserRef.current);
|
|
1096
|
-
warnings = h1Warning ? [...warnings, h1Warning] : warnings;
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
const allErrors = [...errors, ...warnings];
|
|
1100
|
-
|
|
1101
|
-
dispatch(setErrors(allErrors));
|
|
1102
|
-
if (!allErrors.length) {
|
|
1033
|
+
const errors = findFieldsErrors(editorContent);
|
|
1034
|
+
dispatch(setErrors(errors));
|
|
1035
|
+
if (errors.length === 0) {
|
|
1103
1036
|
!publish && dispatch(setValidated(true));
|
|
1104
1037
|
return true;
|
|
1105
|
-
} else if (publish && !errors.length) {
|
|
1106
|
-
return true;
|
|
1107
1038
|
} else {
|
|
1108
1039
|
dispatch(setValidated(false));
|
|
1109
1040
|
return false;
|
|
@@ -18,8 +18,8 @@ export const SET_ERRORS = `${NAME}/SET_ERRORS`;
|
|
|
18
18
|
export const SET_VALIDATED = `${NAME}/SET_VALIDATED`;
|
|
19
19
|
export const SET_SITE_PAGE_ID = `${NAME}/SET_SITE_PAGE_ID`;
|
|
20
20
|
export const SET_USER_EDITING = `${NAME}/SET_USER_EDITING`;
|
|
21
|
-
export const SET_COPY_MODULE = `${NAME}/SET_COPY_MODULE`;
|
|
22
21
|
export const SET_LAST_ELEMENT_ADDED_ID = `${NAME}/SET_LAST_ELEMENT_ADDED_ID`;
|
|
22
|
+
export const SET_COPY_MODULE = `${NAME}/SET_COPY_MODULE`;
|
|
23
23
|
|
|
24
24
|
export const INITIAL_TEMPLATE = "BasicTemplate";
|
|
25
25
|
export const MULTIMEDIA_COMPONENTS = ["LinkableImage", "Video"];
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
SET_VALIDATED,
|
|
18
18
|
SET_SITE_PAGE_ID,
|
|
19
19
|
SET_USER_EDITING,
|
|
20
|
-
SET_COPY_MODULE,
|
|
21
20
|
SET_LAST_ELEMENT_ADDED_ID,
|
|
21
|
+
SET_COPY_MODULE,
|
|
22
22
|
} from "./constants";
|
|
23
23
|
import { IBreadcrumbItem, ISchema, IPage, IErrorItem, IUserEditing } from "@ax/types";
|
|
24
24
|
|
|
@@ -112,16 +112,16 @@ export interface ISetUserEditing {
|
|
|
112
112
|
payload: { userEditing: IUserEditing | null };
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
export interface ISetCopyModule {
|
|
116
|
-
type: typeof SET_COPY_MODULE;
|
|
117
|
-
payload: { moduleCopy: Record<string, unknown> | null };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
115
|
export interface ISetLastElementAddedId {
|
|
121
116
|
type: typeof SET_LAST_ELEMENT_ADDED_ID;
|
|
122
117
|
payload: { lastElementAddedId: null | number };
|
|
123
118
|
}
|
|
124
119
|
|
|
120
|
+
export interface ISetCopyModule {
|
|
121
|
+
type: typeof SET_COPY_MODULE;
|
|
122
|
+
payload: { moduleCopy: Record<string, unknown> | null };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
125
|
export interface IFieldProps {
|
|
126
126
|
id: number;
|
|
127
127
|
key: string;
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
SET_VALIDATED,
|
|
21
21
|
SET_SITE_PAGE_ID,
|
|
22
22
|
SET_USER_EDITING,
|
|
23
|
-
SET_COPY_MODULE,
|
|
24
23
|
SET_LAST_ELEMENT_ADDED_ID,
|
|
24
|
+
SET_COPY_MODULE,
|
|
25
25
|
} from "./constants";
|
|
26
26
|
|
|
27
27
|
import { PageEditorActionsCreators } from "./interfaces";
|
|
@@ -45,8 +45,8 @@ export interface IPageEditorState {
|
|
|
45
45
|
validated: boolean;
|
|
46
46
|
sitePageID: number | null;
|
|
47
47
|
userEditing: IUserEditing | null;
|
|
48
|
-
moduleCopy: { date: string; element: Record<string, unknown> } | null;
|
|
49
48
|
lastElementAddedId: null | number;
|
|
49
|
+
moduleCopy: { date: string; element: Record<string, unknown> } | null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export const initialState = {
|
|
@@ -68,8 +68,8 @@ export const initialState = {
|
|
|
68
68
|
validated: false,
|
|
69
69
|
sitePageID: null,
|
|
70
70
|
userEditing: null,
|
|
71
|
-
moduleCopy: null,
|
|
72
71
|
lastElementAddedId: null,
|
|
72
|
+
moduleCopy: null,
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
export function reducer(state = initialState, action: PageEditorActionsCreators): IPageEditorState {
|
|
@@ -93,8 +93,8 @@ export function reducer(state = initialState, action: PageEditorActionsCreators)
|
|
|
93
93
|
case SET_VALIDATED:
|
|
94
94
|
case SET_SITE_PAGE_ID:
|
|
95
95
|
case SET_USER_EDITING:
|
|
96
|
-
case SET_COPY_MODULE:
|
|
97
96
|
case SET_LAST_ELEMENT_ADDED_ID:
|
|
97
|
+
case SET_COPY_MODULE:
|
|
98
98
|
return { ...state, ...action.payload };
|
|
99
99
|
default:
|
|
100
100
|
return state;
|
|
@@ -38,7 +38,7 @@ const getTemplateValues = (template: any) => {
|
|
|
38
38
|
|
|
39
39
|
export const getStateValues = (getState: any) => {
|
|
40
40
|
const {
|
|
41
|
-
pageEditor: { editorContent: pageContent, selectedEditorID, selectedContent, template
|
|
41
|
+
pageEditor: { editorContent: pageContent, selectedEditorID, selectedContent, template },
|
|
42
42
|
} = getState();
|
|
43
43
|
const { editorContent, header, footer } = pageContent;
|
|
44
44
|
|
|
@@ -53,7 +53,6 @@ export const getStateValues = (getState: any) => {
|
|
|
53
53
|
editorID,
|
|
54
54
|
template,
|
|
55
55
|
selectedContent,
|
|
56
|
-
errors,
|
|
57
56
|
};
|
|
58
57
|
};
|
|
59
58
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from "redux";
|
|
2
2
|
import {
|
|
3
3
|
SET_SITES,
|
|
4
|
-
SET_SITES_BY_LANG,
|
|
5
4
|
SET_CURRENT_SITE_INFO,
|
|
6
5
|
SET_CURRENT_SITE_PAGES,
|
|
7
6
|
SET_FILTER,
|
|
@@ -12,7 +11,6 @@ import {
|
|
|
12
11
|
} from "./constants";
|
|
13
12
|
import {
|
|
14
13
|
ISetSitesAction,
|
|
15
|
-
ISetSitesByLangAction,
|
|
16
14
|
ISetCurrentSiteInfoAction,
|
|
17
15
|
ISetCurrentSitePagesAction,
|
|
18
16
|
ISetFilter,
|
|
@@ -44,10 +42,6 @@ function setSites(sitesList: ISite[]): ISetSitesAction {
|
|
|
44
42
|
return { type: SET_SITES, payload: { sites: sitesList } };
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
function setSitesByLang(sitesList: ISite[]): ISetSitesByLangAction {
|
|
48
|
-
return { type: SET_SITES_BY_LANG, payload: { sitesByLang: sitesList } };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
45
|
function setCurrentSiteInfo(currentSiteInfo: ISite): ISetCurrentSiteInfoAction {
|
|
52
46
|
return { type: SET_CURRENT_SITE_INFO, payload: { currentSiteInfo } };
|
|
53
47
|
}
|
|
@@ -73,34 +67,20 @@ function setSavedSiteInfo(savedSiteInfo: ISite): ISetSavedSiteInfoAction {
|
|
|
73
67
|
}
|
|
74
68
|
|
|
75
69
|
// TODO: hay que controlar que cuando da error la API borrar los sites ya guardados y sacar el error (ver los siguientes FIXME)
|
|
76
|
-
function getSites(): (dispatch: Dispatch) => Promise<void> {
|
|
77
|
-
return async (dispatch) => {
|
|
78
|
-
try {
|
|
79
|
-
const responseActions = {
|
|
80
|
-
handleSuccess: (data: any) => dispatch(setSites(data)),
|
|
81
|
-
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
82
|
-
};
|
|
83
|
-
const callback = async () => sites.getAllSites();
|
|
84
|
-
|
|
85
|
-
await handleRequest(callback, responseActions, [])(dispatch);
|
|
86
|
-
} catch (e) {
|
|
87
|
-
console.log(e);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function getSitesByLang(language: number): (dispatch: Dispatch) => Promise<void> {
|
|
70
|
+
function getSites(token: string): (dispatch: Dispatch) => Promise<void> {
|
|
93
71
|
return async (dispatch) => {
|
|
94
72
|
try {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
73
|
+
dispatch(setIsLoading(true));
|
|
74
|
+
const sitesResponse: { status: number; data: ISite[] } = await sites.getAllSites(token); // FIXME: establecer type
|
|
75
|
+
if (isReqOk(sitesResponse.status)) {
|
|
76
|
+
dispatch(setSites(sitesResponse.data));
|
|
77
|
+
} else {
|
|
78
|
+
console.log("Error en getSites"); // TODO: capturar errores mejor
|
|
79
|
+
}
|
|
80
|
+
dispatch(setIsLoading(false));
|
|
102
81
|
} catch (e) {
|
|
103
|
-
|
|
82
|
+
dispatch(setIsLoading(false));
|
|
83
|
+
console.log(e); // TODO: capturar errores mejor
|
|
104
84
|
}
|
|
105
85
|
};
|
|
106
86
|
}
|
|
@@ -326,7 +306,10 @@ function deleteSite(siteID: number): (dispatch: Dispatch, getState: any) => Prom
|
|
|
326
306
|
try {
|
|
327
307
|
const response = await sites.deleteSite(siteID);
|
|
328
308
|
if (isReqOk(response.status)) {
|
|
329
|
-
|
|
309
|
+
const {
|
|
310
|
+
app: { token },
|
|
311
|
+
} = getState();
|
|
312
|
+
getSites(token)(dispatch);
|
|
330
313
|
}
|
|
331
314
|
} catch (e) {
|
|
332
315
|
console.log(e); // TODO: capturar error bien
|
|
@@ -339,7 +322,10 @@ function publishSite(siteID: number): (dispatch: Dispatch, getState: any) => Pro
|
|
|
339
322
|
try {
|
|
340
323
|
const response = await sites.publishSite(siteID);
|
|
341
324
|
if (isReqOk(response.status)) {
|
|
342
|
-
|
|
325
|
+
const {
|
|
326
|
+
app: { token },
|
|
327
|
+
} = getState();
|
|
328
|
+
getSites(token)(dispatch);
|
|
343
329
|
}
|
|
344
330
|
} catch (e) {
|
|
345
331
|
console.log(e); // TODO: capturar error bien
|
|
@@ -352,7 +338,10 @@ function unpublishSite(siteID: number): (dispatch: Dispatch, getState: any) => P
|
|
|
352
338
|
try {
|
|
353
339
|
const response = await sites.unpublishSite(siteID);
|
|
354
340
|
if (isReqOk(response.status)) {
|
|
355
|
-
|
|
341
|
+
const {
|
|
342
|
+
app: { token },
|
|
343
|
+
} = getState();
|
|
344
|
+
getSites(token)(dispatch);
|
|
356
345
|
}
|
|
357
346
|
} catch (e) {
|
|
358
347
|
console.log(e); // TODO: capturar error bien
|
|
@@ -475,7 +464,6 @@ export {
|
|
|
475
464
|
setTotalItems,
|
|
476
465
|
setCurrentSiteLanguages,
|
|
477
466
|
getSites,
|
|
478
|
-
getSitesByLang,
|
|
479
467
|
setSiteInfo,
|
|
480
468
|
getFilteredContent,
|
|
481
469
|
getSitePages,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export const NAME = "sites";
|
|
2
2
|
|
|
3
3
|
export const SET_SITES = `${NAME}/SET_SITES`;
|
|
4
|
-
export const SET_SITES_BY_LANG = `${NAME}/SET_SITES_BY_LANG`;
|
|
5
4
|
export const SET_CURRENT_SITE_INFO = `${NAME}/SET_CURRENT_SITE_INFO`;
|
|
6
5
|
export const SET_CURRENT_SITE_PAGES = `${NAME}/SET_CURRENT_SITE_PAGES`;
|
|
7
6
|
export const SET_FILTER: string | null = `${NAME}/SET_FILTER`;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SET_SITES,
|
|
3
|
-
SET_SITES_BY_LANG,
|
|
4
3
|
SET_CURRENT_SITE_INFO,
|
|
5
4
|
SET_CURRENT_SITE_PAGES,
|
|
6
5
|
SET_FILTER,
|
|
@@ -21,11 +20,6 @@ export interface ISetSitesAction {
|
|
|
21
20
|
payload: { sites: ISite[] };
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
export interface ISetSitesByLangAction {
|
|
25
|
-
type: typeof SET_SITES_BY_LANG;
|
|
26
|
-
payload: { sitesByLang: ISite[] };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
23
|
export interface ISetCurrentSiteInfoAction {
|
|
30
24
|
type: typeof SET_CURRENT_SITE_INFO;
|
|
31
25
|
payload: { currentSiteInfo: ISite };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SET_SITES,
|
|
3
|
-
SET_SITES_BY_LANG,
|
|
4
3
|
SET_CURRENT_SITE_INFO,
|
|
5
4
|
SET_CURRENT_SITE_PAGES,
|
|
6
5
|
SET_FILTER,
|
|
@@ -18,7 +17,6 @@ export interface ISitesState {
|
|
|
18
17
|
currentSiteName: string | null;
|
|
19
18
|
currentSitePages: IPage[];
|
|
20
19
|
sites: ISite[];
|
|
21
|
-
sitesByLang: ISite[];
|
|
22
20
|
currentSiteInfo: any;
|
|
23
21
|
currentFilter: string | null;
|
|
24
22
|
totalItems: number;
|
|
@@ -30,7 +28,6 @@ export const initialState = {
|
|
|
30
28
|
currentSiteName: null,
|
|
31
29
|
currentSitePages: [],
|
|
32
30
|
sites: [],
|
|
33
|
-
sitesByLang: [],
|
|
34
31
|
currentSiteInfo: null,
|
|
35
32
|
currentFilter: "unique-pages",
|
|
36
33
|
totalItems: 0,
|
|
@@ -42,7 +39,6 @@ export function reducer(state = initialState, action: SitesActionsCreators): ISi
|
|
|
42
39
|
switch (action.type) {
|
|
43
40
|
case SET_FILTER:
|
|
44
41
|
case SET_SITES:
|
|
45
|
-
case SET_SITES_BY_LANG:
|
|
46
42
|
case SET_CURRENT_SITE_INFO:
|
|
47
43
|
case SET_CURRENT_SITE_PAGES:
|
|
48
44
|
case SET_TOTAL_ITEMS:
|
package/src/forms/editor.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deepClone
|
|
1
|
+
import { deepClone } from "@ax/helpers";
|
|
2
2
|
import { IPage, IBreadcrumbItem } from "@ax/types";
|
|
3
3
|
|
|
4
4
|
const configKeys = ["headerConfig", "footerConfig"];
|
|
@@ -164,38 +164,6 @@ const getParentKey = (parentModule: any, editorID: number) => {
|
|
|
164
164
|
return keyFound;
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
-
const checkMaxModules = (content: any, type: string): { isMaxModules: boolean; errorMessage?: string } => {
|
|
168
|
-
const { maxModulesPerPage } = getSchema(type);
|
|
169
|
-
const queue: any[] = [content];
|
|
170
|
-
let counter = 0;
|
|
171
|
-
|
|
172
|
-
while (queue.length > 0 && counter < maxModulesPerPage) {
|
|
173
|
-
const obj = queue.shift();
|
|
174
|
-
const currentObj = obj;
|
|
175
|
-
|
|
176
|
-
if (currentObj.component === type) {
|
|
177
|
-
counter++;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const keys = currentObj instanceof Object ? Object.keys(currentObj) : [];
|
|
181
|
-
|
|
182
|
-
for (const key of keys) {
|
|
183
|
-
const objVal = currentObj[key];
|
|
184
|
-
if (objVal instanceof Object) {
|
|
185
|
-
queue.push(objVal);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const isMaxModules = counter >= maxModulesPerPage;
|
|
191
|
-
const errorMessage = `There can be only ${maxModulesPerPage} ${type} on page. You already have it.`;
|
|
192
|
-
|
|
193
|
-
return {
|
|
194
|
-
isMaxModules,
|
|
195
|
-
...(isMaxModules && { errorMessage }),
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
|
|
199
167
|
export {
|
|
200
168
|
parseData,
|
|
201
169
|
cleanContent,
|
|
@@ -209,5 +177,4 @@ export {
|
|
|
209
177
|
getLastModuleEditorID,
|
|
210
178
|
getLastComponentEditorID,
|
|
211
179
|
getParentKey,
|
|
212
|
-
checkMaxModules,
|
|
213
180
|
};
|
package/src/forms/errors.tsx
CHANGED
|
@@ -40,7 +40,6 @@ const ERRORS: Record<string, string> = {
|
|
|
40
40
|
ERR039: "Sorry, this color doesn't exist. Please add new one.",
|
|
41
41
|
ERR040: "Sorry, the file is not in a valid format.",
|
|
42
42
|
ERR041: "Sorry, the password doesn’t match.",
|
|
43
|
-
ERR042: "This content is part of disabled content type package. To publish it, you must first activate it."
|
|
44
43
|
};
|
|
45
44
|
|
|
46
45
|
export { ERRORS };
|
package/src/forms/index.tsx
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
getLastModuleEditorID,
|
|
11
11
|
getLastComponentEditorID,
|
|
12
12
|
getParentKey,
|
|
13
|
-
checkMaxModules,
|
|
14
13
|
} from "./editor";
|
|
15
14
|
import {
|
|
16
15
|
getUpdatedComponents,
|
|
@@ -24,15 +23,7 @@ import {
|
|
|
24
23
|
replaceElements,
|
|
25
24
|
} from "./elements";
|
|
26
25
|
import { getInnerFields, getStructuredDataInnerFields } from "./fields";
|
|
27
|
-
import {
|
|
28
|
-
getValidity,
|
|
29
|
-
findPackagesActivationErrors,
|
|
30
|
-
findFieldsErrors,
|
|
31
|
-
isTemplateActivated,
|
|
32
|
-
findMandatoryStructuredDataErrors,
|
|
33
|
-
checkH1content,
|
|
34
|
-
parseValidationErrors,
|
|
35
|
-
} from "./validators";
|
|
26
|
+
import { getValidity, findFieldsErrors, findMandatoryStructuredDataErrors } from "./validators";
|
|
36
27
|
|
|
37
28
|
export {
|
|
38
29
|
parseData,
|
|
@@ -58,11 +49,6 @@ export {
|
|
|
58
49
|
getLastComponentEditorID,
|
|
59
50
|
getParentKey,
|
|
60
51
|
getValidity,
|
|
61
|
-
findPackagesActivationErrors,
|
|
62
52
|
findFieldsErrors,
|
|
63
|
-
isTemplateActivated,
|
|
64
53
|
findMandatoryStructuredDataErrors,
|
|
65
|
-
checkMaxModules,
|
|
66
|
-
checkH1content,
|
|
67
|
-
parseValidationErrors,
|
|
68
54
|
};
|