Commit d1ab29c3 by Marcus Efraimsson Committed by Hugo Häggmark

Explore: Makes it possible to use a different query field per mode (#17395)

parent 1e76f1a7
...@@ -50,6 +50,16 @@ export class DataSourcePlugin< ...@@ -50,6 +50,16 @@ export class DataSourcePlugin<
return this; return this;
} }
setExploreMetricsQueryField(ExploreQueryField: ComponentClass<ExploreQueryFieldProps<DSType, TQuery, TOptions>>) {
this.components.ExploreMetricsQueryField = ExploreQueryField;
return this;
}
setExploreLogsQueryField(ExploreQueryField: ComponentClass<ExploreQueryFieldProps<DSType, TQuery, TOptions>>) {
this.components.ExploreLogsQueryField = ExploreQueryField;
return this;
}
setExploreStartPage(ExploreStartPage: ComponentClass<ExploreStartPageProps>) { setExploreStartPage(ExploreStartPage: ComponentClass<ExploreStartPageProps>) {
this.components.ExploreStartPage = ExploreStartPage; this.components.ExploreStartPage = ExploreStartPage;
return this; return this;
...@@ -109,6 +119,8 @@ export interface DataSourcePluginComponents< ...@@ -109,6 +119,8 @@ export interface DataSourcePluginComponents<
VariableQueryEditor?: any; VariableQueryEditor?: any;
QueryEditor?: ComponentType<QueryEditorProps<DSType, TQuery, TOptions>>; QueryEditor?: ComponentType<QueryEditorProps<DSType, TQuery, TOptions>>;
ExploreQueryField?: ComponentClass<ExploreQueryFieldProps<DSType, TQuery, TOptions>>; ExploreQueryField?: ComponentClass<ExploreQueryFieldProps<DSType, TQuery, TOptions>>;
ExploreMetricsQueryField?: ComponentClass<ExploreQueryFieldProps<DSType, TQuery, TOptions>>;
ExploreLogsQueryField?: ComponentClass<ExploreQueryFieldProps<DSType, TQuery, TOptions>>;
ExploreStartPage?: ComponentClass<ExploreStartPageProps>; ExploreStartPage?: ComponentClass<ExploreStartPageProps>;
ConfigEditor?: ComponentType<DataSourcePluginOptionsEditorProps<DataSourceSettings<TOptions>>>; ConfigEditor?: ComponentType<DataSourcePluginOptionsEditorProps<DataSourceSettings<TOptions>>>;
} }
......
...@@ -22,7 +22,7 @@ import { ...@@ -22,7 +22,7 @@ import {
PanelData, PanelData,
DataQueryError, DataQueryError,
} from '@grafana/ui'; } from '@grafana/ui';
import { HistoryItem, ExploreItemState, ExploreId } from 'app/types/explore'; import { HistoryItem, ExploreItemState, ExploreId, ExploreMode } from 'app/types/explore';
import { Emitter } from 'app/core/utils/emitter'; import { Emitter } from 'app/core/utils/emitter';
import { highlightLogsExpressionAction, removeQueryRowAction } from './state/actionTypes'; import { highlightLogsExpressionAction, removeQueryRowAction } from './state/actionTypes';
import QueryStatus from './QueryStatus'; import QueryStatus from './QueryStatus';
...@@ -50,6 +50,7 @@ interface QueryRowProps extends PropsFromParent { ...@@ -50,6 +50,7 @@ interface QueryRowProps extends PropsFromParent {
queryResponse: PanelData; queryResponse: PanelData;
latency: number; latency: number;
queryErrors: DataQueryError[]; queryErrors: DataQueryError[];
mode: ExploreMode;
} }
export class QueryRow extends PureComponent<QueryRowProps> { export class QueryRow extends PureComponent<QueryRowProps> {
...@@ -114,8 +115,17 @@ export class QueryRow extends PureComponent<QueryRowProps> { ...@@ -114,8 +115,17 @@ export class QueryRow extends PureComponent<QueryRowProps> {
queryResponse, queryResponse,
latency, latency,
queryErrors, queryErrors,
mode,
} = this.props; } = this.props;
const QueryField = datasourceInstance.components.ExploreQueryField; let QueryField;
if (mode === ExploreMode.Metrics && datasourceInstance.components.ExploreMetricsQueryField) {
QueryField = datasourceInstance.components.ExploreMetricsQueryField;
} else if (mode === ExploreMode.Logs && datasourceInstance.components.ExploreLogsQueryField) {
QueryField = datasourceInstance.components.ExploreLogsQueryField;
} else {
QueryField = datasourceInstance.components.ExploreQueryField;
}
return ( return (
<div className="query-row"> <div className="query-row">
...@@ -182,6 +192,7 @@ function mapStateToProps(state: StoreState, { exploreId, index }: QueryRowProps) ...@@ -182,6 +192,7 @@ function mapStateToProps(state: StoreState, { exploreId, index }: QueryRowProps)
loadingState, loadingState,
latency, latency,
queryErrors, queryErrors,
mode,
} = item; } = item;
const query = queries[index]; const query = queries[index];
const datasourceStatus = datasourceError ? DataSourceStatus.Disconnected : DataSourceStatus.Connected; const datasourceStatus = datasourceError ? DataSourceStatus.Disconnected : DataSourceStatus.Connected;
...@@ -202,6 +213,7 @@ function mapStateToProps(state: StoreState, { exploreId, index }: QueryRowProps) ...@@ -202,6 +213,7 @@ function mapStateToProps(state: StoreState, { exploreId, index }: QueryRowProps)
queryResponse, queryResponse,
latency, latency,
queryErrors, queryErrors,
mode,
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment