diff --git a/ui/src/kapacitor/components/RuleMessage.js b/ui/src/kapacitor/components/RuleMessage.js index a2808f2dad..70f20fc778 100644 --- a/ui/src/kapacitor/components/RuleMessage.js +++ b/ui/src/kapacitor/components/RuleMessage.js @@ -3,6 +3,8 @@ import Dropdown from 'shared/components/Dropdown'; import ReactTooltip from 'react-tooltip'; import {RULE_MESSAGE_TEMPLATES as templates} from '../constants/index.js'; +const DEFAULT_ALERTS = ['http', 'tcp']; + const { arrayOf, func, @@ -19,6 +21,12 @@ export const RuleMessage = React.createClass({ enabledAlerts: arrayOf(string.isRequired).isRequired, }, + getInitialState() { + return { + selectedAlert: null, + }; + }, + handleChangeMessage() { const {actions, rule} = this.props; actions.updateMessage(rule.id, this.message.value); @@ -27,13 +35,17 @@ export const RuleMessage = React.createClass({ handleChooseAlert(item) { const {actions} = this.props; actions.updateAlerts(item.ruleID, [item.text]); + this.setState({selectedAlert: item.text}); }, render() { - const {rule, actions} = this.props; - const alerts = this.props.enabledAlerts.map((text) => { + const {rule, actions, enabledAlerts} = this.props; + const defaultAlertEndpoints = DEFAULT_ALERTS.map((text) => { return {text, ruleID: rule.id}; }); + const alerts = enabledAlerts.map((text) => { + return {text, ruleID: rule.id}; + }).concat(defaultAlertEndpoints); return (
Send this Alert to: