|
@@ -2,11 +2,11 @@ import React, { PureComponent } from 'react';
|
|
|
import { JSONFormatter } from 'app/core/components/JSONFormatter/JSONFormatter';
|
|
import { JSONFormatter } from 'app/core/components/JSONFormatter/JSONFormatter';
|
|
|
import { getBackendSrv } from 'app/core/services/backend_srv';
|
|
import { getBackendSrv } from 'app/core/services/backend_srv';
|
|
|
import { DashboardModel } from '../dashboard/dashboard_model';
|
|
import { DashboardModel } from '../dashboard/dashboard_model';
|
|
|
|
|
+import { LoadingPlaceholder } from '@grafana/ui/src';
|
|
|
|
|
|
|
|
export interface Props {
|
|
export interface Props {
|
|
|
panelId: number;
|
|
panelId: number;
|
|
|
dashboard: DashboardModel;
|
|
dashboard: DashboardModel;
|
|
|
- LoadingPlaceholder: any;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
interface State {
|
|
interface State {
|
|
@@ -14,7 +14,7 @@ interface State {
|
|
|
testRuleResponse: {};
|
|
testRuleResponse: {};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export class TestRuleButton extends PureComponent<Props, State> {
|
|
|
|
|
|
|
+export class TestRuleResult extends PureComponent<Props, State> {
|
|
|
readonly state: State = {
|
|
readonly state: State = {
|
|
|
isLoading: false,
|
|
isLoading: false,
|
|
|
testRuleResponse: {},
|
|
testRuleResponse: {},
|
|
@@ -27,13 +27,14 @@ export class TestRuleButton extends PureComponent<Props, State> {
|
|
|
async testRule() {
|
|
async testRule() {
|
|
|
const { panelId, dashboard } = this.props;
|
|
const { panelId, dashboard } = this.props;
|
|
|
const payload = { dashboard: dashboard.getSaveModelClone(), panelId };
|
|
const payload = { dashboard: dashboard.getSaveModelClone(), panelId };
|
|
|
|
|
+
|
|
|
|
|
+ this.setState({ isLoading: true });
|
|
|
const testRuleResponse = await getBackendSrv().post(`/api/alerts/test`, payload);
|
|
const testRuleResponse = await getBackendSrv().post(`/api/alerts/test`, payload);
|
|
|
- this.setState(prevState => ({ ...prevState, isLoading: false, testRuleResponse }));
|
|
|
|
|
|
|
+ this.setState({ isLoading: false, testRuleResponse });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
const { testRuleResponse, isLoading } = this.state;
|
|
const { testRuleResponse, isLoading } = this.state;
|
|
|
- const { LoadingPlaceholder } = this.props;
|
|
|
|
|
|
|
|
|
|
if (isLoading === true) {
|
|
if (isLoading === true) {
|
|
|
return <LoadingPlaceholder text="Evaluating rule" />;
|
|
return <LoadingPlaceholder text="Evaluating rule" />;
|