diff --git a/ui/src/kapacitor/components/KapacitorRulesTable.tsx b/ui/src/kapacitor/components/KapacitorRulesTable.tsx index e6998db995..02ee526eee 100644 --- a/ui/src/kapacitor/components/KapacitorRulesTable.tsx +++ b/ui/src/kapacitor/components/KapacitorRulesTable.tsx @@ -1,4 +1,4 @@ -import React, {PureComponent, SFC, MouseEvent} from 'react' +import React, {PureComponent, SFC, ChangeEvent} from 'react' import {Link} from 'react-router' import _ from 'lodash' @@ -65,15 +65,28 @@ const KapacitorRulesTable: SFC = ({ ) -const handleDelete = (rule, onDelete) => onDelete(rule) - class RuleRow extends PureComponent { - handleClickRuleStatusEnabled(_: MouseEvent) { - return (rule: AlertRule) => this.props.onChangeRuleStatus(rule) + constructor(props) { + super(props) + + this.handleClickRuleStatusEnabled = this.handleClickRuleStatusEnabled.bind(this) + this.handleDelete = this.handleDelete.bind(this) + } + + handleClickRuleStatusEnabled(rule: AlertRule) { + return (_: ChangeEvent) => { + this.props.onChangeRuleStatus(rule) + } + } + + handleDelete(rule: AlertRule) { + return () => { + this.props.onDelete(rule) + } } render() { - const {rule, source, onDelete} = this.props + const {rule, source} = this.props return ( @@ -93,8 +106,8 @@ class RuleRow extends PureComponent { id={`kapacitor-rule-row-task-enabled ${rule.id}`} className="form-control-static" type="checkbox" - defaultChecked={rule.status === 'enabled'} - onClick={this.handleClickRuleStatusEnabled} + checked={rule.status === 'enabled'} + onChange={this.handleClickRuleStatusEnabled(rule)} />