mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Fix iteration property change triggering unsaved changes warning (#51272)
This commit is contained in:
parent
3bc13e2335
commit
9f4683b3d0
@ -60,12 +60,6 @@ describe('DashboardPrompt', () => {
|
||||
expect(hasChanges(dash, original)).toBe(false);
|
||||
});
|
||||
|
||||
it('Should ignore .iteration changes', () => {
|
||||
const { original, dash } = getTestContext();
|
||||
dash.iteration = new Date().getTime() + 1;
|
||||
expect(hasChanges(dash, original)).toBe(false);
|
||||
});
|
||||
|
||||
it('Should ignore row collapse change', () => {
|
||||
const { original, dash } = getTestContext();
|
||||
dash.toggleRow(dash.panels[1]);
|
||||
|
@ -181,9 +181,6 @@ function cleanDashboardFromIgnoredChanges(dashData: any) {
|
||||
dash.schemaVersion = 0;
|
||||
dash.timezone = 0;
|
||||
|
||||
// ignore iteration property
|
||||
delete dash.iteration;
|
||||
|
||||
dash.panels = [];
|
||||
|
||||
// ignore template variable values
|
||||
|
@ -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?
|
||||
|
@ -76,7 +76,6 @@ const mustKeepProps: { [str: string]: boolean } = {
|
||||
title: true,
|
||||
scopedVars: true,
|
||||
repeat: true,
|
||||
repeatIteration: true,
|
||||
repeatPanelId: true,
|
||||
repeatDirection: true,
|
||||
repeatedByRow: true,
|
||||
|
Loading…
Reference in New Issue
Block a user