Display error and prevent new db creation if new db name matches existing db name

pull/10616/head
deniz kusefoglu 2017-09-18 19:34:58 -07:00
parent 2b2cfeb51c
commit 3b1482261f
1 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import React, {PropTypes, Component} from 'react'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import _ from 'lodash'
import DatabaseManager from 'src/admin/components/DatabaseManager'
@ -57,12 +58,16 @@ class DatabaseManagerPage extends Component {
}
handleCreateDatabase = database => {
const {actions, notify, source} = this.props
const {actions, notify, source, databases} = this.props
if (!database.name) {
return notify('error', 'Database name cannot be blank')
}
if (_.findIndex(databases, {name: database.name}, 1)) {
return notify('error', 'A database by this name already exists')
}
actions.createDatabaseAsync(source.links.databases, database)
}