diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ServiceConfig/ConnectionConfigForm.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ServiceConfig/ConnectionConfigForm.tsx index f351f23c606..b522b5cfed9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ServiceConfig/ConnectionConfigForm.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ServiceConfig/ConnectionConfigForm.tsx @@ -14,7 +14,7 @@ import { ISubmitEvent } from '@rjsf/core'; import { cloneDeep, isNil } from 'lodash'; import { LoadingState } from 'Models'; -import React, { FunctionComponent } from 'react'; +import React, { Fragment, FunctionComponent } from 'react'; import { TestConnection } from '../../axiosAPIs/serviceAPI'; import { ServiceCategory } from '../../enums/service.enum'; import { @@ -36,7 +36,7 @@ import { getDashboardConfig } from '../../utils/DashboardServiceUtils'; import { getDatabaseConfig } from '../../utils/DatabaseServiceUtils'; import { getMessagingConfig } from '../../utils/MessagingServiceUtils'; import { getPipelineConfig } from '../../utils/PipelineServiceUtils'; -import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils'; +import { showErrorToast } from '../../utils/ToastUtils'; import FormBuilder from '../common/FormBuilder/FormBuilder'; interface Props { @@ -73,9 +73,6 @@ const ConnectionConfigForm: FunctionComponent = ({ // This api only responds with status 200 on success // No data sent on api success if (res.status === 200) { - showSuccessToast( - jsonData['api-success-messages']['test-connection-success'] - ); resolve(); } else { throw jsonData['api-error-messages']['unexpected-server-response']; @@ -149,7 +146,7 @@ const ConnectionConfigForm: FunctionComponent = ({ ); }; - return <>{getDatabaseFields()}; + return {getDatabaseFields()}; }; export default ConnectionConfigForm; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/FormBuilder/FormBuilder.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/FormBuilder/FormBuilder.tsx index 7aab1896055..68ddb0e4293 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/FormBuilder/FormBuilder.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/FormBuilder/FormBuilder.tsx @@ -147,6 +147,8 @@ const FormBuilder: FunctionComponent = ({ formData ); const [connectionTesting, setConnectionTesting] = useState(false); + const [connectionTestingState, setConnectionTestingState] = + useState('initial'); const handleCancel = () => { setLocalFormData(formData); @@ -164,9 +166,23 @@ const FormBuilder: FunctionComponent = ({ const handleTestConnection = () => { if (localFormData && onTestConnection) { setConnectionTesting(true); - onTestConnection(localFormData).finally(() => { - setConnectionTesting(false); - }); + setConnectionTestingState('waiting'); + onTestConnection(localFormData) + .then(() => { + setTimeout(() => { + setConnectionTestingState('success'); + }, 500); + }) + .catch(() => { + setTimeout(() => { + setConnectionTestingState('initial'); + }, 500); + }) + .finally(() => { + setTimeout(() => { + setConnectionTesting(false); + }, 500); + }); } }; const debouncedOnChange = useCallback( @@ -183,6 +199,29 @@ const FormBuilder: FunctionComponent = ({ debounceOnSearch(updatedData); }; + const getConnectionTestingMessage = () => { + switch (connectionTestingState) { + case 'waiting': + return ( +
+ {' '} + Running test... +
+ ); + case 'success': + return ( +
+ + Connection test was successful +
+ ); + + case 'initial': + default: + return 'Test your connections before creating service'; + } + }; + return (
= ({ No Connection Configs available. )} -
-
- {!isEmpty(schema) && onTestConnection && ( - - )} + {!isEmpty(schema) && onTestConnection && ( +
+
{getConnectionTestingMessage()}
+
+ )} +
+