Commit 3797054e by Patrick O'Carroll

made a view of filtered list

parent 5079dcdc
......@@ -47,16 +47,12 @@ export class AlertRuleList extends React.Component<IContainerProps, any> {
onSearchFilter(event) {
this.setState({ search: event.target.value });
console.log('yo');
}
render() {
const { nav, alertList } = this.props;
let regex = new RegExp(this.state.search, 'ig');
const filteredAlerts = alertList.rules.filter(alert => {
return regex.test(alert.name) || regex.test(alert.stateText);
});
return (
<div>
......@@ -94,7 +90,7 @@ export class AlertRuleList extends React.Component<IContainerProps, any> {
<section>
<ol className="alert-rule-list">
{filteredAlerts.map(rule => <AlertRuleItem rule={rule} key={rule.id} />)}
{alertList.searchFilter(regex).map(rule => <AlertRuleItem rule={rule} key={rule.id} />)}
</ol>
</section>
</div>
......
......@@ -31,4 +31,11 @@ export const AlertListStore = types
self.rules.push(AlertRule.create(rule));
}
}),
}))
.views(self => ({
searchFilter(regex) {
return self.rules.filter(alert => {
return regex.test(alert.name) || regex.test(alert.stateText);
});
},
}));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment