Fixed : App allows to create a datasource with no name (#1253)

* Update DataSourceManager.jsx

* Update DataSourceManager.jsx
This commit is contained in:
SAI SUMANTH KUMAR 2021-10-29 14:36:44 +05:30 committed by GitHub
parent 1aca2b0ea0
commit 56165ad8bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,23 +111,29 @@ class DataSourceManager extends React.Component {
encrypted: keyMeta ? keyMeta.encrypted : false,
};
});
if (selectedDataSource.id) {
this.setState({ isSaving: true });
datasourceService.save(selectedDataSource.id, appId, name, parsedOptions).then(() => {
this.setState({ isSaving: false });
this.hideModal();
toast.success('Datasource Saved', { hideProgressBar: true, position: 'top-center' });
this.props.dataSourcesChanged();
});
if (name.trim() !== ''){
if (selectedDataSource.id) {
this.setState({ isSaving: true });
datasourceService.save(selectedDataSource.id, appId, name, parsedOptions).then(() => {
this.setState({ isSaving: false });
this.hideModal();
toast.success('Datasource Saved', { hideProgressBar: true, position: 'top-center' });
this.props.dataSourcesChanged();
});
} else {
this.setState({ isSaving: true });
datasourceService.create(appId, name, kind, parsedOptions).then(() => {
this.setState({ isSaving: false });
this.hideModal();
toast.success('Datasource Added', { hideProgressBar: true, position: 'top-center' });
this.props.dataSourcesChanged();
});
}
} else {
this.setState({ isSaving: true });
datasourceService.create(appId, name, kind, parsedOptions).then(() => {
this.setState({ isSaving: false });
this.hideModal();
toast.success('Datasource Added', { hideProgressBar: true, position: 'top-center' });
this.props.dataSourcesChanged();
});
toast.error(
"The name of datasource should not be empty",
{ hideProgressBar: true, position: 'top-center' }
);
}
};