From 67482bf13633ad7b67d89ea338098cf098849f3b Mon Sep 17 00:00:00 2001 From: Polina Vorozheykina Date: Thu, 6 Jan 2022 09:26:27 -0800 Subject: [PATCH 01/11] Add preview 2.0 changes. --- .../gatsby-plugin-gatsby-cloud/package.json | 4 +- .../src/components/Indicator.js | 2 +- .../buttons/GatsbyIndicatorButton.js | 44 ++------- .../src/components/buttons/IndicatorButton.js | 34 +++++-- .../components/buttons/InfoIndicatorButton.js | 47 ++++++++-- .../src/components/icons.js | 90 +++++++++++++++++++ .../tooltips/BuildSuccessTooltipContent.js | 6 +- .../tooltips/IndicatorButtonTooltip.js | 3 +- 8 files changed, 171 insertions(+), 59 deletions(-) diff --git a/packages/gatsby-plugin-gatsby-cloud/package.json b/packages/gatsby-plugin-gatsby-cloud/package.json index 4c60d3b69c35a..4ad78440cf1f3 100644 --- a/packages/gatsby-plugin-gatsby-cloud/package.json +++ b/packages/gatsby-plugin-gatsby-cloud/package.json @@ -1,7 +1,7 @@ { "name": "gatsby-plugin-gatsby-cloud", "description": "A Gatsby plugin which optimizes working with Gatsby Cloud", - "version": "3.1.0-next.0", + "version": "4.4.0", "author": "Kyle Mathews ", "bugs": { "url": "https://github.com/gatsbyjs/gatsby/issues" @@ -41,7 +41,7 @@ "license": "MIT", "main": "index.js", "peerDependencies": { - "gatsby": "^3.0.0-next.0" + "gatsby": "^4.0.0" }, "repository": { "type": "git", diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/Indicator.js b/packages/gatsby-plugin-gatsby-cloud/src/components/Indicator.js index d4cfc8687954d..274f7031afd87 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/components/Indicator.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/components/Indicator.js @@ -131,8 +131,8 @@ export default function Indicator() { return ( - + ) } diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/GatsbyIndicatorButton.js b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/GatsbyIndicatorButton.js index d541dc8b646b3..19455f3f41ebc 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/GatsbyIndicatorButton.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/GatsbyIndicatorButton.js @@ -16,49 +16,15 @@ const getButtonProps = ({ erroredBuildId, }) => { switch (buildStatus) { - case `SUCCESS`: { - return { - tooltipContent: ( - - ), - overrideShowTooltip: true, - active: true, - } - } - case `ERROR`: { - return { - tooltipContent: ( - - ), - overrideShowTooltip: true, - active: true, - } - } - case `BUILDING`: { - return { - tooltipContent: `Building a new preview`, - showSpinner: true, - overrideShowTooltip: true, - } - } - case `UPTODATE`: { + case `BUILDING`: + case `ERROR`: + case `SUCCESS`: + case `UPTODATE`: + default: { return { active: true, } } - default: { - return {} - } } } diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/IndicatorButton.js b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/IndicatorButton.js index 223286bbcd0d4..af7f57536d944 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/IndicatorButton.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/IndicatorButton.js @@ -1,6 +1,6 @@ import React, { useState } from "react" import { IndicatorButtonTooltip } from "../tooltips" -import { spinnerIcon } from "../icons" +import { spinnerIcon, exitIcon } from "../icons" export default function IndicatorButton({ buttonIndex, @@ -13,6 +13,7 @@ export default function IndicatorButton({ testId, onMouseEnter, hoverable, + exitButton, }) { const [showTooltip, setShowTooltip] = useState(false) const isFirstButton = buttonIndex === 0 @@ -32,15 +33,23 @@ export default function IndicatorButton({ >
{ + setShowTooltip(!showTooltip) + }} onMouseEnter={() => { - setShowTooltip(true) + if (hoverable) { + setShowTooltip(true) - if (onMouseEnter) { - onMouseEnter() + if (onMouseEnter) { + onMouseEnter() + } + } + }} + onMouseLeave={() => { + if (hoverable) { + setShowTooltip(false) } }} - onMouseLeave={onMouseLeave} - onClick={active ? onClick : null} > {iconSvg} {showSpinner && ( @@ -51,6 +60,19 @@ export default function IndicatorButton({ {tooltipContent && ( { + setShowTooltip(false) + }} + data-gatsby-preview-indicator="tooltip-link" + > + {exitIcon} + + ) + } overrideShowTooltip={overrideShowTooltip} showTooltip={showTooltip} buttonIndex={buttonIndex} diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js index 4113c0d37ad66..1d6701e9736f1 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js @@ -3,10 +3,24 @@ import { formatDistance } from "date-fns" import trackEvent from "../../utils/trackEvent" import IndicatorButton from "./IndicatorButton" -import { infoIcon } from "../icons" +import { exitIcon, infoIcon, infoIconActive } from "../icons" +import { + BuildErrorTooltipContent, + BuildSuccessTooltipContent, +} from "../tooltips" const getButtonProps = props => { - const { createdAt, buildStatus } = props + const { + createdAt, + buildStatus, + isOnPrettyUrl, + sitePrefix, + siteId, + buildId, + orgId, + } = props + + const foo = `SUCCESS` switch (buildStatus) { case `UPTODATE`: { return { @@ -16,13 +30,30 @@ const getButtonProps = props => { { includeSeconds: true } )} ago`, active: true, + exitButton: false, + hoverable: true, + } + } + case `SUCCESS`: { + return { + tooltipContent: ( + + ), + overrideShowTooltip: false, + active: true, + showInfo: true, + exitButton: true, } } - case `SUCCESS`: - case `ERROR`: case `BUILDING`: + case `ERROR`: default: { - return {} } } } @@ -43,10 +74,10 @@ export default function InfoIndicatorButton(props) { return ( ) diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/icons.js b/packages/gatsby-plugin-gatsby-cloud/src/components/icons.js index be2f23b40fe31..65da88903675d 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/components/icons.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/components/icons.js @@ -89,6 +89,96 @@ export const successIcon = ( ) +export const exitIcon = ( + + + +) + +export const infoIconActive = ( + + + + + + + + + + + + + + + + + + + + +) + +export const notificationIcon = ( + + + +) + export const spinnerIcon = ( - {`New preview available`} + {`This page has been updated. `}

{`Click to view`}

+

+ {`View Changes `} +

) diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/tooltips/IndicatorButtonTooltip.js b/packages/gatsby-plugin-gatsby-cloud/src/components/tooltips/IndicatorButtonTooltip.js index 50a74bc8151bf..f64193b8b7071 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/components/tooltips/IndicatorButtonTooltip.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/components/tooltips/IndicatorButtonTooltip.js @@ -6,6 +6,7 @@ export default function IndicatorButtonTooltip({ showTooltip, buttonIndex, testId, + iconExit, }) { return (
- {tooltipContent} + {tooltipContent} {iconExit}
) } From 31737ea5b20b9c7351a6fad58040cde48b4dc062 Mon Sep 17 00:00:00 2001 From: Polina Vorozheykina Date: Thu, 6 Jan 2022 09:28:04 -0800 Subject: [PATCH 02/11] Add preview 2.0 changes. --- .../src/components/buttons/InfoIndicatorButton.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js index 1d6701e9736f1..a7ef23d779ce5 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js @@ -3,11 +3,8 @@ import { formatDistance } from "date-fns" import trackEvent from "../../utils/trackEvent" import IndicatorButton from "./IndicatorButton" -import { exitIcon, infoIcon, infoIconActive } from "../icons" -import { - BuildErrorTooltipContent, - BuildSuccessTooltipContent, -} from "../tooltips" +import { infoIcon, infoIconActive } from "../icons" +import { BuildSuccessTooltipContent } from "../tooltips" const getButtonProps = props => { const { From 0fc75091e12d9448a54141fb985d127769ad68b0 Mon Sep 17 00:00:00 2001 From: Polina Vorozheykina Date: Thu, 6 Jan 2022 09:29:55 -0800 Subject: [PATCH 03/11] Add preview 2.0 changes. --- .../src/components/buttons/InfoIndicatorButton.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js index a7ef23d779ce5..2d5461a5f128c 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/InfoIndicatorButton.js @@ -17,7 +17,6 @@ const getButtonProps = props => { orgId, } = props - const foo = `SUCCESS` switch (buildStatus) { case `UPTODATE`: { return { @@ -51,6 +50,9 @@ const getButtonProps = props => { case `BUILDING`: case `ERROR`: default: { + return { + active: true, + } } } } From de6be1770e8d83206d4e119afe541b586d196710 Mon Sep 17 00:00:00 2001 From: Polina Vorozheykina Date: Thu, 6 Jan 2022 11:14:40 -0800 Subject: [PATCH 04/11] Fix link regression. --- .../src/components/buttons/IndicatorButton.js | 14 +++++++----- .../components/buttons/InfoIndicatorButton.js | 22 ++++++++++++++++--- .../components/buttons/LinkIndicatorButton.js | 1 + .../tooltips/BuildErrorTooltipContent.js | 2 +- .../tooltips/IndicatorButtonTooltip.js | 3 ++- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/IndicatorButton.js b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/IndicatorButton.js index af7f57536d944..d08d0987d9af8 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/IndicatorButton.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/components/buttons/IndicatorButton.js @@ -13,14 +13,13 @@ export default function IndicatorButton({ testId, onMouseEnter, hoverable, + clickable, exitButton, }) { const [showTooltip, setShowTooltip] = useState(false) const isFirstButton = buttonIndex === 0 const marginTop = isFirstButton ? `0px` : `8px` - const onMouseLeave = () => setShowTooltip(false) - return ( <>