@griddo/ax 1.67.0 → 1.67.3
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/containers/PageEditor/actions.tsx +12 -5
- package/src/forms/errors.tsx +1 -0
- package/src/forms/index.tsx +4 -0
- package/src/forms/validators.tsx +64 -2
- package/src/helpers/dataPacks.tsx +8 -1
- package/src/helpers/index.tsx +2 -1
- package/src/modules/PageEditor/index.tsx +14 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "1.67.
|
|
4
|
+
"version": "1.67.3",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -221,5 +221,5 @@
|
|
|
221
221
|
"publishConfig": {
|
|
222
222
|
"access": "public"
|
|
223
223
|
},
|
|
224
|
-
"gitHead": "
|
|
224
|
+
"gitHead": "f74caa35c567a1b658a8a2cc27fa2dd37ca6bf44"
|
|
225
225
|
}
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
getParentKey,
|
|
29
29
|
checkH1content,
|
|
30
30
|
parseValidationErrors,
|
|
31
|
+
findPackagesActivationErrors,
|
|
31
32
|
} from "@ax/forms";
|
|
32
33
|
import { appActions } from "@ax/containers/App";
|
|
33
34
|
import { navigationActions } from "@ax/containers/Navigation";
|
|
@@ -92,7 +93,7 @@ import {
|
|
|
92
93
|
ISetCopyModule,
|
|
93
94
|
} from "./interfaces";
|
|
94
95
|
|
|
95
|
-
const { setIsLoading, setIsSaving } = appActions;
|
|
96
|
+
const { setIsLoading, setIsSaving, handleError } = appActions;
|
|
96
97
|
const { getSiteDefaults, getDefaults } = navigationActions;
|
|
97
98
|
|
|
98
99
|
// AUDIT: THIS FILE IS WAY TOO LONG - LOOK FOR A REFACTOR SOLUTION
|
|
@@ -200,7 +201,7 @@ function setTranslatedParent(): (dispatch: Dispatch, getState: any) => void {
|
|
|
200
201
|
const translatedParentId = translatedParent && translatedParent[0] ? translatedParent[0].pageId : null;
|
|
201
202
|
updateEditorContent(selectedEditorID, "parent", translatedParentId)(dispatch, getState);
|
|
202
203
|
},
|
|
203
|
-
handleError: (response: any) =>
|
|
204
|
+
handleError: (response: any) => handleError(response)(dispatch),
|
|
204
205
|
};
|
|
205
206
|
|
|
206
207
|
const callback = async () => pages.getPageLanguages(parent, site, entity);
|
|
@@ -576,7 +577,6 @@ function getPageLanguages(pageID: number, siteID: number | null, entity?: string
|
|
|
576
577
|
};
|
|
577
578
|
}
|
|
578
579
|
|
|
579
|
-
|
|
580
580
|
function duplicatePage(pageID: number, data: any, siteID?: number): (dispatch: Dispatch) => Promise<boolean> {
|
|
581
581
|
return async (dispatch) => {
|
|
582
582
|
try {
|
|
@@ -1073,11 +1073,16 @@ function validatePage(publish?: boolean, browserRef?: any): (dispatch: Dispatch,
|
|
|
1073
1073
|
return async (dispatch, getState) => {
|
|
1074
1074
|
try {
|
|
1075
1075
|
const { editorContent } = getStateValues(getState);
|
|
1076
|
+
const content = deepClone(editorContent);
|
|
1077
|
+
|
|
1078
|
+
const {
|
|
1079
|
+
dataPacks: { modules, templates },
|
|
1080
|
+
pageEditor,
|
|
1081
|
+
} = getState();
|
|
1082
|
+
|
|
1076
1083
|
const page = getPageData(getState, false);
|
|
1077
1084
|
const { values } = parseData(page, false);
|
|
1078
1085
|
|
|
1079
|
-
const content = deepClone(editorContent);
|
|
1080
|
-
|
|
1081
1086
|
let errors: IErrorItem[] = [];
|
|
1082
1087
|
|
|
1083
1088
|
const responseActions = {
|
|
@@ -1095,6 +1100,8 @@ function validatePage(publish?: boolean, browserRef?: any): (dispatch: Dispatch,
|
|
|
1095
1100
|
const fieldErrors = findFieldsErrors(content);
|
|
1096
1101
|
|
|
1097
1102
|
errors = [...errors, ...fieldErrors];
|
|
1103
|
+
const packagesActivationErrors = findPackagesActivationErrors(pageEditor, modules, templates);
|
|
1104
|
+
errors = packagesActivationErrors ? [...errors, packagesActivationErrors] : errors;
|
|
1098
1105
|
|
|
1099
1106
|
let warnings: IErrorItem[] = [];
|
|
1100
1107
|
if (browserRef && browserRef.current) {
|
package/src/forms/errors.tsx
CHANGED
|
@@ -40,6 +40,7 @@ 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.",
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
export { ERRORS };
|
package/src/forms/index.tsx
CHANGED
|
@@ -25,7 +25,9 @@ import {
|
|
|
25
25
|
import { getInnerFields, getStructuredDataInnerFields } from "./fields";
|
|
26
26
|
import {
|
|
27
27
|
getValidity,
|
|
28
|
+
findPackagesActivationErrors,
|
|
28
29
|
findFieldsErrors,
|
|
30
|
+
isTemplateActivated,
|
|
29
31
|
findMandatoryStructuredDataErrors,
|
|
30
32
|
checkH1content,
|
|
31
33
|
parseValidationErrors,
|
|
@@ -55,7 +57,9 @@ export {
|
|
|
55
57
|
getLastComponentEditorID,
|
|
56
58
|
getParentKey,
|
|
57
59
|
getValidity,
|
|
60
|
+
findPackagesActivationErrors,
|
|
58
61
|
findFieldsErrors,
|
|
62
|
+
isTemplateActivated,
|
|
59
63
|
findMandatoryStructuredDataErrors,
|
|
60
64
|
checkH1content,
|
|
61
65
|
parseValidationErrors,
|
package/src/forms/validators.tsx
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dateToString,
|
|
3
|
+
getDeactivatedModules,
|
|
3
4
|
getDefaultSchema,
|
|
4
5
|
getSchema,
|
|
5
6
|
getTemplate,
|
|
6
7
|
hasProps,
|
|
7
8
|
isComponentEmpty,
|
|
8
9
|
isEmptyContainer,
|
|
10
|
+
isModuleDisabled,
|
|
9
11
|
} from "@ax/helpers";
|
|
10
12
|
import { findByEditorID } from "@ax/forms";
|
|
11
|
-
import { IErrorItem } from "@ax/types";
|
|
13
|
+
import { IErrorItem, ITemplate } from "@ax/types";
|
|
12
14
|
import { ERRORS } from "./errors";
|
|
13
15
|
|
|
14
16
|
const VALIDATORS = {
|
|
@@ -290,6 +292,58 @@ const getValidationErrors = (
|
|
|
290
292
|
return errors;
|
|
291
293
|
};
|
|
292
294
|
|
|
295
|
+
const isTemplateActivated = (templates: ITemplate[], currentTemplateType: string): boolean =>
|
|
296
|
+
templates.find((temp: ITemplate) => temp.id === currentTemplateType) ? true : false;
|
|
297
|
+
|
|
298
|
+
const findPackagesActivationErrors = (
|
|
299
|
+
pageEditor: any,
|
|
300
|
+
modules: string[],
|
|
301
|
+
templates: ITemplate[]
|
|
302
|
+
): IErrorItem | null => {
|
|
303
|
+
const {
|
|
304
|
+
schema,
|
|
305
|
+
selectedContent: { component },
|
|
306
|
+
} = pageEditor;
|
|
307
|
+
|
|
308
|
+
const isGlobal = component === "GlobalPage";
|
|
309
|
+
let deactivatedModules: string[] = [];
|
|
310
|
+
let isCurrentTemplateActivated = true;
|
|
311
|
+
let hasDeactivatedModules = false;
|
|
312
|
+
|
|
313
|
+
const {
|
|
314
|
+
editorContent: { template },
|
|
315
|
+
} = pageEditor?.editorContent;
|
|
316
|
+
|
|
317
|
+
if (template && !isGlobal) {
|
|
318
|
+
const mainContentModules = template?.mainContent?.modules;
|
|
319
|
+
|
|
320
|
+
if (mainContentModules) {
|
|
321
|
+
deactivatedModules = getDeactivatedModules(modules, mainContentModules);
|
|
322
|
+
hasDeactivatedModules = deactivatedModules.length > 0;
|
|
323
|
+
} else {
|
|
324
|
+
hasDeactivatedModules = isModuleDisabled(component, schema.schemaType, modules);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
isCurrentTemplateActivated = isTemplateActivated(templates, template.templateType);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (!isCurrentTemplateActivated || hasDeactivatedModules) {
|
|
331
|
+
return {
|
|
332
|
+
type: "error",
|
|
333
|
+
message: getErrorMessage("ERR042", null),
|
|
334
|
+
validator: {},
|
|
335
|
+
editorID: null,
|
|
336
|
+
component: "",
|
|
337
|
+
name: "",
|
|
338
|
+
key: "",
|
|
339
|
+
tab: "",
|
|
340
|
+
template: false,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return null;
|
|
345
|
+
};
|
|
346
|
+
|
|
293
347
|
const findFieldsErrors = (content: any): IErrorItem[] => {
|
|
294
348
|
const queue: any[] = [content];
|
|
295
349
|
let errors: IErrorItem[] = [];
|
|
@@ -386,4 +440,12 @@ interface IError {
|
|
|
386
440
|
errorCode: string;
|
|
387
441
|
}
|
|
388
442
|
|
|
389
|
-
export {
|
|
443
|
+
export {
|
|
444
|
+
getValidity,
|
|
445
|
+
isTemplateActivated,
|
|
446
|
+
findPackagesActivationErrors,
|
|
447
|
+
findFieldsErrors,
|
|
448
|
+
findMandatoryStructuredDataErrors,
|
|
449
|
+
checkH1content,
|
|
450
|
+
parseValidationErrors,
|
|
451
|
+
};
|
|
@@ -8,4 +8,11 @@ const getActivatedDataPacksIds = (activatedDataPacks: any) => {
|
|
|
8
8
|
const isModuleDisabled = (selectedComponent: string, type: string, activatedModules: string[]): boolean =>
|
|
9
9
|
type === "module" && !activatedModules.includes(selectedComponent);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const getDeactivatedModules = (modules: any, currentModules: any) => {
|
|
12
|
+
const deactivatedModules = currentModules
|
|
13
|
+
.map((module: any) => (isModuleDisabled(module.component, "module", modules) ? module.component : null))
|
|
14
|
+
.filter((module: string | null) => !!module);
|
|
15
|
+
return deactivatedModules;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { getActivatedDataPacksIds, isModuleDisabled, getDeactivatedModules };
|
package/src/helpers/index.tsx
CHANGED
|
@@ -92,7 +92,7 @@ import { imageResizeCropAndCompress, compressImage } from "./imageResize";
|
|
|
92
92
|
|
|
93
93
|
import { isEmptyArray, moveArrayElement } from "./arrays";
|
|
94
94
|
|
|
95
|
-
import { getActivatedDataPacksIds, isModuleDisabled } from "./dataPacks";
|
|
95
|
+
import { getActivatedDataPacksIds, isModuleDisabled, getDeactivatedModules } from "./dataPacks";
|
|
96
96
|
|
|
97
97
|
import { isDevelopment } from "./environment";
|
|
98
98
|
|
|
@@ -155,6 +155,7 @@ export {
|
|
|
155
155
|
handleRequest,
|
|
156
156
|
getActivatedDataPacksIds,
|
|
157
157
|
isModuleDisabled,
|
|
158
|
+
getDeactivatedModules,
|
|
158
159
|
getInitials,
|
|
159
160
|
getSchemaType,
|
|
160
161
|
getModuleCategories,
|
|
@@ -10,7 +10,7 @@ import { navigationActions } from "@ax/containers/Navigation";
|
|
|
10
10
|
import { pageStatus } from "@ax/containers/PageEditor/interfaces";
|
|
11
11
|
import { RouteLeavingGuard } from "@ax/guards";
|
|
12
12
|
import { useIsDirty, useModal } from "@ax/hooks";
|
|
13
|
-
import { isModuleDisabled } from "@ax/helpers";
|
|
13
|
+
import { isModuleDisabled, getDeactivatedModules } from "@ax/helpers";
|
|
14
14
|
import { dataPacksActions } from "@ax/containers/Settings/DataPacks";
|
|
15
15
|
import { DeleteModal } from "./atoms";
|
|
16
16
|
import Editor from "./Editor";
|
|
@@ -180,7 +180,7 @@ const PageEditor = (props: IProps) => {
|
|
|
180
180
|
|
|
181
181
|
const reviewPage = () => {
|
|
182
182
|
const { validatePage } = props;
|
|
183
|
-
validatePage(
|
|
183
|
+
validatePage(false, browserRef);
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
const handlePublishDraft = async () => {
|
|
@@ -324,9 +324,18 @@ const PageEditor = (props: IProps) => {
|
|
|
324
324
|
|
|
325
325
|
let isTemplateActivated = true;
|
|
326
326
|
let hasDeactivatedModules = false;
|
|
327
|
+
let deactivatedModules: string[] = [];
|
|
327
328
|
if (editorContent.editorContent && editorContent.editorContent.template) {
|
|
328
329
|
const editorTemplate = editorContent.editorContent.template;
|
|
329
|
-
|
|
330
|
+
const mainContentModules = editorTemplate?.mainContent?.modules;
|
|
331
|
+
|
|
332
|
+
if (mainContentModules) {
|
|
333
|
+
deactivatedModules = getDeactivatedModules(activatedModules, mainContentModules);
|
|
334
|
+
hasDeactivatedModules = deactivatedModules.length > 0;
|
|
335
|
+
} else {
|
|
336
|
+
hasDeactivatedModules = isModuleDisabled(selectedComponent, schema.schemaType, activatedModules);
|
|
337
|
+
}
|
|
338
|
+
|
|
330
339
|
isTemplateActivated = activatedTemplates.find((temp: any) => temp.id === editorTemplate.templateType)
|
|
331
340
|
? true
|
|
332
341
|
: false;
|
|
@@ -410,7 +419,8 @@ const PageEditor = (props: IProps) => {
|
|
|
410
419
|
if (!isTemplateActivated) {
|
|
411
420
|
getSiteDataPackbyTemplate(editorTemplate.templateType);
|
|
412
421
|
} else if (hasDeactivatedModules) {
|
|
413
|
-
|
|
422
|
+
const currentModule = deactivatedModules.length === 1 ? deactivatedModules[0] : selectedComponent;
|
|
423
|
+
getSiteDataPackbyModule(currentModule);
|
|
414
424
|
}
|
|
415
425
|
setHistoryPush("/sites/settings/content-types", false);
|
|
416
426
|
}
|