From 825358318a7aaee76128c838f9aece1942c33c62 Mon Sep 17 00:00:00 2001 From: Louise Davies Date: Fri, 13 Oct 2023 11:36:55 +0100 Subject: [PATCH] update root component to only load App when plugin div is present this prevents the plugin from doing any background loading whilst SG maintenance mode is active --- packages/datagateway-dataview/src/index.tsx | 2 +- packages/datagateway-download/src/index.tsx | 3 ++- packages/datagateway-search/src/index.tsx | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/datagateway-dataview/src/index.tsx b/packages/datagateway-dataview/src/index.tsx index f14c939d1..7b9a80eec 100644 --- a/packages/datagateway-dataview/src/index.tsx +++ b/packages/datagateway-dataview/src/index.tsx @@ -41,7 +41,7 @@ function domElementGetter(): HTMLElement { const reactLifecycles = singleSpaReact({ React, ReactDOM, - rootComponent: App, + rootComponent: () => (document.getElementById(pluginName) ? : null), domElementGetter, }); diff --git a/packages/datagateway-download/src/index.tsx b/packages/datagateway-download/src/index.tsx index 4cb42e282..28c4af484 100644 --- a/packages/datagateway-download/src/index.tsx +++ b/packages/datagateway-download/src/index.tsx @@ -31,7 +31,8 @@ function domElementGetter(): HTMLElement { const reactLifecycles = singleSpaReact({ React, ReactDOM, - rootComponent: App, + rootComponent: () => + document.getElementById('datagateway-download') ? : null, domElementGetter, errorBoundary(error) { log.error(`datagateway-download failed with error: ${error}`); diff --git a/packages/datagateway-search/src/index.tsx b/packages/datagateway-search/src/index.tsx index 14786dcbf..ca3f3595d 100644 --- a/packages/datagateway-search/src/index.tsx +++ b/packages/datagateway-search/src/index.tsx @@ -36,7 +36,7 @@ function domElementGetter(): HTMLElement { const reactLifecycles = singleSpaReact({ React, ReactDOM, - rootComponent: App, + rootComponent: () => (document.getElementById(pluginName) ? : null), domElementGetter, });