mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Makes it possible to use a different query field per mode (#17395)
This commit is contained in:
committed by
Hugo Häggmark
parent
1e76f1a728
commit
d1ab29c36d
@@ -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<
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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> {
|
|||||||
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)
|
|||||||
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)
|
|||||||
queryResponse,
|
queryResponse,
|
||||||
latency,
|
latency,
|
||||||
queryErrors,
|
queryErrors,
|
||||||
|
mode,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user