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:
@@ -22,14 +22,14 @@ 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.GerritProjects), widget.Idx, width) + "\n"
|
||||
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
|
||||
str := widget.settings.PaginationMarker(len(widget.GerritProjects), 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 Incoming Reviews[white]\n", widget.settings.common.Colors.Subheading)
|
||||
str += fmt.Sprintf(" [%s]Open Incoming Reviews[white]\n", widget.settings.Colors.Subheading)
|
||||
str += widget.displayMyIncomingReviews(project, widget.settings.username)
|
||||
str += "\n"
|
||||
str += fmt.Sprintf(" [%s]My Outgoing Reviews[white]\n", widget.settings.common.Colors.Subheading)
|
||||
str += fmt.Sprintf(" [%s]My Outgoing Reviews[white]\n", widget.settings.Colors.Subheading)
|
||||
str += widget.displayMyOutgoingReviews(project, widget.settings.username)
|
||||
|
||||
return title, str, false
|
||||
@@ -72,10 +72,10 @@ func (widget *Widget) displayStats(project *GerritProject) string {
|
||||
|
||||
func (widget *Widget) rowColor(idx int) string {
|
||||
if widget.View.HasFocus() && (idx == widget.selected) {
|
||||
return widget.settings.common.DefaultFocusedRowColor()
|
||||
return widget.settings.DefaultFocusedRowColor()
|
||||
}
|
||||
|
||||
return widget.settings.common.RowColor(idx)
|
||||
return widget.settings.RowColor(idx)
|
||||
}
|
||||
|
||||
func (widget *Widget) title(project *GerritProject) string {
|
||||
|
||||
@@ -21,7 +21,7 @@ type colors struct {
|
||||
|
||||
type Settings struct {
|
||||
colors
|
||||
common *cfg.Common
|
||||
*cfg.Common
|
||||
|
||||
domain string `help:"Your Gerrit corporate domain."`
|
||||
password string `help:"Your Gerrit HTTP Password."`
|
||||
@@ -32,7 +32,7 @@ type Settings struct {
|
||||
|
||||
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),
|
||||
|
||||
domain: ymlConfig.UString("domain", ""),
|
||||
password: ymlConfig.UString("password", os.Getenv("WTF_GERRIT_PASSWORD")),
|
||||
|
||||
@@ -31,7 +31,7 @@ var (
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: view.NewTextWidget(app, nil, settings.common),
|
||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
||||
|
||||
Idx: 0,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user