TimeRangePicker: Use week start (#89765)

This commit is contained in:
Alex Khomenko
2024-06-27 07:53:46 +03:00
committed by GitHub
parent ed13959e33
commit 9056ff73f6
4 changed files with 21 additions and 5 deletions

View File

@@ -2,8 +2,8 @@ import { Component } from 'react';
import { Unsubscribable } from 'rxjs';
import { dateMath, TimeRange, TimeZone } from '@grafana/data';
import { TimeRangeUpdatedEvent } from '@grafana/runtime';
import { defaultIntervals, RefreshPicker } from '@grafana/ui';
import { config, TimeRangeUpdatedEvent } from '@grafana/runtime';
import { defaultIntervals, getWeekStart, RefreshPicker } from '@grafana/ui';
import { TimePickerWithHistory } from 'app/core/components/TimePicker/TimePickerWithHistory';
import { appEvents } from 'app/core/core';
import { t } from 'app/core/internationalization';
@@ -100,6 +100,7 @@ export class DashNavTimeControls extends Component<Props> {
const timeZone = dashboard.getTimezone();
const fiscalYearStartMonth = dashboard.fiscalYearStartMonth;
const hideIntervalPicker = dashboard.panelInEdit?.isEditing;
const weekStart = dashboard.weekStart || getWeekStart(config.bootData.user.weekStart);
let text: string | undefined = undefined;
if (dashboard.refresh === AutoRefreshInterval) {
@@ -120,6 +121,7 @@ export class DashNavTimeControls extends Component<Props> {
onChangeFiscalYearStartMonth={this.onChangeFiscalYearStartMonth}
isOnCanvas={isOnCanvas}
onToolbarTimePickerClick={this.props.onToolbarTimePickerClick}
weekStart={weekStart}
/>
<RefreshPicker
onIntervalChanged={this.onChangeRefreshInterval}

View File

@@ -1,8 +1,9 @@
import { Component } from 'react';
import { TimeRange, RawTimeRange, dateTimeForTimeZone, dateMath } from '@grafana/data';
import { reportInteraction } from '@grafana/runtime';
import { config, reportInteraction } from '@grafana/runtime';
import { TimeZone } from '@grafana/schema';
import { getWeekStart } from '@grafana/ui';
import { TimePickerWithHistory } from 'app/core/components/TimePicker/TimePickerWithHistory';
import { getShiftedTimeRange, getZoomedTimeRange } from 'app/core/utils/timePicker';
@@ -85,7 +86,7 @@ export class ExploreTimeControls extends Component<Props> {
onZoom: this.onZoom,
hideText,
};
const weekStart = getWeekStart(config.bootData.user.weekStart);
return (
<TimePickerWithHistory
isOnCanvas
@@ -96,6 +97,7 @@ export class ExploreTimeControls extends Component<Props> {
onChange={this.onChangeTimePicker}
onChangeTimeZone={onChangeTimeZone}
onChangeFiscalYearStartMonth={onChangeFiscalYearStartMonth}
weekStart={weekStart}
/>
);
}