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

@@ -35,21 +35,21 @@ func (widget *Widget) content() (string, string, bool) {
}
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.PaginationMarker(len(widget.GithubRepos), widget.Idx, width)
str := widget.settings.PaginationMarker(len(widget.GithubRepos), widget.Idx, width)
if widget.settings.showStats {
str += fmt.Sprintf("\n [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf("\n [%s]Stats[white]\n", widget.settings.Colors.Subheading)
str += widget.displayStats(repo)
}
if widget.settings.showOpenReviewRequests {
str += fmt.Sprintf("\n [%s]Open Review Requests[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf("\n [%s]Open Review Requests[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyReviewRequests(repo, username)
}
if widget.settings.showMyPullRequests {
str += fmt.Sprintf("\n [%s]My Pull Requests[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf("\n [%s]My Pull Requests[white]\n", widget.settings.Colors.Subheading)
str += widget.displayMyPullRequests(repo, username)
}
for _, customQuery := range widget.settings.customQueries {
str += fmt.Sprintf("\n [%s]%s[white]\n", widget.settings.common.Colors.Subheading, customQuery.title)
str += fmt.Sprintf("\n [%s]%s[white]\n", widget.settings.Colors.Subheading, customQuery.title)
str += widget.displayCustomQuery(repo, customQuery.filter, customQuery.perPage)
}
@@ -139,7 +139,7 @@ func (widget *Widget) displayStats(repo *Repo) string {
func (widget *Widget) title(repo *Repo) string {
return fmt.Sprintf(
"[%s]%s - %s[white]",
widget.settings.common.Colors.TextTheme.Title,
widget.settings.Colors.TextTheme.Title,
repo.Owner,
repo.Name,
)

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:"Your GitHub API token."`
baseURL string `help:"Your GitHub Enterprise API URL." optional:"true"`
@@ -37,7 +37,7 @@ type customQuery 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_GITHUB_TOKEN"))),
baseURL: ymlConfig.UString("baseURL", os.Getenv("WTF_GITHUB_BASE_URL")),

View File

@@ -25,8 +25,8 @@ type Widget struct {
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
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),
settings: settings,
}