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

Move jenkins filter to the data retrieval portion (#533)

Per #532, we are keeping track of all items regardless of filter,
meaning that selection does not work as expected
This commit is contained in:
Sean Smith 2019-08-17 15:58:59 -04:00 committed by GitHub
parent 2efa6eed7c
commit 28f9b55e4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 11 deletions

View File

@ -8,6 +8,7 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"regexp"
"strings" "strings"
) )
@ -43,6 +44,17 @@ func (widget *Widget) Create(jenkinsURL string, username string, apiKey string)
view := &View{} view := &View{}
parseJson(view, resp.Body) parseJson(view, resp.Body)
jobs := []Job{}
var validID = regexp.MustCompile(widget.settings.jobNameRegex)
for _, job := range view.Jobs {
if validID.MatchString(job.Name) {
jobs = append(jobs, job)
}
}
view.Jobs = jobs
return view, nil return view, nil
} }

View File

@ -2,7 +2,6 @@ package jenkins
import ( import (
"fmt" "fmt"
"regexp"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/utils" "github.com/wtfutil/wtf/utils"
@ -73,18 +72,15 @@ func (widget *Widget) Render() {
func (widget *Widget) contentFrom(view *View) string { func (widget *Widget) contentFrom(view *View) string {
var str string var str string
for idx, job := range view.Jobs { for idx, job := range view.Jobs {
var validID = regexp.MustCompile(widget.settings.jobNameRegex)
if validID.MatchString(job.Name) { row := fmt.Sprintf(
row := fmt.Sprintf( `[%s] [%s]%-6s[white]`,
`[%s] [%s]%-6s[white]`, widget.RowColor(idx),
widget.RowColor(idx), widget.jobColor(&job),
widget.jobColor(&job), job.Name,
job.Name, )
)
str += utils.HighlightableHelper(widget.View, row, idx, len(job.Name)) str += utils.HighlightableHelper(widget.View, row, idx, len(job.Name))
}
} }
return str return str