Dashboards: Only refresh panels on panel edit exit if refresh is set (#67652)

Closes #66838

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
kay delaney
2023-05-10 14:12:55 +01:00
committed by GitHub
parent e51b92991d
commit 7801cf6585
5 changed files with 108 additions and 90 deletions

View File

@@ -101,6 +101,7 @@ export class DashboardModel implements TimeModel {
private panelsAffectedByVariableChange: number[] | null;
private appEventsSubscription: Subscription;
private lastRefresh: number;
private timeRangeUpdatedDuringEdit = false;
// ------------------
// not persisted
@@ -126,6 +127,7 @@ export class DashboardModel implements TimeModel {
appEventsSubscription: true,
panelsAffectedByVariableChange: true,
lastRefresh: true,
timeRangeUpdatedDuringEdit: true,
};
constructor(
@@ -379,6 +381,10 @@ export class DashboardModel implements TimeModel {
timeRangeUpdated(timeRange: TimeRange) {
this.events.publish(new TimeRangeUpdatedEvent(timeRange));
dispatch(onTimeRangeUpdated(this.uid, timeRange));
if (this.panelInEdit) {
this.timeRangeUpdatedDuringEdit = true;
}
}
startRefresh(event: VariablesChangedEvent = { refreshAll: true, panelIds: [] }) {
@@ -417,11 +423,28 @@ export class DashboardModel implements TimeModel {
}
initEditPanel(sourcePanel: PanelModel): PanelModel {
getTimeSrv().pauseAutoRefresh();
getTimeSrv().stopAutoRefresh();
this.panelInEdit = sourcePanel.getEditClone();
this.timeRangeUpdatedDuringEdit = false;
return this.panelInEdit;
}
exitPanelEditor() {
this.panelInEdit!.destroy();
this.panelInEdit = undefined;
getTimeSrv().resumeAutoRefresh();
if (this.panelsAffectedByVariableChange || this.timeRangeUpdatedDuringEdit) {
this.startRefresh({
panelIds: this.panelsAffectedByVariableChange ?? [],
refreshAll: this.timeRangeUpdatedDuringEdit,
});
this.panelsAffectedByVariableChange = null;
this.timeRangeUpdatedDuringEdit = false;
}
}
initViewPanel(panel: PanelModel) {
this.panelInView = panel;
panel.setIsViewing(true);
@@ -433,13 +456,6 @@ export class DashboardModel implements TimeModel {
this.refreshIfPanelsAffectedByVariableChange();
}
exitPanelEditor() {
this.panelInEdit!.destroy();
this.panelInEdit = undefined;
getTimeSrv().resumeAutoRefresh();
this.refreshIfPanelsAffectedByVariableChange();
}
private refreshIfPanelsAffectedByVariableChange() {
if (!this.panelsAffectedByVariableChange) {
return;