DashboardScene: Add time picker keybindings (#78632)

* grafana/data: Add time range zoom out util

* Add keybindings for time range zoom out

* TimeRangePicker: change the way absolute time range is detected

* Depend on dashboard scene tructure rather

* Revert "grafana/data: Add time range zoom out util"

This reverts commit bc1602db57.

* Lint

* Lint

* dashboardSceneGraph tests
This commit is contained in:
Dominik Prokop
2023-11-27 00:32:23 -08:00
committed by GitHub
parent 0f25f18739
commit 703deeff0b
5 changed files with 113 additions and 3 deletions
@@ -214,7 +214,7 @@ export const convertRawToRange = (
return { from, to, raw: { from, to } };
};
function isRelativeTime(v: DateTime | string) {
export function isRelativeTime(v: DateTime | string) {
if (typeof v === 'string') {
return v.indexOf('now') >= 0;
}
@@ -5,7 +5,6 @@ import { useOverlay } from '@react-aria/overlays';
import React, { memo, createRef, useState, useEffect } from 'react';
import {
isDateTime,
rangeUtil,
GrafanaTheme2,
dateTimeFormat,
@@ -108,7 +107,8 @@ export function TimeRangePicker(props: TimeRangePickerProps) {
const styles = useStyles2(getStyles);
const { modalBackdrop } = useStyles2(getModalStyles);
const hasAbsolute = isDateTime(value.raw.from) || isDateTime(value.raw.to);
const hasAbsolute = !rangeUtil.isRelativeTime(value.raw.from) || !rangeUtil.isRelativeTime(value.raw.to);
const variant = isSynced ? 'active' : isOnCanvas ? 'canvas' : 'default';
const currentTimeRange = formattedRange(value, timeZone);