diff --git a/frontend/src/Editor/DataSourceManager/DataSourceManager.jsx b/frontend/src/Editor/DataSourceManager/DataSourceManager.jsx index 53e9370dc7..35c5ad822b 100644 --- a/frontend/src/Editor/DataSourceManager/DataSourceManager.jsx +++ b/frontend/src/Editor/DataSourceManager/DataSourceManager.jsx @@ -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' } + ); } };