Skip to content

Commit

Permalink
feat: add labels to the issue listing
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny committed Nov 27, 2022
1 parent 9ac3591 commit 84206aa
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions internal/view/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ const (
fieldStartDate = "START"
fieldEndDate = "END"
fieldCompleteDate = "COMPLETE"
fieldLabels = "LABELS"
)
1 change: 1 addition & 0 deletions internal/view/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func ValidIssueColumns() []string {
fieldResolution,
fieldCreated,
fieldUpdated,
fieldLabels,
}
}

Expand Down
2 changes: 2 additions & 0 deletions internal/view/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ func (IssueList) assignColumns(columns []string, issue *jira.Issue) []string {
bucket = append(bucket, formatDateTime(issue.Fields.Created, jira.RFC3339))
case fieldUpdated:
bucket = append(bucket, formatDateTime(issue.Fields.Updated, jira.RFC3339))
case fieldLabels:
bucket = append(bucket, strings.Join(issue.Fields.Labels, ","))
}
}

Expand Down
18 changes: 10 additions & 8 deletions internal/view/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func TestIssueData(t *testing.T) {
expected := tui.TableData{
[]string{
"TYPE", "KEY", "SUMMARY", "STATUS", "ASSIGNEE", "REPORTER", "PRIORITY", "RESOLUTION",
"CREATED", "UPDATED",
"CREATED", "UPDATED", "LABELS",
},
[]string{
"Bug", "TEST-1", "This is a test", "Done", "Person A", "Person Z", "High", "Fixed",
"2020-12-13 14:05:20", "2020-12-13 14:07:20",
"2020-12-13 14:05:20", "2020-12-13 14:07:20", "krakatit",
},
[]string{
"Story", "TEST-2", "This is another test", "Open", "", "Person A", "Normal", "",
"2020-12-13 14:05:20", "2020-12-13 14:07:20",
"2020-12-13 14:05:20", "2020-12-13 14:07:20", "pat,mat",
},
}
assert.Equal(t, expected, issue.data())
Expand Down Expand Up @@ -77,9 +77,9 @@ func TestIssueRenderInPlainViewAndNoTruncate(t *testing.T) {
}
assert.NoError(t, issue.renderPlain(&b))

expected := `TYPE KEY SUMMARY STATUS ASSIGNEE REPORTER PRIORITY RESOLUTION CREATED UPDATED
Bug TEST-1 This is a test Done Person A Person Z High Fixed 2020-12-13 14:05:20 2020-12-13 14:07:20
Story TEST-2 This is another test Open Person A Normal 2020-12-13 14:05:20 2020-12-13 14:07:20
expected := `TYPE KEY SUMMARY STATUS ASSIGNEE REPORTER PRIORITY RESOLUTION CREATED UPDATED LABELS
Bug TEST-1 This is a test Done Person A Person Z High Fixed 2020-12-13 14:05:20 2020-12-13 14:07:20 krakatit
Story TEST-2 This is another test Open Person A Normal 2020-12-13 14:05:20 2020-12-13 14:07:20 pat,mat
`
assert.Equal(t, expected, b.String())
}
Expand All @@ -100,8 +100,8 @@ func TestIssueRenderInPlainViewWithoutHeaders(t *testing.T) {
}
assert.NoError(t, issue.renderPlain(&b))

expected := `Bug TEST-1 This is a test Done Person A Person Z High Fixed 2020-12-13 14:05:20 2020-12-13 14:07:20
Story TEST-2 This is another test Open Person A Normal 2020-12-13 14:05:20 2020-12-13 14:07:20
expected := `Bug TEST-1 This is a test Done Person A Person Z High Fixed 2020-12-13 14:05:20 2020-12-13 14:07:20 krakatit
Story TEST-2 This is another test Open Person A Normal 2020-12-13 14:05:20 2020-12-13 14:07:20 pat,mat
`
assert.Equal(t, expected, b.String())
}
Expand Down Expand Up @@ -155,6 +155,7 @@ func getIssues() []*jira.Issue {
}{Name: "Done"},
Created: "2020-12-13T14:05:20.974+0100",
Updated: "2020-12-13T14:07:20.974+0100",
Labels: []string{"krakatit"},
},
},
{
Expand All @@ -173,6 +174,7 @@ func getIssues() []*jira.Issue {
}{Name: "Open"},
Created: "2020-12-13T14:05:20.974+0100",
Updated: "2020-12-13T14:07:20.974+0100",
Labels: []string{"pat", "mat"},
},
},
}
Expand Down
1 change: 1 addition & 0 deletions internal/view/sprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (sl *SprintList) tabularize(issues []*jira.Issue) tui.TableData {
issue.Fields.Resolution.Name,
formatDateTime(issue.Fields.Created, jira.RFC3339),
formatDateTime(issue.Fields.Updated, jira.RFC3339),
strings.Join(issue.Fields.Labels, ","),
})
}

Expand Down
12 changes: 7 additions & 5 deletions internal/view/sprint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestSprintPreviewLayoutData(t *testing.T) {
}{Name: "Done"},
Created: "2020-12-13T14:05:20.974+0100",
Updated: "2020-12-13T14:07:20.974+0100",
Labels: []string{"urgent"},
},
}
issue2 := jira.Issue{
Expand All @@ -68,6 +69,7 @@ func TestSprintPreviewLayoutData(t *testing.T) {
}{Name: "Open"},
Created: "2020-12-13T14:05:20.974+0100",
Updated: "2020-12-13T14:07:20.974+0100",
Labels: []string{"blocked"},
},
}

Expand Down Expand Up @@ -100,11 +102,11 @@ func TestSprintPreviewLayoutData(t *testing.T) {
Contents: tui.TableData{
[]string{
"TYPE", "KEY", "SUMMARY", "STATUS", "ASSIGNEE", "REPORTER", "PRIORITY", "RESOLUTION",
"CREATED", "UPDATED",
"CREATED", "UPDATED", "LABELS",
},
[]string{
"Bug", "ISSUE-1", "This is an issue", "Done", "Person A", "Person Z", "High", "Fixed",
"2020-12-13 14:05:20", "2020-12-13 14:07:20",
"2020-12-13 14:05:20", "2020-12-13 14:07:20", "urgent",
},
},
},
Expand All @@ -114,15 +116,15 @@ func TestSprintPreviewLayoutData(t *testing.T) {
Contents: tui.TableData{
[]string{
"TYPE", "KEY", "SUMMARY", "STATUS", "ASSIGNEE", "REPORTER", "PRIORITY", "RESOLUTION",
"CREATED", "UPDATED",
"CREATED", "UPDATED", "LABELS",
},
[]string{
"Story", "ISSUE-2", "This is another issue", "Open", "", "Person A", "Normal", "",
"2020-12-13 14:05:20", "2020-12-13 14:07:20",
"2020-12-13 14:05:20", "2020-12-13 14:07:20", "blocked",
},
[]string{
"Bug", "ISSUE-1", "This is an issue", "Done", "Person A", "Person Z", "High", "Fixed",
"2020-12-13 14:05:20", "2020-12-13 14:07:20",
"2020-12-13 14:05:20", "2020-12-13 14:07:20", "urgent",
},
},
},
Expand Down

0 comments on commit 84206aa

Please sign in to comment.