Skip to content

Commit

Permalink
Closes #268. Jira now supports help modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Cummer committed Aug 1, 2018
1 parent 40db4b1 commit e5a66ed
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
35 changes: 34 additions & 1 deletion jira/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,38 @@ import (
"fmt"

"github.com/gdamore/tcell"
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/wtf"
)

const HelpText = `
Keyboard commands for Jira:
/: Show/hide this help window
j: Select the next item in the list
k: Select the previous item in the list
arrow down: Select the next item in the list
arrow up: Select the previous item in the list
return: Open the selected issue in a browser
`

type Widget struct {
wtf.TextWidget

app *tview.Application
pages *tview.Pages
result *SearchResult
selected int
}

func NewWidget() *Widget {
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget("Jira", "jira", true),

app: app,
pages: pages,
}
widget.unselect()

Expand Down Expand Up @@ -153,6 +172,8 @@ func getProjects() []string {

func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
switch string(event.Rune()) {
case "/":
widget.showHelp()
case "j":
// Select the next item down
widget.next()
Expand Down Expand Up @@ -189,3 +210,15 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
return event
}
}

func (widget *Widget) showHelp() {
closeFunc := func() {
widget.pages.RemovePage("help")
widget.app.SetFocus(widget.View)
}

modal := wtf.NewBillboardModal(HelpText, closeFunc)

widget.pages.AddPage("help", modal, false, true)
widget.app.SetFocus(modal)
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
case "jenkins":
widgets = append(widgets, jenkins.NewWidget())
case "jira":
widgets = append(widgets, jira.NewWidget())
widgets = append(widgets, jira.NewWidget(app, pages))
case "logger":
widgets = append(widgets, logger.NewWidget())
case "newrelic":
Expand Down

0 comments on commit e5a66ed

Please sign in to comment.