Merge pull request #2006 from influxdata/bugfix/duplicateDBname
Display error if new db name matches an existing db namepull/10616/head
commit
ba5f10a9fb
|
@ -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
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -45,5 +45,4 @@ export const NEW_DEFAULT_DATABASE = {
|
|||
name: '',
|
||||
isNew: true,
|
||||
retentionPolicies: [NEW_DEFAULT_RP],
|
||||
links: {self: ''},
|
||||
}
|
||||
|
|
|
@ -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,15 @@ 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) !== -1) {
|
||||
return notify('error', 'A database by this name already exists')
|
||||
}
|
||||
|
||||
actions.createDatabaseAsync(source.links.databases, database)
|
||||
}
|
||||
|
||||
|
@ -73,7 +77,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)
|
||||
|
@ -84,6 +88,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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
NEW_DEFAULT_DATABASE,
|
||||
NEW_EMPTY_RP,
|
||||
} from 'src/admin/constants'
|
||||
import uuid from 'node-uuid'
|
||||
|
||||
const initialState = {
|
||||
users: null,
|
||||
|
@ -50,7 +51,11 @@ export default function admin(state = initialState, action) {
|
|||
}
|
||||
|
||||
case 'ADD_DATABASE': {
|
||||
const newDatabase = {...NEW_DEFAULT_DATABASE, isEditing: true}
|
||||
const newDatabase = {
|
||||
...NEW_DEFAULT_DATABASE,
|
||||
links: {self: `temp-ID${uuid.v4()}`},
|
||||
isEditing: true,
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
|
|
Loading…
Reference in New Issue