Display all alert-rules regardless of origin

Alert rules can be generated by Chronograf or manually
by the user outide of the Chronograf UI.
pull/10616/head
Andrew Watkins 2017-05-05 11:23:41 -07:00
parent 92bd5d10b4
commit ff65bea7a7
1 changed files with 75 additions and 67 deletions

View File

@ -1,8 +1,7 @@
import React, {PropTypes} from 'react'
import {Link} from 'react-router'
const KapacitorRulesTable = ({source, rules, onDelete, onChangeRuleStatus}) => {
return (
const KapacitorRulesTable = ({rules, onDelete, onChangeRuleStatus}) => (
<div className="panel-body">
<table className="table v-center">
<thead>
@ -21,7 +20,6 @@ const KapacitorRulesTable = ({source, rules, onDelete, onChangeRuleStatus}) => {
<RuleRow
key={rule.id}
rule={rule}
source={source}
onDelete={onDelete}
onChangeRuleStatus={onChangeRuleStatus}
/>
@ -31,15 +29,11 @@ const KapacitorRulesTable = ({source, rules, onDelete, onChangeRuleStatus}) => {
</table>
</div>
)
}
const RuleRow = ({rule, source, onDelete, onChangeRuleStatus}) => {
return (
const RuleRow = ({rule, onDelete, onChangeRuleStatus}) => (
<tr key={rule.id}>
<td className="monotype">
<Link to={`/sources/${source.id}/alert-rules/${rule.id}`}>
{rule.name}
</Link>
<RuleTitle rule={rule} />
</td>
<td className="monotype">{rule.trigger}</td>
<td className="monotype">{rule.message}</td>
@ -57,21 +51,25 @@ const RuleRow = ({rule, source, onDelete, onChangeRuleStatus}) => {
</div>
</td>
<td className="text-right">
<button
className="btn btn-danger btn-xs"
onClick={() => onDelete(rule)}
>
<button className="btn btn-danger btn-xs" onClick={() => onDelete(rule)}>
Delete
</button>
</td>
</tr>
)
const RuleTitle = ({rule: {name, links, query}}) => {
// no queryConfig means the rule was manually created outside of Chronograf
if (!query) {
return <i>{name}</i>
}
const {arrayOf, func, shape} = PropTypes
return <Link to={links.self}>{name}</Link>
}
const {arrayOf, func, shape, string} = PropTypes
KapacitorRulesTable.propTypes = {
source: shape(),
rules: arrayOf(shape()),
onChangeRuleStatus: func,
onDelete: func,
@ -84,4 +82,14 @@ RuleRow.propTypes = {
onDelete: func,
}
RuleTitle.propTypes = {
rule: shape({
name: string.isRequired,
query: shape(),
links: shape({
self: string.isRequired,
}).isRequired,
}),
}
export default KapacitorRulesTable