diff --git a/ui/src/kapacitor/components/Deadman.js b/ui/src/kapacitor/components/Deadman.js new file mode 100644 index 000000000..029cc2c13 --- /dev/null +++ b/ui/src/kapacitor/components/Deadman.js @@ -0,0 +1,32 @@ +import React, {PropTypes} from 'react' +import {PERIODS} from 'src/kapacitor/constants' +import Dropdown from 'shared/components/Dropdown' + +const periods = PERIODS.map(text => { + return {text} +}) + +const Deadman = ({rule, onChange}) => +
+

Send Alert if Data is missing for

+ +
+ +const {shape, string, func} = PropTypes + +Deadman.propTypes = { + rule: shape({ + values: shape({ + period: string, + }), + }), + onChange: func.isRequired, +} + +export default Deadman diff --git a/ui/src/kapacitor/components/KapacitorRule.js b/ui/src/kapacitor/components/KapacitorRule.js index 76a39650a..00c19f964 100644 --- a/ui/src/kapacitor/components/KapacitorRule.js +++ b/ui/src/kapacitor/components/KapacitorRule.js @@ -106,6 +106,11 @@ class KapacitorRule extends Component { return '' } + handleDeadmanChange = ({text}) => { + const {ruleActions, rule} = this.props + ruleActions.updateRuleValues(rule.id, rule.trigger, {period: text}) + } + render() { const { queryConfigActions, @@ -141,6 +146,7 @@ class KapacitorRule extends Component { query={queryConfigs[rule.queryID]} onChooseTrigger={chooseTrigger} onUpdateValues={updateRuleValues} + onDeadmanChange={this.handleDeadmanChange} /> arr.map(text => ({text, type})) @@ -15,10 +19,11 @@ export const ValuesSection = React.createClass({ onChooseTrigger: PropTypes.func.isRequired, onUpdateValues: PropTypes.func.isRequired, query: PropTypes.shape({}).isRequired, + onDeadmanChange: PropTypes.func.isRequired, }, render() { - const {rule, query} = this.props + const {rule, query, onDeadmanChange} = this.props const initialIndex = TABS.indexOf(_.startCase(rule.trigger)) return ( @@ -46,7 +51,7 @@ export const ValuesSection = React.createClass({ - + @@ -216,38 +221,4 @@ const Relative = React.createClass({ }, }) -const Deadman = React.createClass({ - propTypes: { - rule: PropTypes.shape({ - values: PropTypes.shape({ - period: PropTypes.string, - }), - }), - onChange: PropTypes.func.isRequired, - }, - - handleChange(item) { - this.props.onChange({period: item.text}) - }, - - render() { - const periods = PERIODS.map(text => { - return {text} - }) - - return ( -
-

Send Alert if Data is missing for

- -
- ) - }, -}) - export default ValuesSection