@griddo/ax 11.4.12-rc.0 → 11.4.13-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.4.12-rc.0",
4
+ "version": "11.4.13-rc.0",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -220,5 +220,5 @@
220
220
  "publishConfig": {
221
221
  "access": "public"
222
222
  },
223
- "gitHead": "738fb7222de3e13dd8a31eeba849450735e090a7"
223
+ "gitHead": "ce34b7c15cd11a725be71a317afd8bde37880bb2"
224
224
  }
package/src/api/utils.tsx CHANGED
@@ -108,7 +108,7 @@ export const sendInitialRequest = async (
108
108
  const response = await axios(config);
109
109
  return response;
110
110
  } catch (e) {
111
- return e.response || { data: { code: e.code || "unknown", message: e.message || "Platform error" } };
111
+ return e.response;
112
112
  }
113
113
  };
114
114
 
@@ -146,7 +146,7 @@ export const sendRequest = async (
146
146
  // return response;
147
147
  return await axios(requestConfig);
148
148
  } catch (e) {
149
- return e.response || { data: { code: e.code || "unknown", message: e.message || "Platform error" } };
149
+ return e.response;
150
150
  }
151
151
  };
152
152
 
@@ -174,7 +174,7 @@ export const sendUploadRequest = async (
174
174
 
175
175
  return await axios(requestConfig);
176
176
  } catch (e) {
177
- return e.response || { data: { code: e.code || "unknown", message: e.message || "Platform error" } };
177
+ return e.response;
178
178
  }
179
179
  };
180
180
 
@@ -1,7 +1,5 @@
1
1
  import React from "react";
2
2
  import { IErrorItem, ILanguage } from "@ax/types";
3
- import { useNetworkStatus } from "@ax/hooks";
4
- import { Notification } from "@ax/components";
5
3
 
6
4
  import AppBar from "./AppBar";
7
5
 
@@ -10,19 +8,11 @@ import * as S from "./style";
10
8
  const MainWrapper = (props: IWrapperProps): JSX.Element => {
11
9
  const { children, fixedAppBar, fullWidth, hasAnimation } = props;
12
10
 
13
- const { isOnline } = useNetworkStatus();
14
-
15
11
  return (
16
12
  <S.Wrapper fixedAppBar={fixedAppBar} data-testid="main-wrapper">
17
13
  {hasAnimation && <S.BackgroundAnimation />}
18
14
  <AppBar {...props} />
19
15
  <S.Main fullWidth={fullWidth} data-testid="main-component" id="main-component">
20
- {!isOnline && (
21
- <Notification
22
- type="error"
23
- text="You are offline. Please, check your internet connection. Changes you make may not be saved."
24
- />
25
- )}
26
16
  {children}
27
17
  </S.Main>
28
18
  </S.Wrapper>
@@ -1,3 +1,4 @@
1
+ import { setError } from "@ax/containers/App/actions";
1
2
  import { Dispatch } from "redux";
2
3
 
3
4
  const isReqOk = (reqStatus: number) => reqStatus >= 200 && reqStatus < 400;
@@ -14,6 +15,15 @@ function handleRequest(
14
15
 
15
16
  const response = await callback();
16
17
 
18
+ if (!response) {
19
+ dispatch(
20
+ setError({
21
+ text: "You are offline. Please, check your internet connection. Changes you make may not be saved.",
22
+ })
23
+ );
24
+ return false;
25
+ }
26
+
17
27
  const responseArr = Array.isArray(response) ? response : [response];
18
28
 
19
29
  let result = true;
@@ -7,7 +7,6 @@ import { useWindowSize } from "./window";
7
7
  import { useOnMessageReceivedFromIframe, useOnMessageReceivedFromOutside } from "./iframe";
8
8
  import { usePermission, useGlobalPermission } from "./users";
9
9
  import { useResizable } from "./resize";
10
- import { useNetworkStatus } from "./network";
11
10
 
12
11
  export {
13
12
  useModal,
@@ -29,5 +28,4 @@ export {
29
28
  useGlobalPermission,
30
29
  useOnMessageReceivedFromIframe,
31
30
  useOnMessageReceivedFromOutside,
32
- useNetworkStatus,
33
31
  };
@@ -53,7 +53,9 @@ const NavItem = (props: IProps) => {
53
53
  )}
54
54
  </S.NavLink>
55
55
  <S.Dropdown isSubmenu={hasSubmenu} isSubmenuOpen={state[name]} className={DropdownClass} type={type}>
56
- <S.Heading>{name}</S.Heading>
56
+ <S.Heading onClick={handleClick}>
57
+ <div>{name}</div>
58
+ </S.Heading>
57
59
  {routesGroups &&
58
60
  routesGroups.map((subGroup: any, groupI: any) => (
59
61
  <React.Fragment key={groupI}>
@@ -2,7 +2,10 @@ import styled from "styled-components";
2
2
 
3
3
  export const Heading = styled.li`
4
4
  ${(p) => p.theme.textStyle.headingXXS};
5
- cursor: default;
5
+ width: 100%;
6
+ height: 100%;
7
+ display: flex;
8
+ align-items: center;
6
9
  `;
7
10
 
8
11
  export const Dropdown = styled.ul<{ isSubmenu?: boolean; isSubmenuOpen: boolean; type: string }>`
@@ -18,6 +21,7 @@ export const Dropdown = styled.ul<{ isSubmenu?: boolean; isSubmenuOpen: boolean;
18
21
 
19
22
  ${Heading} {
20
23
  margin-bottom: ${(p) => (p.isSubmenu ? p.theme.spacing.xs : "0")};
24
+ cursor: ${(p) => (p.isSubmenu ? "default" : "pointer")};
21
25
  }
22
26
 
23
27
  &.floating {
@@ -63,23 +67,24 @@ export const Arrow = styled.div`
63
67
  export const LinkName = styled.span<{ active: boolean }>`
64
68
  white-space: nowrap;
65
69
  overflow: hidden;
66
- color: ${(p) => p.active ? p.theme.color.textHighEmphasisInverse : p.theme.color.textMediumEmphasisInverse};
70
+ color: ${(p) => (p.active ? p.theme.color.textHighEmphasisInverse : p.theme.color.textMediumEmphasisInverse)};
67
71
  `;
68
72
 
69
73
  export const Item = styled.li<{ type: string; isOpened: boolean; isSubmenuOpen: boolean; active: boolean }>`
70
74
  position: relative;
71
- margin-left: ${(p) => p.isSubmenuOpen ? "0" : p.theme.spacing.s};
72
- margin-right: ${(p) => p.isOpened && !p.isSubmenuOpen ? p.theme.spacing.s : "0"};
73
- padding-left: ${(p) => p.isSubmenuOpen ? p.theme.spacing.s : "0"};
74
- padding-right: ${(p) => p.isOpened && !p.isSubmenuOpen ? "0" : p.theme.spacing.s};
75
- border-radius: ${(p) => p.isOpened ? p.theme.radii.s : `${p.theme.radii.s} 0 0 ${p.theme.radii.s}`};
76
- background-color: ${(p) => p.isSubmenuOpen ? p.theme.color.overlayHoverDark : "transparent" };
77
- color: ${(p) => p.isSubmenuOpen ? p.theme.color.textHighEmphasisInverse : "inherit" };
75
+ margin-left: ${(p) => (p.isSubmenuOpen ? "0" : p.theme.spacing.s)};
76
+ margin-right: ${(p) => (p.isOpened && !p.isSubmenuOpen ? p.theme.spacing.s : "0")};
77
+ padding-left: ${(p) => (p.isSubmenuOpen ? p.theme.spacing.s : "0")};
78
+ padding-right: ${(p) => (p.isOpened && !p.isSubmenuOpen ? "0" : p.theme.spacing.s)};
79
+ border-radius: ${(p) => (p.isOpened ? p.theme.radii.s : `${p.theme.radii.s} 0 0 ${p.theme.radii.s}`)};
80
+ background-color: ${(p) => (p.isSubmenuOpen ? p.theme.color.overlayHoverDark : "transparent")};
81
+ color: ${(p) => (p.isSubmenuOpen ? p.theme.color.textHighEmphasisInverse : "inherit")};
78
82
  margin-bottom: ${(p) => p.theme.spacing.xxs};
79
83
 
80
84
  svg {
81
85
  path {
82
- fill: ${(p) => (p.isSubmenuOpen || p.active) ? p.theme.color.textHighEmphasisInverse : p.theme.color.textMediumEmphasisInverse };
86
+ fill: ${(p) =>
87
+ p.isSubmenuOpen || p.active ? p.theme.color.textHighEmphasisInverse : p.theme.color.textMediumEmphasisInverse};
83
88
  }
84
89
  }
85
90
 
@@ -120,7 +125,7 @@ export const Item = styled.li<{ type: string; isOpened: boolean; isSubmenuOpen:
120
125
  cursor: pointer;
121
126
 
122
127
  &.selected {
123
- background-color: ${(p) => p.isSubmenuOpen ? "transparent" : p.theme.color.overlayPressedDark };
128
+ background-color: ${(p) => (p.isSubmenuOpen ? "transparent" : p.theme.color.overlayPressedDark)};
124
129
  color: ${(p) => p.theme.color.textHighEmphasisInverse};
125
130
 
126
131
  path {
@@ -113,9 +113,9 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
113
113
  const isTranslated = pageLanguages.length > 1;
114
114
  const activeColumns = columns.filter((col) => col.show).map((col) => col.id);
115
115
  const API_URL = process.env.GRIDDO_API_URL || process.env.REACT_APP_API_ENDPOINT;
116
- const isPublished = liveStatus.status === pageStatus.PUBLISHED || liveStatus.status === pageStatus.UPLOAD_PENDING;
116
+ const isPublished = liveStatus?.status === pageStatus.PUBLISHED || liveStatus?.status === pageStatus.UPLOAD_PENDING;
117
117
  const isAllowedToDelete = (isPublished && isAllowedToDeletePublishedPage) || (!isPublished && isAllowedToDeletePage);
118
- const isScheduledPub = !!publicationScheduled && (liveStatus.status === pageStatus.SCHEDULED || haveDraftPage);
118
+ const isScheduledPub = !!publicationScheduled && (liveStatus?.status === pageStatus.SCHEDULED || haveDraftPage);
119
119
 
120
120
  const publishedTooltip: Record<string, string> = {
121
121
  active: "Live",
@@ -408,7 +408,7 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
408
408
  action: viewPage,
409
409
  };
410
410
 
411
- const publishAction = getPublishItem(page.liveStatus.status, canBeUnpublished);
411
+ const publishAction = getPublishItem(page.liveStatus?.status, canBeUnpublished);
412
412
 
413
413
  menuOptions = publishAction && isAllowedToPublishPages ? [publishAction, ...menuOptions] : menuOptions;
414
414
 
@@ -432,7 +432,7 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
432
432
 
433
433
  menuOptions = page.haveDraftPage ? [...editOptions, ...menuOptions] : menuOptions;
434
434
 
435
- menuOptions = page.liveStatus.status === pageStatus.PUBLISHED ? [viewOption, ...menuOptions] : menuOptions;
435
+ menuOptions = page.liveStatus?.status === pageStatus.PUBLISHED ? [viewOption, ...menuOptions] : menuOptions;
436
436
 
437
437
  const GlobalMark = () => (
438
438
  <Tooltip content="Global Page">
@@ -467,7 +467,7 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
467
467
 
468
468
  const mainCopyModalAction = { title: "Copy page", onClick: copyToOtherSite, disabled: !site };
469
469
 
470
- const getLiveStatus = () => (isScheduledPub ? "scheduled" : haveDraftPage ? "modified" : liveStatus.status);
470
+ const getLiveStatus = () => (isScheduledPub ? "scheduled" : haveDraftPage ? "modified" : liveStatus?.status);
471
471
 
472
472
  const mainUnpublishAction = { title: "Ok", onClick: toggleUnpublishModal };
473
473
 
@@ -268,12 +268,12 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
268
268
  });
269
269
  }
270
270
 
271
- const publishAction = getPublishItem(globalPage.liveStatus.status);
271
+ const publishAction = getPublishItem(globalPage.liveStatus?.status);
272
272
  menuOptions = publishAction && isAllowedToPublishPages ? [publishAction, ...menuOptions] : menuOptions;
273
273
 
274
274
  menuOptions = globalPage.haveDraftPage ? [...editOptions, ...menuOptions] : menuOptions;
275
275
 
276
- menuOptions = globalPage.liveStatus.status === pageStatus.PUBLISHED ? [viewOption, ...menuOptions] : menuOptions;
276
+ menuOptions = globalPage.liveStatus?.status === pageStatus.PUBLISHED ? [viewOption, ...menuOptions] : menuOptions;
277
277
 
278
278
  const mainDuplicateModalAction = {
279
279
  title: "Duplicate",
@@ -1,31 +0,0 @@
1
- import { useEffect, useState } from "react";
2
-
3
- const useNetworkStatus = () => {
4
- const [isOnline, setOnline] = useState<boolean>(true);
5
-
6
- const updateNetworkStatus = () => {
7
- setOnline(navigator.onLine);
8
- };
9
-
10
- // sometimes, the load event does not trigger on some browsers, that is why manually calling updateNetworkStatus on initial mount
11
- useEffect(() => {
12
- updateNetworkStatus();
13
- }, []);
14
-
15
- useEffect(() => {
16
- window.addEventListener("load", updateNetworkStatus);
17
- window.addEventListener("online", updateNetworkStatus);
18
- window.addEventListener("offline", updateNetworkStatus);
19
-
20
- return () => {
21
- window.removeEventListener("load", updateNetworkStatus);
22
- window.removeEventListener("online", updateNetworkStatus);
23
- window.removeEventListener("offline", updateNetworkStatus);
24
- };
25
- // eslint-disable-next-line react-hooks/exhaustive-deps
26
- }, [navigator.onLine]);
27
-
28
- return { isOnline };
29
- };
30
-
31
- export { useNetworkStatus };