Dashboard: Fix iteration property change triggering unsaved changes warning (#51272)

This commit is contained in:
Torkel Ödegaard
2022-07-20 03:41:54 +02:00
committed by GitHub
parent 3bc13e2335
commit 9f4683b3d0
4 changed files with 5 additions and 19 deletions

View File

@@ -105,7 +105,6 @@ export class DashboardModel implements TimeModel {
// ------------------
// repeat process cycles
iteration?: number;
declare meta: DashboardMeta;
events: EventBusExtended;
@@ -507,13 +506,10 @@ export class DashboardModel implements TimeModel {
return;
}
this.iteration = (this.iteration || new Date().getTime()) + 1;
// cleanup scopedVars
deleteScopeVars(this.panels);
const panelsToRemove = this.panels.filter(
(p) => (!p.repeat || p.repeatedByRow) && p.repeatPanelId && p.repeatIteration !== this.iteration
);
const panelsToRemove = this.panels.filter((p) => (!p.repeat || p.repeatedByRow) && p.repeatPanelId);
// remove panels
pull(this.panels, ...panelsToRemove);
@@ -528,8 +524,6 @@ export class DashboardModel implements TimeModel {
this.cleanUpRepeats();
this.iteration = (this.iteration || new Date().getTime()) + 1;
for (let i = 0; i < this.panels.length; i++) {
const panel = this.panels[i];
if (panel.repeat) {
@@ -584,7 +578,6 @@ export class DashboardModel implements TimeModel {
// insert after source panel + value index
this.panels.splice(sourcePanelIndex + valueIndex, 0, clone);
clone.repeatIteration = this.iteration;
clone.repeatPanelId = sourcePanel.id;
clone.repeat = undefined;
@@ -747,12 +740,13 @@ export class DashboardModel implements TimeModel {
updateRepeatedPanelIds(panel: PanelModel, repeatedByRow?: boolean) {
panel.repeatPanelId = panel.id;
panel.id = this.getNextPanelId();
panel.repeatIteration = this.iteration;
if (repeatedByRow) {
panel.repeatedByRow = true;
} else {
panel.repeat = undefined;
}
return panel;
}
@@ -827,9 +821,11 @@ export class DashboardModel implements TimeModel {
delete newPanel.repeatIteration;
delete newPanel.repeatPanelId;
delete newPanel.scopedVars;
if (newPanel.alert) {
delete newPanel.thresholds;
}
delete newPanel.alert;
// does it fit to the right?