1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Simplify the inclusion of the Common config settings into each module

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2020-11-26 19:53:21 -08:00
parent f9a06540f1
commit d6a0797bf2
161 changed files with 378 additions and 330 deletions

View File

@@ -39,20 +39,20 @@ func (widget *Widget) content() (string, string, bool) {
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.title(project))
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.PaginationMarker(len(widget.GitlabProjects), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
str := widget.settings.PaginationMarker(len(widget.GitlabProjects), widget.Idx, width) + "\n"
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.Colors.Subheading)
str += widget.displayStats(project)
str += "\n"
str += fmt.Sprintf(" [%s]Open Assigned Merge Requests[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]Open Assigned Merge Requests[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyAssignedMergeRequests(project, widget.settings.username)
str += "\n"
str += fmt.Sprintf(" [%s]My Merge Requests[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]My Merge Requests[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyMergeRequests(project, widget.settings.username)
str += "\n"
str += fmt.Sprintf(" [%s]Open Assigned Issues[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]Open Assigned Issues[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyAssignedIssues(project, widget.settings.username)
str += "\n"
str += fmt.Sprintf(" [%s]My Issues[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" [%s]My Issues[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyIssues(project, widget.settings.username)
return title, str, false

View File

@@ -14,7 +14,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"A GitLab personal access token. Requires at least api access."`
domain string `help:"Your GitLab corporate domain."`
@@ -25,7 +25,7 @@ type Settings struct {
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_GITLAB_TOKEN"))),
domain: ymlConfig.UString("domain", "https://gitlab.com"),

View File

@@ -33,8 +33,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
context, err := newContext(settings)
widget := Widget{
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
TextWidget: view.NewTextWidget(app, pages, settings.Common),
context: context,
settings: settings,