mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 19:00:54 -06:00
made a view of filtered list
This commit is contained in:
parent
5079dcdc62
commit
3797054eb4
@ -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);
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user