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:
Guilherme Caulada
2021-10-18 10:27:14 -03:00
committed by GitHub
co-authored by achatterjee-grafana Emil Tullstedt Hugo Häggmark Alex Khomenko
parent db62ce477d
commit a9faab6b09
27 changed files with 362 additions and 21 deletions
+7 -5
View File
@@ -11,6 +11,7 @@ type DateFormats struct {
UseBrowserLocale bool `json:"useBrowserLocale"`
Interval DateFormatIntervals `json:"interval"`
DefaultTimezone string `json:"defaultTimezone"`
DefaultWeekStart string `json:"defaultWeekStart"`
}
type DateFormatIntervals struct {
@@ -22,17 +23,17 @@ type DateFormatIntervals struct {
Year string `json:"year"`
}
const localBrowserTimezone = "browser"
const localBrowser = "browser"
func valueAsTimezone(section *ini.Section, keyName string) (string, error) {
timezone := section.Key(keyName).MustString(localBrowserTimezone)
if timezone == localBrowserTimezone {
return localBrowserTimezone, nil
timezone := section.Key(keyName).MustString(localBrowser)
if timezone == localBrowser {
return localBrowser, nil
}
location, err := time.LoadLocation(timezone)
if err != nil {
return localBrowserTimezone, err
return localBrowser, err
}
return location.String(), nil
@@ -54,4 +55,5 @@ func (cfg *Cfg) readDateFormats() {
cfg.Logger.Warn("Unknown timezone as default_timezone", "err", err)
}
cfg.DateFormats.DefaultTimezone = timezone
cfg.DateFormats.DefaultWeekStart = valueAsString(dateFormats, "default_week_start", "browser")
}