diff options
author | Michael Muré <batolettre@gmail.com> | 2018-08-02 16:48:07 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-08-02 16:48:07 +0200 |
commit | 9488467c754230288934dde4a49b9046e658986c (patch) | |
tree | 89a3b0c85ec4171f3b2c388d3786a3e92e92c938 | |
parent | ae1ed6c11f3ae5675c80f377dd7f3996b3d621d0 (diff) | |
download | git-bug-9488467c754230288934dde4a49b9046e658986c.tar.gz |
termui: show the last edit in a dedicated column
-rw-r--r-- | bug/snapshot.go | 4 | ||||
-rw-r--r-- | graphql/graph/gen_graph.go | 72 | ||||
-rw-r--r-- | graphql/schema.graphql | 7 | ||||
-rw-r--r-- | termui/bug_table.go | 14 |
4 files changed, 71 insertions, 26 deletions
diff --git a/bug/snapshot.go b/bug/snapshot.go index 9001d2c7..7f1d6099 100644 --- a/bug/snapshot.go +++ b/bug/snapshot.go @@ -2,7 +2,6 @@ package bug import ( "fmt" - "github.com/dustin/go-humanize" "time" ) @@ -31,10 +30,9 @@ func (snap Snapshot) HumanId() string { } func (snap Snapshot) Summary() string { - return fmt.Sprintf("C:%d L:%d %s", + return fmt.Sprintf("C:%d L:%d", len(snap.Comments)-1, len(snap.Labels), - humanize.Time(snap.LastEdit()), ) } diff --git a/graphql/graph/gen_graph.go b/graphql/graph/gen_graph.go index 0bba58e3..63a0c9b5 100644 --- a/graphql/graph/gen_graph.go +++ b/graphql/graph/gen_graph.go @@ -341,12 +341,18 @@ func (ec *executionContext) _Bug(ctx context.Context, sel []query.Selection, obj out.Values[i] = ec._Bug_id(ctx, field, obj) case "humanId": out.Values[i] = ec._Bug_humanId(ctx, field, obj) - case "title": - out.Values[i] = ec._Bug_title(ctx, field, obj) case "status": out.Values[i] = ec._Bug_status(ctx, field, obj) + case "title": + out.Values[i] = ec._Bug_title(ctx, field, obj) case "labels": out.Values[i] = ec._Bug_labels(ctx, field, obj) + case "author": + out.Values[i] = ec._Bug_author(ctx, field, obj) + case "createdAt": + out.Values[i] = ec._Bug_createdAt(ctx, field, obj) + case "lastEdit": + out.Values[i] = ec._Bug_lastEdit(ctx, field, obj) case "comments": out.Values[i] = ec._Bug_comments(ctx, field, obj) case "operations": @@ -381,17 +387,6 @@ func (ec *executionContext) _Bug_humanId(ctx context.Context, field graphql.Coll return graphql.MarshalString(res) } -func (ec *executionContext) _Bug_title(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Bug" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() - res := obj.Title - return graphql.MarshalString(res) -} - func (ec *executionContext) _Bug_status(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Bug", @@ -422,6 +417,17 @@ func (ec *executionContext) _Bug_status(ctx context.Context, field graphql.Colle }) } +func (ec *executionContext) _Bug_title(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Bug" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + res := obj.Title + return graphql.MarshalString(res) +} + func (ec *executionContext) _Bug_labels(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { rctx := graphql.GetResolverContext(ctx) rctx.Object = "Bug" @@ -442,6 +448,39 @@ func (ec *executionContext) _Bug_labels(ctx context.Context, field graphql.Colle return arr1 } +func (ec *executionContext) _Bug_author(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Bug" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + res := obj.Author + return ec._Person(ctx, field.Selections, &res) +} + +func (ec *executionContext) _Bug_createdAt(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Bug" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + res := obj.CreatedAt + return graphql.MarshalTime(res) +} + +func (ec *executionContext) _Bug_lastEdit(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { + rctx := graphql.GetResolverContext(ctx) + rctx.Object = "Bug" + rctx.Args = nil + rctx.Field = field + rctx.PushField(field.Alias) + defer rctx.Pop() + res := obj.LastEdit() + return graphql.MarshalTime(res) +} + func (ec *executionContext) _Bug_comments(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { args := map[string]interface{}{} var arg0 *string @@ -3202,11 +3241,12 @@ type BugEdge { type Bug { id: String! humanId: String! - title: String! status: Status! - - # A list of labels associated with the repository. + title: String! labels: [Label!]! + author: Person! + createdAt: Time! + lastEdit: Time! comments( # Returns the elements in the list that come after the specified cursor. diff --git a/graphql/schema.graphql b/graphql/schema.graphql index 970166cb..410ecde9 100644 --- a/graphql/schema.graphql +++ b/graphql/schema.graphql @@ -133,11 +133,12 @@ type BugEdge { type Bug { id: String! humanId: String! - title: String! status: Status! - - # A list of labels associated with the repository. + title: String! labels: [Label!]! + author: Person! + createdAt: Time! + lastEdit: Time! comments( # Returns the elements in the list that come after the specified cursor. diff --git a/termui/bug_table.go b/termui/bug_table.go index 55b451af..f300c422 100644 --- a/termui/bug_table.go +++ b/termui/bug_table.go @@ -5,6 +5,7 @@ import ( "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/cache" "github.com/MichaelMure/git-bug/util" + "github.com/dustin/go-humanize" "github.com/jroimartin/gocui" ) @@ -243,11 +244,14 @@ func (bt *bugTable) getColumnWidths(maxX int) map[string]int { m["id"] = 10 m["status"] = 8 - left := maxX - 4 - m["id"] - m["status"] + left := maxX - 5 - m["id"] - m["status"] - m["summary"] = maxInt(30, left/3) + m["summary"] = maxInt(11, left/6) left -= m["summary"] + m["lastEdit"] = maxInt(19, left/6) + left -= m["lastEdit"] + m["author"] = maxInt(left*2/5, 15) m["title"] = maxInt(left-m["author"], 10) @@ -270,8 +274,9 @@ func (bt *bugTable) render(v *gocui.View, maxX int) { title := util.LeftPaddedString(snap.Title, columnWidths["title"], 2) author := util.LeftPaddedString(person.Name, columnWidths["author"], 2) summary := util.LeftPaddedString(snap.Summary(), columnWidths["summary"], 2) + lastEdit := util.LeftPaddedString(humanize.Time(snap.LastEdit()), columnWidths["lastEdit"], 2) - fmt.Fprintf(v, "%s %s %s %s %s\n", id, status, title, author, summary) + fmt.Fprintf(v, "%s %s %s %s %s %s\n", id, status, title, author, summary, lastEdit) } } @@ -283,9 +288,10 @@ func (bt *bugTable) renderHeader(v *gocui.View, maxX int) { title := util.LeftPaddedString("TITLE", columnWidths["title"], 2) author := util.LeftPaddedString("AUTHOR", columnWidths["author"], 2) summary := util.LeftPaddedString("SUMMARY", columnWidths["summary"], 2) + lastEdit := util.LeftPaddedString("LAST EDIT", columnWidths["lastEdit"], 2) fmt.Fprintf(v, "\n") - fmt.Fprintf(v, "%s %s %s %s %s\n", id, status, title, author, summary) + fmt.Fprintf(v, "%s %s %s %s %s %s\n", id, status, title, author, summary, lastEdit) } |