From 3b1482261ffa510dd766e959c3bb2de520ab7ac2 Mon Sep 17 00:00:00 2001 From: deniz kusefoglu Date: Mon, 18 Sep 2017 19:34:58 -0700 Subject: [PATCH 1/6] Display error and prevent new db creation if new db name matches existing db name --- ui/src/admin/containers/DatabaseManagerPage.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/src/admin/containers/DatabaseManagerPage.js b/ui/src/admin/containers/DatabaseManagerPage.js index a1f2b74d39..cf67c9e658 100644 --- a/ui/src/admin/containers/DatabaseManagerPage.js +++ b/ui/src/admin/containers/DatabaseManagerPage.js @@ -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) } From e032e2699366903b315d20f77d8c78882993d61d Mon Sep 17 00:00:00 2001 From: deniz kusefoglu Date: Mon, 18 Sep 2017 20:07:21 -0700 Subject: [PATCH 2/6] 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) } } From 8b8e4bff95465c45e1ba9e01841d2eedaad8b090 Mon Sep 17 00:00:00 2001 From: deniz kusefoglu Date: Mon, 18 Sep 2017 20:17:43 -0700 Subject: [PATCH 3/6] camelCase is alWays beTTer --- ui/src/admin/components/DatabaseManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/admin/components/DatabaseManager.js b/ui/src/admin/components/DatabaseManager.js index 9f3b55e554..511092ff7c 100644 --- a/ui/src/admin/components/DatabaseManager.js +++ b/ui/src/admin/components/DatabaseManager.js @@ -41,9 +41,9 @@ const DatabaseManager = ({
- {databases.map((db, db_ind) => + {databases.map((db, dbInd) => Date: Mon, 18 Sep 2017 20:20:26 -0700 Subject: [PATCH 4/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 156c4a4417..84178b9ea4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v1.3.9.0 [unreleased] ### Bug Fixes 1.[#2004](https://github.com/influxdata/chronograf/pull/2004): Fix DE query templates dropdown disappearance. +1.[#2006](https://github.com/influxdata/chronograf/pull/2006): Fix no alert for duplicate db name ### Features 1. [#1885](https://github.com/influxdata/chronograf/pull/1885): Add `fill` options to data explorer and dashboard queries 1. [#1978](https://github.com/influxdata/chronograf/pull/1978): Support editing kapacitor TICKScript From 5310548c47d878560f69906edacfa806483de5f6 Mon Sep 17 00:00:00 2001 From: deniz kusefoglu Date: Tue, 19 Sep 2017 13:05:31 -0700 Subject: [PATCH 5/6] Generate a unique db self.link for use as a temp-id-key --- ui/spec/admin/reducers/adminSpec.js | 8 ++++++-- ui/src/admin/components/DatabaseManager.js | 4 ++-- ui/src/admin/constants/index.js | 1 - ui/src/admin/reducers/admin.js | 7 ++++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ui/spec/admin/reducers/adminSpec.js b/ui/spec/admin/reducers/adminSpec.js index 06b5c584ba..24941cf6d6 100644 --- a/ui/spec/admin/reducers/adminSpec.js +++ b/ui/spec/admin/reducers/adminSpec.js @@ -145,8 +145,12 @@ describe('Admin.Reducers', () => { it('can add a database', () => { const actual = reducer(state, addDatabase()) const expected = [{...NEW_DEFAULT_DATABASE, isEditing: true}, db1, db2] - - expect(actual.databases).to.deep.equal(expected) + expect(actual.databases.length).to.equal(expected.length) + expect(actual.databases[0].name).to.equal(expected[0].name) + expect(actual.databases[0].isNew).to.equal(expected[0].isNew) + expect(actual.databases[0].retentionPolicies).to.equal( + expected[0].retentionPolicies + ) }) it('can edit a database', () => { diff --git a/ui/src/admin/components/DatabaseManager.js b/ui/src/admin/components/DatabaseManager.js index 511092ff7c..2d3484fc9a 100644 --- a/ui/src/admin/components/DatabaseManager.js +++ b/ui/src/admin/components/DatabaseManager.js @@ -41,9 +41,9 @@ const DatabaseManager = ({
- {databases.map((db, dbInd) => + {databases.map(db => Date: Tue, 19 Sep 2017 13:09:08 -0700 Subject: [PATCH 6/6] Allow code to breathe --- ui/src/admin/containers/DatabaseManagerPage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/src/admin/containers/DatabaseManagerPage.js b/ui/src/admin/containers/DatabaseManagerPage.js index 78c12ce152..8a7247df1f 100644 --- a/ui/src/admin/containers/DatabaseManagerPage.js +++ b/ui/src/admin/containers/DatabaseManagerPage.js @@ -62,6 +62,7 @@ class DatabaseManagerPage extends Component { if (!database.name) { 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') }