aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
Diffstat (limited to 'termui')
-rw-r--r--termui/show_bug.go44
1 files changed, 29 insertions, 15 deletions
diff --git a/termui/show_bug.go b/termui/show_bug.go
index 560ac765..5a3ea1d5 100644
--- a/termui/show_bug.go
+++ b/termui/show_bug.go
@@ -5,8 +5,8 @@ import (
"fmt"
"strings"
+ "github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/operations"
"github.com/MichaelMure/git-bug/util/colors"
"github.com/MichaelMure/git-bug/util/text"
"github.com/jroimartin/gocui"
@@ -209,12 +209,20 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
sb.mainSelectableView = nil
- bugHeader := fmt.Sprintf("[%s] %s\n\n[%s] %s opened this bug on %s",
+ createTimelineItem := snap.Timeline[0].(*bug.CreateTimelineItem)
+
+ edited := ""
+ if createTimelineItem.Edited() {
+ edited = " (edited)"
+ }
+
+ bugHeader := fmt.Sprintf("[%s] %s\n\n[%s] %s opened this bug on %s%s",
colors.Cyan(snap.HumanId()),
colors.Bold(snap.Title),
colors.Yellow(snap.Status),
colors.Magenta(snap.Author.Name),
snap.CreatedAt.Format(timeLayout),
+ edited,
)
bugHeader, lines := text.Wrap(bugHeader, maxX)
@@ -226,7 +234,7 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
fmt.Fprint(v, bugHeader)
y0 += lines + 1
- for i, op := range snap.Operations {
+ for i, op := range snap.Timeline {
viewName := fmt.Sprintf("op%d", i)
// TODO: me might skip the rendering of blocks that are outside of the view
@@ -234,8 +242,8 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
switch op.(type) {
- case operations.CreateOperation:
- create := op.(operations.CreateOperation)
+ case *bug.CreateTimelineItem:
+ create := op.(*bug.CreateTimelineItem)
content, lines := text.WrapLeftPadded(create.Message, maxX, 4)
v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true)
@@ -245,13 +253,19 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
fmt.Fprint(v, content)
y0 += lines + 2
- case operations.AddCommentOperation:
- comment := op.(operations.AddCommentOperation)
+ case *bug.CommentTimelineItem:
+ comment := op.(*bug.CommentTimelineItem)
+
+ edited := ""
+ if comment.Edited() {
+ edited = " (edited)"
+ }
message, _ := text.WrapLeftPadded(comment.Message, maxX, 4)
- content := fmt.Sprintf("%s commented on %s\n\n%s",
+ content := fmt.Sprintf("%s commented on %s%s\n\n%s",
colors.Magenta(comment.Author.Name),
- comment.Time().Format(timeLayout),
+ comment.CreatedAt.Time().Format(timeLayout),
+ edited,
message,
)
content, lines = text.Wrap(content, maxX)
@@ -263,8 +277,8 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
fmt.Fprint(v, content)
y0 += lines + 2
- case operations.SetTitleOperation:
- setTitle := op.(operations.SetTitleOperation)
+ case *bug.SetTitleOperation:
+ setTitle := op.(*bug.SetTitleOperation)
content := fmt.Sprintf("%s changed the title to %s on %s",
colors.Magenta(setTitle.Author.Name),
@@ -280,8 +294,8 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
fmt.Fprint(v, content)
y0 += lines + 2
- case operations.SetStatusOperation:
- setStatus := op.(operations.SetStatusOperation)
+ case *bug.SetStatusOperation:
+ setStatus := op.(*bug.SetStatusOperation)
content := fmt.Sprintf("%s %s the bug on %s",
colors.Magenta(setStatus.Author.Name),
@@ -297,8 +311,8 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
fmt.Fprint(v, content)
y0 += lines + 2
- case operations.LabelChangeOperation:
- labelChange := op.(operations.LabelChangeOperation)
+ case *bug.LabelChangeOperation:
+ labelChange := op.(*bug.LabelChangeOperation)
var added []string
for _, label := range labelChange.Added {