@griddo/ax 11.13.3-rc.0 → 11.13.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.
Files changed (59) hide show
  1. package/config/jest/setup.js +10 -0
  2. package/package.json +2 -2
  3. package/src/GlobalStore.tsx +1 -1
  4. package/src/__tests__/components/Fields/AsyncCheckGroup/AsyncCheckGroup.test.tsx +276 -66
  5. package/src/__tests__/components/FloatingMenu/FloatingMenu.test.tsx +300 -99
  6. package/src/__tests__/modules/Settings/Social/Social.test.tsx +12 -4
  7. package/src/api/checkgroups.tsx +4 -3
  8. package/src/api/selects.tsx +12 -5
  9. package/src/components/ActionMenu/index.tsx +1 -3
  10. package/src/components/Browser/index.tsx +12 -3
  11. package/src/components/Browser/style.tsx +7 -0
  12. package/src/components/ConfigPanel/Form/index.tsx +47 -53
  13. package/src/components/Fields/AnalyticsField/PageAnalytics/atoms.tsx +9 -13
  14. package/src/components/Fields/AnalyticsField/PageAnalytics/index.tsx +37 -29
  15. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/atoms.tsx +9 -13
  16. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/index.tsx +17 -11
  17. package/src/components/Fields/AnalyticsField/index.tsx +1 -2
  18. package/src/components/Fields/AnalyticsField/utils.tsx +4 -4
  19. package/src/components/Fields/AsyncCheckGroup/index.tsx +97 -79
  20. package/src/components/Fields/AsyncSelect/index.tsx +33 -22
  21. package/src/components/Fields/DateField/DatePickerInput/index.tsx +2 -2
  22. package/src/components/Fields/DateField/index.tsx +3 -3
  23. package/src/components/Fields/IntegrationsField/SideModal/index.tsx +2 -2
  24. package/src/components/Fields/IntegrationsField/index.tsx +14 -10
  25. package/src/components/Fields/MultiCheckSelect/index.tsx +6 -6
  26. package/src/components/Fields/MultiCheckSelectGroup/index.tsx +39 -37
  27. package/src/components/Fields/MultiCheckSelectGroup/style.tsx +1 -1
  28. package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +0 -2
  29. package/src/components/Fields/RichText/index.tsx +15 -7
  30. package/src/components/Fields/TextArea/index.tsx +9 -6
  31. package/src/components/FloatingMenu/index.tsx +32 -31
  32. package/src/components/FloatingMenu/style.tsx +23 -5
  33. package/src/components/Loader/components/SmallCircle.js +3 -3
  34. package/src/components/MainWrapper/AppBar/style.tsx +1 -0
  35. package/src/components/SideModal/index.tsx +1 -1
  36. package/src/components/TableFilters/CategoryFilter/index.tsx +14 -15
  37. package/src/containers/App/actions.tsx +7 -1
  38. package/src/containers/App/constants.tsx +2 -0
  39. package/src/containers/App/interfaces.tsx +5 -0
  40. package/src/containers/App/reducer.tsx +11 -2
  41. package/src/containers/Forms/actions.tsx +5 -7
  42. package/src/containers/Integrations/actions.tsx +1 -3
  43. package/src/containers/Navigation/Menu/actions.tsx +2 -2
  44. package/src/containers/PageEditor/actions.tsx +3 -2
  45. package/src/containers/Settings/DataPacks/actions.tsx +35 -29
  46. package/src/containers/Sites/actions.tsx +40 -33
  47. package/src/containers/StructuredData/actions.tsx +3 -9
  48. package/src/modules/ActivityLog/LogFilters/DateFilter/index.tsx +5 -4
  49. package/src/modules/Content/NewContentModal/PageImporter/index.tsx +1 -2
  50. package/src/modules/Content/index.tsx +8 -3
  51. package/src/modules/Content/style.tsx +7 -0
  52. package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +58 -45
  53. package/src/modules/Navigation/Defaults/index.tsx +103 -104
  54. package/src/modules/PageEditor/index.tsx +9 -1
  55. package/src/modules/PublicPreview/index.tsx +2 -1
  56. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +60 -44
  57. package/src/modules/Settings/ContentTypes/DataPacks/Config/index.tsx +32 -37
  58. package/src/modules/Sites/index.tsx +3 -3
  59. package/src/modules/Users/UserList/index.tsx +1 -1
@@ -1,4 +1,4 @@
1
- import { useState } from "react";
1
+ import { useCallback, useState } from "react";
2
2
  import { connect } from "react-redux";
3
3
 
4
4
  import { FieldsBehavior, Modal, Tag } from "@ax/components";
@@ -11,7 +11,7 @@ import type {
11
11
  IRootState,
12
12
  ISite,
13
13
  IStructuredData,
14
- ITemplate,
14
+ ILanguage,
15
15
  } from "@ax/types";
16
16
 
17
17
  import TemplateConfig from "./TemplateConfig";
@@ -19,7 +19,7 @@ import TemplateConfig from "./TemplateConfig";
19
19
  import * as S from "./style";
20
20
 
21
21
  const Form = (props: IProps): JSX.Element => {
22
- const { currentSite, selected, updateFormValue, configFormData, allStructuredData } = props;
22
+ const { currentSite, selected, updateFormValue, configFormData, allStructuredData, currentSiteLanguages } = props;
23
23
 
24
24
  if (!currentSite) {
25
25
  throw new Error(`ERROR: User reached Data Pack form with null site info`);
@@ -31,7 +31,9 @@ const Form = (props: IProps): JSX.Element => {
31
31
 
32
32
  const { templates, categories, structuredData } = selected;
33
33
 
34
- const getSubscribedData = (importValue: IDataPackConfigImport[]) => {
34
+ const defaultLanguage = currentSiteLanguages?.find((lang) => lang.isDefault);
35
+
36
+ const getSubscribedData = (importValue: IDataPackConfigImport[] | undefined) => {
35
37
  const value: Record<string, ICategoryValue[]> = {};
36
38
  if (!importValue) return value;
37
39
  importValue.forEach((item: IDataPackConfigImport) => {
@@ -47,14 +49,6 @@ const Form = (props: IProps): JSX.Element => {
47
49
  const [selectedCategories, setSelectedCategories] = useState(initialValues);
48
50
  const { isOpen, toggleModal } = useModal();
49
51
 
50
- const selectOptions: { value: string; label: string }[] = [];
51
- templates.forEach((template: ITemplate) => {
52
- selectOptions.push({
53
- value: template.id,
54
- label: template.title,
55
- });
56
- });
57
-
58
52
  const indexDefaultOptions = [
59
53
  {
60
54
  value: true,
@@ -94,15 +88,23 @@ const Form = (props: IProps): JSX.Element => {
94
88
 
95
89
  const secondaryAction = { title: "Cancel", onClick: toggleModal };
96
90
 
97
- const getCategoryText = (id: string): string => {
98
- const data = [...categories, ...allStructuredData.global, ...allStructuredData.site].find((elem) => elem.id === id);
99
- return data ? data.title : id;
100
- };
91
+ const getCategoryText = useCallback(
92
+ (id: string): string => {
93
+ const data = [...categories, ...allStructuredData.global, ...allStructuredData.site].find(
94
+ (elem) => elem.id === id,
95
+ );
96
+ return data ? data.title : id;
97
+ },
98
+ [categories, allStructuredData],
99
+ );
101
100
 
102
- const getIsGlobal = (id: string): boolean => {
103
- const data = allStructuredData?.site.find((elem) => elem.id === id);
104
- return !data?.local;
105
- };
101
+ const getIsGlobal = useCallback(
102
+ (id: string): boolean => {
103
+ const data = allStructuredData?.site.find((elem) => elem.id === id);
104
+ return !data?.local;
105
+ },
106
+ [allStructuredData],
107
+ );
106
108
 
107
109
  const globalPageData = structuredData.find((data) => data.fromPage && !data.local);
108
110
 
@@ -110,14 +112,18 @@ const Form = (props: IProps): JSX.Element => {
110
112
  return { source: cat, key: cat, placeholder: getCategoryText(cat), isGlobal: getIsGlobal(cat) };
111
113
  });
112
114
 
113
- const deleteTag = (catID: number) => {
114
- const newCategories = configFormData.import.map((type: IDataPackConfigImport) => {
115
- const filteredCats = type.categories.filter((el: IDataPackConfigImportCategory) => el.id !== catID);
116
- return { ...type, categories: filteredCats };
117
- });
118
- const filteredNewCategories = newCategories.filter((cat: IDataPackConfigImport) => cat.categories.length);
119
- updateFormValue({ import: filteredNewCategories });
120
- };
115
+ const deleteTag = useCallback(
116
+ (catID: number) => {
117
+ if (!configFormData.import) return;
118
+ const newCategories = configFormData.import.map((type: IDataPackConfigImport) => {
119
+ const filteredCats = type.categories.filter((el: IDataPackConfigImportCategory) => el.id !== catID);
120
+ return { ...type, categories: filteredCats };
121
+ });
122
+ const filteredNewCategories = newCategories.filter((cat: IDataPackConfigImport) => cat.categories.length);
123
+ updateFormValue({ import: filteredNewCategories });
124
+ },
125
+ [configFormData.import, updateFormValue],
126
+ );
121
127
 
122
128
  const getCategoryLabels = () => (
123
129
  <S.CategoriesWrapper isEmpty={!Object.keys(selectedCategories).length}>
@@ -168,10 +174,11 @@ const Form = (props: IProps): JSX.Element => {
168
174
  value={configFormData?.defaultParent}
169
175
  onChange={setDefaultParent}
170
176
  options={{ excludeDetailPages: true }}
177
+ forceLanguage={defaultLanguage?.id}
171
178
  />
172
179
  <FieldsBehavior
173
180
  title="Modifiable in page"
174
- name="defaultParent"
181
+ name="modifiableOnPage"
175
182
  fieldType="ToggleField"
176
183
  value={configFormData?.modifiableOnPage || false}
177
184
  onChange={setModifiableOnPage}
@@ -195,19 +202,19 @@ const Form = (props: IProps): JSX.Element => {
195
202
  mainAction={mainAction}
196
203
  secondaryAction={secondaryAction}
197
204
  >
198
- {isOpen ? (
199
- <S.ModalContent>
200
- <FieldsBehavior
201
- fieldType="MultiCheckSelectGroup"
202
- title="Select Categories"
203
- filled={true}
204
- elements={elements}
205
- site={currentSite}
206
- value={selectedCategories}
207
- onChange={setSelectedCategories}
208
- />
209
- </S.ModalContent>
210
- ) : null}
205
+ <S.ModalContent>
206
+ <FieldsBehavior
207
+ fieldType="MultiCheckSelectGroup"
208
+ title="Select Categories"
209
+ filled={true}
210
+ elements={elements}
211
+ site={currentSite}
212
+ value={selectedCategories}
213
+ onChange={setSelectedCategories}
214
+ contentLanguages={defaultLanguage?.locale ? [defaultLanguage.locale] : []}
215
+ languages={currentSiteLanguages}
216
+ />
217
+ </S.ModalContent>
211
218
  </Modal>
212
219
  </>
213
220
  );
@@ -219,12 +226,20 @@ interface ICategoryValue {
219
226
  structuredData: string;
220
227
  }
221
228
 
229
+ interface IDataPackConfig {
230
+ defaultParent?: number;
231
+ modifiableOnPage?: boolean;
232
+ indexDefault?: boolean;
233
+ import?: IDataPackConfigImport[];
234
+ }
235
+
222
236
  interface IProps {
223
237
  selected: IDataPack | null;
224
238
  currentSite: ISite | null;
225
- updateFormValue: (config?: any) => void;
226
- configFormData: any;
239
+ updateFormValue: (config: Partial<IDataPackConfig>) => void;
240
+ configFormData: IDataPackConfig;
227
241
  allStructuredData: { global: IStructuredData[]; site: IStructuredData[] };
242
+ currentSiteLanguages: ILanguage[];
228
243
  }
229
244
 
230
245
  const mapDispatchToProps = {
@@ -236,6 +251,7 @@ const mapStateToProps = (state: IRootState) => ({
236
251
  currentSite: state.sites.currentSiteInfo,
237
252
  configFormData: state.dataPacks.configFormData,
238
253
  allStructuredData: state.structuredData.structuredData,
254
+ currentSiteLanguages: state.sites.currentSiteLanguages,
239
255
  });
240
256
 
241
257
  export default connect(mapStateToProps, mapDispatchToProps)(Form);
@@ -1,8 +1,7 @@
1
- import React from "react";
2
1
  import { connect } from "react-redux";
3
2
 
4
- import { IRootState, ISite, ITemplate } from "@ax/types";
5
3
  import { getSchemaThumbnails, getTemplateThumbnails } from "@ax/helpers";
4
+ import type { IRootState, ISite, ITemplate } from "@ax/types";
6
5
 
7
6
  import Card from "./Card";
8
7
  import Form from "./Form";
@@ -26,43 +25,39 @@ const ConfigPack = (props: IProps): JSX.Element => {
26
25
  <S.Description>{description}</S.Description>
27
26
  <S.Items>
28
27
  <S.CardList>
29
- {structuredData &&
30
- structuredData.map(
31
- (data: any, key: number) =>
32
- data.fromPage === false && (
33
- <Card key={`${key}${data.title}`} title={"Content Type"} subtitle={data.title} />
34
- ),
35
- )}
36
- {categories &&
37
- categories.map((categorie: any, key: number) => (
38
- <Card key={`${key}${categorie.title}`} title={"Categories"} subtitle={categorie.title} />
39
- ))}
28
+ {structuredData?.map(
29
+ (data: any, key: number) =>
30
+ data.fromPage === false && (
31
+ <Card key={`${key}${data.title}`} title={"Content Type"} subtitle={data.title} />
32
+ ),
33
+ )}
34
+ {categories?.map((categorie: any, key: number) => (
35
+ <Card key={`${key}${categorie.title}`} title={"Categories"} subtitle={categorie.title} />
36
+ ))}
40
37
  </S.CardList>
41
38
  <S.CardList>
42
- {modules &&
43
- modules.map((module: any, key: number) => {
44
- const thumbnails = getSchemaThumbnails(module.id, currentSiteInfo.theme);
45
- return (
46
- <Card
47
- key={`${key}${module.title}`}
48
- title={"Module"}
49
- subtitle={module.title}
50
- thumbnail={thumbnails && thumbnails["2x"]}
51
- />
52
- );
53
- })}
54
- {templates &&
55
- templates.map((template: ITemplate, key: number) => {
56
- const thumbnails = getTemplateThumbnails(template.id, currentSiteInfo.theme);
57
- return (
58
- <Card
59
- key={`${key}${template.title}`}
60
- title={"Template"}
61
- subtitle={template.title}
62
- thumbnail={thumbnails && thumbnails["2x"]}
63
- />
64
- );
65
- })}
39
+ {modules?.map((module: any, key: number) => {
40
+ const thumbnails = getSchemaThumbnails(module.id, currentSiteInfo.theme);
41
+ return (
42
+ <Card
43
+ key={`${key}${module.title}`}
44
+ title={"Module"}
45
+ subtitle={module.title}
46
+ thumbnail={thumbnails?.["2x"]}
47
+ />
48
+ );
49
+ })}
50
+ {templates?.map((template: ITemplate, key: number) => {
51
+ const thumbnails = getTemplateThumbnails(template.id, currentSiteInfo.theme);
52
+ return (
53
+ <Card
54
+ key={`${key}${template.title}`}
55
+ title={"Template"}
56
+ subtitle={template.title}
57
+ thumbnail={thumbnails?.["2x"]}
58
+ />
59
+ );
60
+ })}
66
61
  </S.CardList>
67
62
  </S.Items>
68
63
  </S.Pack>
@@ -33,9 +33,9 @@ const Sites = (props: ISitesProps): JSX.Element => {
33
33
  setCurrentSiteInfo(null);
34
34
  updateCurrentSearch("");
35
35
  resetCurrentData();
36
- await getRoles({ siteId: "global" }, token, false);
36
+ await getRoles({ siteId: "global" }, token);
37
37
  await getUserCurrentPermissions();
38
- await getStructuredData(token, null, false);
38
+ await getStructuredData(token, null);
39
39
  await getAllDataPacks();
40
40
 
41
41
  const defaultLanguage = globalLangs.find((language) => language.isDefault);
@@ -72,7 +72,7 @@ interface IDispatchProps {
72
72
  getStructuredData(token: string, siteId?: number | null, hasLoading?: boolean): Promise<void>;
73
73
  setLanguage(lang: { locale: string; id: number | null }): void;
74
74
  getAllDataPacks: () => Promise<void>;
75
- getRoles: (params: IGetRoles, token?: string, hasLoading?: boolean) => Promise<void>;
75
+ getRoles: (params: IGetRoles, token?: string) => Promise<void>;
76
76
  updateCurrentSearch(query: string): Promise<void>;
77
77
  resetCurrentData(): Promise<void>;
78
78
  setIsLoading(isLoading: boolean): void;
@@ -99,7 +99,7 @@ const UserList = (props: IUserListProps): JSX.Element => {
99
99
  useEffect(() => {
100
100
  const handleRolesSites = async () => {
101
101
  const siteId = isSiteView ? currentSiteInfo.id : "global";
102
- await getRoles({ siteId }, undefined, false);
102
+ await getRoles({ siteId });
103
103
  await getSites({ pagination: false, recentSitesNumber: 0 });
104
104
  };
105
105
  handleRolesSites();