diff --git a/ui/src/kapacitor/components/ValuesSection.js b/ui/src/kapacitor/components/ValuesSection.js index 2aa49a93c..eed2cc582 100644 --- a/ui/src/kapacitor/components/ValuesSection.js +++ b/ui/src/kapacitor/components/ValuesSection.js @@ -12,113 +12,104 @@ import {Tab, TabList, TabPanels, TabPanel, Tabs} from 'shared/components/Tabs' const TABS = ['Threshold', 'Relative', 'Deadman'] -export const ValuesSection = React.createClass({ - propTypes: { - rule: PropTypes.shape({ - id: PropTypes.string, - }).isRequired, - onChooseTrigger: PropTypes.func.isRequired, - onUpdateValues: PropTypes.func.isRequired, - query: PropTypes.shape({}).isRequired, - onDeadmanChange: PropTypes.func.isRequired, - onRuleTypeDropdownChange: PropTypes.func.isRequired, - onRuleTypeInputChange: PropTypes.func.isRequired, - onAddEvery: PropTypes.func.isRequired, - onRemoveEvery: PropTypes.func.isRequired, - timeRange: PropTypes.shape({}).isRequired, - queryConfigActions: PropTypes.shape({}).isRequired, - source: PropTypes.shape({}).isRequired, - }, +const handleChooseTrigger = (rule, onChooseTrigger) => { + if (TABS[triggerIndex] === rule.trigger) { + return + } + return onChooseTrigger(rule.id, TABS[triggerIndex]) +} +const initialIndex = rule => TABS.indexOf(_.startCase(rule.trigger)) +const isDeadman = rule => rule.trigger === 'deadman' - render() { - const { - rule, - query, - source, - timeRange, - onAddEvery, - onRemoveEvery, - onDeadmanChange, - queryConfigActions, - onRuleTypeInputChange, - onRuleTypeDropdownChange, - } = this.props - const initialIndex = TABS.indexOf(_.startCase(rule.trigger)) - const isDeadman = rule.trigger === 'deadman' - - return ( -
-

Alert Type

-
- - - {TABS.map(tab => - - {tab} - - )} - -
-

Time Series

- -
- -

Rule Conditions

- - - - - - - - - - - - {isDeadman - ? null - : } -
+const ValuesSection = ({ + rule, + query, + source, + timeRange, + onAddEvery, + onRemoveEvery, + onDeadmanChange, + queryConfigActions, + onRuleTypeInputChange, + onRuleTypeDropdownChange, + onChooseTrigger, +}) => +
+

Alert Type

+
+ + + {TABS.map(tab => + + {tab} + + )} + +
+

Time Series

+
-
- ) - }, +

Rule Conditions

+ + + + + + + + + + + + {isDeadman(rule) + ? null + : } + +
+
- handleChooseTrigger(triggerIndex) { - const {rule, onChooseTrigger} = this.props - if (TABS[triggerIndex] === rule.trigger) { - return - } +const {shape, string, func} = PropTypes - onChooseTrigger(rule.id, TABS[triggerIndex]) - }, - - handleValuesChange(values) { - const {onUpdateValues, rule} = this.props - onUpdateValues(rule.id, rule.trigger, values) - }, -}) +ValuesSection.propTypes = { + rule: shape({ + id: string, + }).isRequired, + onChooseTrigger: func.isRequired, + onUpdateValues: func.isRequired, + query: shape({}).isRequired, + onDeadmanChange: func.isRequired, + onRuleTypeDropdownChange: func.isRequired, + onRuleTypeInputChange: func.isRequired, + onAddEvery: func.isRequired, + onRemoveEvery: func.isRequired, + timeRange: shape({}).isRequired, + queryConfigActions: shape({}).isRequired, + source: shape({}).isRequired, +} export default ValuesSection