From 9aede9e6368947543d6488a0c6f99e4367ba1790 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Sun, 13 Jan 2019 23:26:04 +0100 Subject: [PATCH] Fix reducer issues --- public/app/core/utils/explore.ts | 8 ++++---- public/app/features/explore/QueryEditor.tsx | 2 +- public/app/features/explore/state/reducers.ts | 12 +++++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/public/app/core/utils/explore.ts b/public/app/core/utils/explore.ts index b0dcf2117d0..b05e38a4b33 100644 --- a/public/app/core/utils/explore.ts +++ b/public/app/core/utils/explore.ts @@ -17,7 +17,7 @@ import { QueryIntervals, QueryOptions, } from 'app/types/explore'; -import { DataQuery, DataSourceApi } from 'app/types/series'; +import { DataQuery } from 'app/types/series'; export const DEFAULT_RANGE = { from: 'now-6h', @@ -243,8 +243,8 @@ export function calculateResultsFromQueryTransactions( }; } -export function getIntervals(range: RawTimeRange, datasource: DataSourceApi, resolution: number): IntervalValues { - if (!datasource || !resolution) { +export function getIntervals(range: RawTimeRange, lowLimit: string, resolution: number): IntervalValues { + if (!resolution) { return { interval: '1s', intervalMs: 1000 }; } @@ -253,7 +253,7 @@ export function getIntervals(range: RawTimeRange, datasource: DataSourceApi, res to: parseDate(range.to, true), }; - return kbn.calculateInterval(absoluteRange, resolution, datasource.interval); + return kbn.calculateInterval(absoluteRange, resolution, lowLimit); } export function makeTimeSeriesList(dataList) { diff --git a/public/app/features/explore/QueryEditor.tsx b/public/app/features/explore/QueryEditor.tsx index ce0a8a6e03e..dde674d3fcd 100644 --- a/public/app/features/explore/QueryEditor.tsx +++ b/public/app/features/explore/QueryEditor.tsx @@ -48,7 +48,7 @@ export default class QueryEditor extends PureComponent { getNextQueryLetter: x => '', }, hideEditorRowActions: true, - ...getIntervals(range, datasource, null), // Possible to get resolution? + ...getIntervals(range, (datasource || {}).interval, null), // Possible to get resolution? }, }; diff --git a/public/app/features/explore/state/reducers.ts b/public/app/features/explore/state/reducers.ts index b8273051ffe..91d5c4cf925 100644 --- a/public/app/features/explore/state/reducers.ts +++ b/public/app/features/explore/state/reducers.ts @@ -122,11 +122,12 @@ const itemReducer = (state, action: Action): ExploreItemState => { case ActionTypes.ChangeSize: { const { range, datasourceInstance } = state; - if (!datasourceInstance) { - return state; + let interval = '1s'; + if (datasourceInstance && datasourceInstance.interval) { + interval = datasourceInstance.interval; } const containerWidth = action.width; - const queryIntervals = getIntervals(range, datasourceInstance.interval, containerWidth); + const queryIntervals = getIntervals(range, interval, containerWidth); return { ...state, containerWidth, queryIntervals }; } @@ -189,6 +190,11 @@ const itemReducer = (state, action: Action): ExploreItemState => { return { ...state, ...results, queryTransactions: nextQueryTransactions, showingTable }; } + case ActionTypes.HighlightLogsExpression: { + const { expressions } = action; + return { ...state, logsHighlighterExpressions: expressions }; + } + case ActionTypes.InitializeExplore: { const { containerWidth, eventBridge, exploreDatasources, range } = action; return {