@griddo/ax 10.2.21 → 10.2.23

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.2.21",
4
+ "version": "10.2.23",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -109,7 +109,6 @@
109
109
  "lodash.isequal": "4.5.0",
110
110
  "markdown-draft-js": "^2.2.1",
111
111
  "mini-css-extract-plugin": "0.11.3",
112
- "node-sass": "^6.0.0",
113
112
  "optimize-css-assets-webpack-plugin": "^6.0.1",
114
113
  "pkg-dir": "^5.0.0",
115
114
  "polished": "3.4.1",
@@ -231,5 +230,5 @@
231
230
  "publishConfig": {
232
231
  "access": "public"
233
232
  },
234
- "gitHead": "76f7c6804b511c785978ceb9bf94a2516c7da5bd"
233
+ "gitHead": "11929aed979e56dedf6e794d85fa73f5e3340bdd"
235
234
  }
@@ -538,10 +538,7 @@ describe("onChange events", () => {
538
538
  // rerender(Component);
539
539
  // });
540
540
 
541
- referenceFieldItems = screen.getAllByTestId("reference-field-item");
542
- =======
543
541
  const referenceFieldItems = screen.getAllByTestId("reference-field-item");
544
- >>>>>>> release/1.72
545
542
  expect(referenceFieldItems[0]).toHaveTextContent("Article 02");
546
543
 
547
544
  const droppable = screen.getByTestId("droppable");
@@ -630,55 +627,5 @@ describe("onChange events", () => {
630
627
  expect(referenceFieldItems[0]).toHaveTextContent("Article 02");
631
628
  });*/
632
629
 
633
- test("should hide the drag handle if list length is lower than two", async () => {
634
- defaultProps.source = ["ARTICLES"];
635
- defaultProps.value = {
636
- mode: "manual",
637
- fixed: [],
638
- };
639
- const initialState = { ...initialStore, ...defaultProps };
640
- const onChange = jest.fn();
641
-
642
- mockApiCalls();
643
-
644
- const Component = (
645
- <ThemeProvider theme={parseTheme(globalTheme)}>
646
- <ReferenceField {...initialState} onChange={onChange} />
647
- </ThemeProvider>
648
- );
649
-
650
- const { rerender } = render(Component, { store });
651
-
652
- await act(async () => {
653
- rerender(Component);
654
- });
655
-
656
- let referenceFieldItems = screen.getAllByTestId("reference-field-item");
657
- expect(referenceFieldItems.length).toBe(2);
658
-
659
- const iconActionComponents = screen.getAllByTestId("icon-action-component");
660
-
661
- await act(async () => {
662
- fireEvent.click(iconActionComponents[2]);
663
- });
664
-
665
- await act(async () => {
666
- rerender(Component);
667
- });
668
-
669
- const actionMenuItem = screen.getByTestId("action-menu-item");
670
630
 
671
- await act(async () => {
672
- fireEvent.click(actionMenuItem);
673
- });
674
-
675
- await act(async () => {
676
- rerender(Component);
677
- });
678
-
679
- referenceFieldItems = screen.getAllByTestId("reference-field-item");
680
- expect(referenceFieldItems.length).toBe(1);
681
- const handleWrappers = screen.getAllByTestId("handle-wrapper");
682
- expect(handleWrappers[0].hidden).toBe(true);
683
- });
684
631
  });
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect } from "react";
2
2
  import * as components from "components";
3
3
  import { builderSSR, ssrHelpers, SiteProvider } from "components";
4
- import { Preview } from "@griddo/core";
4
+ import { Core, Preview } from "@griddo/core";
5
5
  import { ILanguage, ISocialState } from "@ax/types";
6
6
 
7
7
  const BrowserContent = (props: IProps) => {
@@ -72,7 +72,7 @@ interface IProps {
72
72
  header?: any;
73
73
  footer?: any;
74
74
  languageID: number;
75
- pageLanguages: ILanguage[];
75
+ pageLanguages: Core.Page["pageLanguages"];
76
76
  renderer: "editor" | "preview";
77
77
  selectEditorID?(
78
78
  selectedComponent: { editorID: number; component: any; type: string; parentEditorID: number },
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
2
 
3
3
  import { IconAction } from "@ax/components";
4
+ import { ISite } from "@ax/types";
4
5
 
5
6
  import * as S from "./style";
6
7
 
7
8
  const ArrayFieldInline = (props: IProps): JSX.Element => {
8
- const { fields, item, index, onChange, handleDelete } = props;
9
+ const { fields, item, index, onChange, handleDelete, site } = props;
9
10
 
10
11
  const deleteItem = () => handleDelete(index);
11
12
 
@@ -19,7 +20,7 @@ const ArrayFieldInline = (props: IProps): JSX.Element => {
19
20
 
20
21
  return {
21
22
  ...field,
22
- props: { ...field.props, value: item[key], objKey: key, onChange: handleChange, innerFields },
23
+ props: { ...field.props, value: item[key], objKey: key, onChange: handleChange, innerFields, site },
23
24
  key,
24
25
  };
25
26
  });
@@ -43,6 +44,7 @@ interface IProps {
43
44
  index: number;
44
45
  onChange: (value: Record<string, unknown>) => void;
45
46
  handleDelete: (index: number) => void;
47
+ site: ISite | null;
46
48
  }
47
49
 
48
50
  export default ArrayFieldInline;
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
+ import { ISite } from "@ax/types";
2
3
 
3
4
  import * as S from "./style";
4
5
 
5
6
  const ArrayFieldItem = (props: IProps): JSX.Element => {
6
- const { fields, item, name, index, onChange, handleDelete, isOpen, setIsOpen } = props;
7
+ const { fields, item, name, index, onChange, handleDelete, isOpen, setIsOpen, site } = props;
7
8
 
8
9
  const handleClick = () => (isOpen === index ? setIsOpen(null) : setIsOpen(index));
9
10
 
@@ -35,7 +36,7 @@ const ArrayFieldItem = (props: IProps): JSX.Element => {
35
36
 
36
37
  return {
37
38
  ...field,
38
- props: { ...field.props, value: item[key], objKey: key, onChange: handleChange, innerFields },
39
+ props: { ...field.props, value: item[key], objKey: key, onChange: handleChange, innerFields, site },
39
40
  key,
40
41
  };
41
42
  });
@@ -61,6 +62,7 @@ interface IProps {
61
62
  handleDelete: (index: number) => void;
62
63
  isOpen: number | null;
63
64
  setIsOpen: (index: number | null) => void;
65
+ site: ISite | null;
64
66
  }
65
67
 
66
68
  export default ArrayFieldItem;
@@ -2,13 +2,14 @@ import React, { useState } from "react";
2
2
  import { v4 as uuidv4 } from "uuid";
3
3
 
4
4
  import { Button, FieldsDivider } from "@ax/components";
5
+ import { ISite } from "@ax/types";
5
6
  import ArrayFieldItem from "./ArrayFieldItem";
6
7
  import ArrayFieldInline from "./ArrayFieldInline";
7
8
 
8
9
  import * as S from "./style";
9
10
 
10
11
  const ArrayFieldGroup = (props: IProps): JSX.Element => {
11
- const { value, name, innerFields, onChange, divider, arrayType } = props;
12
+ const { value, name, innerFields, onChange, divider, arrayType, site } = props;
12
13
 
13
14
  const initialValue = value ? Object.values(value) : [];
14
15
  const initialValueMapped = initialValue.map((val: any) => {
@@ -59,6 +60,7 @@ const ArrayFieldGroup = (props: IProps): JSX.Element => {
59
60
  index={index}
60
61
  onChange={handleFieldChange}
61
62
  handleDelete={handleDelete}
63
+ site={site}
62
64
  />
63
65
  ) : (
64
66
  <ArrayFieldItem
@@ -71,6 +73,7 @@ const ArrayFieldGroup = (props: IProps): JSX.Element => {
71
73
  handleDelete={handleDelete}
72
74
  isOpen={isOpen}
73
75
  setIsOpen={setIsOpen}
76
+ site={site}
74
77
  />
75
78
  );
76
79
  })}
@@ -91,6 +94,7 @@ export interface IProps {
91
94
  innerFields: any[];
92
95
  divider: { title: string; text: string };
93
96
  arrayType: string;
97
+ site: ISite | null;
94
98
  }
95
99
 
96
100
  export default ArrayFieldGroup;
@@ -133,14 +133,14 @@ const FileDragAndDrop = (props: IProps) => {
133
133
  <S.FilesButton ref={filesButtonRef} type="button" buttonStyle="line" onClick={handleFileClick}>
134
134
  Select files
135
135
  </S.FilesButton>
136
- <S.DragSubtitle>Valid formats: {validFormats.join(", ")}. Max. size: 25MB</S.DragSubtitle>
136
+ <S.DragSubtitle>Valid formats: {validFormats.join(", ")}. Max. size: {MAX_SIZE}MB</S.DragSubtitle>
137
137
  </S.DragStatus>
138
138
  <S.DragOverStatus>
139
139
  <S.DragIcon>
140
140
  <Icon name="success" size="48" />
141
141
  </S.DragIcon>
142
142
  <S.DragTitle>Drop your file</S.DragTitle>
143
- <S.DragSubtitle>Valid formats: {validFormats.join(", ")}. Max. size: 25MB</S.DragSubtitle>
143
+ <S.DragSubtitle>Valid formats: {validFormats.join(", ")}. Max. size: {MAX_SIZE}MB</S.DragSubtitle>
144
144
  </S.DragOverStatus>
145
145
  </S.StatusWrapper>
146
146
  </DragAndDrop>
@@ -4,6 +4,7 @@ import { useModal } from "@ax/hooks";
4
4
  import { formatBytes, getFormattedDateWithTimezone } from "@ax/helpers";
5
5
  import { Icon, Modal, TextField } from "@ax/components";
6
6
  import FileDragAndDrop from "./FileDragAndDrop";
7
+ import { MAX_SIZE } from "./store";
7
8
 
8
9
  import * as S from "./style";
9
10
 
@@ -87,7 +88,7 @@ const FileField = (props: IFileFieldProps): JSX.Element => {
87
88
  <Icon name="File" size="24" />
88
89
  </S.IconWrapper>
89
90
  </S.Field>
90
- <S.HelpText>Valid formats: {validFormats.join(", ")}. Max. size: 25MB</S.HelpText>
91
+ <S.HelpText>Valid formats: {validFormats.join(", ")}. Max. size: {MAX_SIZE}MB</S.HelpText>
91
92
  </>
92
93
  )}
93
94
  {value && (
@@ -3,7 +3,7 @@ const SET_IN_DROP_ZONE = "SET_IN_DROP_ZONE";
3
3
  const SET_IS_UPLOADING = "SET_IS_UPLOADING";
4
4
  const SET_UPLOAD_SUCCESS = "SET_UPLOAD_SUCCESS";
5
5
  const SET_UPLOAD_ERROR = "SET_UPLOAD_ERROR";
6
- export const MAX_SIZE = 25; // MB
6
+ export const MAX_SIZE = 50; // MB
7
7
 
8
8
  export const reducer = (prevState: IGalleryStore, action: any): IGalleryStore => {
9
9
  switch (action.type) {
@@ -4,6 +4,7 @@ import { structuredData } from "@ax/api";
4
4
  import { isReqOk } from "@ax/helpers";
5
5
  import { IGetStructuredDataParams, IDataSource, ISite, IStructuredData } from "@ax/types";
6
6
  import { Button, CheckField, FieldsBehavior, FloatingMenu, Icon, IconAction, SearchField, Tag } from "@ax/components";
7
+ import { IFilter } from "../../Context";
7
8
 
8
9
  import * as S from "./style";
9
10
 
@@ -207,7 +208,7 @@ interface IState {
207
208
  interface IProps {
208
209
  source: IDataSource;
209
210
  canDelete: boolean;
210
- filter: number[];
211
+ filter: IFilter[];
211
212
  currentSite: ISite | null;
212
213
  structuredDataSite: IStructuredData[];
213
214
  handleDelete: (value: string) => void;
@@ -14,7 +14,7 @@ import {
14
14
  UniqueCheck,
15
15
  } from "@ax/components";
16
16
 
17
- import { IReferenceState, useReference } from "../Context";
17
+ import { IFilter, IReferenceState, useReference } from "../Context";
18
18
  import AutoItem from "./AutoItem";
19
19
 
20
20
  import * as S from "./style";
@@ -277,7 +277,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
277
277
  {state.source &&
278
278
  state.source.length > 0 &&
279
279
  state.source.map((singleSource: string) => {
280
- const sourceFilters = state.filter.filter((f: any) => f.source === singleSource);
280
+ const sourceFilters = state.filter.filter((f: IFilter) => f.source === singleSource);
281
281
  const source = state.sourceTitles.find((el: IDataSource) => el.id === singleSource);
282
282
  return source ? (
283
283
  <AutoItem
@@ -38,7 +38,7 @@ const useReferenceProvider = (modes?: string[]) => {
38
38
  const [state, setState] = useState<IReferenceState>({ ...initState, mode });
39
39
 
40
40
  const setModeAndSource = useCallback(
41
- (mode: string, source: never[]) => {
41
+ (mode: string, source: string[]) => {
42
42
  const defaultState = {
43
43
  ...state,
44
44
  mode,
@@ -92,7 +92,7 @@ export interface IReferenceState {
92
92
  site?: number;
93
93
  }
94
94
 
95
- interface IFilter {
95
+ export interface IFilter {
96
96
  id: number;
97
97
  label: string;
98
98
  source: string;
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useCallback, useEffect } from "react";
2
2
  import { connect } from "react-redux";
3
3
  import { DragDropContext, Droppable, Draggable, DropResult } from "react-beautiful-dnd";
4
4
 
@@ -16,7 +16,7 @@ const ItemList = (props: IProps) => {
16
16
  const { state, setState, setReorderElements } = useReference();
17
17
  const { fixed, selectedItems, sourceTitles, fullRelations } = state;
18
18
 
19
- useEffect(() => {
19
+ const getParams = useCallback(() => {
20
20
  const params = {
21
21
  mode: "manual",
22
22
  fixed: items,
@@ -24,8 +24,13 @@ const ItemList = (props: IProps) => {
24
24
  site,
25
25
  };
26
26
 
27
+ return params;
28
+ }, [items]);
29
+
30
+ useEffect(() => {
27
31
  const getItems = async () => {
28
32
  const siteID = currentSite ? currentSite : "global";
33
+ const params = getParams();
29
34
  const response = await structuredData.getDistributorContent(siteID, params);
30
35
  if (isReqOk(response?.status)) {
31
36
  setState((state: IReferenceState) => ({ ...state, selectedItems: response.data }));
@@ -37,9 +42,9 @@ const ItemList = (props: IProps) => {
37
42
  console.log("Error en getItems");
38
43
  }
39
44
  };
40
- getItems();
45
+ items.length && getItems();
41
46
  // eslint-disable-next-line react-hooks/exhaustive-deps
42
- }, [items]);
47
+ }, [getParams]);
43
48
 
44
49
  const handleDelete = (item: IStructuredDataContent) => {
45
50
  const langItem = item.dataLanguages?.length
@@ -73,7 +73,7 @@ const ManualPanel = (props: IProps) => {
73
73
 
74
74
  const handleOnClick = (item: IStructuredDataContent) => {
75
75
  let newSelIds: number[];
76
- let selItems: number[];
76
+ let selItems: IStructuredDataContent[];
77
77
  const itemSelectedID = item.dataLanguages?.length
78
78
  ? item.dataLanguages.find((dataLang: IDataLanguage) => state.fixed.includes(dataLang.id))?.id
79
79
  : state.fixed.includes(item.id)
@@ -196,7 +196,7 @@ const ReferenceField = (props: IReferenceFieldProps) => {
196
196
  const dataBlock = isAuto ? (
197
197
  <AutoData />
198
198
  ) : (
199
- <ItemList items={value ? value.fixed : []} handleListDelete={handleListDelete} site={value.site} />
199
+ <ItemList items={value?.fixed ? value.fixed : []} handleListDelete={handleListDelete} site={value?.site} />
200
200
  );
201
201
 
202
202
  return (
@@ -1,5 +1,5 @@
1
+ import { GriddoImage, GriddoImageCommonProps } from "@griddo/core";
1
2
  import React from "react";
2
- import { GriddoImage } from "@griddo/core";
3
3
  import { createCloudinaryUrl, isCloudinary } from "./utils";
4
4
 
5
5
  const DAM_DEFAULTS = {
@@ -9,25 +9,29 @@ const DAM_DEFAULTS = {
9
9
  formats: ["webp"],
10
10
  };
11
11
 
12
- const Image = (props: IImageProps): React.ReactElement => {
12
+ const Image = (props: ICloudinaryImageProps | GriddoImageCommonProps) => {
13
13
  const { url } = props;
14
14
 
15
+ if (!url) {
16
+ return null;
17
+ }
18
+
15
19
  if (isCloudinary(url)) {
16
- const cloudinaryUrl = createCloudinaryUrl({ props });
17
- return <img data-testid="image-wrapper" src={cloudinaryUrl} alt="Griddo site thumbnail" />;
20
+ const cloudinaryProps = props as ICloudinaryImageProps;
21
+ const cloudinaryUrl = createCloudinaryUrl({ props: cloudinaryProps });
22
+ return <img src={cloudinaryUrl} data-testid="image-wrapper" />;
18
23
  } else {
19
- return <GriddoImage {...DAM_DEFAULTS} {...props} />;
24
+ const griddoProps = { ...DAM_DEFAULTS, ...props } as GriddoImageCommonProps;
25
+ return <GriddoImage {...griddoProps} />;
20
26
  }
21
27
  };
22
28
 
23
- export interface IImageProps {
29
+ export interface ICloudinaryImageProps {
30
+ url: string;
24
31
  width: number;
25
32
  height?: number;
26
- url: string;
27
33
  quality?: number;
28
- crop?: string;
29
- loading?: string;
30
- formats?: string[];
34
+ alt?: string;
31
35
  }
32
36
 
33
37
  export default Image;
@@ -1,4 +1,4 @@
1
- import { IImageProps } from "./index";
1
+ import { ICloudinaryImageProps } from "./index";
2
2
 
3
3
  // The string to split up the cloudinary url
4
4
  const CLOUDINARY_SEPARATOR = "image/upload";
@@ -48,7 +48,7 @@ interface ICloudinaryParams {
48
48
  }
49
49
 
50
50
  interface ICreateCloudinaryUrl {
51
- props: IImageProps;
51
+ props: ICloudinaryImageProps;
52
52
  retina?: boolean;
53
53
  }
54
54
 
package/src/global.d.ts CHANGED
@@ -6,6 +6,5 @@ declare module "lodash.isequal";
6
6
  declare module "is-wsl";
7
7
  declare module "react-draft-wysiwyg";
8
8
  declare module "history";
9
- declare module "@griddo/core";
10
9
  declare module "draftjs-to-html";
11
10
  declare module "html-to-draftjs";
@@ -32,7 +32,7 @@ const UserEdit = (props: IProps) => {
32
32
  }, [user]);
33
33
 
34
34
  const handleSave = async () => {
35
- if(isOpenAdvise){
35
+ if (isOpenAdvise) {
36
36
  toggleAdviseModal();
37
37
  }
38
38
  const updated = form.id ? await updateUser(form.id, form, false) : false;
@@ -60,12 +60,13 @@ const UserEdit = (props: IProps) => {
60
60
  const isSameUser = currentUser && currentUser.id === user.id;
61
61
  const isDeleteDisabled = isSiteView && user.isSuperAdmin;
62
62
 
63
- const rightLineButtonProps = !isSameUser && !isDeleteDisabled
64
- ? {
65
- label: isSiteView ? "Remove user from this site" : "Delete User",
66
- action: toggleModal,
67
- }
68
- : undefined;
63
+ const rightLineButtonProps =
64
+ !isSameUser && !isDeleteDisabled
65
+ ? {
66
+ label: isSiteView ? "Remove user from this site" : "Delete User",
67
+ action: toggleModal,
68
+ }
69
+ : undefined;
69
70
 
70
71
  const getUpdatedSites = () => {
71
72
  const hasAll = form.roles.find((siteRole: ISiteRoles) => siteRole.siteId === "all");
@@ -87,7 +88,7 @@ const UserEdit = (props: IProps) => {
87
88
  const updatedSites = getUpdatedSites();
88
89
  const formWithUpdatedSites = { ...form, roles: updatedSites };
89
90
 
90
- const updated = await updateUser(user.id, formWithUpdatedSites, true);
91
+ const updated = await updateUser(user.id, formWithUpdatedSites, false, false);
91
92
  if (updated) {
92
93
  setHistoryPush(usersRoute);
93
94
  }
@@ -157,8 +158,8 @@ const UserEdit = (props: IProps) => {
157
158
  size="S"
158
159
  >
159
160
  <S.ModalContent>
160
- Before editing an user, <strong>select the user's permissions and site access</strong>. If you proceed without selecting
161
- any permissions, the user <strong>won't have access to anything or view any content</strong>.
161
+ Before editing an user, <strong>select the user's permissions and site access</strong>. If you proceed without
162
+ selecting any permissions, the user <strong>won't have access to anything or view any content</strong>.
162
163
  </S.ModalContent>
163
164
  </Modal>
164
165
  {isVisible && <Toast {...toastProps} />}
@@ -177,7 +178,7 @@ const mapStateToProps = (state: IRootState) => ({
177
178
 
178
179
  interface IDispatchProps {
179
180
  setHistoryPush(path: string): void;
180
- updateUser(id: number, data: any, isProfile: boolean): Promise<boolean>;
181
+ updateUser(id: number, data: IUser, isProfile: boolean, isList?: boolean): Promise<boolean>;
181
182
  deleteUser(id: number): Promise<boolean>;
182
183
  }
183
184