Commit 8e9cb5c8 by Torkel Ödegaard Committed by GitHub

Explore: Fixes query hint issues (#18803)

* Explore: clear results when you change datasource

* Explore: Clear results on data source change, and fix query hints issue

* Clear results on clear all

* Prometheus: Update logic of when to re-check query hints
parent 89abc77b
......@@ -96,10 +96,11 @@ function convertTimeSeriesToDataFrame(timeSeries: TimeSeries): DataFrame {
function convertGraphSeriesToDataFrame(graphSeries: GraphSeriesXY): DataFrame {
const x = new ArrayVector();
const y = new ArrayVector();
for (let i = 0; i < graphSeries.data.length; i++) {
const row = graphSeries.data[i];
x.buffer.push(row[0]);
y.buffer.push(row[1]);
x.buffer.push(row[1]);
y.buffer.push(row[0]);
}
return {
......
......@@ -157,6 +157,9 @@ describe('Explore item reducer', () => {
showingStartPage: true,
queries,
queryKeys,
graphResult: null,
logsResult: null,
tableResult: null,
supportedModes: [ExploreMode.Metrics, ExploreMode.Logs],
mode: ExploreMode.Metrics,
loadingState: LoadingState.NotStarted,
......
......@@ -210,6 +210,9 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
return {
...state,
queries: queries.slice(),
graphResult: null,
tableResult: null,
logsResult: null,
showingStartPage: Boolean(state.StartPage),
queryKeys: getQueryKeys(queries, state.datasourceInstance),
};
......@@ -271,6 +274,9 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...state,
datasourceInstance,
queryErrors: [],
graphResult: null,
tableResult: null,
logsResult: null,
latency: 0,
loadingState: LoadingState.NotStarted,
StartPage,
......
......@@ -109,7 +109,7 @@ interface PromQueryFieldProps extends ExploreQueryFieldProps<PrometheusDatasourc
interface PromQueryFieldState {
metricsOptions: any[];
syntaxLoaded: boolean;
hint: QueryHint;
hint: QueryHint | null;
}
class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryFieldState> {
......@@ -154,8 +154,7 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
componentDidUpdate(prevProps: PromQueryFieldProps) {
const { queryResponse } = this.props;
const currentHasSeries = queryResponse && queryResponse.series && queryResponse.series.length > 0 ? true : false;
if (currentHasSeries && prevProps.queryResponse && prevProps.queryResponse.series !== queryResponse.series) {
if (prevProps.queryResponse && prevProps.queryResponse.series !== queryResponse.series) {
this.refreshHint();
}
......@@ -177,7 +176,9 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
refreshHint = () => {
const { datasource, query, queryResponse } = this.props;
if (!queryResponse || !queryResponse.series || queryResponse.series.length === 0) {
if (!queryResponse.series || queryResponse.series.length === 0) {
this.setState({ hint: null });
return;
}
......
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