Fix reducer issues

This commit is contained in:
David Kaltschmidt 2019-01-13 23:26:04 +01:00
parent 546a3a9d98
commit 9aede9e636
3 changed files with 14 additions and 8 deletions

View File

@ -17,7 +17,7 @@ import {
QueryIntervals, QueryIntervals,
QueryOptions, QueryOptions,
} from 'app/types/explore'; } from 'app/types/explore';
import { DataQuery, DataSourceApi } from 'app/types/series'; import { DataQuery } from 'app/types/series';
export const DEFAULT_RANGE = { export const DEFAULT_RANGE = {
from: 'now-6h', from: 'now-6h',
@ -243,8 +243,8 @@ export function calculateResultsFromQueryTransactions(
}; };
} }
export function getIntervals(range: RawTimeRange, datasource: DataSourceApi, resolution: number): IntervalValues { export function getIntervals(range: RawTimeRange, lowLimit: string, resolution: number): IntervalValues {
if (!datasource || !resolution) { if (!resolution) {
return { interval: '1s', intervalMs: 1000 }; return { interval: '1s', intervalMs: 1000 };
} }
@ -253,7 +253,7 @@ export function getIntervals(range: RawTimeRange, datasource: DataSourceApi, res
to: parseDate(range.to, true), to: parseDate(range.to, true),
}; };
return kbn.calculateInterval(absoluteRange, resolution, datasource.interval); return kbn.calculateInterval(absoluteRange, resolution, lowLimit);
} }
export function makeTimeSeriesList(dataList) { export function makeTimeSeriesList(dataList) {

View File

@ -48,7 +48,7 @@ export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
getNextQueryLetter: x => '', getNextQueryLetter: x => '',
}, },
hideEditorRowActions: true, hideEditorRowActions: true,
...getIntervals(range, datasource, null), // Possible to get resolution? ...getIntervals(range, (datasource || {}).interval, null), // Possible to get resolution?
}, },
}; };

View File

@ -122,11 +122,12 @@ const itemReducer = (state, action: Action): ExploreItemState => {
case ActionTypes.ChangeSize: { case ActionTypes.ChangeSize: {
const { range, datasourceInstance } = state; const { range, datasourceInstance } = state;
if (!datasourceInstance) { let interval = '1s';
return state; if (datasourceInstance && datasourceInstance.interval) {
interval = datasourceInstance.interval;
} }
const containerWidth = action.width; const containerWidth = action.width;
const queryIntervals = getIntervals(range, datasourceInstance.interval, containerWidth); const queryIntervals = getIntervals(range, interval, containerWidth);
return { ...state, containerWidth, queryIntervals }; return { ...state, containerWidth, queryIntervals };
} }
@ -189,6 +190,11 @@ const itemReducer = (state, action: Action): ExploreItemState => {
return { ...state, ...results, queryTransactions: nextQueryTransactions, showingTable }; return { ...state, ...results, queryTransactions: nextQueryTransactions, showingTable };
} }
case ActionTypes.HighlightLogsExpression: {
const { expressions } = action;
return { ...state, logsHighlighterExpressions: expressions };
}
case ActionTypes.InitializeExplore: { case ActionTypes.InitializeExplore: {
const { containerWidth, eventBridge, exploreDatasources, range } = action; const { containerWidth, eventBridge, exploreDatasources, range } = action;
return { return {