@griddo/ax 1.72.11 → 1.73.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.
- package/package.json +2 -2
- package/scripts/griddo-sync-schemas.js +1 -1
- package/src/__tests__/components/ErrorCenter/ErrorCenter.test.tsx +186 -0
- package/src/__tests__/components/Flag/Flag.test.tsx +60 -0
- package/src/__tests__/components/FloatingMenu/FloatingMenu.test.tsx +712 -0
- package/src/__tests__/components/FloatingPanel/FloatingPanel.test.tsx +149 -0
- package/src/__tests__/components/GuardModal/GuardModal.test.tsx +31 -0
- package/src/__tests__/components/Icon/Icon.test.tsx +76 -0
- package/src/__tests__/components/IconAction/IconAction.test.tsx +91 -0
- package/src/__tests__/components/Notification/Notification.test.tsx +206 -0
- package/src/__tests__/components/Notification/SubNotification/Subnotification.test.tsx +46 -0
- package/src/__tests__/components/ReorderArrows/ReorderArrows.test.tsx +96 -0
- package/src/__tests__/components/ResizePanel/ResizePanel.test.tsx +200 -0
- package/src/__tests__/components/SearchField/SearchField.test.tsx +375 -0
- package/src/api/analytics.tsx +4 -4
- package/src/components/ActionMenu/style.tsx +1 -0
- package/src/components/ConfigPanel/Form/ConnectedField/NavConnectedField/index.tsx +1 -1
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +2 -1
- package/src/components/ConfigPanel/Form/index.tsx +22 -1
- package/src/components/ConfigPanel/Form/style.tsx +19 -0
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +22 -3
- package/src/components/ConfigPanel/GlobalPageForm/style.tsx +18 -2
- package/src/components/ConfigPanel/NavigationForm/Field/index.tsx +25 -13
- package/src/components/ConfigPanel/index.tsx +8 -0
- package/src/components/ErrorCenter/index.tsx +8 -4
- package/src/components/Fields/DateField/DatePickerInput/index.tsx +30 -8
- package/src/components/Fields/DateField/index.tsx +8 -2
- package/src/components/Fields/Select/index.tsx +1 -0
- package/src/components/Flag/index.tsx +13 -11
- package/src/components/FloatingMenu/index.tsx +23 -7
- package/src/components/FloatingMenu/style.tsx +1 -0
- package/src/components/FloatingPanel/index.tsx +9 -3
- package/src/components/GuardModal/index.tsx +3 -3
- package/src/components/Icon/index.tsx +2 -1
- package/src/components/IconAction/index.tsx +3 -3
- package/src/components/MainWrapper/AppBar/index.tsx +3 -1
- package/src/components/MainWrapper/AppBar/style.tsx +3 -0
- package/src/components/MenuItem/index.tsx +1 -1
- package/src/components/Modal/index.tsx +1 -1
- package/src/components/Notification/SubNotification/index.tsx +33 -0
- package/src/components/Notification/SubNotification/style.tsx +49 -0
- package/src/components/Notification/index.tsx +31 -17
- package/src/components/Notification/style.tsx +33 -8
- package/src/components/ReorderArrows/index.tsx +3 -3
- package/src/components/ResizePanel/ResizeHandle/index.tsx +29 -38
- package/src/components/ResizePanel/index.tsx +13 -15
- package/src/components/SearchField/index.tsx +9 -8
- package/src/containers/Analytics/actions.tsx +14 -4
- package/src/containers/App/actions.tsx +18 -6
- package/src/containers/App/reducer.tsx +1 -0
- package/src/containers/Domains/actions.tsx +8 -1
- package/src/containers/Navigation/Defaults/actions.tsx +16 -2
- package/src/containers/PageEditor/actions.tsx +82 -6
- package/src/containers/PageEditor/utils.tsx +28 -10
- package/src/containers/Redirects/actions.tsx +16 -2
- package/src/containers/Sites/actions.tsx +80 -3
- package/src/containers/StructuredData/actions.tsx +24 -3
- package/src/containers/Users/actions.tsx +8 -1
- package/src/forms/errors.tsx +1 -0
- package/src/forms/fields.tsx +6 -3
- package/src/forms/validators.tsx +14 -4
- package/src/guards/error/index.tsx +17 -21
- package/src/helpers/dates.tsx +2 -0
- package/src/helpers/index.tsx +2 -0
- package/src/hooks/modals.tsx +4 -4
- package/src/modules/Content/OptionTable/index.tsx +20 -7
- package/src/modules/Content/index.tsx +4 -7
- package/src/modules/Content/utils.tsx +18 -13
- package/src/modules/FramePreview/index.tsx +39 -12
- package/src/modules/GlobalEditor/index.tsx +17 -20
- package/src/modules/Navigation/Menus/List/Table/index.tsx +2 -2
- package/src/modules/PageEditor/Editor/index.tsx +13 -0
- package/src/modules/PageEditor/index.tsx +17 -20
- package/src/modules/Redirects/RedirectItem/index.tsx +17 -3
- package/src/modules/Settings/ContentTypes/DataPacks/Item/index.tsx +1 -1
- package/src/modules/StructuredData/Form/index.tsx +10 -13
|
@@ -35,7 +35,7 @@ import { appActions } from "@ax/containers/App";
|
|
|
35
35
|
import { navigationActions } from "@ax/containers/Navigation";
|
|
36
36
|
import { setCurrentSiteErrorPages } from "@ax/containers/Sites/actions";
|
|
37
37
|
import { pages, sites, structuredData } from "@ax/api";
|
|
38
|
-
import { getPageData, getPageNavigation, getStateValues } from "./utils";
|
|
38
|
+
import { getDefaultPageNavigation, getPageData, getPageNavigation, getStateValues } from "./utils";
|
|
39
39
|
import {
|
|
40
40
|
SET_BREADCRUMB,
|
|
41
41
|
SET_SCHEMA,
|
|
@@ -485,7 +485,14 @@ function deleteBulk(ids: any): (dispatch: Dispatch) => Promise<boolean> {
|
|
|
485
485
|
try {
|
|
486
486
|
const responseActions = {
|
|
487
487
|
handleSuccess: () => true,
|
|
488
|
-
handleError: (response: any) =>
|
|
488
|
+
handleError: (response: any) => {
|
|
489
|
+
const {
|
|
490
|
+
data: { message },
|
|
491
|
+
} = response;
|
|
492
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
493
|
+
const msg = isMultiple ? `The delete action failed due to ${message.length} errors.` : undefined;
|
|
494
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
495
|
+
},
|
|
489
496
|
};
|
|
490
497
|
|
|
491
498
|
const callback = async () => pages.bulkDelete(ids);
|
|
@@ -503,7 +510,14 @@ function restorePage(id: number | number[]): (dispatch: Dispatch) => Promise<boo
|
|
|
503
510
|
try {
|
|
504
511
|
const responseActions = {
|
|
505
512
|
handleSuccess: () => true,
|
|
506
|
-
handleError: (response: any) =>
|
|
513
|
+
handleError: (response: any) => {
|
|
514
|
+
const {
|
|
515
|
+
data: { message },
|
|
516
|
+
} = response;
|
|
517
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
518
|
+
const msg = isMultiple ? `The restore action failed due to ${message.length} errors.` : undefined;
|
|
519
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
520
|
+
},
|
|
507
521
|
};
|
|
508
522
|
|
|
509
523
|
const callback = async () => (Array.isArray(id) ? pages.bulkRestore(id) : pages.restorePage(id));
|
|
@@ -919,11 +933,16 @@ function generatePageContent(editorContent: IPage, dispatch: Dispatch, getState:
|
|
|
919
933
|
navigation: { currentDefaultsContent },
|
|
920
934
|
dataPacks: { configFormData },
|
|
921
935
|
} = getState();
|
|
922
|
-
|
|
936
|
+
|
|
937
|
+
const { header: headerID, footer: footerID, isGlobal } = editorContent;
|
|
923
938
|
const { defaultHeader, defaultFooter } = (configFormData.templates && configFormData.templates[template]) || {};
|
|
939
|
+
|
|
940
|
+
const header = headerID === null ? defaultHeader : headerID;
|
|
941
|
+
const footer = footerID === null ? defaultFooter : footerID;
|
|
942
|
+
|
|
924
943
|
const { header: pageHeader, footer: pageFooter } = getPageNavigation(
|
|
925
|
-
header
|
|
926
|
-
footer
|
|
944
|
+
header,
|
|
945
|
+
footer,
|
|
927
946
|
currentDefaultsContent,
|
|
928
947
|
isGlobal
|
|
929
948
|
);
|
|
@@ -972,6 +991,15 @@ function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: an
|
|
|
972
991
|
by DCX
|
|
973
992
|
*/
|
|
974
993
|
|
|
994
|
+
const iframe = document.querySelector("iframe");
|
|
995
|
+
iframe?.contentWindow?.postMessage(
|
|
996
|
+
{
|
|
997
|
+
type: "selected-content",
|
|
998
|
+
message: editorID,
|
|
999
|
+
},
|
|
1000
|
+
"*"
|
|
1001
|
+
);
|
|
1002
|
+
|
|
975
1003
|
localStorage.setItem("selectedID", `${editorID}`);
|
|
976
1004
|
|
|
977
1005
|
dispatch(setIsLoading(true));
|
|
@@ -1252,6 +1280,52 @@ function discardDraft(): (dispatch: Dispatch, getState: any) => Promise<void> {
|
|
|
1252
1280
|
};
|
|
1253
1281
|
}
|
|
1254
1282
|
|
|
1283
|
+
function removeNavigationFromPage(key: string): (dispatch: Dispatch, getState: any) => void {
|
|
1284
|
+
return (dispatch, getState) => {
|
|
1285
|
+
const {
|
|
1286
|
+
pageEditor: { editorContent },
|
|
1287
|
+
} = getState();
|
|
1288
|
+
|
|
1289
|
+
const updatedEditorContent = {
|
|
1290
|
+
...editorContent,
|
|
1291
|
+
editorContent: { ...editorContent.editorContent, [key]: 0 },
|
|
1292
|
+
[key]: null,
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1295
|
+
setSelectedContent(0)(dispatch, getState);
|
|
1296
|
+
dispatch(setEditorContent(updatedEditorContent));
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
function restorePageNavigation(key: string): (dispatch: Dispatch, getState: any) => void {
|
|
1301
|
+
return (dispatch, getState) => {
|
|
1302
|
+
const {
|
|
1303
|
+
pageEditor: { editorContent },
|
|
1304
|
+
navigation: { currentDefaultsContent },
|
|
1305
|
+
} = getState();
|
|
1306
|
+
|
|
1307
|
+
const { header, footer } = editorContent;
|
|
1308
|
+
|
|
1309
|
+
const navigation = getDefaultPageNavigation(currentDefaultsContent, key);
|
|
1310
|
+
|
|
1311
|
+
const pageHeader = key === "header" ? navigation : header;
|
|
1312
|
+
const pageFooter = key === "footer" ? navigation : footer;
|
|
1313
|
+
|
|
1314
|
+
const updatedEditorContent = {
|
|
1315
|
+
...editorContent,
|
|
1316
|
+
editorContent: { ...editorContent.editorContent, [key]: navigation.id },
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
const { pageContent } = generateEditorIDs({
|
|
1320
|
+
editorContent: updatedEditorContent.editorContent,
|
|
1321
|
+
header: pageHeader,
|
|
1322
|
+
footer: pageFooter,
|
|
1323
|
+
});
|
|
1324
|
+
|
|
1325
|
+
dispatch(setEditorContent(pageContent));
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1255
1329
|
export {
|
|
1256
1330
|
setEditorContent,
|
|
1257
1331
|
setTemplate,
|
|
@@ -1298,4 +1372,6 @@ export {
|
|
|
1298
1372
|
getTemplatePage,
|
|
1299
1373
|
copyModule,
|
|
1300
1374
|
pasteModule,
|
|
1375
|
+
removeNavigationFromPage,
|
|
1376
|
+
restorePageNavigation,
|
|
1301
1377
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ISavePageParams } from "@ax/types";
|
|
2
2
|
import { cleanContent } from "@ax/forms";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const getPageParams = (getState: any): ISavePageParams => {
|
|
5
5
|
const {
|
|
6
6
|
sites: { currentSiteInfo },
|
|
7
7
|
pageEditor: { editorContent },
|
|
@@ -12,7 +12,7 @@ export const getPageParams = (getState: any): ISavePageParams => {
|
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const getPageData = (getState: any, deleted: boolean, params = getPageParams(getState)) => {
|
|
16
16
|
const { site, page } = params;
|
|
17
17
|
const siteID = site ? site.id : null;
|
|
18
18
|
const updatedPageContent = { ...page, site: siteID };
|
|
@@ -36,7 +36,7 @@ const getTemplateValues = (template: any) => {
|
|
|
36
36
|
return sections;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
const getStateValues = (getState: any) => {
|
|
40
40
|
const {
|
|
41
41
|
pageEditor: { editorContent: pageContent, selectedEditorID, selectedContent, template, errors },
|
|
42
42
|
} = getState();
|
|
@@ -57,7 +57,7 @@ export const getStateValues = (getState: any) => {
|
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
const getPageNavigation = (
|
|
61
61
|
headerID: number | null,
|
|
62
62
|
footerID: number | null,
|
|
63
63
|
defaultsContent: any,
|
|
@@ -69,12 +69,30 @@ export const getPageNavigation = (
|
|
|
69
69
|
|
|
70
70
|
const headers: any = defaultsContent.filter((content: any) => content.type === "header");
|
|
71
71
|
const footers: any = defaultsContent.filter((content: any) => content.type === "footer");
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
|
|
73
|
+
const header =
|
|
74
|
+
headerID === 0
|
|
75
|
+
? null
|
|
76
|
+
: headerID === undefined || headerID === null
|
|
77
|
+
? headers.find((content: any) => content.setAsDefault)
|
|
78
|
+
: headers.find((content: any) => content.id === headerID);
|
|
79
|
+
|
|
80
|
+
const footer =
|
|
81
|
+
footerID === 0
|
|
82
|
+
? null
|
|
83
|
+
: footerID === undefined || footerID === null
|
|
84
|
+
? footers.find((content: any) => content.setAsDefault)
|
|
85
|
+
: footers.find((content: any) => content.id === footerID);
|
|
78
86
|
|
|
79
87
|
return { header, footer };
|
|
80
88
|
};
|
|
89
|
+
|
|
90
|
+
const getDefaultPageNavigation = (defaultsContent: any, type: string) => {
|
|
91
|
+
const navigations: any = defaultsContent.filter((content: any) => content.type === type);
|
|
92
|
+
|
|
93
|
+
const navitagion = navigations.find((content: any) => content.setAsDefault);
|
|
94
|
+
|
|
95
|
+
return navitagion;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { getPageParams, getPageData, getStateValues, getPageNavigation, getDefaultPageNavigation };
|
|
@@ -130,7 +130,14 @@ function deleteRedirect(
|
|
|
130
130
|
const siteFilterQuery = currentSiteInfo && currentSiteInfo.id ? `&sites=${currentSiteInfo.id}` : filter;
|
|
131
131
|
dispatch(getRedirects(params, siteFilterQuery));
|
|
132
132
|
},
|
|
133
|
-
handleError: (response: any) =>
|
|
133
|
+
handleError: (response: any) => {
|
|
134
|
+
const {
|
|
135
|
+
data: { message },
|
|
136
|
+
} = response;
|
|
137
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
138
|
+
const msg = isMultiple ? `The delete action failed due to ${message.length} errors.` : undefined;
|
|
139
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
140
|
+
},
|
|
134
141
|
};
|
|
135
142
|
|
|
136
143
|
return await handleRequest(callback, responseActions, [])(dispatch);
|
|
@@ -161,7 +168,14 @@ function importRedirects(
|
|
|
161
168
|
dispatch(getRedirects(params));
|
|
162
169
|
}
|
|
163
170
|
},
|
|
164
|
-
handleError: (response: any) =>
|
|
171
|
+
handleError: (response: any) => {
|
|
172
|
+
const {
|
|
173
|
+
data: { message },
|
|
174
|
+
} = response;
|
|
175
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
176
|
+
const msg = isMultiple ? `The import action failed due to ${message.length} errors.` : undefined;
|
|
177
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
178
|
+
},
|
|
165
179
|
};
|
|
166
180
|
|
|
167
181
|
return await handleRequest(callback, responseActions, [])(dispatch);
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from "./interfaces";
|
|
27
27
|
|
|
28
28
|
import { ISite, IGetSitePagesParams, ISettingsForm, IGetGlobalPagesParams, IPage } from "@ax/types";
|
|
29
|
-
import { sites, languages, dataPack, social, structuredData, analytics } from "@ax/api";
|
|
29
|
+
import { sites, languages, dataPack, social, structuredData, analytics, pages } from "@ax/api";
|
|
30
30
|
import { appActions } from "@ax/containers/App";
|
|
31
31
|
import { structuredDataActions } from "@ax/containers/StructuredData";
|
|
32
32
|
import { navigationActions, menuActions } from "@ax/containers/Navigation";
|
|
@@ -411,7 +411,14 @@ function importPageFromGlobal(pageID: number | number[]): (dispatch: any, getSta
|
|
|
411
411
|
const filter = currentFilter === "unique-pages" ? null : currentFilter;
|
|
412
412
|
getSitePages(params, filter)(dispatch);
|
|
413
413
|
},
|
|
414
|
-
handleError: (response: any) =>
|
|
414
|
+
handleError: (response: any) => {
|
|
415
|
+
const {
|
|
416
|
+
data: { message },
|
|
417
|
+
} = response;
|
|
418
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
419
|
+
const msg = isMultiple ? `The import action failed due to ${message.length} errors.` : undefined;
|
|
420
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
421
|
+
},
|
|
415
422
|
};
|
|
416
423
|
|
|
417
424
|
const callback = async () =>
|
|
@@ -463,7 +470,14 @@ function removePageFromSite(
|
|
|
463
470
|
getSitePages(params, filter)(dispatch);
|
|
464
471
|
}
|
|
465
472
|
},
|
|
466
|
-
handleError: (response: any) =>
|
|
473
|
+
handleError: (response: any) => {
|
|
474
|
+
const {
|
|
475
|
+
data: { message },
|
|
476
|
+
} = response;
|
|
477
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
478
|
+
const msg = isMultiple ? `The delete action failed due to ${message.length} errors.` : undefined;
|
|
479
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
480
|
+
},
|
|
467
481
|
};
|
|
468
482
|
|
|
469
483
|
const callback = async () =>
|
|
@@ -479,6 +493,68 @@ function removePageFromSite(
|
|
|
479
493
|
};
|
|
480
494
|
}
|
|
481
495
|
|
|
496
|
+
function deleteAndRemoveFromSiteBulk(
|
|
497
|
+
pageIds: number[],
|
|
498
|
+
globalPageIds: number[]
|
|
499
|
+
): (dispatch: Dispatch, getState: any) => Promise<boolean> {
|
|
500
|
+
return async (dispatch, getState) => {
|
|
501
|
+
try {
|
|
502
|
+
const {
|
|
503
|
+
sites: { currentSiteInfo },
|
|
504
|
+
} = getState();
|
|
505
|
+
|
|
506
|
+
let responseErrorPages: any = { data: { code: null, message: [] } };
|
|
507
|
+
|
|
508
|
+
const responsePageActions = {
|
|
509
|
+
handleSuccess: () => true,
|
|
510
|
+
handleError: (response: any) => {
|
|
511
|
+
responseErrorPages = response;
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
const getMessageErrors = () => {
|
|
516
|
+
const {
|
|
517
|
+
data: { message },
|
|
518
|
+
} = responseErrorPages;
|
|
519
|
+
|
|
520
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
521
|
+
const msg = isMultiple ? `The delete action failed due to ${message.length} errors.` : undefined;
|
|
522
|
+
appActions.handleError(responseErrorPages, isMultiple, msg)(dispatch);
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
const responseGlobalPageActions = {
|
|
526
|
+
handleSuccess: () => {
|
|
527
|
+
if (responseErrorPages.data.message.length > 0) {
|
|
528
|
+
getMessageErrors();
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
handleError: (response: any) => {
|
|
532
|
+
responseErrorPages = {
|
|
533
|
+
...responseErrorPages,
|
|
534
|
+
data: {
|
|
535
|
+
code: responseErrorPages.data.code || response.data.code,
|
|
536
|
+
message: [...responseErrorPages.data.message, ...response.data.message],
|
|
537
|
+
},
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
getMessageErrors();
|
|
541
|
+
},
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
const callbackPages = async () => pages.bulkDelete(pageIds);
|
|
545
|
+
const callbackGlobalPages = async () => sites.removePageBulk(currentSiteInfo.id, globalPageIds);
|
|
546
|
+
|
|
547
|
+
const resultPages = await handleRequest(callbackPages, responsePageActions, [])(dispatch);
|
|
548
|
+
const resultGlobalPages = await handleRequest(callbackGlobalPages, responseGlobalPageActions, [])(dispatch);
|
|
549
|
+
|
|
550
|
+
return resultPages && resultGlobalPages;
|
|
551
|
+
} catch (e) {
|
|
552
|
+
console.log(e);
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
|
|
482
558
|
function resetCurrentSiteErrorPages(): (dispatch: Dispatch) => Promise<void> {
|
|
483
559
|
return async (dispatch) => {
|
|
484
560
|
try {
|
|
@@ -514,4 +590,5 @@ export {
|
|
|
514
590
|
setCurrentSiteErrorPages,
|
|
515
591
|
resetCurrentSiteErrorPages,
|
|
516
592
|
setContentFilters,
|
|
593
|
+
deleteAndRemoveFromSiteBulk,
|
|
517
594
|
};
|
|
@@ -385,7 +385,14 @@ function deleteStructuredDataContent(id: number | number[]): (dispatch: Dispatch
|
|
|
385
385
|
|
|
386
386
|
const responseActions = {
|
|
387
387
|
handleSuccess: () => getStructuredDataContents(params, siteID)(dispatch, getState),
|
|
388
|
-
handleError: (response: any) =>
|
|
388
|
+
handleError: (response: any) => {
|
|
389
|
+
const {
|
|
390
|
+
data: { message },
|
|
391
|
+
} = response;
|
|
392
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
393
|
+
const msg = isMultiple ? `The delete action failed due to ${message.length} errors.` : undefined;
|
|
394
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
395
|
+
},
|
|
389
396
|
};
|
|
390
397
|
|
|
391
398
|
const callback = async () =>
|
|
@@ -415,7 +422,14 @@ function restoreStructuredDataContent(dataID: number | number[]): (dispatch: Dis
|
|
|
415
422
|
|
|
416
423
|
const responseActions = {
|
|
417
424
|
handleSuccess: () => getStructuredDataContents(params, siteID)(dispatch, getState),
|
|
418
|
-
handleError: (response: any) =>
|
|
425
|
+
handleError: (response: any) => {
|
|
426
|
+
const {
|
|
427
|
+
data: { message },
|
|
428
|
+
} = response;
|
|
429
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
430
|
+
const msg = isMultiple ? `The restore action failed due to ${message.length} errors.` : undefined;
|
|
431
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
432
|
+
},
|
|
419
433
|
};
|
|
420
434
|
|
|
421
435
|
const callback = async () =>
|
|
@@ -483,7 +497,14 @@ function setStatusStructuredDataContent(
|
|
|
483
497
|
|
|
484
498
|
const responseActions = {
|
|
485
499
|
handleSuccess: () => getStructuredDataContents(params, siteID)(dispatch, getState),
|
|
486
|
-
handleError: (response: any) =>
|
|
500
|
+
handleError: (response: any) => {
|
|
501
|
+
const {
|
|
502
|
+
data: { message },
|
|
503
|
+
} = response;
|
|
504
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
505
|
+
const msg = isMultiple ? `The action failed due to ${message.length} errors.` : undefined;
|
|
506
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
507
|
+
},
|
|
487
508
|
};
|
|
488
509
|
|
|
489
510
|
const callback = async () =>
|
|
@@ -137,7 +137,14 @@ function deleteUser(id: number | number[]): (dispatch: Dispatch) => Promise<bool
|
|
|
137
137
|
|
|
138
138
|
const responseActions = {
|
|
139
139
|
handleSuccess: () => getUsers(params)(dispatch),
|
|
140
|
-
handleError: (response: any) =>
|
|
140
|
+
handleError: (response: any) => {
|
|
141
|
+
const {
|
|
142
|
+
data: { message },
|
|
143
|
+
} = response;
|
|
144
|
+
const isMultiple = Array.isArray(message) && message.length > 1;
|
|
145
|
+
const msg = isMultiple ? `The delete action failed due to ${message.length} errors.` : undefined;
|
|
146
|
+
appActions.handleError(response, isMultiple, msg)(dispatch);
|
|
147
|
+
},
|
|
141
148
|
};
|
|
142
149
|
|
|
143
150
|
const callback = async () => (Array.isArray(id) ? users.deleteUserBulk(id) : users.deleteUser(id));
|
package/src/forms/errors.tsx
CHANGED
|
@@ -41,6 +41,7 @@ const ERRORS: Record<string, string> = {
|
|
|
41
41
|
ERR040: "Sorry, the file is not in a valid format.",
|
|
42
42
|
ERR041: "Sorry, the password doesn’t match.",
|
|
43
43
|
ERR042: "This content is part of disabled content type package. To publish it, you must first activate it.",
|
|
44
|
+
ERR043: "Please, enter a valid date.",
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
export { ERRORS };
|
package/src/forms/fields.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FieldContainer, FieldsBehavior } from "@ax/components";
|
|
3
|
-
import { IErrorItem, IPage } from "@ax/types";
|
|
3
|
+
import { IErrorItem, IPage, ISite } from "@ax/types";
|
|
4
4
|
|
|
5
5
|
const getInnerFields = (
|
|
6
6
|
innerFields: any[],
|
|
@@ -8,8 +8,9 @@ const getInnerFields = (
|
|
|
8
8
|
selectedContent: IPage,
|
|
9
9
|
isTemplateActivated: boolean,
|
|
10
10
|
theme: string,
|
|
11
|
+
site?: ISite,
|
|
11
12
|
errors?: IErrorItem[],
|
|
12
|
-
deleteError?: (error: IErrorItem) => void
|
|
13
|
+
deleteError?: (error: IErrorItem) => void,
|
|
13
14
|
) => {
|
|
14
15
|
let fieldArr: any[] = [];
|
|
15
16
|
|
|
@@ -26,8 +27,9 @@ const getInnerFields = (
|
|
|
26
27
|
selectedContent,
|
|
27
28
|
isTemplateActivated,
|
|
28
29
|
theme,
|
|
30
|
+
site,
|
|
29
31
|
errors,
|
|
30
|
-
deleteError
|
|
32
|
+
deleteError,
|
|
31
33
|
);
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -41,6 +43,7 @@ const getInnerFields = (
|
|
|
41
43
|
selectedContent={selectedContent}
|
|
42
44
|
updateValue={innerActions.updateValue}
|
|
43
45
|
goTo={innerActions.goTo}
|
|
46
|
+
site={site}
|
|
44
47
|
{...singleFieldProps}
|
|
45
48
|
disabled={!isTemplateActivated || singleFieldProps.disabled}
|
|
46
49
|
error={error}
|
package/src/forms/validators.tsx
CHANGED
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
isComponentEmpty,
|
|
9
9
|
isEmptyContainer,
|
|
10
10
|
isModuleDisabled,
|
|
11
|
+
getRange,
|
|
12
|
+
isValidDate,
|
|
13
|
+
isValidDateRange,
|
|
14
|
+
stringToDate,
|
|
11
15
|
} from "@ax/helpers";
|
|
16
|
+
|
|
12
17
|
import { findByEditorID } from "@ax/forms";
|
|
13
18
|
import { IErrorItem, ITemplate } from "@ax/types";
|
|
14
19
|
import { ERRORS } from "./errors";
|
|
@@ -37,7 +42,7 @@ const VALIDATORS = {
|
|
|
37
42
|
return { isValid, errorCode: "ERR008" };
|
|
38
43
|
},
|
|
39
44
|
format: (val: string, type: string): IError => {
|
|
40
|
-
if (!val || val.trim().length === 0) {
|
|
45
|
+
if (!val || (typeof val === "string" && val.trim().length === 0)) {
|
|
41
46
|
return { isValid: true, errorCode: "" };
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -79,6 +84,11 @@ const VALIDATORS = {
|
|
|
79
84
|
const isValid = re.test(val);
|
|
80
85
|
return { isValid, errorCode: "ERR007" };
|
|
81
86
|
}
|
|
87
|
+
case "date": {
|
|
88
|
+
const range = getRange(val);
|
|
89
|
+
const isValid = range.length === 2 ? isValidDateRange(val) : isValidDate(val);
|
|
90
|
+
return { isValid, errorCode: "ERR043" };
|
|
91
|
+
}
|
|
82
92
|
default:
|
|
83
93
|
return { isValid: true, errorCode: "" };
|
|
84
94
|
}
|
|
@@ -93,14 +103,14 @@ const VALIDATORS = {
|
|
|
93
103
|
return { isValid: true, errorCode: "" };
|
|
94
104
|
}
|
|
95
105
|
const now = new Date();
|
|
96
|
-
const date =
|
|
106
|
+
const date = stringToDate(val);
|
|
97
107
|
switch (type) {
|
|
98
108
|
case "futureDate": {
|
|
99
|
-
const isValid = dateToString(date) >= dateToString(now);
|
|
109
|
+
const isValid = isValidDate(val) && dateToString(date) >= dateToString(now);
|
|
100
110
|
return { isValid, errorCode: "ERR010" };
|
|
101
111
|
}
|
|
102
112
|
case "pastDate": {
|
|
103
|
-
const isValid = dateToString(date) <= dateToString(now);
|
|
113
|
+
const isValid = isValidDate(val) && dateToString(date) <= dateToString(now);
|
|
104
114
|
return { isValid, errorCode: "ERR011" };
|
|
105
115
|
}
|
|
106
116
|
default:
|
|
@@ -19,7 +19,7 @@ const ErrorView = (props: any) => {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const ErrorGuard = (props: IProps) => {
|
|
22
|
-
const { text, code, resetError, btnText, actionsBelow } = props;
|
|
22
|
+
const { text, code, resetError, btnText, actionsBelow, subErrors } = props;
|
|
23
23
|
|
|
24
24
|
const isBlocking = blockingErrors.includes(code);
|
|
25
25
|
|
|
@@ -28,26 +28,20 @@ const ErrorGuard = (props: IProps) => {
|
|
|
28
28
|
const lastErrorElement = errorElements.length - 1;
|
|
29
29
|
const domNode = errorElements[lastErrorElement] || document.getElementById("default-error");
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
))}
|
|
45
|
-
</>
|
|
46
|
-
) : (
|
|
47
|
-
<Notification resetError={resetError} text={text} type="error" btnText={btnText} actionsBelow={actionsBelow} />
|
|
31
|
+
return (
|
|
32
|
+
domNode &&
|
|
33
|
+
createPortal(
|
|
34
|
+
<Notification
|
|
35
|
+
resetError={resetError}
|
|
36
|
+
text={text}
|
|
37
|
+
type="error"
|
|
38
|
+
btnText={btnText}
|
|
39
|
+
actionsBelow={actionsBelow}
|
|
40
|
+
subErrors={subErrors}
|
|
41
|
+
/>,
|
|
42
|
+
domNode
|
|
43
|
+
)
|
|
48
44
|
);
|
|
49
|
-
|
|
50
|
-
return domNode && createPortal(Notifications, domNode);
|
|
51
45
|
};
|
|
52
46
|
|
|
53
47
|
return code || text ? isBlocking ? <ErrorView code={code} text={text} /> : createErrorNotification() : null;
|
|
@@ -56,7 +50,7 @@ const ErrorGuard = (props: IProps) => {
|
|
|
56
50
|
const mapStateToProps = (state: IRootState) => {
|
|
57
51
|
const {
|
|
58
52
|
app: {
|
|
59
|
-
error: { code, text, btnText, actionsBelow },
|
|
53
|
+
error: { code, text, btnText, actionsBelow, subErrors },
|
|
60
54
|
},
|
|
61
55
|
} = state;
|
|
62
56
|
return {
|
|
@@ -64,6 +58,7 @@ const mapStateToProps = (state: IRootState) => {
|
|
|
64
58
|
text,
|
|
65
59
|
btnText,
|
|
66
60
|
actionsBelow,
|
|
61
|
+
subErrors,
|
|
67
62
|
};
|
|
68
63
|
};
|
|
69
64
|
|
|
@@ -77,6 +72,7 @@ interface IProps {
|
|
|
77
72
|
resetError: () => void;
|
|
78
73
|
btnText?: string;
|
|
79
74
|
actionsBelow?: boolean | undefined;
|
|
75
|
+
subErrors?: any[];
|
|
80
76
|
}
|
|
81
77
|
|
|
82
78
|
export default connect(mapStateToProps, mapDispatchToProps)(ErrorGuard);
|
package/src/helpers/dates.tsx
CHANGED
|
@@ -16,6 +16,7 @@ const isValidDate = (value: string): boolean => {
|
|
|
16
16
|
// eslint-disable-next-line
|
|
17
17
|
const regEx = /^[0-9]{4}[\/][0-9]{2}[\/][0-9]{2}$/g;
|
|
18
18
|
const regEx2 = /^[0-9]{2}[\/][0-9]{2}[\/][0-9]{4}$/g;
|
|
19
|
+
|
|
19
20
|
if (regEx.test(value) || regEx2.test(value)) {
|
|
20
21
|
const date = stringToDate(value);
|
|
21
22
|
return isValid(date);
|
|
@@ -89,4 +90,5 @@ export {
|
|
|
89
90
|
getHumanLastModifiedDate,
|
|
90
91
|
getFormattedDateWithTimezone,
|
|
91
92
|
getDaysAgo,
|
|
93
|
+
getRange,
|
|
92
94
|
};
|
package/src/helpers/index.tsx
CHANGED
|
@@ -87,6 +87,7 @@ import {
|
|
|
87
87
|
getHumanLastModifiedDate,
|
|
88
88
|
getFormattedDateWithTimezone,
|
|
89
89
|
getDaysAgo,
|
|
90
|
+
getRange,
|
|
90
91
|
} from "./dates";
|
|
91
92
|
|
|
92
93
|
import { imageResizeCropAndCompress, compressImage } from "./imageResize";
|
|
@@ -150,6 +151,7 @@ export {
|
|
|
150
151
|
getHumanLastModifiedDate,
|
|
151
152
|
getFormattedDateWithTimezone,
|
|
152
153
|
getDaysAgo,
|
|
154
|
+
getRange,
|
|
153
155
|
imageResizeCropAndCompress,
|
|
154
156
|
compressImage,
|
|
155
157
|
validateEmail,
|
package/src/hooks/modals.tsx
CHANGED
|
@@ -14,7 +14,7 @@ const useModal = (initialState?: boolean) => {
|
|
|
14
14
|
|
|
15
15
|
return {
|
|
16
16
|
isOpen,
|
|
17
|
-
toggleModal
|
|
17
|
+
toggleModal,
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -36,16 +36,16 @@ const useToast = () => {
|
|
|
36
36
|
const [isVisible, setIsVisible] = useState(false);
|
|
37
37
|
|
|
38
38
|
let temp: any;
|
|
39
|
-
const setTemp = () => temp = setTimeout(() => setIsVisible(false), 6000);
|
|
39
|
+
const setTemp = () => (temp = setTimeout(() => setIsVisible(false), 6000));
|
|
40
40
|
const stopTemp = () => clearTimeout(temp);
|
|
41
41
|
|
|
42
42
|
const toggleToast = () => {
|
|
43
43
|
setIsVisible(true);
|
|
44
44
|
setTemp();
|
|
45
45
|
stopTemp();
|
|
46
|
-
}
|
|
46
|
+
};
|
|
47
47
|
|
|
48
48
|
return { isVisible, setIsVisible, toggleToast };
|
|
49
|
-
}
|
|
49
|
+
};
|
|
50
50
|
|
|
51
51
|
export { useModal, useHandleClickOutside, useToast };
|