diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index b0a17884fc3..b34986f81ef 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -6,7 +6,14 @@ import { AutoSizer } from 'react-virtualized'; import { RawTimeRange, TimeRange } from '@grafana/ui'; import { DataSourceSelectItem } from 'app/types/datasources'; -import { ExploreUrlState, HistoryItem, QueryTransaction, RangeScanner, ExploreId } from 'app/types/explore'; +import { + ExploreItemState, + ExploreUrlState, + HistoryItem, + QueryTransaction, + RangeScanner, + ExploreId, +} from 'app/types/explore'; import { DataQuery } from 'app/types/series'; import { StoreState } from 'app/types'; import store from 'app/core/store'; @@ -37,7 +44,6 @@ import { scanStart, scanStop, } from './state/actions'; -import { ExploreItemState } from './state/reducers'; import Panel from './Panel'; import QueryRows from './QueryRows'; diff --git a/public/app/features/explore/state/actions.ts b/public/app/features/explore/state/actions.ts index 979c80395c3..26811606bd9 100644 --- a/public/app/features/explore/state/actions.ts +++ b/public/app/features/explore/state/actions.ts @@ -21,6 +21,8 @@ import { DataQuery, StoreState } from 'app/types'; import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; import { ExploreId, + ExploreItemState, + ExploreUrlState, HistoryItem, RangeScanner, ResultType, @@ -28,10 +30,8 @@ import { QueryTransaction, QueryHint, QueryHintGetter, - ExploreUrlState, } from 'app/types/explore'; import { Emitter } from 'app/core/core'; -import { ExploreItemState } from './reducers'; export enum ActionTypes { AddQueryRow = 'ADD_QUERY_ROW', diff --git a/public/app/features/explore/state/reducers.ts b/public/app/features/explore/state/reducers.ts index dda3b37fdae..9474bc717e0 100644 --- a/public/app/features/explore/state/reducers.ts +++ b/public/app/features/explore/state/reducers.ts @@ -1,61 +1,13 @@ -import { RawTimeRange, TimeRange } from '@grafana/ui'; - import { calculateResultsFromQueryTransactions, generateEmptyQuery, getIntervals, ensureQueries, } from 'app/core/utils/explore'; -import { DataSourceSelectItem } from 'app/types/datasources'; -import { HistoryItem, QueryTransaction, QueryIntervals, RangeScanner } from 'app/types/explore'; +import { ExploreItemState, ExploreState, QueryTransaction } from 'app/types/explore'; import { DataQuery } from 'app/types/series'; import { Action, ActionTypes } from './actions'; -import { Emitter } from 'app/core/core'; -import { LogsModel } from 'app/core/logs_model'; -import TableModel from 'app/core/table_model'; - -// TODO move to types - -export interface ExploreState { - split: boolean; - left: ExploreItemState; - right: ExploreItemState; -} - -export interface ExploreItemState { - StartPage?: any; - containerWidth: number; - datasourceInstance: any; - datasourceError: string; - datasourceLoading: boolean | null; - datasourceMissing: boolean; - eventBridge?: Emitter; - exploreDatasources: DataSourceSelectItem[]; - graphResult?: any[]; - history: HistoryItem[]; - initialDatasource?: string; - initialQueries: DataQuery[]; - initialized: boolean; - logsHighlighterExpressions?: string[]; - logsResult?: LogsModel; - modifiedQueries: DataQuery[]; - queryIntervals: QueryIntervals; - queryTransactions: QueryTransaction[]; - requestedDatasourceId?: number; - range: TimeRange | RawTimeRange; - scanner?: RangeScanner; - scanning?: boolean; - scanRange?: RawTimeRange; - showingGraph: boolean; - showingLogs: boolean; - showingStartPage?: boolean; - showingTable: boolean; - supportsGraph: boolean | null; - supportsLogs: boolean | null; - supportsTable: boolean | null; - tableResult?: TableModel; -} export const DEFAULT_RANGE = { from: 'now-6h', diff --git a/public/app/types/explore.ts b/public/app/types/explore.ts index 525c8f74c81..3cef4124ee4 100644 --- a/public/app/types/explore.ts +++ b/public/app/types/explore.ts @@ -1,9 +1,12 @@ import { Value } from 'slate'; +import { RawTimeRange, TimeRange } from '@grafana/ui'; + +import { Emitter } from 'app/core/core'; +import { LogsModel } from 'app/core/logs_model'; +import TableModel from 'app/core/table_model'; +import { DataSourceSelectItem } from 'app/types/datasources'; import { DataQuery } from './series'; -import { RawTimeRange } from '@grafana/ui'; -import TableModel from 'app/core/table_model'; -import { LogsModel } from 'app/core/logs_model'; export interface CompletionItem { /** @@ -80,6 +83,52 @@ export enum ExploreId { right = 'right', } +export interface ExploreState { + split: boolean; + left: ExploreItemState; + right: ExploreItemState; +} + +export interface ExploreItemState { + StartPage?: any; + containerWidth: number; + datasourceInstance: any; + datasourceError: string; + datasourceLoading: boolean | null; + datasourceMissing: boolean; + eventBridge?: Emitter; + exploreDatasources: DataSourceSelectItem[]; + graphResult?: any[]; + history: HistoryItem[]; + initialDatasource?: string; + initialQueries: DataQuery[]; + initialized: boolean; + logsHighlighterExpressions?: string[]; + logsResult?: LogsModel; + modifiedQueries: DataQuery[]; + queryIntervals: QueryIntervals; + queryTransactions: QueryTransaction[]; + requestedDatasourceId?: number; + range: TimeRange | RawTimeRange; + scanner?: RangeScanner; + scanning?: boolean; + scanRange?: RawTimeRange; + showingGraph: boolean; + showingLogs: boolean; + showingStartPage?: boolean; + showingTable: boolean; + supportsGraph: boolean | null; + supportsLogs: boolean | null; + supportsTable: boolean | null; + tableResult?: TableModel; +} + +export interface ExploreUrlState { + datasource: string; + queries: any[]; // Should be a DataQuery, but we're going to strip refIds, so typing makes less sense + range: RawTimeRange; +} + export interface HistoryItem { ts: number; query: DataQuery; @@ -168,31 +217,4 @@ export interface TextMatch { end: number; } -export interface ExploreState { - StartPage?: any; - datasource: any; - datasourceError: any; - graphResult?: any[]; - history: HistoryItem[]; - logsHighlighterExpressions?: string[]; - logsResult?: LogsModel; - queryTransactions: QueryTransaction[]; - scanning?: boolean; - scanRange?: RawTimeRange; - showingGraph: boolean; - showingLogs: boolean; - showingStartPage?: boolean; - showingTable: boolean; - supportsGraph: boolean | null; - supportsLogs: boolean | null; - supportsTable: boolean | null; - tableResult?: TableModel; -} - -export interface ExploreUrlState { - datasource: string; - queries: any[]; // Should be a DataQuery, but we're going to strip refIds, so typing makes less sense - range: RawTimeRange; -} - export type ResultType = 'Graph' | 'Logs' | 'Table'; diff --git a/public/app/types/index.ts b/public/app/types/index.ts index 018c4c51d3d..ad9f19e2c9f 100644 --- a/public/app/types/index.ts +++ b/public/app/types/index.ts @@ -19,7 +19,7 @@ import { } from './appNotifications'; import { DashboardSearchHit } from './search'; import { ValidationEvents, ValidationRule } from './form'; -import { ExploreState } from 'app/features/explore/state/reducers'; +import { ExploreState } from './explore'; export { Team, TeamsState,