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

WTF-400 Fix missed wtf.Config occurrances

This commit is contained in:
Chris Cummer 2019-04-16 21:47:51 -07:00
parent 6f98ecccf7
commit 2807a2200e
7 changed files with 16 additions and 18 deletions

View File

@ -3,16 +3,14 @@ package clocks
import (
"sort"
"time"
"github.com/wtfutil/wtf/wtf"
)
type ClockCollection struct {
Clocks []Clock
}
func (clocks *ClockCollection) Sorted() []Clock {
if "chronological" == wtf.Config.UString("wtf.mods.clocks.sort", "alphabetical") {
func (clocks *ClockCollection) Sorted(sortOrder string) []Clock {
if sortOrder == "chronological" {
clocks.SortedChronologically()
} else {
clocks.SortedAlphabetically()

View File

@ -34,7 +34,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.display(widget.clockColl.Sorted(), widget.dateFormat, widget.timeFormat)
widget.display(widget.clockColl.Sorted(widget.settings.sort), widget.dateFormat, widget.timeFormat)
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -19,7 +19,7 @@ func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
args: wtf.ToStrs(wtf.Config.UList("args")),
args: wtf.ToStrs(localConfig.UList("args")),
cmd: localConfig.UString("cmd"),
}

View File

@ -8,16 +8,14 @@ import (
"io/ioutil"
"net/http"
"net/url"
"github.com/wtfutil/wtf/wtf"
)
func CurrentActiveItems(accessToken string) (*ActiveItems, error) {
func CurrentActiveItems(accessToken, assignedToName string, activeOnly bool) (*ActiveItems, error) {
items := &ActiveItems{}
rollbarAPIURL.Host = "api.rollbar.com"
rollbarAPIURL.Path = "/api/1/items"
resp, err := rollbarItemRequest(accessToken)
resp, err := rollbarItemRequest(accessToken, assignedToName, activeOnly)
if err != nil {
return items, err
}
@ -33,13 +31,11 @@ var (
rollbarAPIURL = &url.URL{Scheme: "https"}
)
func rollbarItemRequest(accessToken string) (*http.Response, error) {
func rollbarItemRequest(accessToken, assignedToName string, activeOnly bool) (*http.Response, error) {
params := url.Values{}
params.Add("access_token", accessToken)
userName := wtf.Config.UString("wtf.mods.rollbar.assignedToName", "")
params.Add("assigned_user", userName)
active := wtf.Config.UBool("wtf.mods.rollbar.activeOnly", false)
if active {
params.Add("assigned_user", assignedToName)
if activeOnly {
params.Add("status", "active")
}

View File

@ -23,7 +23,7 @@ func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
accessToken: localConfig.UString("accessToken"),
activeOnly: localConfig.UBool("activeOnly"),
activeOnly: localConfig.UBool("activeOnly", false),
assignedToName: localConfig.UString("assignedToName"),
count: localConfig.UInt("count", 10),
projectName: localConfig.UString("projectName", "Items"),

View File

@ -55,7 +55,11 @@ func (widget *Widget) Refresh() {
return
}
items, err := CurrentActiveItems(widget.settings.accessToken)
items, err := CurrentActiveItems(
widget.settings.accessToken,
widget.settings.assignedToName,
widget.settings.activeOnly,
)
if err != nil {
widget.View.SetWrap(true)

View File

@ -150,7 +150,7 @@ func (widget *Widget) openBuild() {
sel := widget.selected
if sel >= 0 && widget.builds != nil && sel < len(widget.builds.Builds) {
build := &widget.builds.Builds[widget.selected]
travisHost := TRAVIS_HOSTS[wtf.Config.UBool("wtf.mods.travisci.pro", false)]
travisHost := TRAVIS_HOSTS[widget.settings.pro]
wtf.OpenFile(fmt.Sprintf("https://%s/%s/%s/%d", travisHost, build.Repository.Slug, "builds", build.ID))
}
}