diff --git a/console/src/components/Services/Data/DataActions.js b/console/src/components/Services/Data/DataActions.js index 3d0ad04c27f..1e35453225b 100644 --- a/console/src/components/Services/Data/DataActions.js +++ b/console/src/components/Services/Data/DataActions.js @@ -780,7 +780,8 @@ const makeMigrationCall = ( shouldSkipSchemaReload, skipExecution = false, isRetry = false, - source = getState().tables.currentDataSource + source = getState().tables.currentDataSource, + shouldShowNotifications = true ) => { const { resourceVersion } = getState().metadata; const upQuery = { @@ -837,7 +838,7 @@ const makeMigrationCall = ( } dispatch(updateSchemaInfo()); } - if (successMsg) { + if (successMsg && shouldShowNotifications) { dispatch(showSuccessNotification(successMsg)); } customOnSuccess(data, globals.consoleMode, currMigrationMode); @@ -846,44 +847,46 @@ const makeMigrationCall = ( const errorDetails = getErrorMessage('', err); const errorDetailsLines = errorDetails.split('\n'); - dispatch( - showNotification( - { - title: errMsg, - level: 'error', - message: ( -

- {errorDetailsLines.map((m, i) => ( -

{m}
- ))} -
- Do you want to drop the dependent items as well? -

- ), - autoDismiss: 0, - action: { - label: 'Continue', - callback: () => - makeMigrationCall( - dispatch, - getState, - cascadeUpQueries(upQueries, isPgCascade), // cascaded new up queries - downQueries, - migrationName, - customOnSuccess, - customOnError, - requestMsg, - successMsg, - errorMsg, - shouldSkipSchemaReload, - false, - true // prevent further retry - ), + if (shouldShowNotifications) { + dispatch( + showNotification( + { + title: errMsg, + level: 'error', + message: ( +

+ {errorDetailsLines.map((m, i) => ( +

{m}
+ ))} +
+ Do you want to drop the dependent items as well? +

+ ), + autoDismiss: 0, + action: { + label: 'Continue', + callback: () => + makeMigrationCall( + dispatch, + getState, + cascadeUpQueries(upQueries, isPgCascade), // cascaded new up queries + downQueries, + migrationName, + customOnSuccess, + customOnError, + requestMsg, + successMsg, + errorMsg, + shouldSkipSchemaReload, + false, + true // prevent further retry + ), + }, }, - }, - 'error' - ) - ); + 'error' + ) + ); + } }; const onError = err => { @@ -904,7 +907,10 @@ const makeMigrationCall = ( }; dispatch({ type: MAKE_REQUEST }); - dispatch(showSuccessNotification(requestMsg)); + + if (shouldShowNotifications) { + dispatch(showSuccessNotification(requestMsg)); + } return dispatch( requestAction(url, options, REQUEST_SUCCESS, REQUEST_ERROR) ).then(onSuccess, onError); diff --git a/console/src/components/Services/Data/DataSources/state.ts b/console/src/components/Services/Data/DataSources/state.ts index 1da5b23db1e..08c5c9f83de 100644 --- a/console/src/components/Services/Data/DataSources/state.ts +++ b/console/src/components/Services/Data/DataSources/state.ts @@ -138,7 +138,8 @@ export const connectDataSource = ( >[], isEditState = false, isRenameSource = false, - currentName = '' + currentName = '', + shouldShowNotification = true ) => { let connectionParams: ConnectionParams | undefined; let databaseURL: string | { from_env: string } = @@ -220,7 +221,8 @@ export const connectDataSource = ( ) ); } - return dispatch(addDataSource(data, cb, replicas)); + + return dispatch(addDataSource(data, cb, replicas, shouldShowNotification)); }; export const removeEmptyValues = (obj: any) => diff --git a/console/src/metadata/actions.ts b/console/src/metadata/actions.ts index c7071a511d6..a2c72fbbca3 100644 --- a/console/src/metadata/actions.ts +++ b/console/src/metadata/actions.ts @@ -281,7 +281,8 @@ export const addDataSource = | 'use_prepared_statements' | 'ssl_configuration' | 'isolation_level' - >[] + >[], + shouldShowNotifications = true ): Thunk, MetadataActions> => (dispatch, getState) => { const upQuery = addSource(data.driver, data.payload, replicas); @@ -306,23 +307,25 @@ export const addDataSource = }; return dispatch(exportMetadata()).then(() => { dispatch(fetchDataInit(data.payload.name, data.driver)); - dispatch( - showNotification( - { - title: `Data source ${ - !isEdit ? 'added' : 'updated' - } successfully!`, - level: 'success', - autoDismiss: 0, - alternateActionButtonProps: { - label: 'View Database', - onClick: onButtonClick, - trackId: 'data-tab-view-database-notification-button-add-db', + if (shouldShowNotifications) { + dispatch( + showNotification( + { + title: `Data source ${ + !isEdit ? 'added' : 'updated' + } successfully!`, + level: 'success', + autoDismiss: 0, + alternateActionButtonProps: { + label: 'View Database', + onClick: onButtonClick, + trackId: 'data-tab-view-database-notification-button-add-db', + }, }, - }, - 'success' - ) - ); + 'success' + ) + ); + } if (successCb) successCb(); return getState(); }); @@ -350,7 +353,8 @@ export const addDataSource = false, false, false, - data.payload.name + data.payload.name, + shouldShowNotifications ); };