mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboards: It always detect changes when saving an existing dashboard (#76116)
Deep clone originalDashboard to avoid mutations by object reference
This commit is contained in:
@@ -24,6 +24,7 @@ import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT, REPEAT_DIR_VERT
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
import { sortedDeepCloneWithoutNulls } from 'app/core/utils/object';
|
||||
import { isAngularDatasourcePlugin } from 'app/features/plugins/angularDeprecation/utils';
|
||||
import { deepFreeze } from 'app/features/plugins/extensions/utils';
|
||||
import { variableAdapters } from 'app/features/variables/adapters';
|
||||
import { onTimeRangeUpdated } from 'app/features/variables/state/actions';
|
||||
import { GetVariables, getVariablesByKey } from 'app/features/variables/state/selectors';
|
||||
@@ -172,7 +173,8 @@ export class DashboardModel implements TimeModel {
|
||||
this.links = data.links ?? [];
|
||||
this.gnetId = data.gnetId || null;
|
||||
this.panels = map(data.panels ?? [], (panelData: any) => new PanelModel(panelData));
|
||||
this.originalDashboard = data;
|
||||
// Deep clone original dashboard to avoid mutations by object reference
|
||||
this.originalDashboard = cloneDeep(data);
|
||||
this.ensurePanelsHaveUniqueIds();
|
||||
this.formatDate = this.formatDate.bind(this);
|
||||
|
||||
@@ -1081,7 +1083,7 @@ export class DashboardModel implements TimeModel {
|
||||
}
|
||||
|
||||
resetOriginalTime() {
|
||||
this.originalTime = cloneDeep(this.time);
|
||||
this.originalTime = deepFreeze(this.time);
|
||||
}
|
||||
|
||||
hasTimeChanged() {
|
||||
@@ -1267,8 +1269,8 @@ export class DashboardModel implements TimeModel {
|
||||
return variables.map((variable) => ({
|
||||
name: variable.name,
|
||||
type: variable.type,
|
||||
current: cloneDeep(variable.current),
|
||||
filters: cloneDeep(variable.filters),
|
||||
current: deepFreeze(variable.current),
|
||||
filters: deepFreeze(variable.filters),
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user