mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
[Shortcuts] Fixes shortcuts for moving time range backwards and forwards (#18305)
Closes #18159
This commit is contained in:
committed by
Leonard Gram
parent
21f702f7c9
commit
bcf28cb7a2
@@ -1,6 +1,6 @@
|
||||
// Libaries
|
||||
import React, { Component } from 'react';
|
||||
import { toUtc, dateMath } from '@grafana/data';
|
||||
import { dateMath } from '@grafana/data';
|
||||
|
||||
// Types
|
||||
import { DashboardModel } from '../../state';
|
||||
@@ -16,7 +16,6 @@ import { TimePicker, RefreshPicker } from '@grafana/ui';
|
||||
// Utils & Services
|
||||
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import { defaultSelectOptions } from '@grafana/ui/src/components/TimePicker/TimePicker';
|
||||
import { getShiftedTimeRange } from 'app/core/utils/timePicker';
|
||||
|
||||
export interface Props {
|
||||
$injector: any;
|
||||
@@ -43,18 +42,12 @@ export class DashNavTimeControls extends Component<Props> {
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
onMoveTimePicker = (direction: number) => {
|
||||
const range = this.timeSrv.timeRange();
|
||||
const { from, to } = getShiftedTimeRange(direction, range);
|
||||
|
||||
this.timeSrv.setTime({
|
||||
from: toUtc(from),
|
||||
to: toUtc(to),
|
||||
});
|
||||
onMoveBack = () => {
|
||||
this.$rootScope.appEvent('shift-time', -1);
|
||||
};
|
||||
onMoveForward = () => {
|
||||
this.$rootScope.appEvent('shift-time', 1);
|
||||
};
|
||||
|
||||
onMoveForward = () => this.onMoveTimePicker(1);
|
||||
onMoveBack = () => this.onMoveTimePicker(-1);
|
||||
|
||||
onChangeTimePicker = (timeRange: TimeRange) => {
|
||||
const { dashboard } = this.props;
|
||||
|
||||
Reference in New Issue
Block a user