@griddo/ax 10.1.22 → 10.1.24

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": "10.1.22",
4
+ "version": "10.1.24",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -230,5 +230,5 @@
230
230
  "publishConfig": {
231
231
  "access": "public"
232
232
  },
233
- "gitHead": "f4c83713875a78532a56ccae4e29731252f4ea6a"
233
+ "gitHead": "9f7d623c271600fa67301cfa3609055775af1445"
234
234
  }
@@ -28,7 +28,7 @@ export const TemplateManager = (props: IProps): JSX.Element => {
28
28
  moduleCopy,
29
29
  availableDataPacks,
30
30
  setHistoryPush,
31
- lang
31
+ lang,
32
32
  } = props;
33
33
 
34
34
  const isConfig = selectedTab === "config";
@@ -46,12 +46,17 @@ export const TemplateManager = (props: IProps): JSX.Element => {
46
46
  updateValue(fieldKey, value, templateContent.editorID, slugTo);
47
47
  const error = errors.find((err: any) => err.editorID === templateContent.editorID && err.key === key);
48
48
 
49
- const addedModules = modulesDataPacks
50
- .filter(
51
- (mod: any) =>
52
- mod.sectionList && mod.sectionList[template.component] && mod.sectionList[template.component].includes(key)
53
- )
54
- .map((mod: any) => mod.id);
49
+ const addedModules = modulesDataPacks.reduce((acc: string[], current: any) => {
50
+ if (
51
+ current.sectionList &&
52
+ current.sectionList[template.component] &&
53
+ current.sectionList[template.component].includes(key) &&
54
+ !acc.includes(current.id)
55
+ ) {
56
+ return [...acc, current.id];
57
+ }
58
+ return acc;
59
+ }, []);
55
60
 
56
61
  const mappedWhiteList = whiteList ? [...whiteList, ...addedModules].sort() : [...addedModules.sort()];
57
62
  const categories = getModuleCategories(mappedWhiteList);
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useCallback, useState, useRef } from "react";
2
2
  import { connect } from "react-redux";
3
- import { useLocation } from "react-router-dom";
3
+ import { useHistory, useLocation } from "react-router-dom";
4
4
  import { schemas } from "components";
5
5
 
6
6
  import { useModal, useBulkSelection, useToast, useCategoryColors } from "@ax/hooks";
@@ -180,6 +180,7 @@ const Content = (props: IProps): JSX.Element => {
180
180
  const [arePagesTranslated, setArePagesTranslated] = useState(false);
181
181
  const [templateInstanceError, setTemplateInstanceError] = useState({ error: false, templateName: "" });
182
182
  const [pagesSelected, setPagesSelected] = useState<any[]>([]);
183
+ const history = useHistory();
183
184
 
184
185
  const {
185
186
  resetBulkSelection,
@@ -273,7 +274,7 @@ const Content = (props: IProps): JSX.Element => {
273
274
 
274
275
  useEffect(() => {
275
276
  checkUserSession();
276
- if (!locationState || locationState.isFromEditor !== true) {
277
+ if (history.action !== "POP" && (!locationState || locationState.isFromEditor !== true)) {
277
278
  setFilter("unique-pages");
278
279
  }
279
280
  resetPageEditor();
@@ -1,10 +1,10 @@
1
1
  import { schemas } from "components";
2
2
  import { filterDuplicatedValues, getActivatedDataPacksIds } from "@ax/helpers";
3
3
  import { pageStatus } from "@ax/containers/PageEditor/interfaces";
4
- import { IPage, IStructuredDataContent } from "@ax/types";
4
+ import { IDataPack, IPage, IStructuredDataContent } from "@ax/types";
5
5
 
6
- const getTemplatesFilters = (activatedDataPacks: any) => {
7
- const filters: any[] = [];
6
+ const getTemplatesFilters = (activatedDataPacks: IDataPack[]) => {
7
+ const filters: { label: string; value: string; mode: string }[] = [];
8
8
  const activatedDataPacksIds = getActivatedDataPacksIds(activatedDataPacks);
9
9
  const { templates } = schemas;
10
10
 
@@ -15,21 +15,23 @@ const getTemplatesFilters = (activatedDataPacks: any) => {
15
15
  if (isActivated) {
16
16
  !dataPacks
17
17
  ? filters.push({ ...type })
18
- : dataPacks.map((dataPack: string) => {
18
+ : dataPacks.forEach((dataPack: string) => {
19
19
  const currentDataPack = activatedDataPacks.find(
20
- (activatedDataPack: any) => dataPack === activatedDataPack.id
20
+ (activatedDataPack: IDataPack) => dataPack === activatedDataPack.id
21
21
  );
22
22
 
23
- return filters.push({
24
- label: currentDataPack.title,
25
- value: currentDataPack.id,
26
- mode: type.mode,
27
- });
23
+ if (currentDataPack) {
24
+ filters.push({
25
+ label: currentDataPack?.title,
26
+ value: currentDataPack?.id,
27
+ mode: type.mode,
28
+ });
29
+ }
28
30
  });
29
31
  }
30
32
  });
31
33
 
32
- const uniqueFilters = filterDuplicatedValues(filters);
34
+ const uniqueFilters: { label: string; value: string; mode: string }[] = filterDuplicatedValues(filters);
33
35
  return uniqueFilters;
34
36
  };
35
37
 
@@ -45,7 +47,7 @@ const mapStructuredOptions = (options: any[]) => {
45
47
  type: id,
46
48
  isData: true,
47
49
  dataPacks,
48
- editable
50
+ editable,
49
51
  };
50
52
  });
51
53
  };
@@ -74,29 +76,36 @@ const getOptionValues = (options: any) => {
74
76
  return [...templatesOptionsValues, ...mapStructuredOptions(options)];
75
77
  };
76
78
 
77
- const getOptionFilters = (options: IStructuredDataContent[], activatedDataPacks: any) => {
78
- const pureOptions = options.filter((option: any) => !option.fromPage);
79
+ const getOptionFilters = (options: IStructuredDataContent[], activatedDataPacks: IDataPack[]) => {
80
+ const pureOptions = options.filter((option: IStructuredDataContent) => !option.fromPage);
79
81
  const templateFilters = getTemplatesFilters(activatedDataPacks);
80
82
  const activatedDataPacksIds = getActivatedDataPacksIds(activatedDataPacks);
81
83
 
82
-
83
- const mappedOptions = pureOptions.flatMap((option: any) =>
84
- option.dataPacks.filter((dataPack: string) => activatedDataPacksIds.includes(dataPack)).map((dataPack: string) => {
85
- const currentDataPack = activatedDataPacks.find((activatedDataPack: any) => dataPack === activatedDataPack.id);
86
- return {
87
- label: currentDataPack.title,
88
- value: currentDataPack.id,
89
- isData: true,
90
- };
91
- })
84
+ const mappedOptions = pureOptions.flatMap((option: IStructuredDataContent) =>
85
+ option.dataPacks.reduce((acc: { label: string; value: string; isData: boolean }[], current: string) => {
86
+ if (activatedDataPacksIds.includes(current)) {
87
+ const currentDataPack = activatedDataPacks.find(
88
+ (activatedDataPack: IDataPack) => current === activatedDataPack.id
89
+ );
90
+ if (currentDataPack) {
91
+ const option = {
92
+ label: currentDataPack.title,
93
+ value: currentDataPack.id,
94
+ isData: true,
95
+ };
96
+ return [...acc, option];
97
+ }
98
+ }
99
+ return acc;
100
+ }, [])
92
101
  );
102
+
93
103
  const filters = [...templateFilters, ...mappedOptions];
94
104
  const uniqueFilters = [...new Map(filters.map((item: any) => [item.value, item])).values()];
95
105
  const sortedUniqueFilters = uniqueFilters.sort((a, b) => a.label.localeCompare(b.label));
96
106
  const staticFilterIdx = sortedUniqueFilters.findIndex((filter) => filter.value === "static");
97
107
  const staticFilter = sortedUniqueFilters.splice(staticFilterIdx, 1);
98
108
  sortedUniqueFilters.unshift(...staticFilter);
99
-
100
109
  return sortedUniqueFilters;
101
110
  };
102
111
 
@@ -57,7 +57,6 @@ interface IPageBrowserStateProps {
57
57
  globalLangs: ILanguage[];
58
58
  schema: ISchema | Record<string, unknown>;
59
59
  selectedParent: any;
60
- activatedModules: string[];
61
60
  }
62
61
 
63
62
  interface IPageBrowserDispatchProps {
@@ -79,7 +78,6 @@ const mapStateToProps = (state: IRootState): IPageBrowserStateProps => ({
79
78
  globalLangs: state.app.globalLangs,
80
79
  schema: state.pageEditor.schema,
81
80
  selectedParent: state.pageEditor.selectedParent,
82
- activatedModules: state.dataPacks.modules,
83
81
  });
84
82
 
85
83
  const mapDispatchToProps = {
@@ -61,7 +61,6 @@ interface IPageBrowserStateProps {
61
61
  cloudinaryName: string | null;
62
62
  siteLangs: ILanguage[];
63
63
  selectedParent: any;
64
- activatedModules: string[];
65
64
  }
66
65
 
67
66
  interface IPageBrowserDispatchProps {
@@ -83,7 +82,6 @@ const mapStateToProps = (state: IRootState): IPageBrowserStateProps => ({
83
82
  cloudinaryName: state.app.globalSettings.cloudinaryName,
84
83
  siteLangs: state.sites.currentSiteLanguages,
85
84
  selectedParent: state.pageEditor.selectedParent,
86
- activatedModules: state.dataPacks.modules,
87
85
  });
88
86
 
89
87
  const mapDispatchToProps = {
@@ -27,7 +27,6 @@ const Form = (props: IProps) => {
27
27
  isLoading,
28
28
  siteLanguages,
29
29
  globalLangs,
30
- currentSite,
31
30
  lang,
32
31
  setLanguage,
33
32
  getDataContent,
@@ -112,7 +111,7 @@ const Form = (props: IProps) => {
112
111
  ...form,
113
112
  structuredData: currentStructuredData ? currentStructuredData.id : null,
114
113
  draft: publish === true ? false : status,
115
- relatedSite: currentSite ? currentSite.id : null,
114
+ relatedSite: site ? site.id : null,
116
115
  };
117
116
 
118
117
  let saved = false;
@@ -139,7 +138,7 @@ const Form = (props: IProps) => {
139
138
  action: handleSaveAndPublish,
140
139
  };
141
140
 
142
- const inversed = !currentSite;
141
+ const inversed = !site;
143
142
 
144
143
  const createNewTranslation = async (value: boolean, lang: { locale: string; id: number }) => {
145
144
  const isUsedLang = currentLanguages.find((currentLang: ILanguage) => currentLang.id === lang.id);
@@ -155,7 +154,7 @@ const Form = (props: IProps) => {
155
154
  createNewTranslation,
156
155
  };
157
156
 
158
- const languages = currentSite ? siteLanguages : globalLangs;
157
+ const languages = site ? siteLanguages : globalLangs;
159
158
 
160
159
  const getCurrentLanguages = () => {
161
160
  const availables: any[] = [];
@@ -196,7 +195,7 @@ const Form = (props: IProps) => {
196
195
  };
197
196
 
198
197
  const removeItem = async () => {
199
- const path = currentSite ? "/sites/pages" : "/data";
198
+ const path = site ? "/sites/pages" : "/data";
200
199
  deleteStructuredDataContent(form.id).then((deleted: boolean) => {
201
200
  if (deleted) {
202
201
  setHistoryPush(path, false);
@@ -326,7 +325,6 @@ interface IProps {
326
325
  isLoading: boolean;
327
326
  siteLanguages: any[];
328
327
  globalLangs: any[];
329
- currentSite: any;
330
328
  lang: { locale: string; id: number | null };
331
329
  activatedDataPacks: IDataPack[];
332
330
  errors: IErrorItem[];
@@ -355,7 +353,6 @@ const mapStateToProps = (state: IRootState) => ({
355
353
  lang: state.app.lang,
356
354
  siteLanguages: state.sites.currentSiteLanguages,
357
355
  globalLangs: state.app.globalLangs,
358
- currentSite: state.sites.currentSiteInfo && state.sites.currentSiteInfo.id,
359
356
  activatedDataPacks: state.dataPacks.activated,
360
357
  errors: state.structuredData.errors,
361
358
  skipReviewOnPublish: state.app.globalSettings.skipReviewOnPublish,
@@ -485,6 +485,8 @@ export interface IStructuredDataContent {
485
485
  dataLanguages: IDataLanguage[];
486
486
  entity: string;
487
487
  structuredData: string;
488
+ fromPage: boolean;
489
+ dataPacks: string[];
488
490
  }
489
491
 
490
492
  export interface ICategory {