import React from 'react'; import classNames from 'classnames'; import { inject, observer } from 'mobx-react'; import PageHeader from 'app/core/components/PageHeader/PageHeader'; import { IAlertRule } from 'app/stores/AlertListStore/AlertListStore'; import appEvents from 'app/core/app_events'; import IContainerProps from 'app/containers/IContainerProps'; import Highlighter from 'react-highlight-words'; @inject('view', 'nav', 'alertList') @observer export class AlertRuleList extends React.Component { stateFilters = [ { text: 'All', value: 'all' }, { text: 'OK', value: 'ok' }, { text: 'Not OK', value: 'not_ok' }, { text: 'Alerting', value: 'alerting' }, { text: 'No Data', value: 'no_data' }, { text: 'Paused', value: 'paused' }, ]; constructor(props) { super(props); this.props.nav.load('alerting', 'alert-list'); this.fetchRules(); } onStateFilterChanged = evt => { this.props.view.updateQuery({ state: evt.target.value }); this.fetchRules(); }; fetchRules() { this.props.alertList.loadRules({ state: this.props.view.query.get('state') || 'all', }); } onOpenHowTo = () => { appEvents.emit('show-modal', { src: 'public/app/features/alerting/partials/alert_howto.html', modalClass: 'confirm-modal', model: {}, }); }; onSearchQueryChange = evt => { this.props.alertList.setSearchQuery(evt.target.value); }; render() { const { nav, alertList } = this.props; return (
    {alertList.filteredRules.map(rule => ( ))}
); } } function AlertStateFilterOption({ text, value }) { return ( ); } export interface AlertRuleItemProps { rule: IAlertRule; search: string; } @observer export class AlertRuleItem extends React.Component { toggleState = () => { this.props.rule.togglePaused(); }; renderText(text: string) { return ( ); } render() { const { rule } = this.props; let stateClass = classNames({ fa: true, 'fa-play': rule.isPaused, 'fa-pause': !rule.isPaused, }); let ruleUrl = `${rule.url}?panelId=${rule.panelId}&fullscreen=true&edit=true&tab=alert`; return (
  • {this.renderText(rule.stateText)} for {rule.stateAge}
    {rule.info &&
    {this.renderText(rule.info)}
    }
  • ); } }