Dashboards: Fixes issue with the initial panel layout counting as an unsaved change (#51439)
This commit is contained in:
+17
-17
@@ -5195,7 +5195,7 @@ exports[`better eslint`] = {
|
||||
[21, 38, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[21, 59, 3, "Unexpected any. Specify a different type.", "193409811"]
|
||||
],
|
||||
"public/app/features/dashboard/dashgrid/DashboardGrid.tsx:3771579139": [
|
||||
"public/app/features/dashboard/dashgrid/DashboardGrid.tsx:25656274": [
|
||||
[79, 22, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[189, 40, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[189, 53, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
@@ -5418,7 +5418,7 @@ exports[`better eslint`] = {
|
||||
[1137, 40, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[1137, 48, 3, "Unexpected any. Specify a different type.", "193409811"]
|
||||
],
|
||||
"public/app/features/dashboard/state/PanelModel.test.ts:1787146930": [
|
||||
"public/app/features/dashboard/state/PanelModel.test.ts:4035235685": [
|
||||
[29, 11, 92, "Do not use any type assertions.", "2976372744"],
|
||||
[34, 5, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[52, 15, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
@@ -5431,12 +5431,12 @@ exports[`better eslint`] = {
|
||||
[373, 28, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[376, 80, 25, "Do not use any type assertions.", "2825799852"],
|
||||
[376, 102, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[453, 49, 81, "Do not use any type assertions.", "1932069967"],
|
||||
[454, 32, 15, "Do not use any type assertions.", "1703404951"],
|
||||
[490, 25, 293, "Do not use any type assertions.", "3989849883"],
|
||||
[492, 21, 213, "Do not use any type assertions.", "2695721884"]
|
||||
[459, 49, 81, "Do not use any type assertions.", "1932069967"],
|
||||
[460, 32, 15, "Do not use any type assertions.", "1703404951"],
|
||||
[496, 25, 293, "Do not use any type assertions.", "3989849883"],
|
||||
[498, 21, 213, "Do not use any type assertions.", "2695721884"]
|
||||
],
|
||||
"public/app/features/dashboard/state/PanelModel.ts:3946442076": [
|
||||
"public/app/features/dashboard/state/PanelModel.ts:1479907667": [
|
||||
[112, 16, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[131, 10, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[145, 15, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
@@ -5455,16 +5455,16 @@ exports[`better eslint`] = {
|
||||
[221, 7, 11, "Do not use any type assertions.", "3816020039"],
|
||||
[221, 15, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[270, 17, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[345, 21, 11, "Do not use any type assertions.", "3816020039"],
|
||||
[345, 29, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[358, 7, 11, "Do not use any type assertions.", "3816020039"],
|
||||
[358, 15, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[397, 14, 11, "Do not use any type assertions.", "3816020039"],
|
||||
[397, 22, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[415, 22, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[466, 22, 18, "Do not use any type assertions.", "1060162663"],
|
||||
[549, 38, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[608, 14, 3, "Unexpected any. Specify a different type.", "193409811"]
|
||||
[347, 21, 11, "Do not use any type assertions.", "3816020039"],
|
||||
[347, 29, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[360, 7, 11, "Do not use any type assertions.", "3816020039"],
|
||||
[360, 15, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[399, 14, 11, "Do not use any type assertions.", "3816020039"],
|
||||
[399, 22, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[417, 22, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[468, 22, 18, "Do not use any type assertions.", "1060162663"],
|
||||
[551, 38, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[610, 14, 3, "Unexpected any. Specify a different type.", "193409811"]
|
||||
],
|
||||
"public/app/features/dashboard/state/TimeModel.ts:2763994651": [
|
||||
[3, 8, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
|
||||
@@ -100,7 +100,7 @@ export class DashboardGridUnconnected extends PureComponent<Props, State> {
|
||||
|
||||
onLayoutChange = (newLayout: ReactGridLayout.Layout[]) => {
|
||||
for (const newPos of newLayout) {
|
||||
this.panelMap[newPos.i!].updateGridPos(newPos);
|
||||
this.panelMap[newPos.i!].updateGridPos(newPos, this.state.isLayoutInitialized);
|
||||
}
|
||||
|
||||
this.props.dashboard.sortPanelsByGridPos();
|
||||
|
||||
@@ -436,17 +436,23 @@ describe('PanelModel', () => {
|
||||
});
|
||||
|
||||
describe('updateGridPos', () => {
|
||||
it('Should not cause configRev if no change', () => {
|
||||
it('Should not have changes if no change', () => {
|
||||
model.gridPos = { w: 1, h: 1, x: 1, y: 2 };
|
||||
model.updateGridPos({ w: 1, h: 1, x: 1, y: 2 });
|
||||
expect(model.hasChanged).toBe(false);
|
||||
});
|
||||
|
||||
it('Should not cause configRev if gridPos is different', () => {
|
||||
it('Should have changes if gridPos is different', () => {
|
||||
model.gridPos = { w: 1, h: 1, x: 1, y: 2 };
|
||||
model.updateGridPos({ w: 10, h: 1, x: 1, y: 2 });
|
||||
expect(model.hasChanged).toBe(true);
|
||||
});
|
||||
|
||||
it('Should not have changes if not manually updated', () => {
|
||||
model.gridPos = { w: 1, h: 1, x: 1, y: 2 };
|
||||
model.updateGridPos({ w: 10, h: 1, x: 1, y: 2 }, false);
|
||||
expect(model.hasChanged).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroy', () => {
|
||||
|
||||
@@ -289,7 +289,7 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
this.isViewing = isViewing;
|
||||
}
|
||||
|
||||
updateGridPos(newPos: GridPos) {
|
||||
updateGridPos(newPos: GridPos, manuallyUpdated = true) {
|
||||
if (
|
||||
newPos.x === this.gridPos.x &&
|
||||
newPos.y === this.gridPos.y &&
|
||||
@@ -303,7 +303,9 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
this.gridPos.y = newPos.y;
|
||||
this.gridPos.w = newPos.w;
|
||||
this.gridPos.h = newPos.h;
|
||||
this.configRev++;
|
||||
if (manuallyUpdated) {
|
||||
this.configRev++;
|
||||
}
|
||||
}
|
||||
|
||||
runAllPanelQueries(dashboardId: number, dashboardTimezone: string, timeData: TimeOverrideResult, width: number) {
|
||||
|
||||
Reference in New Issue
Block a user