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
This commit is contained in:
Torkel Ödegaard 2019-08-30 15:22:36 +02:00 committed by GitHub
parent 89abc77b22
commit 8e9cb5c81a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View File

@ -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 {

View File

@ -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,

View File

@ -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,

View File

@ -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;
}