Bladeren bron

Move types to types/explore

David Kaltschmidt 7 jaren geleden
bovenliggende
commit
f02f41c9b0

+ 8 - 2
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';

+ 2 - 2
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',

+ 1 - 49
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',

+ 52 - 30
public/app/types/explore.ts

@@ -1,9 +1,12 @@
 import { Value } from 'slate';
+import { RawTimeRange, TimeRange } from '@grafana/ui';
 
-import { DataQuery } from './series';
-import { RawTimeRange } from '@grafana/ui';
-import TableModel from 'app/core/table_model';
+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';
 
 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';

+ 1 - 1
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,