diff --git a/web-common/src/features/alerts/CreateAlertForm.svelte b/web-common/src/features/alerts/CreateAlertForm.svelte index c5b51b489a2..f263f262a55 100644 --- a/web-common/src/features/alerts/CreateAlertForm.svelte +++ b/web-common/src/features/alerts/CreateAlertForm.svelte @@ -40,6 +40,7 @@ metricsViewName, exploreName, dashboardStore, + validSpecStore, selectors: { timeRangeSelectors: { timeControlsState }, }, @@ -56,8 +57,11 @@ dimension = $dashboardStore.selectedDimensionName ?? ""; } - // TODO: get metrics view spec - const timeRange = mapTimeRange(timeControls, {}); + const timeRange = mapTimeRange( + timeControls, + $validSpecStore.data?.explore ?? {}, + $dashboardStore, + ); const comparisonTimeRange = mapComparisonTimeRange( $dashboardStore, timeControls, diff --git a/web-common/src/features/dashboards/dimension-table/dimension-table-export-utils.ts b/web-common/src/features/dashboards/dimension-table/dimension-table-export-utils.ts index f402d8be476..274e9df7c50 100644 --- a/web-common/src/features/dashboards/dimension-table/dimension-table-export-utils.ts +++ b/web-common/src/features/dashboards/dimension-table/dimension-table-export-utils.ts @@ -40,6 +40,7 @@ export function getDimensionTableExportArgs( const timeRange = mapTimeRange( timeControlState, validSpecStore.data.explore, + dashboardState, ); if (!timeRange) return undefined; diff --git a/web-common/src/features/dashboards/pivot/pivot-export.ts b/web-common/src/features/dashboards/pivot/pivot-export.ts index f5ccc4d8f0d..ec02be67f3d 100644 --- a/web-common/src/features/dashboards/pivot/pivot-export.ts +++ b/web-common/src/features/dashboards/pivot/pivot-export.ts @@ -111,7 +111,11 @@ export function getPivotExportArgs(ctx: StateManagers) { const metricsViewSpec = validSpecStore.data?.metricsView ?? {}; const exploreSpec = validSpecStore.data?.explore ?? {}; - const timeRange = mapTimeRange(timeControlState, exploreSpec); + const timeRange = mapTimeRange( + timeControlState, + exploreSpec, + dashboardState, + ); if (!timeRange) return undefined; return getPivotAggregationRequest( diff --git a/web-common/src/features/dashboards/time-controls/time-range-mappers.ts b/web-common/src/features/dashboards/time-controls/time-range-mappers.ts index b3b5b663269..09db5d63bc7 100644 --- a/web-common/src/features/dashboards/time-controls/time-range-mappers.ts +++ b/web-common/src/features/dashboards/time-controls/time-range-mappers.ts @@ -43,10 +43,13 @@ export const PreviousCompleteRangeMap: Partial< export function mapTimeRange( timeControlState: TimeControlState, explore: V1ExploreSpec, + exploreState: MetricsExplorerEntity, ) { if (!timeControlState.selectedTimeRange?.name) return undefined; - const timeRange: V1TimeRange = {}; + const timeRange: V1TimeRange = { + timeZone: exploreState.selectedTimezone, + }; switch (timeControlState.selectedTimeRange.name) { case TimeRangePreset.DEFAULT: timeRange.isoDuration = explore?.defaultPreset?.timeRange; diff --git a/web-common/src/features/dashboards/time-dimension-details/getTDDExportArgs.ts b/web-common/src/features/dashboards/time-dimension-details/getTDDExportArgs.ts index 002d1439dbb..8955c74df82 100644 --- a/web-common/src/features/dashboards/time-dimension-details/getTDDExportArgs.ts +++ b/web-common/src/features/dashboards/time-dimension-details/getTDDExportArgs.ts @@ -57,7 +57,7 @@ export function getTDDAggregationRequest( ) return undefined; - const timeRange = mapTimeRange(timeControlState, explore); + const timeRange = mapTimeRange(timeControlState, explore, dashboardState); if (!timeRange) return undefined; const comparisonTimeRange = mapComparisonTimeRange(