Add foundation UI for http/tcp alerts
parent
ab3a74b5d2
commit
08d17265f1
|
@ -3,6 +3,8 @@ import Dropdown from 'shared/components/Dropdown';
|
||||||
import ReactTooltip from 'react-tooltip';
|
import ReactTooltip from 'react-tooltip';
|
||||||
import {RULE_MESSAGE_TEMPLATES as templates} from '../constants/index.js';
|
import {RULE_MESSAGE_TEMPLATES as templates} from '../constants/index.js';
|
||||||
|
|
||||||
|
const DEFAULT_ALERTS = ['http', 'tcp'];
|
||||||
|
|
||||||
const {
|
const {
|
||||||
arrayOf,
|
arrayOf,
|
||||||
func,
|
func,
|
||||||
|
@ -19,6 +21,12 @@ export const RuleMessage = React.createClass({
|
||||||
enabledAlerts: arrayOf(string.isRequired).isRequired,
|
enabledAlerts: arrayOf(string.isRequired).isRequired,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getInitialState() {
|
||||||
|
return {
|
||||||
|
selectedAlert: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
handleChangeMessage() {
|
handleChangeMessage() {
|
||||||
const {actions, rule} = this.props;
|
const {actions, rule} = this.props;
|
||||||
actions.updateMessage(rule.id, this.message.value);
|
actions.updateMessage(rule.id, this.message.value);
|
||||||
|
@ -27,13 +35,17 @@ export const RuleMessage = React.createClass({
|
||||||
handleChooseAlert(item) {
|
handleChooseAlert(item) {
|
||||||
const {actions} = this.props;
|
const {actions} = this.props;
|
||||||
actions.updateAlerts(item.ruleID, [item.text]);
|
actions.updateAlerts(item.ruleID, [item.text]);
|
||||||
|
this.setState({selectedAlert: item.text});
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {rule, actions} = this.props;
|
const {rule, actions, enabledAlerts} = this.props;
|
||||||
const alerts = this.props.enabledAlerts.map((text) => {
|
const defaultAlertEndpoints = DEFAULT_ALERTS.map((text) => {
|
||||||
return {text, ruleID: rule.id};
|
return {text, ruleID: rule.id};
|
||||||
});
|
});
|
||||||
|
const alerts = enabledAlerts.map((text) => {
|
||||||
|
return {text, ruleID: rule.id};
|
||||||
|
}).concat(defaultAlertEndpoints);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="kapacitor-rule-section">
|
<div className="kapacitor-rule-section">
|
||||||
|
@ -65,11 +77,20 @@ export const RuleMessage = React.createClass({
|
||||||
<div className="rule-section--item bottom alert-message--endpoint">
|
<div className="rule-section--item bottom alert-message--endpoint">
|
||||||
<p>Send this Alert to:</p>
|
<p>Send this Alert to:</p>
|
||||||
<Dropdown className="size-256 dropdown-kapacitor" selected={rule.alerts[0] || 'Choose an output'} items={alerts} onChoose={this.handleChooseAlert} />
|
<Dropdown className="size-256 dropdown-kapacitor" selected={rule.alerts[0] || 'Choose an output'} items={alerts} onChoose={this.handleChooseAlert} />
|
||||||
|
{this.renderInput(this.state.selectedAlert)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderInput(alert) {
|
||||||
|
if (!DEFAULT_ALERTS.find((a) => a === alert)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <input className="form-control col-xs-6" type="text" ref={(r) => this.selectedAlert = r} />;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const CodeData = React.createClass({
|
const CodeData = React.createClass({
|
||||||
|
|
Loading…
Reference in New Issue