Fix inability to add kapacitor from source page
The kapacitors array on source was not yet defined. So, I added a default empty array to the kapacitors key off of source. Also, cleaned up some logic regarding the duplication of kapacitor names.pull/1951/head
parent
3d2c012e72
commit
c25e15c64d
|
@ -68,11 +68,18 @@ class KapacitorPage extends Component {
|
||||||
|
|
||||||
handleSubmit(e) {
|
handleSubmit(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const {addFlashMessage, source, params, router} = this.props
|
const {
|
||||||
|
addFlashMessage,
|
||||||
|
source,
|
||||||
|
source: {kapacitors = []},
|
||||||
|
params,
|
||||||
|
router,
|
||||||
|
} = this.props
|
||||||
const {kapacitor} = this.state
|
const {kapacitor} = this.state
|
||||||
|
|
||||||
const kapNames = source.kapacitors.map(k => k.name)
|
const isNameTaken = kapacitors.some(k => k.name === kapacitor.name)
|
||||||
if (kapNames.includes(kapacitor.name)) {
|
|
||||||
|
if (isNameTaken) {
|
||||||
addFlashMessage({
|
addFlashMessage({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
text: `There is already a Kapacitor configuration named "${kapacitor.name}"`,
|
text: `There is already a Kapacitor configuration named "${kapacitor.name}"`,
|
||||||
|
|
Loading…
Reference in New Issue