Skip to content

Commit

Permalink
Add commenting support, badly
Browse files Browse the repository at this point in the history
This fixes #9, though still suffering from #8.

I'm not particularly happy here though, the edit interface provided lacks context: it simply
is a raw YAML 'body: |' prompt in $EDITOR. Not very friendly.

Unfortunately, the data is just not available to the 'comment' template to put a reference
to the ticket id and summary into place, so I think this requires a PR to go-jira :(
  • Loading branch information
Mike Pountney committed Jan 6, 2016
1 parent f206d97 commit cad6f1c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jira-ui.go
Expand Up @@ -32,6 +32,10 @@ type TicketEditer interface {
EditTicket()
}

type TicketCommenter interface {
CommentTicket()
}

type PagePager interface {
NextLine(int)
PreviousLine(int)
Expand Down
4 changes: 4 additions & 0 deletions ticket_list_page.go
Expand Up @@ -30,6 +30,10 @@ func (p *TicketListPage) EditTicket() {
runJiraCmdEdit(p.GetSelectedTicketId())
}

func (p *TicketListPage) CommentTicket() {
runJiraCmdComment(p.GetSelectedTicketId())
}

func (p *TicketListPage) Create(opts ...interface{}) {
ui.Clear()
var label string
Expand Down
4 changes: 4 additions & 0 deletions ticket_show_page.go
Expand Up @@ -27,6 +27,10 @@ func (p *TicketShowPage) EditTicket() {
runJiraCmdEdit(p.TicketId)
}

func (p *TicketShowPage) CommentTicket() {
runJiraCmdComment(p.TicketId)
}

func (p *TicketShowPage) lastDisplayedLine() int {
return lastLineDisplayed(p.uiList, p.firstDisplayLine, 5)
}
Expand Down
9 changes: 9 additions & 0 deletions ui_controls.go
Expand Up @@ -38,6 +38,9 @@ func registerKeyboardHandlers() {
ui.Handle("/sys/kbd/E", func(ui.Event) {
handleEditKey()
})
ui.Handle("/sys/kbd/C", func(ui.Event) {
handleCommentKey()
})
ui.Handle("/sys/wnd/resize", func(ui.Event) {
handleResize()
})
Expand All @@ -58,6 +61,12 @@ func handleEditKey() {
}
}

func handleCommentKey() {
if obj, ok := currentPage.(TicketCommenter); ok {
obj.CommentTicket()
}
}

func handleBackKey() {
if obj, ok := currentPage.(GoBacker); ok {
obj.GoBack()
Expand Down
9 changes: 9 additions & 0 deletions utils.go
Expand Up @@ -34,6 +34,15 @@ func runJiraCmdEdit(ticketId string) {
os.Exit(0)
}

func runJiraCmdComment(ticketId string) {
opts := getJiraOpts()
c := jira.New(opts)
ui.Close()
c.CmdComment(ticketId)
log.Notice("Regrettably, need to exit after comment. See https://github.com/mikepea/go-jira-ui/issues/8")
os.Exit(0)
}

func runJiraQuery(query string) (interface{}, error) {
opts := getJiraOpts()
opts["query"] = query
Expand Down

0 comments on commit cad6f1c

Please sign in to comment.