Skip to content

Commit

Permalink
Move jenkins filter to the data retrieval portion
Browse files Browse the repository at this point in the history
Per wtfutil#532, we are keeping track of all items regardless of filter,
meaning that selection does not work as expected
  • Loading branch information
Seanstoppable committed Aug 17, 2019
1 parent 2efa6ee commit f2cb306
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
12 changes: 12 additions & 0 deletions modules/jenkins/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"regexp"
"strings"
)

Expand Down Expand Up @@ -43,6 +44,17 @@ func (widget *Widget) Create(jenkinsURL string, username string, apiKey string)
view := &View{}
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
}

Expand Down
22 changes: 9 additions & 13 deletions modules/jenkins/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package jenkins

import (
"fmt"
"regexp"

"github.com/rivo/tview"
"github.com/wtfutil/wtf/utils"
Expand Down Expand Up @@ -73,18 +72,15 @@ func (widget *Widget) Render() {
func (widget *Widget) contentFrom(view *View) string {
var str string
for idx, job := range view.Jobs {
var validID = regexp.MustCompile(widget.settings.jobNameRegex)

if validID.MatchString(job.Name) {
row := fmt.Sprintf(
`[%s] [%s]%-6s[white]`,
widget.RowColor(idx),
widget.jobColor(&job),
job.Name,
)

str += utils.HighlightableHelper(widget.View, row, idx, len(job.Name))
}

row := fmt.Sprintf(
`[%s] [%s]%-6s[white]`,
widget.RowColor(idx),
widget.jobColor(&job),
job.Name,
)

str += utils.HighlightableHelper(widget.View, row, idx, len(job.Name))
}

return str
Expand Down

0 comments on commit f2cb306

Please sign in to comment.