Fix behavior on db creation with enter and make db keys unique
parent
3b1482261f
commit
e032e26993
|
@ -41,9 +41,9 @@ const DatabaseManager = ({
|
|||
</button>
|
||||
</div>
|
||||
<div className="panel-body">
|
||||
{databases.map(db =>
|
||||
{databases.map((db, db_ind) =>
|
||||
<DatabaseTable
|
||||
key={db.links.self}
|
||||
key={db_ind}
|
||||
database={db}
|
||||
notify={notify}
|
||||
isRFDisplayed={isRFDisplayed}
|
||||
|
|
|
@ -59,12 +59,10 @@ class DatabaseManagerPage extends Component {
|
|||
|
||||
handleCreateDatabase = database => {
|
||||
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)) {
|
||||
if (_.findIndex(databases, {name: database.name}, 1) !== -1) {
|
||||
return notify('error', 'A database by this name already exists')
|
||||
}
|
||||
|
||||
|
@ -78,7 +76,7 @@ class DatabaseManagerPage extends Component {
|
|||
|
||||
handleKeyDownDatabase = database => e => {
|
||||
const {key} = e
|
||||
const {actions, notify, source} = this.props
|
||||
const {actions, notify, source, databases} = this.props
|
||||
|
||||
if (key === 'Escape') {
|
||||
actions.removeDatabase(database)
|
||||
|
@ -89,6 +87,10 @@ class DatabaseManagerPage extends Component {
|
|||
return notify('error', 'Database name cannot be blank')
|
||||
}
|
||||
|
||||
if (_.findIndex(databases, {name: database.name}, 1) !== -1) {
|
||||
return notify('error', 'A database by this name already exists')
|
||||
}
|
||||
|
||||
actions.createDatabaseAsync(source.links.databases, database)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue