From 0593eea5ef9697f99f0705e1b05922de40f8b857 Mon Sep 17 00:00:00 2001 From: Leithon Englidh Date: Wed, 25 Aug 2021 14:55:12 -0500 Subject: [PATCH 1/2] added pluginOptions from wrappRootElement --- packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js index fe223454746ea..498d515882132 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js @@ -28,8 +28,11 @@ const ShadowPortal = ({ children, identifier }) => { ) } -export const wrapRootElement = ({ element }) => { - if (process.env.GATSBY_PREVIEW_INDICATOR_ENABLED === `true`) { +export const wrapRootElement = ({ element }, pluginOptions) => { + if ( + process.env.GATSBY_PREVIEW_INDICATOR_ENABLED === `true` && + !pluginOptions.disablePreviewUI + ) { return ( <> {element} From aa96c3f41fda580de16b8fb3fb4885138775978f Mon Sep 17 00:00:00 2001 From: Leithon Englidh Date: Thu, 26 Aug 2021 13:39:53 -0500 Subject: [PATCH 2/2] updated access to the pluginOptions property and added the disabledPreivew property to the schema --- packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js | 2 +- packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js index 498d515882132..13dc80f2fb7fb 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js @@ -31,7 +31,7 @@ const ShadowPortal = ({ children, identifier }) => { export const wrapRootElement = ({ element }, pluginOptions) => { if ( process.env.GATSBY_PREVIEW_INDICATOR_ENABLED === `true` && - !pluginOptions.disablePreviewUI + !pluginOptions?.disablePreviewUI ) { return ( <> diff --git a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js index c461d2392eec1..cd3b40a70871c 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js @@ -150,6 +150,9 @@ const pluginOptionsSchema = function ({ Joi }) { generateMatchPathRewrites: Joi.boolean().description( `When set to false, turns off automatic creation of redirect rules for client only paths` ), + disablePreviewUI: Joi.boolean().description( + `When set to true, turns off Gatsby Preview if enabled` + ), }) }