@griddo/ax 11.7.4 → 11.7.6-rc.0

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": "11.7.4",
4
+ "version": "11.7.6-rc.0",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -223,5 +223,5 @@
223
223
  "publishConfig": {
224
224
  "access": "public"
225
225
  },
226
- "gitHead": "aca11f96f7cba5a12a8c2b76cac78c08c8b39ea9"
226
+ "gitHead": "f66a1f3378c5f35a178406b98338533202c5105c"
227
227
  }
@@ -152,7 +152,7 @@ const AsyncSelect = (props: IAsyncSelectProps): JSX.Element => {
152
152
  isDisabled={disabled}
153
153
  className={className}
154
154
  required={mandatory}
155
- isClearable={state.hasEmptyOption}
155
+ isClearable={false}
156
156
  isSearchable={searchable}
157
157
  maxWidth={maxWidth}
158
158
  inputValue={state.inputText}
@@ -57,7 +57,7 @@ const Select = (props: ISelectProps): JSX.Element => {
57
57
  error={error}
58
58
  onChange={handleChange}
59
59
  isSearchable={searchable}
60
- isClearable={hasEmptyOption}
60
+ isClearable={false}
61
61
  onInputChange={handleInputChange}
62
62
  alignRight={alignRight}
63
63
  aria-label={name}
@@ -30,7 +30,9 @@ const Wysiwyg = (props: IWysiwygProps): JSX.Element => {
30
30
  const handleChange = (model: string) => {
31
31
  onChange(model);
32
32
  const stripedHtml = decodeEntities(model);
33
- error && handleValidation && handleValidation(stripedHtml);
33
+ setTimeout(() => {
34
+ error && handleValidation && handleValidation(stripedHtml);
35
+ }, 300);
34
36
  };
35
37
 
36
38
  const dynamicConfig = {
@@ -41,28 +41,22 @@ import { useFilterQuery, useSortedListStatus } from "@ax/modules/MediaGallery/ho
41
41
  import { getSortedListStatus } from "@ax/modules/MediaGallery/utils";
42
42
 
43
43
  const Gallery = (props: IProps): JSX.Element => {
44
- const {
45
- currentFolderContent,
46
- site,
47
- currentFolderID,
48
- breadcrumb,
49
- toggleModal,
50
- getFolderContent,
51
- getFoldersTree,
52
- getImageSelected,
53
- updateCurrentFolder,
54
- } = props;
44
+ const { currentFolderContent, site, breadcrumb, toggleModal, getFolderContent, getFoldersTree, getImageSelected } =
45
+ props;
55
46
 
56
47
  const { images, folders } = currentFolderContent || { images: { items: [], totalItems: 0 }, folders: [] };
57
48
  const { items, totalItems } = images;
58
49
 
59
- const itemsPerPage = 10;
50
+ const itemsPerPage = 20;
60
51
  const firstPage = 1;
52
+ const lastPage = Math.ceil(totalItems / itemsPerPage);
61
53
  const [page, setPage] = useState(firstPage);
62
54
  const [selectedTab, setSelectedTab] = useState(site ? "local" : "global");
63
55
  const [selectedImage, setSelectedImage] = useState<IImage | null>(null);
64
56
  const [isPanelOpen, setPanelOpen] = useState(false);
65
57
  const [isLoading, setIsLoading] = useState(false);
58
+ const [isLoadingMore, setIsLoadingMore] = useState(false);
59
+ const [currentFolderID, setCurrentFolderID] = useState<number | null>(null);
66
60
  const isLocalTab = selectedTab === "local";
67
61
  const galleryScope = isLocalTab && site ? site.id : "global";
68
62
  const hasFolders = !!folders.length;
@@ -127,7 +121,9 @@ const Gallery = (props: IProps): JSX.Element => {
127
121
 
128
122
  useLayoutEffect(() => {
129
123
  return () => {
130
- updateCurrentFolder(null);
124
+ setCurrentFolderID(null);
125
+ setSelectedTab("site");
126
+ setPage(firstPage);
131
127
  };
132
128
  // eslint-disable-next-line react-hooks/exhaustive-deps
133
129
  }, []);
@@ -137,7 +133,8 @@ const Gallery = (props: IProps): JSX.Element => {
137
133
  page === 1 && setIsLoading(true);
138
134
  const params = getParams();
139
135
  await getFolderContent(params);
140
- page === 1 && setIsLoading(false);
136
+ setIsLoading(false);
137
+ setIsLoadingMore(false);
141
138
  };
142
139
  const handleGetTree = async () => await getFoldersTree(siteID);
143
140
  handleGetContent();
@@ -148,7 +145,13 @@ const Gallery = (props: IProps): JSX.Element => {
148
145
  const onScroll = () => {
149
146
  if (galleryRef.current) {
150
147
  const { scrollTop, scrollHeight, clientHeight } = galleryRef.current;
151
- if (scrollTop + clientHeight === scrollHeight && items.length < totalItems) {
148
+ if (
149
+ scrollTop + clientHeight + 100 >= scrollHeight &&
150
+ items.length < totalItems &&
151
+ page < lastPage &&
152
+ !isLoadingMore
153
+ ) {
154
+ setIsLoadingMore(true);
152
155
  setPage((currentPage) => currentPage + 1);
153
156
  }
154
157
  }
@@ -170,18 +173,26 @@ const Gallery = (props: IProps): JSX.Element => {
170
173
 
171
174
  const handleSelectedTab = (tab: string) => {
172
175
  if (tab !== selectedTab) {
173
- updateCurrentFolder(null);
176
+ setSearchQuery("");
177
+ setCurrentFolderID(null);
174
178
  setSelectedImage(null);
175
179
  setSelectedTab(tab);
176
180
  setPage(firstPage);
177
181
  }
178
182
  };
179
183
 
184
+ const handleUpdateCurrentFolder = (folderID: number | null) => {
185
+ setSearchQuery("");
186
+ setPage(firstPage);
187
+ setCurrentFolderID(folderID);
188
+ };
189
+
180
190
  const togglePanel = () => setPanelOpen(!isPanelOpen);
181
191
 
182
192
  const handleBackClick = () => {
183
193
  const parentID = breadcrumb.length >= 2 ? breadcrumb[breadcrumb.length - 2].id : null;
184
- updateCurrentFolder(parentID);
194
+ setPage(firstPage);
195
+ setCurrentFolderID(parentID);
185
196
  };
186
197
 
187
198
  const handleUpload = async (file: IImage[]) => {
@@ -225,7 +236,7 @@ const Gallery = (props: IProps): JSX.Element => {
225
236
  <S.Wrapper data-testid="image-gallery-wrapper">
226
237
  <S.FolderPanel isOpen={isPanelOpen} ref={ref}>
227
238
  <S.FolderPanelContent>
228
- <FolderTree folderID={currentFolderID || 0} onClick={updateCurrentFolder} title="Folders" />
239
+ <FolderTree folderID={currentFolderID || 0} onClick={handleUpdateCurrentFolder} title="Folders" />
229
240
  </S.FolderPanelContent>
230
241
  <S.ResizeHandle className="resizer" />
231
242
  </S.FolderPanel>
@@ -266,7 +277,7 @@ const Gallery = (props: IProps): JSX.Element => {
266
277
  resetFilters={resetFilterQuery}
267
278
  />
268
279
  </S.SearchTags>
269
- {!isRoot && !isSearching && <Breadcrumb breadcrumb={breadcrumb} onClick={updateCurrentFolder} />}
280
+ {!isRoot && !isSearching && <Breadcrumb breadcrumb={breadcrumb} onClick={handleUpdateCurrentFolder} />}
270
281
  {(hasFolders || (!isRoot && !isSearching)) && (
271
282
  <S.SectionWrapper>
272
283
  <S.SectionHeader>
@@ -281,7 +292,7 @@ const Gallery = (props: IProps): JSX.Element => {
281
292
  {!isRoot && !isSearching && <BackFolder onClick={handleBackClick} size="S" />}
282
293
  <S.FoldersGrid>
283
294
  {folders.map((folder: IFolder) => (
284
- <FolderItem folder={folder} onClick={updateCurrentFolder} key={folder.folderName} />
295
+ <FolderItem folder={folder} onClick={handleUpdateCurrentFolder} key={folder.folderName} />
285
296
  ))}
286
297
  </S.FoldersGrid>
287
298
  </S.FoldersWrapper>
@@ -347,7 +358,6 @@ const Gallery = (props: IProps): JSX.Element => {
347
358
  export interface IGalleryProps {
348
359
  site: ISite | null;
349
360
  currentFolderContent: IImageFolder | null;
350
- currentFolderID: number | null;
351
361
  isLoading: boolean;
352
362
  breadcrumb: IFolderTree[];
353
363
  toggleModal: () => void;
@@ -357,20 +367,17 @@ export interface IGalleryProps {
357
367
  const mapStateToProps = (state: IRootState) => ({
358
368
  isLoading: state.app.isLoading,
359
369
  currentFolderContent: state.gallery.currentFolderContent,
360
- currentFolderID: state.gallery.currentFolderID,
361
370
  breadcrumb: state.gallery.breadcrumb,
362
371
  });
363
372
 
364
373
  export interface IDispatchProps {
365
374
  getFolderContent(params: IGetFolderParams): Promise<void>;
366
375
  getFoldersTree(siteID: number | "global"): Promise<void>;
367
- updateCurrentFolder(folderID: number | null): void;
368
376
  }
369
377
 
370
378
  const mapDispatchToProps = {
371
379
  getFolderContent: galleryActions.getFolderContent,
372
380
  getFoldersTree: galleryActions.getFoldersTree,
373
- updateCurrentFolder: galleryActions.updateCurrentFolder,
374
381
  };
375
382
 
376
383
  type IProps = IGalleryProps & IDispatchProps;
@@ -4,6 +4,7 @@ import { navigation } from "@ax/api";
4
4
  import {
5
5
  IBreadcrumbItem,
6
6
  IModule,
7
+ INavigation,
7
8
  INavPages,
8
9
  INotification,
9
10
  IRootState,
@@ -33,7 +34,7 @@ import {
33
34
 
34
35
  import { appActions } from "@ax/containers/App";
35
36
 
36
- import { getFormData, getStateValues } from "./utils";
37
+ import { getFormData, getStateValues, getTranslatedMenus } from "./utils";
37
38
 
38
39
  import {
39
40
  SET_EDITOR_CONTENT,
@@ -138,7 +139,7 @@ function setNavPages(navigationPages: INavPages): ISetNavPages {
138
139
 
139
140
  // API RELATED FUNCTIONS
140
141
 
141
- function getHeaders(params: any): (dispatch: Dispatch, getState: any) => Promise<void> {
142
+ function getHeaders(params: any): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
142
143
  return async (dispatch, getState) => {
143
144
  try {
144
145
  const { currentSiteInfo } = getStateValues(getState);
@@ -184,7 +185,7 @@ function getFooters(params: any): (dispatch: Dispatch, getState: any) => Promise
184
185
  };
185
186
  }
186
187
 
187
- function getDefaults(params?: any): (dispatch: Dispatch, getState: any) => Promise<void> {
188
+ function getDefaults(params?: any): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
188
189
  return async (dispatch, getState) => {
189
190
  try {
190
191
  const { currentSiteInfo } = getStateValues(getState);
@@ -215,7 +216,7 @@ function getDefaults(params?: any): (dispatch: Dispatch, getState: any) => Promi
215
216
  };
216
217
  }
217
218
 
218
- function getNavigationByType(type: string): (dispatch: Dispatch, getState: any) => void {
219
+ function getNavigationByType(type: string): (dispatch: Dispatch, getState: () => IRootState) => void {
219
220
  return async (dispatch, getState) => {
220
221
  const {
221
222
  app: { token, lang },
@@ -242,7 +243,9 @@ function getNavigationByType(type: string): (dispatch: Dispatch, getState: any)
242
243
  };
243
244
  }
244
245
 
245
- function createNavigation(navHtml?: HTMLDivElement | null): (dispatch: Dispatch, getState: any) => Promise<boolean> {
246
+ function createNavigation(
247
+ navHtml?: HTMLDivElement | null
248
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
246
249
  return async (dispatch, getState) => {
247
250
  try {
248
251
  dispatch(appActions.setIsSaving(true));
@@ -253,6 +256,10 @@ function createNavigation(navHtml?: HTMLDivElement | null): (dispatch: Dispatch,
253
256
  app: { lang },
254
257
  } = getState();
255
258
 
259
+ if (!editorContent || !currentSiteInfo) {
260
+ return false;
261
+ }
262
+
256
263
  if (isNewTranslation) {
257
264
  delete editorContent.id;
258
265
  }
@@ -297,7 +304,7 @@ function updateNavigation(
297
304
  data: any,
298
305
  fromEditor?: boolean,
299
306
  navHtml?: HTMLDivElement | null
300
- ): (dispatch: Dispatch, getState: any) => Promise<boolean> {
307
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
301
308
  return async (dispatch, getState) => {
302
309
  try {
303
310
  dispatch(appActions.setIsSaving(true));
@@ -346,7 +353,7 @@ function deleteNavigation(
346
353
  navID: number | number[],
347
354
  type: string,
348
355
  errorAction: () => void
349
- ): (dispatch: Dispatch, getState: any) => Promise<boolean> {
356
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
350
357
  return async (dispatch, getState) => {
351
358
  try {
352
359
  const isBulk = Array.isArray(navID);
@@ -386,7 +393,7 @@ function deleteNavigation(
386
393
  function restoreNavigation(
387
394
  navID: number | number[],
388
395
  type: string
389
- ): (dispatch: Dispatch, getState: any) => Promise<void> {
396
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
390
397
  return async (dispatch, getState) => {
391
398
  try {
392
399
  const responseActions = {
@@ -411,7 +418,10 @@ function restoreNavigation(
411
418
  };
412
419
  }
413
420
 
414
- function setDefaultNavigation(navID: number, type: string): (dispatch: Dispatch, getState: any) => Promise<void> {
421
+ function setDefaultNavigation(
422
+ navID: number,
423
+ type: string
424
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
415
425
  return async (dispatch, getState) => {
416
426
  try {
417
427
  const responseActions = {
@@ -428,7 +438,7 @@ function setDefaultNavigation(navID: number, type: string): (dispatch: Dispatch,
428
438
  };
429
439
  }
430
440
 
431
- function generateNewDefault(dispatch: Dispatch, getState: any) {
441
+ function generateNewDefault(dispatch: Dispatch, getState: () => IRootState) {
432
442
  const {
433
443
  selectedDefault,
434
444
  currentSiteInfo: { navigationModules },
@@ -449,10 +459,10 @@ function generateNewDefault(dispatch: Dispatch, getState: any) {
449
459
  generateContent(defaultSchema)(dispatch, getState);
450
460
  }
451
461
 
452
- function getValues(): (dispatch: Dispatch, getState: any) => Promise<void> {
462
+ function getValues(): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
453
463
  return async (dispatch, getState) => {
454
464
  try {
455
- const { selectedDefault, header, footer, isNewTranslation, currentSiteInfo } = getStateValues(getState);
465
+ const { selectedDefault, header, footer, isNewTranslation, currentSiteInfo, menus } = getStateValues(getState);
456
466
 
457
467
  const isHeader = selectedDefault === "Headers";
458
468
  const currentNavigation = isHeader ? header : footer;
@@ -471,6 +481,9 @@ function getValues(): (dispatch: Dispatch, getState: any) => Promise<void> {
471
481
  if (navigationModuleComponent) {
472
482
  response.component = navigationModuleComponent;
473
483
  }
484
+ if (isNewTranslation) {
485
+ getTranslatedMenus(response, menus);
486
+ }
474
487
  dispatch(setSelectedEditorID(rootEditorID));
475
488
  generateContent(response)(dispatch, getState);
476
489
  },
@@ -542,17 +555,17 @@ function addModule(
542
555
  key: string,
543
556
  selectedID: number,
544
557
  isComponentModule?: boolean
545
- ): (dispatch: Dispatch, getState: any) => void {
558
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
546
559
  return (dispatch, getState) => {
547
560
  addComponent(type, key)(dispatch, getState);
548
561
  };
549
562
  }
550
563
 
551
- function addComponent(type: any, key: string): (dispatch: Dispatch, getState: any) => void {
564
+ function addComponent(type: any, key: string): (dispatch: Dispatch, getState: () => IRootState) => void {
552
565
  return (dispatch, getState) => {
553
566
  const { editorContent, selectedEditorID } = getStateValues(getState);
554
567
  const component = {
555
- editorID: selectedEditorID,
568
+ editorID: selectedEditorID || 0,
556
569
  type,
557
570
  };
558
571
  const updatedContent = getUpdatedComponents(editorContent, component, key);
@@ -568,7 +581,7 @@ function addComponent(type: any, key: string): (dispatch: Dispatch, getState: an
568
581
  };
569
582
  }
570
583
 
571
- function deleteModule(editorID: number[], key: string): (dispatch: Dispatch, getState: any) => void {
584
+ function deleteModule(editorID: number[], key: string): (dispatch: Dispatch, getState: () => IRootState) => void {
572
585
  return (dispatch, getState) => {
573
586
  const { editorContent } = getStateValues(getState);
574
587
  const updatedContent: any = deepClone(editorContent);
@@ -588,7 +601,11 @@ function deleteModule(editorID: number[], key: string): (dispatch: Dispatch, get
588
601
  };
589
602
  }
590
603
 
591
- function replaceModule(module: any, parent: any, objKey: string): (dispatch: Dispatch, getState: any) => void {
604
+ function replaceModule(
605
+ module: any,
606
+ parent: any,
607
+ objKey: string
608
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
592
609
  return async (dispatch, getState) => {
593
610
  const { editorContent } = getStateValues(getState);
594
611
  const updatedVal = {
@@ -610,7 +627,7 @@ function replaceModule(module: any, parent: any, objKey: string): (dispatch: Dis
610
627
  };
611
628
  }
612
629
 
613
- function duplicateModule(editorID: number[], key?: string): (dispatch: Dispatch, getState: any) => number {
630
+ function duplicateModule(editorID: number[], key?: string): (dispatch: Dispatch, getState: () => IRootState) => number {
614
631
  return (dispatch, getState) => {
615
632
  const { editorContent } = getStateValues(getState);
616
633
 
@@ -650,7 +667,7 @@ function moveModule(
650
667
  content: any,
651
668
  newIndex: number,
652
669
  key: string
653
- ): (dispatch: Dispatch, getState: any) => void {
670
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
654
671
  return async (dispatch, getState) => {
655
672
  try {
656
673
  const {
@@ -670,7 +687,7 @@ function moveModule(
670
687
  };
671
688
  }
672
689
 
673
- function copyModule(editorID: number[]): (dispatch: Dispatch, getState: any) => boolean | number {
690
+ function copyModule(editorID: number[]): (dispatch: Dispatch, getState: () => IRootState) => boolean | number {
674
691
  return (dispatch, getState) => {
675
692
  const {
676
693
  navigation: { editorContent },
@@ -704,12 +721,16 @@ function pasteModule(
704
721
  editorID: number,
705
722
  key: string,
706
723
  modulesToPaste: IModule[]
707
- ): (dispatch: Dispatch, getState: any) => Promise<{ error?: INotification }> {
724
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<{ error?: INotification }> {
708
725
  return async (dispatch, getState) => {
709
726
  const {
710
727
  navigation: { editorContent },
711
728
  }: IRootState = getState();
712
729
 
730
+ if (!editorContent) {
731
+ return { error: undefined };
732
+ }
733
+
713
734
  const { element: originalElement } = findByEditorID(editorContent, editorID);
714
735
  const itemsArr = originalElement[key];
715
736
 
@@ -728,7 +749,10 @@ function pasteModule(
728
749
  };
729
750
  }
730
751
 
731
- function replaceElementsInCollection(newValue: string, reference: string): (dispatch: Dispatch, getState: any) => void {
752
+ function replaceElementsInCollection(
753
+ newValue: string,
754
+ reference: string
755
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
732
756
  return async (dispatch, getState) => {
733
757
  const { selectedContent } = getStateValues(getState);
734
758
  const key = reference ? reference : "elements";
@@ -739,19 +763,19 @@ function replaceElementsInCollection(newValue: string, reference: string): (disp
739
763
  };
740
764
  }
741
765
 
742
- function generateContent(editorContent: any): (dispatch: Dispatch, getState: any) => void {
766
+ function generateContent(editorContent: INavigation): (dispatch: Dispatch, getState: () => IRootState) => void {
743
767
  return async (dispatch, getState) => {
744
768
  const {
745
769
  navigation: { selectedEditorID },
746
770
  } = getState();
747
771
  const { pageContent } = generateEditorIDs(editorContent);
748
- const { element: selectedContent, parent: selectedParent } = findByEditorID(pageContent, selectedEditorID);
772
+ const { element: selectedContent, parent: selectedParent } = findByEditorID(pageContent, selectedEditorID || 0);
749
773
  const { component } = selectedContent;
750
774
  const schema = selectedContent && getSchema(component);
751
775
 
752
776
  dispatch(setSchema(schema));
753
777
  dispatch(setEditorContent(pageContent));
754
- dispatch(updateBreadcrumb(selectedEditorID));
778
+ dispatch(updateBreadcrumb(selectedEditorID || 0));
755
779
  dispatch(setSelectedDefaultContent(selectedContent));
756
780
  dispatch(setSelectedDefaultParentContent(selectedParent));
757
781
  dispatch(setTab("content"));
@@ -764,7 +788,7 @@ function updateEditorContent(
764
788
  selectedEditorID: number,
765
789
  key: string,
766
790
  value: any
767
- ): (dispatch: Dispatch, getState: any) => void {
791
+ ): (dispatch: Dispatch, getState: () => IRootState) => void {
768
792
  return (dispatch, getState) => {
769
793
  const {
770
794
  navigation: { selectedContent, editorContent },
@@ -777,7 +801,7 @@ function updateEditorContent(
777
801
  };
778
802
  }
779
803
 
780
- function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: any) => Promise<void> {
804
+ function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
781
805
  return async (dispatch, getState) => {
782
806
  dispatch(setIsLoading(true));
783
807
  /*
@@ -805,7 +829,7 @@ function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: an
805
829
  }
806
830
 
807
831
  function updateBreadcrumb(editorID: number): any {
808
- return async (dispatch: Dispatch, getState: () => any) => {
832
+ return async (dispatch: Dispatch, getState: () => IRootState) => {
809
833
  const {
810
834
  navigation: { editorContent },
811
835
  } = getState();
@@ -1,4 +1,4 @@
1
- import { IBreadcrumbItem, IModule, INavPages, ISchema } from "@ax/types";
1
+ import { IBreadcrumbItem, IModule, INavigation, INavPages, ISchema } from "@ax/types";
2
2
 
3
3
  import {
4
4
  SET_EDITOR_CONTENT,
@@ -20,7 +20,7 @@ import {
20
20
  } from "./constants";
21
21
 
22
22
  export interface INavigationState {
23
- editorContent: any | undefined;
23
+ editorContent: INavigation | null;
24
24
  breadcrumb: IBreadcrumbItem[];
25
25
  schema: ISchema | Record<string, unknown>;
26
26
  selectedContent: any;
@@ -40,7 +40,7 @@ export interface INavigationState {
40
40
  }
41
41
 
42
42
  export const initialState = {
43
- editorContent: undefined,
43
+ editorContent: null,
44
44
  breadcrumb: [],
45
45
  schema: {},
46
46
  selectedContent: {},
@@ -1,4 +1,6 @@
1
- const getStateValues = (getState: any) => {
1
+ import { IMenu, INavigation, IRootState, ISite } from "@ax/types";
2
+
3
+ const getStateValues = (getState: () => IRootState) => {
2
4
  const {
3
5
  sites: { currentSiteInfo },
4
6
  navigation: {
@@ -12,13 +14,14 @@ const getStateValues = (getState: any) => {
12
14
  currentDefaultsContent,
13
15
  selectedContent,
14
16
  },
17
+ menu: { savedMenus },
15
18
  app: { isSaving, isLoading },
16
19
  } = getState();
17
20
  const section = editorContent && editorContent[0];
18
21
  const { modules } = !!section && section;
19
22
 
20
23
  return {
21
- currentSiteInfo,
24
+ currentSiteInfo: currentSiteInfo as ISite,
22
25
  editorContent,
23
26
  selectedDefault,
24
27
  selectedEditorID,
@@ -32,6 +35,7 @@ const getStateValues = (getState: any) => {
32
35
  section,
33
36
  modules,
34
37
  selectedContent,
38
+ menus: savedMenus,
35
39
  };
36
40
  };
37
41
 
@@ -42,4 +46,33 @@ const getFormData = (values: any, image?: File | null): FormData => {
42
46
  return form;
43
47
  };
44
48
 
45
- export { getStateValues, getFormData };
49
+ const getTranslatedMenus = (editorContent: INavigation, menus: IMenu[] | null) => {
50
+ const keys = Object.keys(editorContent).filter((k) => editorContent[k]?.component === "MenuContainer");
51
+
52
+ if (!keys.length) {
53
+ return editorContent;
54
+ }
55
+
56
+ if (!menus || !menus.length) {
57
+ keys.forEach((key) => {
58
+ editorContent[key] = null;
59
+ });
60
+ return editorContent;
61
+ }
62
+
63
+ keys.forEach((key) => {
64
+ const menuName = (editorContent[key] as IMenu).name;
65
+ const translatedMenu = menus.find((menu) => menu.name === menuName);
66
+ const hasElements = !!translatedMenu?.elements?.length;
67
+
68
+ if (translatedMenu && hasElements) {
69
+ editorContent[key] = translatedMenu;
70
+ } else {
71
+ editorContent[key] = null;
72
+ }
73
+ });
74
+
75
+ return editorContent;
76
+ };
77
+
78
+ export { getStateValues, getFormData, getTranslatedMenus };
@@ -70,7 +70,7 @@ const DetailPanel = (props: IProps) => {
70
70
  };
71
71
 
72
72
  const mainNewModalAction = {
73
- title: "Delete document",
73
+ title: "Delete image",
74
74
  onClick: () => handleDeleteFile(),
75
75
  };
76
76
 
@@ -82,7 +82,6 @@ const DetailPanel = (props: IProps) => {
82
82
  <>
83
83
  <S.Wrapper>
84
84
  <S.Header>
85
- DETAILS
86
85
  <Tabs tabs={tabs} active={selectedTab} setSelectedTab={handleSelectedTab} noMargins />
87
86
  </S.Header>
88
87
  {selectedTab === "in use" ? (
@@ -14,7 +14,7 @@ const Wrapper = styled.div`
14
14
 
15
15
  const Header = styled.div`
16
16
  ${(p) => p.theme.textStyle.headingXS};
17
- padding: ${(p) => `${p.theme.spacing.s} ${p.theme.spacing.s} 0 ${p.theme.spacing.s}`};
17
+ padding-top: ${(p) => p.theme.spacing.xs};
18
18
  text-align: center;
19
19
  border-bottom: ${(p) => `1px solid ${p.theme.color.uiLine}`};
20
20
  `;
@@ -61,7 +61,7 @@ const DeleteFolderModal = (props: IDeleteModalProps): JSX.Element => {
61
61
  height={240}
62
62
  >
63
63
  <S.ModalContent>
64
- Are you sure you want to delete <strong>{title} folder</strong>? All documents inside the folder will also be
64
+ Are you sure you want to delete <strong>{title} folder</strong>? All images inside the folder will also be
65
65
  deleted. This action <strong>cannot be undone</strong>.
66
66
  </S.ModalContent>
67
67
  </Modal>
@@ -7,7 +7,7 @@ import { useIsDirty, useModal, usePermission } from "@ax/hooks";
7
7
  import { RouteLeavingGuard } from "@ax/guards";
8
8
 
9
9
  import { appActions } from "@ax/containers/App";
10
- import { navigationActions } from "@ax/containers/Navigation";
10
+ import { navigationActions, menuActions } from "@ax/containers/Navigation";
11
11
  import { ErrorPage, ErrorToast, Loading, MainWrapper, Modal, Notification } from "@ax/components";
12
12
  import Editor from "./Editor";
13
13
 
@@ -32,6 +32,7 @@ const DefaultsEditor = (props: IProps) => {
32
32
  setHeader,
33
33
  setFooter,
34
34
  setHistoryPush,
35
+ getMenus,
35
36
  currentSiteInfo,
36
37
  } = props;
37
38
 
@@ -127,6 +128,7 @@ const DefaultsEditor = (props: IProps) => {
127
128
  } else {
128
129
  setIsDirty(true);
129
130
  createTranslation(true);
131
+ await getMenus();
130
132
  editorContent && (await getNavigation(editorContent.id));
131
133
  }
132
134
  };
@@ -232,6 +234,7 @@ const mapDispatchToProps = {
232
234
  createTranslation: navigationActions.createNewTranslation,
233
235
  setHeader: navigationActions.setHeader,
234
236
  setFooter: navigationActions.setFooter,
237
+ getMenus: menuActions.getMenus,
235
238
  };
236
239
 
237
240
  interface IDispatchProps {
@@ -243,6 +246,7 @@ interface IDispatchProps {
243
246
  createTranslation(isNewTranslation: boolean): void;
244
247
  setHeader(id: number | null): void;
245
248
  setFooter(id: number | null): void;
249
+ getMenus(): Promise<void>;
246
250
  }
247
251
 
248
252
  type IProps = IStateProps & IDispatchProps;
@@ -4,7 +4,7 @@ import { connect } from "react-redux";
4
4
  import { IHeader, IFooter, ICheck, ILanguage, INavigationLanguage } from "@ax/types";
5
5
  import { useModal, usePermission } from "@ax/hooks";
6
6
  import { appActions } from "@ax/containers/App";
7
- import { navigationActions } from "@ax/containers/Navigation";
7
+ import { navigationActions, menuActions } from "@ax/containers/Navigation";
8
8
  import { CheckField, FieldsBehavior, Modal } from "@ax/components";
9
9
 
10
10
  import { Translations } from "./atoms";
@@ -30,6 +30,7 @@ const DefaultItem = (props: IProps): JSX.Element => {
30
30
  onChange,
31
31
  isSelected,
32
32
  toggleReplaceModal,
33
+ getMenus,
33
34
  hoverCheck,
34
35
  } = props;
35
36
 
@@ -132,7 +133,7 @@ const DefaultItem = (props: IProps): JSX.Element => {
132
133
  const getSelectedNavLanguage = (navLanguages: INavigationLanguage[], language: ILanguage) =>
133
134
  navLanguages.find((navLang) => navLang.languageId === language.id);
134
135
 
135
- const handleLanguage = (language: ILanguage) => {
136
+ const handleLanguage = async (language: ILanguage) => {
136
137
  const { locale, id } = language;
137
138
 
138
139
  const lang = {
@@ -148,6 +149,7 @@ const DefaultItem = (props: IProps): JSX.Element => {
148
149
  selectedNavLanguage ? setNav(selectedNavLanguage.navigationId) : setNav(defaultContent.id);
149
150
  setTranslation();
150
151
  !selectedNavLanguage && createNewTranslation(true);
152
+ await getMenus();
151
153
  const path = "/sites/navigations/editor";
152
154
  setHistoryPush(path, true);
153
155
  };
@@ -244,6 +246,7 @@ interface IProps {
244
246
  setHeader(id: number | null): void;
245
247
  setFooter(id: number | null): void;
246
248
  toggleReplaceModal: () => void;
249
+ getMenus(): Promise<void>;
247
250
  hoverCheck: boolean;
248
251
  }
249
252
 
@@ -255,6 +258,7 @@ const mapDispatchToProps = {
255
258
  createNewTranslation: navigationActions.createNewTranslation,
256
259
  setHeader: navigationActions.setHeader,
257
260
  setFooter: navigationActions.setFooter,
261
+ getMenus: menuActions.getMenus,
258
262
  };
259
263
 
260
264
  export default connect(null, mapDispatchToProps)(DefaultItem);
@@ -413,6 +413,20 @@ export interface IMenuForm {
413
413
  footerStyle: string;
414
414
  }
415
415
 
416
+ export interface INavigation {
417
+ id?: number;
418
+ component: string;
419
+ deleted?: boolean;
420
+ entity: string;
421
+ language: number;
422
+ navigationLanguages: INavigationLanguage[];
423
+ setAsDefault: boolean;
424
+ site: number;
425
+ title: string;
426
+ type: "header" | "footer";
427
+ [key: string]: any; // TODO: set type
428
+ }
429
+
416
430
  export interface IHeader {
417
431
  component: string;
418
432
  deleted?: boolean;