Prevent users from giving a Kapacitor a duplicate name

pull/1600/head
Alex P 2017-06-13 17:13:25 -07:00
parent b7cd240bad
commit 439153125d
1 changed files with 17 additions and 0 deletions

View File

@ -71,6 +71,23 @@ class KapacitorPage extends Component {
const {addFlashMessage, source, params, router} = this.props
const {kapacitor} = this.state
let doesKapacitorNameAlreadyExist = false
if (source && source.kapacitors) {
source.kapacitors.map(existingKapacitor => {
if (existingKapacitor.name === kapacitor.name) {
doesKapacitorNameAlreadyExist = true
}
})
}
if (doesKapacitorNameAlreadyExist === true) {
addFlashMessage({
type: 'error',
text: `There is already a Kapacitor configuration named "${kapacitor.name}"`,
})
return
}
if (params.id) {
updateKapacitor(kapacitor)
.then(({data}) => {