Dashboard: Fix issue where out-of-view shared query panels caused blank dependent panels (#83966)

This commit is contained in:
kay delaney 2024-03-11 14:53:59 +00:00 committed by GitHub
parent dd01743de7
commit d8b8a2c2b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 4 deletions

View File

@ -74,6 +74,8 @@ function setupTestContext(options: Partial<Props>) {
</Provider>
);
// Needed so mocks work
props.panel.refreshWhenInView = false;
return { rerender, props, subject, store };
}

View File

@ -384,11 +384,22 @@ export class DashboardModel implements TimeModel {
return;
}
for (const panel of this.panels) {
if (!this.otherPanelInFullscreen(panel) && (event.refreshAll || event.panelIds.includes(panel.id))) {
panel.refresh();
const panelsToRefresh = this.panels.filter(
(panel) => !this.otherPanelInFullscreen(panel) && (event.refreshAll || event.panelIds.includes(panel.id))
);
// We have to mark every panel as refreshWhenInView /before/ we actually refresh any
// in case there is a shared query, as otherwise that might refresh before the source panel is
// marked for refresh, preventing the panel from updating
if (!this.isSnapshot()) {
for (const panel of panelsToRefresh) {
panel.refreshWhenInView = true;
}
}
for (const panel of panelsToRefresh) {
panel.refresh();
}
}
render() {

View File

@ -205,7 +205,7 @@ export class PanelModel implements DataConfigSource, IPanelModel {
cacheTimeout?: string | null;
queryCachingTTL?: number | null;
isNew?: boolean;
refreshWhenInView = false;
refreshWhenInView = true;
cachedPluginOptions: Record<string, PanelOptionsCache> = {};
legend?: { show: boolean; sort?: string; sortDesc?: boolean };