mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboards: Run shared queries even when source panel is in collapsed row (#77792)
This commit is contained in:
parent
3783d87576
commit
6989db1ad3
@ -516,12 +516,22 @@ export class DashboardModel implements TimeModel {
|
||||
}
|
||||
}
|
||||
|
||||
getPanelById(id: number): PanelModel | null {
|
||||
getPanelById(id: number, includeCollapsed = false): PanelModel | null {
|
||||
if (this.panelInEdit && this.panelInEdit.id === id) {
|
||||
return this.panelInEdit;
|
||||
}
|
||||
|
||||
return this.panels.find((p) => p.id === id) ?? null;
|
||||
if (includeCollapsed) {
|
||||
for (const panel of this.panelIterator()) {
|
||||
if (panel.id === id) {
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} else {
|
||||
return this.panels.find((p) => p.id === id) ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
canEditPanel(panel?: PanelModel | null): boolean | undefined | null {
|
||||
|
@ -11,6 +11,7 @@ import {
|
||||
DataTopic,
|
||||
} from '@grafana/data';
|
||||
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
|
||||
import { PanelModel } from 'app/features/dashboard/state';
|
||||
import { QueryRunnerOptions } from 'app/features/query/state/PanelQueryRunner';
|
||||
|
||||
import { DashboardQuery, SHARED_DASHBOARD_QUERY } from './types';
|
||||
@ -42,7 +43,12 @@ export function runSharedRequest(options: QueryRunnerOptions, query: DashboardQu
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const listenToPanel = dashboard?.getPanelById(listenToPanelId);
|
||||
// Source panel might be contained in a collapsed row, in which
|
||||
// case we need to create a PanelModel
|
||||
let listenToPanel = dashboard?.getPanelById(listenToPanelId, true);
|
||||
if (!(listenToPanel instanceof PanelModel)) {
|
||||
listenToPanel = new PanelModel(listenToPanel);
|
||||
}
|
||||
|
||||
if (!listenToPanel) {
|
||||
subscriber.next(getQueryError('Unknown Panel: ' + listenToPanelId));
|
||||
|
Loading…
Reference in New Issue
Block a user