From e032e2699366903b315d20f77d8c78882993d61d Mon Sep 17 00:00:00 2001 From: deniz kusefoglu Date: Mon, 18 Sep 2017 20:07:21 -0700 Subject: [PATCH] Fix behavior on db creation with enter and make db keys unique --- ui/src/admin/components/DatabaseManager.js | 4 ++-- ui/src/admin/containers/DatabaseManagerPage.js | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/src/admin/components/DatabaseManager.js b/ui/src/admin/components/DatabaseManager.js index 2d3484fc9a..9f3b55e554 100644 --- a/ui/src/admin/components/DatabaseManager.js +++ b/ui/src/admin/components/DatabaseManager.js @@ -41,9 +41,9 @@ const DatabaseManager = ({
- {databases.map(db => + {databases.map((db, db_ind) => { 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) } }