@griddo/ax 11.11.8-rc.0 → 11.11.8-rc.1

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.11.8-rc.0",
4
+ "version": "11.11.8-rc.1",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -217,5 +217,5 @@
217
217
  "publishConfig": {
218
218
  "access": "public"
219
219
  },
220
- "gitHead": "13875ca38b93bc95a2bbdd20b073076c9de520b2"
220
+ "gitHead": "a40684db16cac0b3d08bb0437fad6a825d8451e6"
221
221
  }
@@ -2,9 +2,9 @@ import { useEffect, useMemo, useRef, useState } from "react";
2
2
 
3
3
  import type { IShareData } from "@ax/api";
4
4
  import { shareToken as shareTokenApi } from "@ax/api";
5
- import { BrowserContent, Icon, PageInfoBanner, Select, SharePageModal, Toast, Tooltip } from "@ax/components";
5
+ import { BrowserContent, Icon, OcassionalToast, Select, SharePageModal, Toast, Tooltip } from "@ax/components";
6
6
  import { findByEditorID } from "@ax/forms";
7
- import { copyTextToClipboard, DEV_NOW, getShareTokenInfo } from "@ax/helpers";
7
+ import { DEV_NOW, getShareTokenInfo } from "@ax/helpers";
8
8
  import { useModal, useOnMessageReceivedFromIframe, useToast } from "@ax/hooks";
9
9
  import type { HeadingFilter } from "@ax/types";
10
10
 
@@ -144,18 +144,6 @@ const Browser = (props: IBrowserProps): JSX.Element => {
144
144
  }
145
145
  };
146
146
 
147
- const copyUrl = () => {
148
- const sharedUrl = `${domain}/page-preview/${id}/${entity}`;
149
- copyTextToClipboard(sharedUrl).then(
150
- () => {
151
- toggleToast("URL Copied");
152
- },
153
- (err) => {
154
- console.error("Could not copy text: ", err);
155
- },
156
- );
157
- };
158
-
159
147
  const moduleActions = useMemo(
160
148
  () => ({
161
149
  deleteModuleAction: (editorID: number) => {
@@ -358,15 +346,20 @@ const Browser = (props: IBrowserProps): JSX.Element => {
358
346
  )}
359
347
  {isVisible && <Toast message={toastState} setIsVisible={setIsVisible} />}
360
348
  {isPreview && shareData && tokenInfo && (
361
- <PageInfoBanner
349
+ <OcassionalToast
362
350
  message={
363
- tokenInfo.tokenHasExpired
364
- ? `Access to this draft link expired on ${tokenInfo.tokenExpirationDate}. You need to generate a`
365
- : `This draft link expires on ${tokenInfo.tokenExpirationDate}. ${tokenInfo.tokenCanBeRenewed ? "Renew it" : "Open details"}`
351
+ <>
352
+ {tokenInfo.tokenHasExpired
353
+ ? `Access to this draft link expired on ${tokenInfo.tokenExpirationDate}. You need to generate a `
354
+ : `This draft link expires on ${tokenInfo.tokenExpirationDate}. ${tokenInfo.tokenCanBeRenewed ? "Renew it" : "Open details"}${" "}`}
355
+ <button type="button" onClick={toggleSharePageModal}>
356
+ <strong style={{ textDecoration: "underline" }}>
357
+ {tokenInfo.tokenHasExpired ? "new one" : "here"}
358
+ </strong>
359
+ </button>
360
+ </>
366
361
  }
367
- actionLabel={tokenInfo.tokenHasExpired ? "new one" : "here"}
368
362
  icon={tokenInfo.tokenHasExpired ? "hide" : "view"}
369
- onAction={toggleSharePageModal}
370
363
  />
371
364
  )}
372
365
 
@@ -386,16 +379,6 @@ const Browser = (props: IBrowserProps): JSX.Element => {
386
379
  );
387
380
  };
388
381
 
389
- function getWidth(res: string) {
390
- switch (res) {
391
- case "tablet":
392
- return "768px";
393
- case "phone":
394
- return "425px";
395
- default:
396
- return "100%";
397
- }
398
- }
399
382
  export interface IBrowserProps {
400
383
  content: any;
401
384
  header?: any;
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from "react";
2
2
 
3
- import { PageInfoBanner } from "@ax/components";
3
+ import { OcassionalToast } from "@ax/components";
4
4
  import { formatDate } from "@ax/helpers";
5
5
  import type { ILanguage, ISocialState } from "@ax/types";
6
6
 
@@ -59,7 +59,7 @@ const BrowserContent = (props: IProps) => {
59
59
  selectHoverEditorID={selectHoverEditorID}
60
60
  >
61
61
  {renderer === "sharedPage" && showBanner && (
62
- <PageInfoBanner
62
+ <OcassionalToast
63
63
  message={`This draft link expires on ${shareEndDate ? formatDate(new Date(shareEndDate)) : "..."}`}
64
64
  icon="scheduled"
65
65
  onDismiss={() => setShowBanner(false)}
@@ -1,10 +1,11 @@
1
1
  import { createPortal } from "react-dom";
2
+
2
3
  import { Icon } from "@ax/components";
3
4
 
4
5
  import * as S from "./style";
5
6
 
6
7
  const OcassionalToast = (props: IOcassionalToastProps): JSX.Element => {
7
- const { message, icon = "alert" } = props;
8
+ const { message, icon = "alert", onDismiss } = props;
8
9
 
9
10
  return createPortal(
10
11
  <S.Wrapper data-testid="occasional-toast-wrapper">
@@ -12,6 +13,11 @@ const OcassionalToast = (props: IOcassionalToastProps): JSX.Element => {
12
13
  <Icon name={icon} />
13
14
  </S.IconWrapper>
14
15
  <S.Text data-testid="occasional-toast-message">{message}</S.Text>
16
+ {onDismiss && (
17
+ <S.DismissButton type="button" onClick={onDismiss}>
18
+ <Icon name="close" size="16px" />
19
+ </S.DismissButton>
20
+ )}
15
21
  </S.Wrapper>,
16
22
  document.body,
17
23
  );
@@ -20,6 +26,7 @@ const OcassionalToast = (props: IOcassionalToastProps): JSX.Element => {
20
26
  export interface IOcassionalToastProps {
21
27
  message: string | React.ReactNode;
22
28
  icon?: string;
29
+ onDismiss?: () => void;
23
30
  }
24
31
 
25
32
  export default OcassionalToast;
@@ -37,4 +37,18 @@ const IconWrapper = styled.div`
37
37
  }
38
38
  `;
39
39
 
40
- export { Wrapper, Text, IconWrapper };
40
+ const DismissButton = styled.button`
41
+ background: none;
42
+ border: none;
43
+ svg {
44
+ path {
45
+ fill: ${(p) => p.theme.color.textHighEmphasisInverse};
46
+ }
47
+ }
48
+ cursor: pointer;
49
+ margin-left: ${(p) => p.theme.spacing.xs};
50
+ display: flex;
51
+ align-items: center;
52
+ `;
53
+
54
+ export { Wrapper, Text, IconWrapper, DismissButton };
@@ -88,7 +88,6 @@ import Nav from "./Nav";
88
88
  import Notification from "./Notification";
89
89
  import OcassionalToast from "./OcassionalToast";
90
90
  import PageFinder from "./PageFinder";
91
- import PageInfoBanner from "./PageInfoBanner";
92
91
  import Pagination from "./Pagination";
93
92
  import ProgressBar from "./ProgressBar";
94
93
  import ReorderArrows from "./ReorderArrows";
@@ -206,7 +205,6 @@ export {
206
205
  NumberField,
207
206
  OcassionalToast,
208
207
  PageFinder,
209
- PageInfoBanner,
210
208
  Pagination,
211
209
  PermissionsFilter,
212
210
  ProgressBar,
@@ -11,7 +11,7 @@ const PublicPreview = () => {
11
11
  const { id: pageID, entity } = useParams<{ id: string; entity: string }>();
12
12
  const [state, setState] = useState<any>(null);
13
13
  const [isLoading, setIsLoading] = useState(false);
14
- const [tokenError, setTokenError] = useState(false);
14
+ const [tokenError, setTokenError] = useState<string | null>(null);
15
15
  const [shareEndDate, setShareEndDate] = useState<string | null>(null);
16
16
 
17
17
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
@@ -39,7 +39,7 @@ const PublicPreview = () => {
39
39
  setShareEndDate(shareResponse.data.endDate);
40
40
  }
41
41
  } else {
42
- setTokenError(true);
42
+ setTokenError(response.status === 404 ? "404" : response.status === 400 ? "linkExpired" : "wrong");
43
43
  }
44
44
  setIsLoading(false);
45
45
  };
@@ -62,7 +62,7 @@ const PublicPreview = () => {
62
62
  const siteID = state?.siteInfo ? state.siteInfo.siteId : undefined;
63
63
 
64
64
  if (tokenError) {
65
- return <ErrorPage type="linkExpired" />;
65
+ return <ErrorPage type={tokenError} />;
66
66
  }
67
67
 
68
68
  if (isLoading || !state) return <Loading />;
@@ -1,38 +0,0 @@
1
- import { Icon } from "@ax/components";
2
-
3
- import * as S from "./styles";
4
-
5
- const PageInfoBanner = (props: PageInfoBannerProps) => {
6
- const { message, actionLabel, onAction, onDismiss, icon = "view" } = props;
7
-
8
- return (
9
- <S.Container>
10
- <S.Header>
11
- <S.Info>
12
- <Icon name={icon} size="16px" />
13
- {message}{" "}
14
- {onAction && (
15
- <button type="button" onClick={onAction}>
16
- <strong style={{ textDecoration: "underline" }}>{actionLabel}</strong>
17
- </button>
18
- )}
19
- {onDismiss && (
20
- <S.DismissButton type="button" onClick={onDismiss}>
21
- <Icon name="close" size="16px" />
22
- </S.DismissButton>
23
- )}
24
- </S.Info>
25
- </S.Header>
26
- </S.Container>
27
- );
28
- };
29
-
30
- interface PageInfoBannerProps {
31
- message: string;
32
- actionLabel?: string;
33
- onAction?: () => void;
34
- onDismiss?: () => void;
35
- icon?: string;
36
- }
37
-
38
- export default PageInfoBanner;
@@ -1,40 +0,0 @@
1
- import styled from "styled-components";
2
-
3
- const Container = styled.div`
4
- left: 0px;
5
- bottom: ${(p) => p.theme.spacing.s};
6
- width: 100vw;
7
- display: flex;
8
- position: fixed;
9
- z-index: 100;
10
- justify-content: center;
11
- align-items: center;
12
- `;
13
-
14
- const Header = styled.span`
15
- ${({ theme }) => theme.textStyle.uiS}
16
- border-radius: ${(p) => p.theme.radii.s};
17
- background-color: ${(p) => p.theme.color.uiBackground04};
18
- color: ${(p) => p.theme.color.textHighEmphasisInverse};
19
- padding: ${(p) => p.theme.spacing.s};
20
- svg {
21
- path {
22
- fill: ${(p) => p.theme.color.textHighEmphasisInverse};
23
- }
24
- }
25
- `;
26
-
27
- const Info = styled.div`
28
- display: flex;
29
- align-items: center;
30
- column-gap: ${(p) => p.theme.spacing.xs};
31
- `;
32
-
33
- const DismissButton = styled.button`
34
- background: none;
35
- border: none;
36
- color: inherit;
37
- cursor: pointer;
38
- `;
39
-
40
- export { Container, DismissButton, Header, Info };