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/10616/head
parent
60d3433405
commit
6de0c0a5c0
|
@ -68,11 +68,18 @@ class KapacitorPage extends Component {
|
|||
|
||||
handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
const {addFlashMessage, source, params, router} = this.props
|
||||
const {
|
||||
addFlashMessage,
|
||||
source,
|
||||
source: {kapacitors = []},
|
||||
params,
|
||||
router,
|
||||
} = this.props
|
||||
const {kapacitor} = this.state
|
||||
|
||||
const kapNames = source.kapacitors.map(k => k.name)
|
||||
if (kapNames.includes(kapacitor.name)) {
|
||||
const isNameTaken = kapacitors.some(k => k.name === kapacitor.name)
|
||||
|
||||
if (isNameTaken) {
|
||||
addFlashMessage({
|
||||
type: 'error',
|
||||
text: `There is already a Kapacitor configuration named "${kapacitor.name}"`,
|
||||
|
|
Loading…
Reference in New Issue