@griddo/ax 1.75.198 → 1.75.200

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "1.75.198",
4
+ "version": "1.75.200",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -235,5 +235,5 @@
235
235
  "publishConfig": {
236
236
  "access": "public"
237
237
  },
238
- "gitHead": "8ca176c6cc523bf0ebf5cadd2af9715aab6d377e"
238
+ "gitHead": "350ffeddb79e7d6563265fb860116b2579841251"
239
239
  }
@@ -24,6 +24,7 @@ const NavConnectedField = (props: any) => {
24
24
  activatedTemplates,
25
25
  menus,
26
26
  theme,
27
+ moduleCopy,
27
28
  } = props;
28
29
 
29
30
  const updateValue = (key: string, value: any) => {
@@ -74,6 +75,7 @@ const NavConnectedField = (props: any) => {
74
75
  disabled={isDisabled}
75
76
  innerFields={innerFields}
76
77
  theme={theme}
78
+ moduleCopy={moduleCopy}
77
79
  />
78
80
  );
79
81
  };
@@ -87,6 +89,7 @@ const mapStateToProps = (state: IRootState) => ({
87
89
  currentDefaultsContent: state.navigation.currentDefaultsContent,
88
90
  activatedTemplates: state.dataPacks.templates,
89
91
  menus: state.menu.savedMenus,
92
+ moduleCopy: state.navigation.moduleCopy,
90
93
  });
91
94
 
92
95
  const mapDispatchToProps = {
@@ -73,7 +73,7 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
73
73
  const isComponentModule = contentType === "components";
74
74
  const isModuleArr = contentType === "modules";
75
75
 
76
- const handleAddModule = (moduleType: string) => addModuleAction(moduleType, editorID, isComponentModule);
76
+ const handleAddModule = (moduleType: string) => addModuleAction(moduleType, objKey, editorID, isComponentModule);
77
77
 
78
78
  const handleAddComponent = (componentType: string) => addComponentAction && addComponentAction(componentType, objKey);
79
79
 
@@ -48,7 +48,7 @@ const SameComponentArray = (props: ISameComponentArrayProps): JSX.Element => {
48
48
  const isModuleArr = contentType === "modules";
49
49
  const isComponentModule = contentType === "components";
50
50
 
51
- const handleAddModule = (moduleType: string) => addModuleAction(moduleType, editorID, isComponentModule);
51
+ const handleAddModule = (moduleType: string) => addModuleAction(moduleType, objKey, editorID, isComponentModule);
52
52
 
53
53
  const handleAddComponent = () => addComponentAction && addComponentAction(kind, objKey);
54
54
 
@@ -1,7 +1,7 @@
1
1
  import { Dispatch } from "redux";
2
2
 
3
3
  import { navigation } from "@ax/api";
4
- import { IBreadcrumbItem, ISchema } from "@ax/types";
4
+ import { IBreadcrumbItem, INotification, ISchema } from "@ax/types";
5
5
  import {
6
6
  getDefaultSchema,
7
7
  getSchema,
@@ -12,6 +12,7 @@ import {
12
12
  getDefaultNavigationModules,
13
13
  } from "@ax/helpers";
14
14
  import {
15
+ checkMaxModules,
15
16
  findByEditorID,
16
17
  generateEditorIDs,
17
18
  getLastComponentEditorID,
@@ -42,6 +43,7 @@ import {
42
43
  SET_CURRENT_NAVIGATION_LANGUAGES,
43
44
  SET_IS_NEW_TRANSLATION,
44
45
  SET_SELECTED_PARENT,
46
+ SET_COPY_MODULE,
45
47
  } from "./constants";
46
48
 
47
49
  import {
@@ -55,6 +57,7 @@ import {
55
57
  ISetCurrentNavigationLanguages,
56
58
  ISetIsNewTranslation,
57
59
  ISetSelectedParent,
60
+ ISetCopyModule,
58
61
  } from "./interfaces";
59
62
 
60
63
  const { setIsLoading } = appActions;
@@ -115,6 +118,10 @@ function setIsNewTranslation(isNewTranslation: boolean): ISetIsNewTranslation {
115
118
  return { type: SET_IS_NEW_TRANSLATION, payload: { isNewTranslation } };
116
119
  }
117
120
 
121
+ function setCopyModule(moduleCopy: Record<string, unknown> | null): ISetCopyModule {
122
+ return { type: SET_COPY_MODULE, payload: { moduleCopy } };
123
+ }
124
+
118
125
  // API RELATED FUNCTIONS
119
126
 
120
127
  function getHeaders(params: any): (dispatch: Dispatch, getState: any) => Promise<void> {
@@ -525,6 +532,17 @@ const getUpdatedComponents = (editorContent: any, element: any, key: string) =>
525
532
  return updatedDefault;
526
533
  };
527
534
 
535
+ function addModule(
536
+ type: string,
537
+ key: string,
538
+ selectedID: number,
539
+ isComponentModule?: boolean
540
+ ): (dispatch: Dispatch, getState: any) => void {
541
+ return (dispatch, getState) => {
542
+ addComponent(type, key)(dispatch, getState);
543
+ };
544
+ }
545
+
528
546
  function addComponent(type: any, key: string): (dispatch: Dispatch, getState: any) => void {
529
547
  return (dispatch, getState) => {
530
548
  const { editorContent, selectedEditorID } = getStateValues(getState);
@@ -636,6 +654,53 @@ function moveModule(
636
654
  };
637
655
  }
638
656
 
657
+ function copyModule(editorID: number): (dispatch: Dispatch, getState: any) => boolean {
658
+ return (dispatch, getState) => {
659
+ const {
660
+ navigation: { editorContent },
661
+ } = getState();
662
+
663
+ const { element: originalElement } = findByEditorID(editorContent, editorID);
664
+ if (originalElement) {
665
+ const { editorID, parentEditorID, ...element } = originalElement;
666
+ const payload = {
667
+ date: new Date(),
668
+ element,
669
+ };
670
+ dispatch(setCopyModule(payload));
671
+ return true;
672
+ } else {
673
+ return false;
674
+ }
675
+ };
676
+ }
677
+
678
+ function pasteModule(
679
+ editorID: number,
680
+ key: string
681
+ ): (dispatch: Dispatch, getState: any) => Promise<{ error?: INotification }> {
682
+ return async (dispatch, getState) => {
683
+ const {
684
+ navigation: { moduleCopy, editorContent },
685
+ } = getState();
686
+
687
+ const { element: originalElement } = findByEditorID(editorContent, editorID);
688
+
689
+ const validatedModuleCopy: any = deepClone(moduleCopy.element);
690
+
691
+ const itemsArr = originalElement[key];
692
+ itemsArr.push(validatedModuleCopy);
693
+
694
+ const updatedPageContent = {
695
+ ...editorContent,
696
+ };
697
+
698
+ generateContent(updatedPageContent, dispatch, getState);
699
+
700
+ return { error: undefined };
701
+ };
702
+ }
703
+
639
704
  function replaceElementsInCollection(newValue: string, reference: string): (dispatch: Dispatch, getState: any) => void {
640
705
  return async (dispatch, getState) => {
641
706
  const { selectedContent } = getStateValues(getState);
@@ -765,6 +830,7 @@ export {
765
830
  createNewTranslation,
766
831
  getSiteDefaults,
767
832
  getValues,
833
+ addModule,
768
834
  addComponent,
769
835
  replaceElementsInCollection,
770
836
  generateContent,
@@ -786,4 +852,6 @@ export {
786
852
  duplicateModule,
787
853
  deleteModule,
788
854
  moveModule,
855
+ copyModule,
856
+ pasteModule,
789
857
  };
@@ -1,4 +1,4 @@
1
- export const NAME: string = "navigation";
1
+ export const NAME = "navigation";
2
2
 
3
3
  export const SET_EDITOR_CONTENT = `${NAME}/SET_EDITOR_CONTENT`;
4
4
  export const SET_BREADCRUMB = `${NAME}/SET_BREADCRUMB`;
@@ -13,6 +13,7 @@ export const SET_FOOTER = `${NAME}/SET_FOOTER`;
13
13
  export const SET_DEFAULTS_CONTENT = `${NAME}/SET_DEFAULTS_CONTENT`;
14
14
  export const SET_TOTAL_ITEMS = `${NAME}/SET_TOTAL_ITEMS`;
15
15
  export const SET_CURRENT_NAVIGATION_LANGUAGES = `${NAME}/SET_CURRENT_NAVIGATION_LANGUAGES`;
16
- export const SET_IS_NEW_TRANSLATION: string = `${NAME}/SET_IS_NEW_TRANSLATION`;
16
+ export const SET_IS_NEW_TRANSLATION = `${NAME}/SET_IS_NEW_TRANSLATION`;
17
+ export const SET_COPY_MODULE = `${NAME}/SET_COPY_MODULE`;
17
18
 
18
19
  export const ITEMS_PER_PAGE = 50;
@@ -13,6 +13,7 @@ import {
13
13
  SET_CURRENT_NAVIGATION_LANGUAGES,
14
14
  SET_IS_NEW_TRANSLATION,
15
15
  SET_SELECTED_PARENT,
16
+ SET_COPY_MODULE,
16
17
  } from "./constants";
17
18
 
18
19
  export interface ISetEditorContent {
@@ -27,7 +28,7 @@ export interface ISetBreadcrumb {
27
28
 
28
29
  export interface ISetSchema {
29
30
  type: typeof SET_SCHEMA;
30
- payload: { schema: ISchema | {} };
31
+ payload: { schema: ISchema | Record<string, unknown> };
31
32
  }
32
33
 
33
34
  export interface ISetSelectedContent {
@@ -80,6 +81,11 @@ export interface ISetIsNewTranslation {
80
81
  payload: { isNewTranslation: boolean };
81
82
  }
82
83
 
84
+ export interface ISetCopyModule {
85
+ type: typeof SET_COPY_MODULE;
86
+ payload: { moduleCopy: Record<string, unknown> | null };
87
+ }
88
+
83
89
  export type NavigationActionsCreators = ISetEditorContent &
84
90
  ISetBreadcrumb &
85
91
  ISetSchema &
@@ -15,6 +15,7 @@ import {
15
15
  SET_CURRENT_NAVIGATION_LANGUAGES,
16
16
  SET_IS_NEW_TRANSLATION,
17
17
  SET_SELECTED_PARENT,
18
+ SET_COPY_MODULE,
18
19
  } from "./constants";
19
20
  import { NavigationActionsCreators } from "./interfaces";
20
21
 
@@ -34,6 +35,7 @@ export interface INavigationState {
34
35
  currentNavigationLanguages: any[];
35
36
  isNewTranslation: boolean;
36
37
  form: any;
38
+ moduleCopy: { date: string; element: Record<string, unknown> } | null;
37
39
  }
38
40
 
39
41
  export const initialState = {
@@ -52,6 +54,7 @@ export const initialState = {
52
54
  currentNavigationLanguages: [],
53
55
  isNewTranslation: false,
54
56
  form: {},
57
+ moduleCopy: null,
55
58
  };
56
59
 
57
60
  export function reducer(state = initialState, action: NavigationActionsCreators): INavigationState {
@@ -70,6 +73,7 @@ export function reducer(state = initialState, action: NavigationActionsCreators)
70
73
  case SET_TOTAL_ITEMS:
71
74
  case SET_CURRENT_NAVIGATION_LANGUAGES:
72
75
  case SET_IS_NEW_TRANSLATION:
76
+ case SET_COPY_MODULE:
73
77
  return { ...state, ...action.payload };
74
78
  default:
75
79
  return state;
@@ -692,8 +692,8 @@ function addComponent(type: any, key: string): (dispatch: Dispatch, getState: an
692
692
 
693
693
  function addModule(
694
694
  type: string,
695
- selectedID: number,
696
695
  key: string,
696
+ selectedID: number,
697
697
  isComponentModule?: boolean
698
698
  ): (dispatch: Dispatch, getState: any) => void {
699
699
  return (dispatch, getState) => {
@@ -89,7 +89,7 @@ interface IPageBrowserDispatchProps {
89
89
  deleteModule(editorID: number, key?: string): void;
90
90
  duplicateModule(editorID: number, key?: string): Promise<number>;
91
91
  addComponent: (componentType: any, key: string) => void;
92
- addModule: (moduleType: string, selectedID: number, key: string) => void;
92
+ addModule: (moduleType: string, key: string, selectedID: number, isComponentModule?: boolean) => void;
93
93
  moveElement(moduleID: number, selectedContent: any, newIndex: number, key: string): void;
94
94
  replaceModule(module: any, parent: any, objKey: string): void;
95
95
  replaceElementsInCollection(newValue: string, reference: string): void;
@@ -3,7 +3,7 @@ import { connect } from "react-redux";
3
3
  import { navigationActions } from "@ax/containers/Navigation/Defaults";
4
4
 
5
5
  import { ResizePanel, ConfigPanel } from "@ax/components";
6
- import { IBreadcrumbItem, IRootState, ISchema, ISite } from "@ax/types";
6
+ import { IBreadcrumbItem, INotification, IRootState, ISchema, ISite } from "@ax/types";
7
7
  import DefaultsBrowser from "./DefaultsBrowser";
8
8
 
9
9
  const Editor = (props: IProps) => {
@@ -16,10 +16,14 @@ const Editor = (props: IProps) => {
16
16
  selectedParent,
17
17
  activatedModules,
18
18
  addComponent,
19
+ addModule,
19
20
  moveModule,
20
21
  replaceModule,
21
22
  replaceElementsInCollection,
22
23
  setSelectedTab,
24
+ copyModule,
25
+ pasteModule,
26
+ setNotification,
23
27
  selectedTab,
24
28
  isLoading,
25
29
  site,
@@ -29,11 +33,15 @@ const Editor = (props: IProps) => {
29
33
  const actions = {
30
34
  deleteModuleAction: deleteModule,
31
35
  addComponentAction: addComponent,
36
+ addModuleAction: addModule,
32
37
  moveModuleAction: moveModule,
33
38
  replaceModuleAction: replaceModule,
34
39
  duplicateModuleAction: duplicateModule,
35
40
  replaceElementsInCollectionAction: replaceElementsInCollection,
36
41
  setSelectedContentAction: setSelectedContent,
42
+ copyModuleAction: copyModule,
43
+ pasteModuleAction: pasteModule,
44
+ setNotificationAction: setNotification,
37
45
  };
38
46
 
39
47
  return (
@@ -75,10 +83,14 @@ interface IPageBrowserDispatchProps {
75
83
  setSelectedTab(tab: string): void;
76
84
  deleteModule(editorID: number, key?: string): void;
77
85
  duplicateModule(editorID: number, key?: string): Promise<number>;
78
- addComponent: (componentType: any, key: string) => void;
86
+ addComponent(componentType: any, key: string): void;
87
+ addModule(type: string, key: string, selectedID: number, isComponentModule?: boolean): void;
79
88
  replaceModule(module: any, parent: any, objKey: string): void;
80
89
  replaceElementsInCollection(newValue: string, reference: string): void;
81
90
  moveModule(moduleID: number, selectedContent: any, newIndex: number, key: string): void;
91
+ copyModule(editorID: number): boolean;
92
+ pasteModule(editorID: number, key: string): Promise<{ error?: INotification }>;
93
+ setNotification: (notification: INotification) => void;
82
94
  browserRef?: React.RefObject<HTMLDivElement>;
83
95
  }
84
96
 
@@ -100,9 +112,12 @@ const mapDispatchToProps = {
100
112
  deleteModule: navigationActions.deleteModule,
101
113
  duplicateModule: navigationActions.duplicateModule,
102
114
  addComponent: navigationActions.addComponent,
115
+ addModule: navigationActions.addModule,
103
116
  moveModule: navigationActions.moveModule,
104
117
  replaceModule: navigationActions.replaceModule,
105
118
  replaceElementsInCollection: navigationActions.replaceElementsInCollection,
119
+ copyModule: navigationActions.copyModule,
120
+ pasteModule: navigationActions.pasteModule,
106
121
  };
107
122
 
108
123
  export default connect(mapStateToProps, mapDispatchToProps)(Editor);
@@ -1,13 +1,13 @@
1
- import React, { useEffect, useRef } from "react";
1
+ import React, { useEffect, useRef, useState } from "react";
2
2
  import { connect } from "react-redux";
3
3
 
4
- import { IRootState } from "@ax/types";
4
+ import { INotification, IRootState } from "@ax/types";
5
5
  import { useIsDirty, useModal } from "@ax/hooks";
6
6
  import { RouteLeavingGuard } from "@ax/guards";
7
7
 
8
8
  import { appActions } from "@ax/containers/App";
9
9
  import { navigationActions } from "@ax/containers/Navigation";
10
- import { ErrorToast, Loading, MainWrapper, Modal } from "@ax/components";
10
+ import { ErrorToast, Loading, MainWrapper, Modal, Notification } from "@ax/components";
11
11
  import Editor from "./Editor";
12
12
 
13
13
  import * as S from "./style";
@@ -34,6 +34,7 @@ const DefaultsEditor = (props: IProps) => {
34
34
  currentSiteInfo,
35
35
  } = props;
36
36
 
37
+ const [notification, setNotification] = useState<INotification | null>(null);
37
38
  const { isOpen, toggleModal } = useModal();
38
39
  const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent, isNewTranslation);
39
40
  const currentDefaultNav = currentDefaultsContent.find((item: any) => item.setAsDefault);
@@ -136,6 +137,17 @@ const DefaultsEditor = (props: IProps) => {
136
137
  pageLanguages={navLanguages}
137
138
  fullWidth={true}
138
139
  >
140
+ {notification && (
141
+ <S.NotificationWrapper>
142
+ <Notification
143
+ type={notification.type}
144
+ text={notification.text}
145
+ btnText={notification.btnText}
146
+ onClick={notification.onClick}
147
+ resetError={() => setNotification(null)}
148
+ />
149
+ </S.NotificationWrapper>
150
+ )}
139
151
  <ErrorToast size="l" />
140
152
  <Modal
141
153
  isOpen={isOpen}
@@ -148,7 +160,7 @@ const DefaultsEditor = (props: IProps) => {
148
160
  {isOpen ? <S.ModalContent>{setDefaultModalText}</S.ModalContent> : null}
149
161
  </Modal>
150
162
  <S.Content>
151
- <Editor browserRef={browserRef} />
163
+ <Editor browserRef={browserRef} setNotification={setNotification} />
152
164
  </S.Content>
153
165
  </MainWrapper>
154
166
  </>
@@ -8,18 +8,14 @@ const Content = styled.section`
8
8
  const NotificationWrapper = styled.div`
9
9
  position: fixed;
10
10
  width: 100%;
11
- top: ${p => `calc(${p.theme.spacing.s} * 4)`};
11
+ top: ${(p) => `calc(${p.theme.spacing.s} * 4)`};
12
12
  left: 0;
13
13
  right: 0;
14
14
  z-index: 1100;
15
15
  `;
16
16
 
17
17
  const ModalContent = styled.div`
18
- padding: ${p => p.theme.spacing.m};
18
+ padding: ${(p) => p.theme.spacing.m};
19
19
  `;
20
20
 
21
- export {
22
- Content,
23
- NotificationWrapper,
24
- ModalContent
25
- }
21
+ export { Content, NotificationWrapper, ModalContent };
@@ -116,7 +116,7 @@ interface IPageBrowserDispatchProps {
116
116
  deleteModule(editorID: number, key?: string): void;
117
117
  duplicateModule(editorID: number, key?: string): Promise<number>;
118
118
  addComponent: (componentType: any, key: string) => void;
119
- addModule: (moduleType: string, selectedID: number, key: string) => void;
119
+ addModule: (moduleType: string, key: string, selectedID: number, isComponentModule?: boolean) => void;
120
120
  moveElement(moduleID: number, selectedContent: any, newIndex: number, key: string): void;
121
121
  replaceModule(module: any, parent: any, objKey: string): void;
122
122
  replaceElementsInCollection(newValue: string, reference: string): void;
package/tsconfig.json CHANGED
@@ -28,12 +28,11 @@
28
28
  "webpack-env",
29
29
  "react/next",
30
30
  "react-dom/next",
31
- "@testing-library/jest-dom",
32
- "cypress",
31
+ "@testing-library/jest-dom",
33
32
  ],
34
33
  },
35
34
  "include": [
36
- "src"
35
+ "src",
37
36
  ],
38
37
  "extends": "./tsconfig.paths.json"
39
38
  }