Explore: Do not update URL when time range changes to absolute (#72436)

Allow passing updateURL flag to absolute time range event
This commit is contained in:
Piotr Jamróz 2023-07-31 14:11:44 +02:00 committed by GitHub
parent 2ae226de89
commit 89618e0c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 15 deletions

View File

@ -45,7 +45,6 @@ export class KeybindingSrv {
this.bind('g e', this.goToExplore);
this.bind('g a', this.openAlerting);
this.bind('g p', this.goToProfile);
this.bind('t a', this.makeAbsoluteTime);
this.bind('esc', this.exit);
this.bindGlobalEsc();
}
@ -108,10 +107,6 @@ export class KeybindingSrv {
this.locationService.push('/explore');
}
private makeAbsoluteTime() {
appEvents.publish(new AbsoluteTimeEvent());
}
private showHelpModal() {
appEvents.publish(new ShowModalReactEvent({ component: HelpModal }));
}
@ -190,6 +185,10 @@ export class KeybindingSrv {
}
setupTimeRangeBindings(updateUrl = true) {
this.bind('t a', () => {
appEvents.publish(new AbsoluteTimeEvent({ updateUrl }));
});
this.bind('t z', () => {
appEvents.publish(new ZoomOutEvent({ scale: 2, updateUrl }));
});

View File

@ -46,8 +46,8 @@ export class TimeSrv {
this.shiftTime(e.payload.direction, e.payload.updateUrl);
});
appEvents.subscribe(AbsoluteTimeEvent, () => {
this.makeAbsoluteTime();
appEvents.subscribe(AbsoluteTimeEvent, (e) => {
this.makeAbsoluteTime(e.payload.updateUrl);
});
document.addEventListener('visibilitychange', () => {
@ -364,14 +364,9 @@ export class TimeSrv {
);
}
makeAbsoluteTime() {
const params = locationService.getSearch();
if (params.get('left')) {
return; // explore handles this;
}
makeAbsoluteTime(updateUrl: boolean) {
const { from, to } = this.timeRange();
this.setTime({ from, to }, true);
this.setTime({ from, to }, updateUrl);
}
// isRefreshOutsideThreshold function calculates the difference between last refresh and now

View File

@ -160,7 +160,11 @@ export class ShiftTimeEvent extends BusEventWithPayload<ShiftTimeEventPayload> {
static type = 'shift-time';
}
export class AbsoluteTimeEvent extends BusEventBase {
interface AbsoluteTimeEventPayload {
updateUrl: boolean;
}
export class AbsoluteTimeEvent extends BusEventWithPayload<AbsoluteTimeEventPayload> {
static type = 'absolute-time';
}