From ba7d8c1a3d282059f75f632aec522c061619be40 Mon Sep 17 00:00:00 2001 From: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Date: Tue, 14 Jan 2020 19:20:17 +0100 Subject: [PATCH] Explore: Fix timepicker when browsing back after switching datasource (#21454) --- public/app/features/explore/Explore.tsx | 8 ++++++-- public/app/features/explore/state/actions.ts | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index 4938a0ec267..22af9e30c16 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -31,6 +31,7 @@ import { DataSourceApi, PanelData, RawTimeRange, + TimeRange, GraphSeriesXY, TimeZone, AbsoluteTimeRange, @@ -51,6 +52,7 @@ import { DEFAULT_RANGE, DEFAULT_UI_STATE, getTimeRangeFromUrl, + getTimeRange, lastUsedDatasourceKeyForOrgId, } from 'app/core/utils/explore'; import { Emitter } from 'app/core/utils/emitter'; @@ -93,7 +95,7 @@ interface ExploreProps { queryKeys: string[]; initialDatasource: string; initialQueries: DataQuery[]; - initialRange: RawTimeRange; + initialRange: TimeRange; mode: ExploreMode; initialUI: ExploreUIState; isLive: boolean; @@ -394,7 +396,9 @@ function mapStateToProps(state: StoreState, { exploreId }: ExploreProps): Partia {}) as ExploreUrlState; const initialDatasource = datasource || store.get(lastUsedDatasourceKeyForOrgId(state.user.orgId)); const initialQueries: DataQuery[] = ensureQueriesMemoized(queries); - const initialRange = urlRange ? getTimeRangeFromUrlMemoized(urlRange, timeZone).raw : DEFAULT_RANGE; + const initialRange = urlRange + ? getTimeRangeFromUrlMemoized(urlRange, timeZone) + : getTimeRange(timeZone, DEFAULT_RANGE); let newMode: ExploreMode | undefined; diff --git a/public/app/features/explore/state/actions.ts b/public/app/features/explore/state/actions.ts index fc521ed9eaa..2120cd78ae5 100644 --- a/public/app/features/explore/state/actions.ts +++ b/public/app/features/explore/state/actions.ts @@ -265,7 +265,7 @@ export function initializeExplore( exploreId: ExploreId, datasourceName: string, queries: DataQuery[], - rawRange: RawTimeRange, + range: TimeRange, mode: ExploreMode, containerWidth: number, eventBridge: Emitter, @@ -273,8 +273,6 @@ export function initializeExplore( originPanelId: number ): ThunkResult { return async (dispatch, getState) => { - const timeZone = getTimeZone(getState().user); - const range = getTimeRange(timeZone, rawRange); dispatch(loadExploreDatasourcesAndSetDatasource(exploreId, datasourceName)); dispatch( initializeExploreAction({