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

Closes #268. Jira now supports help modal

This commit is contained in:
Chris Cummer 2018-08-01 15:05:43 -07:00
parent 40db4b1ed8
commit e5a66edf61
2 changed files with 35 additions and 2 deletions

View File

@ -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()
@ -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()
@ -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)
}

View File

@ -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":