From 827a332464fc5918a7af287a0374b50d6035b62e Mon Sep 17 00:00:00 2001 From: Sameer Kolhar Date: Wed, 24 Feb 2021 14:56:14 +0530 Subject: [PATCH] console: fixes for cloud console Co-authored-by: Sooraj <8408875+soorajshankar@users.noreply.github.com> GitOrigin-RevId: 7e86572cb18e045520a922e57a22057a82af6f0f --- console/src/components/App/App.js | 11 +++++++++-- console/src/telemetry/Actions.ts | 12 +++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/console/src/components/App/App.js b/console/src/components/App/App.js index a890845d325..d05a54d9397 100644 --- a/console/src/components/App/App.js +++ b/console/src/components/App/App.js @@ -31,16 +31,23 @@ const App = ({ document.getElementById('content').className = className + ' show'; document.getElementById('loading').style.display = 'none'; }, []); + const telemetryShown = React.useRef(false); + // should be true only in the case of hasura cloud + const isContextCloud = + window.__env.userRole || window.location.host.includes('cloud'); React.useEffect(() => { if ( telemetry.console_opts && - !telemetry.console_opts.telemetryNotificationShown + !telemetry.console_opts.telemetryNotificationShown && + !telemetryShown.current && + !isContextCloud ) { + telemetryShown.current = true; dispatch(showTelemetryNotification()); dispatch(telemetryNotificationShown()); } - }, [dispatch, telemetry]); + }, [dispatch, telemetry, isContextCloud]); let connectionFailMsg = null; if (connectionFailed) { diff --git a/console/src/telemetry/Actions.ts b/console/src/telemetry/Actions.ts index 768f717cfe4..9bbfd272924 100644 --- a/console/src/telemetry/Actions.ts +++ b/console/src/telemetry/Actions.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-underscore-dangle */ import { AnyAction, Dispatch } from 'redux'; import { ThunkDispatch } from 'redux-thunk'; @@ -109,9 +110,14 @@ const setOnboardingCompletedInDB = ( getState: GetReduxState ) => { const successCb = () => { - dispatch( - showSuccessNotification('Success', 'Dismissed console onboarding') - ); + // the success notification won't be shown on cloud + const isCloudContext = + window.__env.userRole || window.location.host.includes('cloud'); + if (!isCloudContext) { + dispatch( + showSuccessNotification('Success', 'Dismissed console onboarding') + ); + } }; const errorCb = (error: Error) => {