mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Split main reducer from item reducer * Move query related redux to separate file * Split more parts and tests * Fix import * Remove unused code * Update public/app/features/explore/state/datasource.ts Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com> * Add section comments * Rename ExploreItem to ExplorePane * Fix imports Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import { EventBusExtended, DefaultTimeRange, LoadingState, LogsDedupStrategy, PanelData } from '@grafana/data';
|
|
|
|
import { ExploreItemState, ExploreUpdateState } from 'app/types/explore';
|
|
|
|
export const DEFAULT_RANGE = {
|
|
from: 'now-6h',
|
|
to: 'now',
|
|
};
|
|
|
|
export const makeInitialUpdateState = (): ExploreUpdateState => ({
|
|
datasource: false,
|
|
queries: false,
|
|
range: false,
|
|
mode: false,
|
|
});
|
|
|
|
/**
|
|
* Returns a fresh Explore area state
|
|
*/
|
|
export const makeExplorePaneState = (): ExploreItemState => ({
|
|
containerWidth: 0,
|
|
datasourceInstance: null,
|
|
requestedDatasourceName: null,
|
|
datasourceLoading: null,
|
|
datasourceMissing: false,
|
|
history: [],
|
|
queries: [],
|
|
initialized: false,
|
|
range: {
|
|
from: null,
|
|
to: null,
|
|
raw: DEFAULT_RANGE,
|
|
} as any,
|
|
absoluteRange: {
|
|
from: null,
|
|
to: null,
|
|
} as any,
|
|
scanning: false,
|
|
loading: false,
|
|
queryKeys: [],
|
|
urlState: null,
|
|
update: makeInitialUpdateState(),
|
|
latency: 0,
|
|
isLive: false,
|
|
isPaused: false,
|
|
urlReplaced: false,
|
|
queryResponse: createEmptyQueryResponse(),
|
|
tableResult: null,
|
|
graphResult: null,
|
|
logsResult: null,
|
|
dedupStrategy: LogsDedupStrategy.none,
|
|
eventBridge: (null as unknown) as EventBusExtended,
|
|
});
|
|
|
|
export const createEmptyQueryResponse = (): PanelData => ({
|
|
state: LoadingState.NotStarted,
|
|
series: [],
|
|
timeRange: DefaultTimeRange,
|
|
});
|