@griddo/ax 1.66.4 → 1.66.7

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 (70) hide show
  1. package/package.json +2 -2
  2. package/src/api/pages.tsx +3 -15
  3. package/src/api/redirects.tsx +2 -4
  4. package/src/api/sites.tsx +2 -4
  5. package/src/components/Browser/index.tsx +1 -3
  6. package/src/components/Browser/style.tsx +2 -2
  7. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +1 -0
  8. package/src/components/ErrorCenter/index.tsx +5 -8
  9. package/src/components/ErrorCenter/style.tsx +8 -21
  10. package/src/components/Fields/ColorPicker/index.tsx +0 -1
  11. package/src/components/Fields/ReferenceField/ItemList/index.tsx +1 -5
  12. package/src/components/Fields/ReferenceField/index.tsx +14 -18
  13. package/src/components/Fields/UrlField/index.tsx +1 -13
  14. package/src/components/Fields/index.tsx +0 -2
  15. package/src/components/FieldsBehavior/index.tsx +1 -14
  16. package/src/components/MainWrapper/AppBar/index.tsx +10 -21
  17. package/src/components/MainWrapper/AppBar/style.tsx +3 -11
  18. package/src/components/MainWrapper/index.tsx +0 -2
  19. package/src/components/Modal/style.tsx +1 -0
  20. package/src/components/SearchField/index.tsx +4 -36
  21. package/src/components/SearchField/style.tsx +10 -23
  22. package/src/components/SideModal/style.tsx +6 -6
  23. package/src/components/TableFilters/StatusFilter/index.tsx +2 -2
  24. package/src/components/index.tsx +0 -2
  25. package/src/containers/App/actions.tsx +7 -3
  26. package/src/containers/PageEditor/actions.tsx +22 -91
  27. package/src/containers/PageEditor/constants.tsx +1 -1
  28. package/src/containers/PageEditor/interfaces.tsx +6 -6
  29. package/src/containers/PageEditor/reducer.tsx +4 -4
  30. package/src/containers/PageEditor/utils.tsx +1 -2
  31. package/src/containers/Sites/actions.tsx +23 -35
  32. package/src/containers/Sites/constants.tsx +0 -1
  33. package/src/containers/Sites/interfaces.tsx +0 -6
  34. package/src/containers/Sites/reducer.tsx +0 -4
  35. package/src/forms/editor.tsx +1 -34
  36. package/src/forms/errors.tsx +0 -1
  37. package/src/forms/index.tsx +1 -15
  38. package/src/forms/validators.tsx +9 -168
  39. package/src/guards/error/index.tsx +1 -1
  40. package/src/helpers/dataPacks.tsx +1 -8
  41. package/src/helpers/index.tsx +1 -2
  42. package/src/modules/Content/PageItem/index.tsx +4 -54
  43. package/src/modules/Content/atoms.tsx +3 -41
  44. package/src/modules/Content/index.tsx +64 -111
  45. package/src/modules/Content/style.tsx +1 -8
  46. package/src/modules/GlobalEditor/Editor/index.tsx +1 -3
  47. package/src/modules/GlobalEditor/PageBrowser/index.tsx +0 -3
  48. package/src/modules/GlobalEditor/index.tsx +6 -8
  49. package/src/modules/PageEditor/Editor/index.tsx +2 -6
  50. package/src/modules/PageEditor/PageBrowser/index.tsx +0 -3
  51. package/src/modules/PageEditor/index.tsx +15 -29
  52. package/src/modules/Redirects/index.tsx +10 -40
  53. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +1 -1
  54. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/index.tsx +1 -1
  55. package/src/modules/Settings/ContentTypes/DataPacks/Config/index.tsx +1 -1
  56. package/src/modules/Settings/ContentTypes/DataPacks/index.tsx +1 -1
  57. package/src/modules/Sites/index.tsx +3 -3
  58. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +1 -1
  59. package/src/modules/StructuredData/StructuredDataList/atoms.tsx +1 -1
  60. package/src/modules/Users/Profile/index.tsx +4 -3
  61. package/src/modules/Users/UserCreate/SiteItem/index.tsx +1 -1
  62. package/src/modules/Users/UserCreate/SiteItem/style.tsx +1 -1
  63. package/src/modules/Users/UserForm/style.tsx +3 -3
  64. package/src/modules/Users/UserList/UserItem/index.tsx +1 -3
  65. package/src/modules/Users/UserList/hooks.tsx +1 -1
  66. package/src/modules/Users/UserList/index.tsx +2 -2
  67. package/src/types/index.tsx +3 -16
  68. package/src/components/Fields/LinkField/index.tsx +0 -85
  69. package/src/components/Icon/components/Copy.js +0 -14
  70. package/src/components/Icon/svgs/Copy2.svg +0 -3
@@ -1,15 +1,5 @@
1
- import {
2
- dateToString,
3
- getDeactivatedModules,
4
- getDefaultSchema,
5
- getSchema,
6
- getTemplate,
7
- isComponentEmpty,
8
- isEmptyContainer,
9
- isModuleDisabled,
10
- } from "@ax/helpers";
11
- import { findByEditorID } from "@ax/forms";
12
- import { IErrorItem, ITemplate } from "@ax/types";
1
+ import { dateToString, getSchema, getTemplate, isComponentEmpty, isEmptyContainer } from "@ax/helpers";
2
+ import { IErrorItem } from "@ax/types";
13
3
  import { ERRORS } from "./errors";
14
4
 
15
5
  const VALIDATORS = {
@@ -106,13 +96,6 @@ const VALIDATORS = {
106
96
  return { isValid: true, errorCode: "" };
107
97
  }
108
98
  },
109
- isMockup: (val: any, field: { type: string; defaultValue: any }): IError => {
110
- const isValid = !checkMockupByType(field.type, val, field.defaultValue);
111
- return { isValid, errorCode: "ERR016" };
112
- },
113
- apiValidator: (val: any, code: string): IError => {
114
- return { isValid: false, errorCode: code };
115
- },
116
99
  isSamePass: (pass1: string, pass2: string): IError => {
117
100
  const isValid = pass1 === pass2;
118
101
  return { isValid, errorCode: "ERR041" };
@@ -178,23 +161,6 @@ const isEmptyField = (value: any, fieldType: string, multiple: boolean) => {
178
161
  }
179
162
  };
180
163
 
181
- const checkMockupByType = (type: string, value: any, defaultValue: any) => {
182
- if (!value || !defaultValue) return false;
183
- switch (type) {
184
- case "HeadingField":
185
- return value.content && defaultValue.content && value.content.trim() === defaultValue.content.trim();
186
- case "ImageField":
187
- return value.publicId === defaultValue.publicId;
188
- default:
189
- return value.trim() === defaultValue.trim();
190
- }
191
- };
192
-
193
- const checkMockupContent = (component: string, key: string, type: string, value: any) => {
194
- const moduleDefault = getDefaultSchema(component);
195
- return { isMockup: checkMockupByType(type, value, moduleDefault[key]), defaultValue: moduleDefault[key] };
196
- };
197
-
198
164
  const getValidationErrors = (
199
165
  fields: Record<string, unknown>[],
200
166
  current: any,
@@ -210,8 +176,8 @@ const getValidationErrors = (
210
176
  const isEmpty = isEmptyField(current[field.key], field.type, hasMultipleOptions);
211
177
  if (isEmpty) {
212
178
  errors.push({
213
- type: "error",
214
- message: getErrorMessage("ERR015", null),
179
+ type: "Error",
180
+ message: "Empty Field",
215
181
  validator: { mandatory: true },
216
182
  editorID: current.editorID ? current.editorID : null,
217
183
  component: current.component ? current.component : null,
@@ -223,42 +189,14 @@ const getValidationErrors = (
223
189
  }
224
190
  }
225
191
 
226
- if (current.component && field.isMockup) {
227
- const { isMockup, defaultValue } = checkMockupContent(
228
- current.component,
229
- field.key,
230
- field.type,
231
- current[field.key]
232
- );
233
-
234
- if (isMockup) {
235
- errors.push({
236
- type: "error",
237
- message: getErrorMessage("ERR016", null),
238
- validator: { isMockup: { type: field.type, defaultValue } },
239
- editorID: current.editorID ? current.editorID : null,
240
- component: current.component ? current.component : null,
241
- name: name ? name : field.title,
242
- key: field.key,
243
- tab,
244
- template,
245
- });
246
- }
247
- }
248
-
249
- let fieldValidators: Record<string, unknown> = field.maxValue ? { maxValue: field.maxValue } : {};
250
- fieldValidators = field.minValue ? { ...fieldValidators, minValue: field.minValue } : fieldValidators;
251
-
252
- if (Object.prototype.hasOwnProperty.call(field, "validators") || Object.keys(fieldValidators).length) {
253
- const allValidators = { ...field.validators, ...fieldValidators };
254
-
255
- const { isValid, errorText } = getValidity(allValidators, current[field.key]);
192
+ if (Object.prototype.hasOwnProperty.call(field, "validators")) {
193
+ const { isValid, errorText } = getValidity(field.validators, current[field.key]);
256
194
 
257
195
  if (!isValid) {
258
196
  errors.push({
259
- type: "error",
197
+ type: "Error",
260
198
  message: errorText,
261
- validator: allValidators,
199
+ validator: field.validators,
262
200
  editorID: current.editorID ? current.editorID : null,
263
201
  component: current.component ? current.component : null,
264
202
  name: name ? name : field.title,
@@ -283,57 +221,6 @@ const getValidationErrors = (
283
221
  return errors;
284
222
  };
285
223
 
286
- const isTemplateActivated = (templates: ITemplate[], currentTemplateType: string): boolean =>
287
- templates.find((temp: ITemplate) => temp.id === currentTemplateType) ? true : false;
288
-
289
- const findPackagesActivationErrors = (
290
- pageEditor: any,
291
- modules: string[],
292
- templates: ITemplate[]
293
- ): IErrorItem | null => {
294
- const {
295
- schema,
296
- selectedContent: { component },
297
- } = pageEditor;
298
-
299
- let deactivatedModules: string[] = [];
300
- let isCurrentTemplateActivated = true;
301
- let hasDeactivatedModules = false;
302
-
303
- const {
304
- editorContent: { template },
305
- } = pageEditor?.editorContent;
306
-
307
- if (template) {
308
- const mainContentModules = template?.mainContent?.modules;
309
-
310
- if (mainContentModules) {
311
- deactivatedModules = getDeactivatedModules(modules, mainContentModules);
312
- hasDeactivatedModules = deactivatedModules.length > 0;
313
- } else {
314
- hasDeactivatedModules = isModuleDisabled(component, schema.schemaType, modules);
315
- }
316
-
317
- isCurrentTemplateActivated = isTemplateActivated(templates, template.templateType);
318
- }
319
-
320
- if (!isCurrentTemplateActivated || hasDeactivatedModules) {
321
- return {
322
- type: "error",
323
- message: getErrorMessage("ERR042", null),
324
- validator: {},
325
- editorID: null,
326
- component: "",
327
- name: "",
328
- key: "",
329
- tab: "",
330
- template: false,
331
- };
332
- }
333
-
334
- return null;
335
- };
336
-
337
224
  const findFieldsErrors = (content: any): IErrorItem[] => {
338
225
  const queue: any[] = [content];
339
226
  let errors: IErrorItem[] = [];
@@ -387,55 +274,9 @@ const findMandatoryStructuredDataErrors = (content: any, schema: any): IErrorIte
387
274
  return errors;
388
275
  };
389
276
 
390
- const checkH1content = (content: any): IErrorItem | null => {
391
- const h1s = content.getElementsByTagName("h1");
392
-
393
- if (!h1s.length) {
394
- return {
395
- type: "warning",
396
- message: getErrorMessage("ERR018", null),
397
- validator: {},
398
- editorID: null,
399
- component: null,
400
- name: "",
401
- key: "",
402
- tab: "",
403
- template: false,
404
- };
405
- }
406
-
407
- return null;
408
- };
409
-
410
- const parseValidationErrors = (errors: any[], content: any) => {
411
- return errors.map((err: any) => {
412
- const { element: module } = findByEditorID(content, err.editorID);
413
- const schema = getSchema(module.component);
414
- return {
415
- type: "error",
416
- message: getErrorMessage(err.error, null),
417
- validator: { apiValidator: err.error },
418
- editorID: err.editorID,
419
- component: module.component,
420
- name: schema.displayName,
421
- key: err.key,
422
- tab: "content",
423
- template: false,
424
- };
425
- });
426
- };
427
-
428
277
  interface IError {
429
278
  isValid: boolean;
430
279
  errorCode: string;
431
280
  }
432
281
 
433
- export {
434
- getValidity,
435
- isTemplateActivated,
436
- findPackagesActivationErrors,
437
- findFieldsErrors,
438
- findMandatoryStructuredDataErrors,
439
- checkH1content,
440
- parseValidationErrors,
441
- };
282
+ export { getValidity, findFieldsErrors, findMandatoryStructuredDataErrors };
@@ -50,7 +50,7 @@ const ErrorGuard = (props: IProps) => {
50
50
  return domNode && createPortal(Notifications, domNode);
51
51
  };
52
52
 
53
- return code || text ? isBlocking ? <ErrorView code={code} text={text} /> : createErrorNotification() : null;
53
+ return code ? isBlocking ? <ErrorView code={code} text={text} /> : createErrorNotification() : null;
54
54
  };
55
55
 
56
56
  const mapStateToProps = (state: IRootState) => {
@@ -8,11 +8,4 @@ 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
- 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 };
11
+ export { getActivatedDataPacksIds, isModuleDisabled };
@@ -91,7 +91,7 @@ import { imageResizeCropAndCompress, compressImage } from "./imageResize";
91
91
 
92
92
  import { isEmptyArray, moveArrayElement } from "./arrays";
93
93
 
94
- import { getActivatedDataPacksIds, isModuleDisabled, getDeactivatedModules } from "./dataPacks";
94
+ import { getActivatedDataPacksIds, isModuleDisabled } from "./dataPacks";
95
95
 
96
96
  import { isDevelopment } from "./environment";
97
97
 
@@ -153,7 +153,6 @@ export {
153
153
  handleRequest,
154
154
  getActivatedDataPacksIds,
155
155
  isModuleDisabled,
156
- getDeactivatedModules,
157
156
  getInitials,
158
157
  getSchemaType,
159
158
  getModuleCategories,
@@ -1,9 +1,8 @@
1
1
  import React, { memo, useState } from "react";
2
2
 
3
- import { schemas } from "components";
4
3
  import { useModal } from "@ax/hooks";
5
4
  import { getHumanLastModifiedDate, getTemplateDisplayName, slugify } from "@ax/helpers";
6
- import { IPage, ISite, ISavePageParams, ICheck, IColumn, IDataPack, IPageLanguage } from "@ax/types";
5
+ import { IPage, ISite, ISavePageParams, ICheck, IColumn, IPageLanguage, IDataPack } from "@ax/types";
7
6
  import { pageStatus, ISetCurrentPageIDAction } from "@ax/containers/PageEditor/interfaces";
8
7
 
9
8
  import {
@@ -19,7 +18,7 @@ import {
19
18
  CategoryCell,
20
19
  } from "@ax/components";
21
20
 
22
- import { DeleteModal, CopyModal } from "../atoms";
21
+ import { DeleteModal } from "../atoms";
23
22
 
24
23
  import * as S from "./style";
25
24
 
@@ -35,7 +34,6 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
35
34
  categoryColors,
36
35
  addCategoryColors,
37
36
  dataPacks,
38
- sites,
39
37
  } = props;
40
38
  const { isSelected, siteLanguages, page, lang, isDuplicable } = item;
41
39
  const {
@@ -49,10 +47,9 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
49
47
  languageActions,
50
48
  duplicatePage,
51
49
  removePageFromSite,
52
- getDataPack,
53
50
  deleteBulk,
51
+ getDataPack,
54
52
  setTemplateInstanceError,
55
- toggleCopiedToast,
56
53
  } = functions;
57
54
  const { locale } = lang;
58
55
  const {
@@ -65,22 +62,16 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
65
62
  templateId,
66
63
  structuredDataContent,
67
64
  } = page;
68
-
69
65
  const displayName = getTemplateDisplayName(templateId);
70
66
 
71
67
  const initValue = { title: "", slug: "" };
72
- const [site, setSite] = useState(null);
73
68
  const [modalState, setModalState] = useState(initValue);
74
69
  const [deleteAllVersions, setDeleteAllVersions] = useState(false);
75
70
  const { isOpen, toggleModal } = useModal();
76
71
  const { isOpen: isRemoveOpen, toggleModal: toggleRemoveModal } = useModal();
77
72
  const { isOpen: isUnpublishOpen, toggleModal: toggleUnpublishModal } = useModal();
78
73
  const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
79
- const { isOpen: isCopyOpen, toggleModal: toggleCopyModal } = useModal();
80
-
81
- const currentTemplateDataPacks = schemas.templates[templateId].dataPacks;
82
74
 
83
- const isCopyable = !currentTemplateDataPacks;
84
75
  const isGlobal = origin === "GLOBAL";
85
76
  const isTranslated = pageLanguages.length > 1;
86
77
  const activeColumns = Object.keys(columns).filter((col: string) => columns[col].show);
@@ -320,13 +311,6 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
320
311
  action: toggleModal,
321
312
  };
322
313
 
323
- const copyOption = {
324
- label: "Copy page in another site",
325
- icon: "copy",
326
- action: toggleCopyModal,
327
- };
328
-
329
- if (isCopyable) menuOptions.unshift(copyOption);
330
314
  if (!isGlobal) menuOptions.unshift(duplicateOption);
331
315
 
332
316
  const getPublishItem = (status: string, canBeUnpublished: boolean) => {
@@ -419,25 +403,6 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
419
403
  };
420
404
 
421
405
  const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
422
- const copyToOtherSite = () => {
423
- if (site) {
424
- const siteID = parseInt(site);
425
-
426
- duplicatePage(page.id, null, siteID).then((successEvent: boolean) => {
427
- if (successEvent) {
428
- toggleCopiedToast();
429
- }
430
- toggleCopyModal();
431
- });
432
- }
433
- };
434
-
435
- const secondaryCopyModalAction = {
436
- title: "Cancel",
437
- onClick: toggleCopyModal,
438
- };
439
-
440
- const mainCopyModalAction = { title: "Copy page", onClick: copyToOtherSite, disabled: !site };
441
406
 
442
407
  const CategoryColumns =
443
408
  isGlobal &&
@@ -506,18 +471,6 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
506
471
  <S.StyledActionMenu icon="more" options={menuOptions} tooltip="Page actions" />
507
472
  </S.ActionsCell>
508
473
  </S.PageRow>
509
- <CopyModal
510
- isOpen={isCopyOpen}
511
- toggleModal={() => {
512
- setSite(null);
513
- toggleCopyModal();
514
- }}
515
- mainModalAction={mainCopyModalAction}
516
- secondaryModalAction={secondaryCopyModalAction}
517
- sites={sites}
518
- site={site}
519
- setSite={setSite}
520
- />
521
474
  <Modal
522
475
  isOpen={isOpen}
523
476
  hide={toggleModal}
@@ -581,7 +534,6 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
581
534
  </S.ModalContent>
582
535
  )}
583
536
  </Modal>
584
-
585
537
  <DeleteModal
586
538
  isOpen={isDeleteOpen}
587
539
  toggleModal={toggleDeleteModal}
@@ -624,12 +576,11 @@ interface IPageItemProps {
624
576
  setHistoryPush(path: string, isEditor: boolean): void;
625
577
  updatePageStatus(ids: number[], status: string, updatedFromList: boolean): Promise<boolean>;
626
578
  setCurrentPageID(currentPageID: number | null): ISetCurrentPageIDAction;
627
- duplicatePage(pageID: number, data: any, siteID?: number): Promise<boolean>;
579
+ duplicatePage(pageID: number, data: any): Promise<void>;
628
580
  removePageFromSite(pageID: number): Promise<boolean>;
629
581
  deleteBulk(ids: number[]): void;
630
582
  setTemplateInstanceError(error: any): void;
631
583
  getDataPack: (id: string) => Promise<void>;
632
- toggleCopiedToast(): void;
633
584
  };
634
585
  activatedTemplates: any[];
635
586
  toggleToast(): void;
@@ -639,7 +590,6 @@ interface IPageItemProps {
639
590
  categoryColors: any;
640
591
  addCategoryColors(cats: string[]): void;
641
592
  dataPacks: IDataPack[];
642
- sites: ISite[];
643
593
  }
644
594
 
645
595
  export default memo(PageItem);
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
 
3
- import { IModal, ISite } from "@ax/types";
4
- import { Modal, FieldsBehavior, Select, Button } from "@ax/components";
3
+ import { IModal } from "@ax/types";
4
+ import { Modal, FieldsBehavior, Button } from "@ax/components";
5
5
 
6
6
  import * as S from "./style";
7
7
 
@@ -68,38 +68,6 @@ const DeleteModal = (props: IDeleteModal): JSX.Element => {
68
68
  );
69
69
  };
70
70
 
71
- const CopyModal = (props: ICopyModal): JSX.Element => {
72
- const { isOpen, toggleModal, mainModalAction, secondaryModalAction, setSite, sites, site } = props;
73
- const sitesOptions = sites.map((site: ISite) => ({ label: site.name, value: site.id.toString() }));
74
-
75
- return (
76
- <Modal
77
- isOpen={isOpen}
78
- hide={toggleModal}
79
- size="S"
80
- title="Copy page in another site"
81
- mainAction={mainModalAction}
82
- secondaryAction={secondaryModalAction}
83
- >
84
- <S.ModalContent>
85
- <p>
86
- <strong>Select a site to copy this page. </strong>
87
- <br></br>
88
- You can only select sites with the same language as this page.
89
- </p>
90
- <S.SelectWrapper>
91
- <Select
92
- name="select"
93
- options={sitesOptions}
94
- onChange={(value: string) => setSite(value)}
95
- value={site?.toString() || ""}
96
- mandatory={true}
97
- />
98
- </S.SelectWrapper>
99
- </S.ModalContent>
100
- </Modal>
101
- );
102
- };
103
71
  const MainActionButton = (props: IActionButton): JSX.Element => (
104
72
  <Button type="button" onClick={props.onClick}>
105
73
  {props.title}
@@ -119,15 +87,9 @@ interface IDeleteModal extends IModal {
119
87
  title?: string;
120
88
  }
121
89
 
122
- interface ICopyModal extends IModal {
123
- setSite: React.Dispatch<React.SetStateAction<any>>;
124
- sites: ISite[];
125
- site: string | null;
126
- }
127
-
128
90
  interface IActionButton {
129
91
  onClick: () => void;
130
92
  title: string;
131
93
  }
132
94
 
133
- export { DeleteModal, CopyModal, MainActionButton, SecondaryActionButton };
95
+ export { DeleteModal, MainActionButton, SecondaryActionButton };