Dashboards: Prevent shared queries from being unnecessarily re-run (#77490)

* Dashboards: Prevent shared queries from being unnecessarily re-run

* Minor change

* Set solo panel as being viewed

---------

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
kay delaney
2023-11-09 14:41:47 +00:00
committed by GitHub
parent 3a4f73338c
commit 5f78542366
4 changed files with 18 additions and 9 deletions

View File

@@ -71,7 +71,10 @@ export function runSharedRequest(options: QueryRunnerOptions, query: DashboardQu
// If we are in fullscreen the other panel will not execute any queries
// So we have to trigger it from here
if (!listenToPanel.isInView) {
if (
(!listenToPanel.isInView && listenToPanel.refreshWhenInView) ||
dashboard?.otherPanelInFullscreen(listenToPanel)
) {
const { datasource, targets } = listenToPanel;
const modified = {
...options,
@@ -79,6 +82,8 @@ export function runSharedRequest(options: QueryRunnerOptions, query: DashboardQu
panelId: listenToPanelId,
queries: targets,
};
listenToPanel.refreshWhenInView = false;
listenToRunner.run(modified);
}