DashboardScene: Backward compatability with getDashboardSrv.getCurrent and DashboardModel props and functions (#76371)

* DashboardSrv.getCurrent backward compatibility

* fixes
This commit is contained in:
Torkel Ödegaard
2023-10-13 16:24:04 +02:00
committed by GitHub
parent b01cbc7aef
commit a42040a59a
10 changed files with 236 additions and 28 deletions

View File

@@ -4,7 +4,7 @@ import React, { useState } from 'react';
import { useAsync } from 'react-use';
import { dateMath, dateTime, GrafanaTheme2, PanelProps } from '@grafana/data';
import { getBackendSrv, getTemplateSrv } from '@grafana/runtime';
import { getBackendSrv } from '@grafana/runtime';
import { Card, CustomScrollbar, Icon, useStyles2 } from '@grafana/ui';
import alertDef from 'app/features/alerting/state/alertDef';
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
@@ -23,10 +23,9 @@ export function AlertList(props: PanelProps<AlertListOptions>) {
const params: any = {
state: getStateFilter(props.options.stateFilter),
};
const panel = getDashboardSrv().getCurrent()?.getPanelById(props.id)!;
if (props.options.alertName) {
params.query = getTemplateSrv().replace(props.options.alertName, panel.scopedVars);
params.query = props.replaceVariables(props.options.alertName);
}
if (props.options.folderId >= 0) {