19836: Added security state check
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Tue, 14 Feb 2023 22:49:04 +0000 (23:49 +0100)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Tue, 14 Feb 2023 22:49:04 +0000 (23:49 +0100)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

src/store/tooltips/tooltips-middleware.ts

index 901374d2fd07babfa26c83fcbcd7d5e93f7141b6..d4ea41ee51f08395f22b23502e18f2ebb48292ed 100644 (file)
@@ -18,16 +18,17 @@ const tippySingleton = createSingleton([], {delay: 10});
 
 export const tooltipsMiddleware = (services: ServiceRepository): Middleware => (store: Store) => next => action => {
     const state: RootState = store.getState();
-    const hideTooltip = localStorage.getItem(TOOLTIP_LOCAL_STORAGE_KEY);
-    const { BannerUUID } = (state.auth.config.clusterConfig.Workbench as any);
 
-    const bannerUUID = BannerUUID || 'tordo-4zz18-1buneu6sb8zxiti';
-
-    if (bannerUUID && !tooltipsContents && !hideTooltip && !tooltipsFetchFailed && !running) {
-        running = true;
-        fetchTooltips(services, bannerUUID);
-    } else if (tooltipsContents && !hideTooltip && !tooltipsFetchFailed) {
-        applyTooltips();
+    if (state && state.auth && state.auth.config && state.auth.config.clusterConfig && state.auth.config.clusterConfig.Workbench) {
+        const hideTooltip = localStorage.getItem(TOOLTIP_LOCAL_STORAGE_KEY);
+        const { BannerUUID: bannerUUID } = state.auth.config.clusterConfig.Workbench;
+    
+        if (bannerUUID && !tooltipsContents && !hideTooltip && !tooltipsFetchFailed && !running) {
+            running = true;
+            fetchTooltips(services, bannerUUID);
+        } else if (tooltipsContents && !hideTooltip && !tooltipsFetchFailed) {
+            applyTooltips();
+        }
     }
 
     return next(action);