Display error and prevent new db creation if new db name matches existing db name
parent
2b2cfeb51c
commit
3b1482261f
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue