diff --git a/docs/configuration.md b/docs/configuration.md index 0d90c9d5..1f82b39b 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1035,6 +1035,11 @@ Preview:  +#### Property +| Name | Type | Required | Default | +| ---- | ---- | -------- | ------- | +| default-tab | int | no | 1 | + #### Sharing properties To avoid repetition you can use [YAML anchors](https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/) and share properties between widgets. diff --git a/internal/glance/static/js/main.js b/internal/glance/static/js/main.js index a10804e6..9ee1c541 100644 --- a/internal/glance/static/js/main.js +++ b/internal/glance/static/js/main.js @@ -257,7 +257,7 @@ function setupGroups() { const group = groups[g]; const titles = group.getElementsByClassName("widget-header")[0].children; const tabs = group.getElementsByClassName("widget-group-contents")[0].children; - let current = 0; + let current = Array.from(titles).findIndex(c => c.classList.contains('widget-group-title-current')) || 0; for (let t = 0; t < titles.length; t++) { const title = titles[t]; diff --git a/internal/glance/templates/group.html b/internal/glance/templates/group.html index 646df2f6..4b1aa098 100644 --- a/internal/glance/templates/group.html +++ b/internal/glance/templates/group.html @@ -6,14 +6,14 @@
diff --git a/internal/glance/widget-group.go b/internal/glance/widget-group.go index 2ea38133..80373c12 100644 --- a/internal/glance/widget-group.go +++ b/internal/glance/widget-group.go @@ -12,12 +12,21 @@ var groupWidgetTemplate = mustParseTemplate("group.html", "widget-base.html") type groupWidget struct { widgetBase `yaml:",inline"` containerWidgetBase `yaml:",inline"` + DefaultTab int `yaml:"default-tab"` } func (widget *groupWidget) initialize() error { widget.withError(nil) widget.HideHeader = true + if widget.DefaultTab > 0 { + widget.DefaultTab = widget.DefaultTab - 1 + } + + if widget.DefaultTab > (len(widget.Widgets) - 1) { + widget.DefaultTab = len(widget.Widgets) - 1 + } + for i := range widget.Widgets { widget.Widgets[i].setHideHeader(true)