TimeSrv: Don't modify refresh interval when editing panel (#51718)
This commit is contained in:
+1
-2
@@ -4532,8 +4532,7 @@ exports[`better eslint`] = {
|
|||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
|
|
||||||
],
|
],
|
||||||
"public/app/features/dashboard/state/DashboardMigrator.test.ts:5381": [
|
"public/app/features/dashboard/state/DashboardMigrator.test.ts:5381": [
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||||
|
|||||||
@@ -253,24 +253,18 @@ describe('timeSrv', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('pauseAutoRefresh', () => {
|
describe('pauseAutoRefresh', () => {
|
||||||
it('should set refresh to empty value', () => {
|
it('should set autoRefreshPaused to true', () => {
|
||||||
_dashboard.refresh = '10s';
|
_dashboard.refresh = '10s';
|
||||||
timeSrv.pauseAutoRefresh();
|
timeSrv.pauseAutoRefresh();
|
||||||
expect(_dashboard.refresh).toBe('');
|
expect(timeSrv.autoRefreshPaused).toBe(true);
|
||||||
});
|
|
||||||
|
|
||||||
it('should set previousAutoRefresh value', () => {
|
|
||||||
_dashboard.refresh = '10s';
|
|
||||||
timeSrv.pauseAutoRefresh();
|
|
||||||
expect(timeSrv.previousAutoRefresh).toBe('10s');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('resumeAutoRefresh', () => {
|
describe('resumeAutoRefresh', () => {
|
||||||
it('should set refresh to empty value', () => {
|
it('should set refresh to empty value', () => {
|
||||||
timeSrv.previousAutoRefresh = '10s';
|
timeSrv.autoRefreshPaused = true;
|
||||||
timeSrv.resumeAutoRefresh();
|
timeSrv.resumeAutoRefresh();
|
||||||
expect(_dashboard.refresh).toBe('10s');
|
expect(timeSrv.autoRefreshPaused).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class TimeSrv {
|
|||||||
time: any;
|
time: any;
|
||||||
refreshTimer: any;
|
refreshTimer: any;
|
||||||
refresh: any;
|
refresh: any;
|
||||||
previousAutoRefresh: any;
|
autoRefreshPaused = false;
|
||||||
oldRefresh: string | null | undefined;
|
oldRefresh: string | null | undefined;
|
||||||
timeModel?: TimeModel;
|
timeModel?: TimeModel;
|
||||||
timeAtLoad: any;
|
timeAtLoad: any;
|
||||||
@@ -232,7 +232,7 @@ export class TimeSrv {
|
|||||||
|
|
||||||
this.refreshTimer = setTimeout(() => {
|
this.refreshTimer = setTimeout(() => {
|
||||||
this.startNextRefreshTimer(intervalMs);
|
this.startNextRefreshTimer(intervalMs);
|
||||||
this.refreshTimeModel();
|
!this.autoRefreshPaused && this.refreshTimeModel();
|
||||||
}, intervalMs);
|
}, intervalMs);
|
||||||
|
|
||||||
const refresh = this.contextSrv.getValidInterval(interval);
|
const refresh = this.contextSrv.getValidInterval(interval);
|
||||||
@@ -250,7 +250,7 @@ export class TimeSrv {
|
|||||||
this.refreshTimer = setTimeout(() => {
|
this.refreshTimer = setTimeout(() => {
|
||||||
this.startNextRefreshTimer(afterMs);
|
this.startNextRefreshTimer(afterMs);
|
||||||
if (this.contextSrv.isGrafanaVisible()) {
|
if (this.contextSrv.isGrafanaVisible()) {
|
||||||
this.refreshTimeModel();
|
!this.autoRefreshPaused && this.refreshTimeModel();
|
||||||
} else {
|
} else {
|
||||||
this.autoRefreshBlocked = true;
|
this.autoRefreshBlocked = true;
|
||||||
}
|
}
|
||||||
@@ -264,13 +264,13 @@ export class TimeSrv {
|
|||||||
// store timeModel refresh value and pause auto-refresh in some places
|
// store timeModel refresh value and pause auto-refresh in some places
|
||||||
// i.e panel edit
|
// i.e panel edit
|
||||||
pauseAutoRefresh() {
|
pauseAutoRefresh() {
|
||||||
this.previousAutoRefresh = this.timeModel?.refresh;
|
this.autoRefreshPaused = true;
|
||||||
this.setAutoRefresh('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// resume auto-refresh based on old dashboard refresh property
|
// resume auto-refresh based on old dashboard refresh property
|
||||||
resumeAutoRefresh() {
|
resumeAutoRefresh() {
|
||||||
this.setAutoRefresh(this.previousAutoRefresh);
|
this.autoRefreshPaused = false;
|
||||||
|
this.refreshTimeModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
setTime(time: RawTimeRange, updateUrl = true) {
|
setTime(time: RawTimeRange, updateUrl = true) {
|
||||||
|
|||||||
@@ -976,7 +976,7 @@ describe('exitViewPanel', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('exitPanelEditor', () => {
|
describe('exitPanelEditor', () => {
|
||||||
function getTestContext(setPreviousAutoRefresh = false) {
|
function getTestContext(pauseAutoRefresh = false) {
|
||||||
const panel: any = { destroy: jest.fn() };
|
const panel: any = { destroy: jest.fn() };
|
||||||
const dashboard = new DashboardModel({});
|
const dashboard = new DashboardModel({});
|
||||||
const timeSrvMock = {
|
const timeSrvMock = {
|
||||||
@@ -986,8 +986,8 @@ describe('exitPanelEditor', () => {
|
|||||||
} as unknown as TimeSrv;
|
} as unknown as TimeSrv;
|
||||||
dashboard.startRefresh = jest.fn();
|
dashboard.startRefresh = jest.fn();
|
||||||
dashboard.panelInEdit = panel;
|
dashboard.panelInEdit = panel;
|
||||||
if (setPreviousAutoRefresh) {
|
if (pauseAutoRefresh) {
|
||||||
timeSrvMock.previousAutoRefresh = '5s';
|
timeSrvMock.autoRefreshPaused = true;
|
||||||
}
|
}
|
||||||
setTimeSrv(timeSrvMock);
|
setTimeSrv(timeSrvMock);
|
||||||
return { dashboard, panel, timeSrvMock };
|
return { dashboard, panel, timeSrvMock };
|
||||||
|
|||||||
Reference in New Issue
Block a user