mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Refactor ExploreGraph (#58660)
* WIP * revert collapse changes * use HorizontalGroup instead of custom styles * fix tests * use import aliases
This commit is contained in:
@@ -30,7 +30,7 @@ import { RefreshPicker } from '@grafana/ui';
|
||||
import store from 'app/core/store';
|
||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import { PanelModel } from 'app/features/dashboard/state';
|
||||
import { EXPLORE_GRAPH_STYLES, ExploreGraphStyle, ExploreId, QueryOptions, QueryTransaction } from 'app/types/explore';
|
||||
import { ExploreId, QueryOptions, QueryTransaction } from 'app/types/explore';
|
||||
|
||||
import { config } from '../config';
|
||||
|
||||
@@ -205,21 +205,6 @@ export const safeStringifyValue = (value: any, space?: number) => {
|
||||
return '';
|
||||
};
|
||||
|
||||
const DEFAULT_GRAPH_STYLE: ExploreGraphStyle = 'lines';
|
||||
// we use this function to take any kind of data we loaded
|
||||
// from an external source (URL, localStorage, whatever),
|
||||
// and extract the graph-style from it, or return the default
|
||||
// graph-style if we are not able to do that.
|
||||
// it is important that this function is able to take any form of data,
|
||||
// (be it objects, or arrays, or booleans or whatever),
|
||||
// and produce a best-effort graphStyle.
|
||||
// note that typescript makes sure we make no mistake in this function.
|
||||
// we do not rely on ` as ` or ` any `.
|
||||
export const toGraphStyle = (data: unknown): ExploreGraphStyle => {
|
||||
const found = EXPLORE_GRAPH_STYLES.find((v) => v === data);
|
||||
return found ?? DEFAULT_GRAPH_STYLE;
|
||||
};
|
||||
|
||||
export function parseUrlState(initial: string | undefined): ExploreUrlState {
|
||||
const parsed = safeParseJson(initial);
|
||||
const errorResult: any = {
|
||||
|
||||
Reference in New Issue
Block a user