From 818d6c1509f96cba08acdc67b522d5c60f625982 Mon Sep 17 00:00:00 2001 From: Leithon English Date: Thu, 26 Aug 2021 14:29:54 -0500 Subject: [PATCH] feat(gatsby-plugin-gatsby-cloud): Add `disablePreviewUI` option (#32907) * added pluginOptions from wrappRootElement * updated access to the pluginOptions property and added the disabledPreivew property to the schema Co-authored-by: Leithon Englidh --- packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js | 7 +++++-- packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js | 3 +++ 2 files changed, 8 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..13dc80f2fb7fb 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} 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` + ), }) }