mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-24 17:08:28 +00:00
parent
7c8c51e862
commit
6fd572d635
@ -14,7 +14,7 @@
|
|||||||
import { ISubmitEvent } from '@rjsf/core';
|
import { ISubmitEvent } from '@rjsf/core';
|
||||||
import { cloneDeep, isNil } from 'lodash';
|
import { cloneDeep, isNil } from 'lodash';
|
||||||
import { LoadingState } from 'Models';
|
import { LoadingState } from 'Models';
|
||||||
import React, { FunctionComponent } from 'react';
|
import React, { Fragment, FunctionComponent } from 'react';
|
||||||
import { TestConnection } from '../../axiosAPIs/serviceAPI';
|
import { TestConnection } from '../../axiosAPIs/serviceAPI';
|
||||||
import { ServiceCategory } from '../../enums/service.enum';
|
import { ServiceCategory } from '../../enums/service.enum';
|
||||||
import {
|
import {
|
||||||
@ -36,7 +36,7 @@ import { getDashboardConfig } from '../../utils/DashboardServiceUtils';
|
|||||||
import { getDatabaseConfig } from '../../utils/DatabaseServiceUtils';
|
import { getDatabaseConfig } from '../../utils/DatabaseServiceUtils';
|
||||||
import { getMessagingConfig } from '../../utils/MessagingServiceUtils';
|
import { getMessagingConfig } from '../../utils/MessagingServiceUtils';
|
||||||
import { getPipelineConfig } from '../../utils/PipelineServiceUtils';
|
import { getPipelineConfig } from '../../utils/PipelineServiceUtils';
|
||||||
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
|
import { showErrorToast } from '../../utils/ToastUtils';
|
||||||
import FormBuilder from '../common/FormBuilder/FormBuilder';
|
import FormBuilder from '../common/FormBuilder/FormBuilder';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -73,9 +73,6 @@ const ConnectionConfigForm: FunctionComponent<Props> = ({
|
|||||||
// This api only responds with status 200 on success
|
// This api only responds with status 200 on success
|
||||||
// No data sent on api success
|
// No data sent on api success
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
showSuccessToast(
|
|
||||||
jsonData['api-success-messages']['test-connection-success']
|
|
||||||
);
|
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
throw jsonData['api-error-messages']['unexpected-server-response'];
|
throw jsonData['api-error-messages']['unexpected-server-response'];
|
||||||
@ -149,7 +146,7 @@ const ConnectionConfigForm: FunctionComponent<Props> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return <>{getDatabaseFields()}</>;
|
return <Fragment>{getDatabaseFields()}</Fragment>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ConnectionConfigForm;
|
export default ConnectionConfigForm;
|
||||||
|
@ -147,6 +147,8 @@ const FormBuilder: FunctionComponent<Props> = ({
|
|||||||
formData
|
formData
|
||||||
);
|
);
|
||||||
const [connectionTesting, setConnectionTesting] = useState<boolean>(false);
|
const [connectionTesting, setConnectionTesting] = useState<boolean>(false);
|
||||||
|
const [connectionTestingState, setConnectionTestingState] =
|
||||||
|
useState<LoadingState>('initial');
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setLocalFormData(formData);
|
setLocalFormData(formData);
|
||||||
@ -164,9 +166,23 @@ const FormBuilder: FunctionComponent<Props> = ({
|
|||||||
const handleTestConnection = () => {
|
const handleTestConnection = () => {
|
||||||
if (localFormData && onTestConnection) {
|
if (localFormData && onTestConnection) {
|
||||||
setConnectionTesting(true);
|
setConnectionTesting(true);
|
||||||
onTestConnection(localFormData).finally(() => {
|
setConnectionTestingState('waiting');
|
||||||
setConnectionTesting(false);
|
onTestConnection(localFormData)
|
||||||
});
|
.then(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
setConnectionTestingState('success');
|
||||||
|
}, 500);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
setConnectionTestingState('initial');
|
||||||
|
}, 500);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
setConnectionTesting(false);
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const debouncedOnChange = useCallback(
|
const debouncedOnChange = useCallback(
|
||||||
@ -183,6 +199,29 @@ const FormBuilder: FunctionComponent<Props> = ({
|
|||||||
debounceOnSearch(updatedData);
|
debounceOnSearch(updatedData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getConnectionTestingMessage = () => {
|
||||||
|
switch (connectionTestingState) {
|
||||||
|
case 'waiting':
|
||||||
|
return (
|
||||||
|
<div className="tw-flex">
|
||||||
|
<Loader size="small" type="default" />{' '}
|
||||||
|
<span className="tw-ml-2">Running test...</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case 'success':
|
||||||
|
return (
|
||||||
|
<div className="tw-flex">
|
||||||
|
<SVGIcons alt="success-badge" icon={Icons.SUCCESS_BADGE} />
|
||||||
|
<span className="tw-ml-2">Connection test was successful</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'initial':
|
||||||
|
default:
|
||||||
|
return 'Test your connections before creating service';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
ArrayFieldTemplate={ArrayFieldTemplate}
|
ArrayFieldTemplate={ArrayFieldTemplate}
|
||||||
@ -206,23 +245,25 @@ const FormBuilder: FunctionComponent<Props> = ({
|
|||||||
No Connection Configs available.
|
No Connection Configs available.
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="tw-mt-6 tw-flex tw-justify-between">
|
{!isEmpty(schema) && onTestConnection && (
|
||||||
<div>
|
<div className="tw-flex tw-justify-between tw-bg-white tw-border tw-border-main tw-shadow tw-rounded tw-p-3 tw-mt-4">
|
||||||
{!isEmpty(schema) && onTestConnection && (
|
<div className="tw-self-center">{getConnectionTestingMessage()}</div>
|
||||||
<Button
|
<Button
|
||||||
className={classNames({
|
className={classNames('tw-self-center tw-py-1 tw-px-1.5', {
|
||||||
'tw-opacity-40': connectionTesting,
|
'tw-opacity-40': connectionTesting,
|
||||||
})}
|
})}
|
||||||
data-testid="test-connection-btn"
|
data-testid="test-connection-btn"
|
||||||
disabled={connectionTesting}
|
disabled={connectionTesting}
|
||||||
size="regular"
|
size="small"
|
||||||
theme="primary"
|
theme="primary"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={handleTestConnection}>
|
onClick={handleTestConnection}>
|
||||||
Test Connection
|
Test Connection
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="tw-mt-6 tw-flex tw-justify-between">
|
||||||
|
<div />
|
||||||
<div className="tw-text-right" data-testid="buttons">
|
<div className="tw-text-right" data-testid="buttons">
|
||||||
<Button
|
<Button
|
||||||
size="regular"
|
size="regular"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user