mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Add week start option to global and dashboard preferences (#40010)
* Add global week start option to shared preferences * Add default_week_start to configuration docs * Add week start option to dashboards * Add week start argument to tsdb time range parser * Fix strict check issues * Add tests for week start * Change wording on default_week_start documentation Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update week_start column to be a nullable field Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> * Update configuration to include browser option * Update WeekStartPicker container selector Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> * Add menuShouldPortal to WeekStartPicker to remove deprecation warning Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * Add inputId to WeekStartPicker * Use e2e selector on WeekStartPicker aria-label * Simplify WeekStartPicker onChange condition * Specify value type on WeekStartPicker weekStarts * Remove setWeekStart side effect from reducer * Fix updateLocale failing to reset week start * Store week start as string to handle empty values Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
db62ce477d
commit
a9faab6b09
@@ -12,6 +12,7 @@ import {
|
||||
Select,
|
||||
stylesFactory,
|
||||
TimeZonePicker,
|
||||
WeekStartPicker,
|
||||
Tooltip,
|
||||
} from '@grafana/ui';
|
||||
import { SelectableValue } from '@grafana/data';
|
||||
@@ -29,6 +30,7 @@ export interface State {
|
||||
homeDashboardId: number;
|
||||
theme: string;
|
||||
timezone: string;
|
||||
weekStart: string;
|
||||
dashboards: DashboardSearchHit[];
|
||||
}
|
||||
|
||||
@@ -49,6 +51,7 @@ export class SharedPreferences extends PureComponent<Props, State> {
|
||||
homeDashboardId: 0,
|
||||
theme: '',
|
||||
timezone: '',
|
||||
weekStart: '',
|
||||
dashboards: [],
|
||||
};
|
||||
}
|
||||
@@ -84,13 +87,14 @@ export class SharedPreferences extends PureComponent<Props, State> {
|
||||
homeDashboardId: prefs.homeDashboardId,
|
||||
theme: prefs.theme,
|
||||
timezone: prefs.timezone,
|
||||
weekStart: prefs.weekStart,
|
||||
dashboards: [defaultDashboardHit, ...dashboards],
|
||||
});
|
||||
}
|
||||
|
||||
onSubmitForm = async () => {
|
||||
const { homeDashboardId, theme, timezone } = this.state;
|
||||
await this.service.update({ homeDashboardId, theme, timezone });
|
||||
const { homeDashboardId, theme, timezone, weekStart } = this.state;
|
||||
await this.service.update({ homeDashboardId, theme, timezone, weekStart });
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
@@ -105,6 +109,10 @@ export class SharedPreferences extends PureComponent<Props, State> {
|
||||
this.setState({ timezone: timezone });
|
||||
};
|
||||
|
||||
onWeekStartChanged = (weekStart: string) => {
|
||||
this.setState({ weekStart: weekStart });
|
||||
};
|
||||
|
||||
onHomeDashboardChanged = (dashboardId: number) => {
|
||||
this.setState({ homeDashboardId: dashboardId });
|
||||
};
|
||||
@@ -117,7 +125,7 @@ export class SharedPreferences extends PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { theme, timezone, homeDashboardId, dashboards } = this.state;
|
||||
const { theme, timezone, weekStart, homeDashboardId, dashboards } = this.state;
|
||||
const styles = getStyles();
|
||||
|
||||
return (
|
||||
@@ -161,6 +169,10 @@ export class SharedPreferences extends PureComponent<Props, State> {
|
||||
<Field label="Timezone" aria-label={selectors.components.TimeZonePicker.container}>
|
||||
<TimeZonePicker includeInternal={true} value={timezone} onChange={this.onTimeZoneChanged} />
|
||||
</Field>
|
||||
|
||||
<Field label="Week start" aria-label={selectors.components.WeekStartPicker.container}>
|
||||
<WeekStartPicker value={weekStart} onChange={this.onWeekStartChanged} />
|
||||
</Field>
|
||||
<div className="gf-form-button-row">
|
||||
<Button variant="primary" aria-label="User preferences save button">
|
||||
Save
|
||||
|
Reference in New Issue
Block a user