Skip to content

Commit

Permalink
feat: show issue summary when tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
dhth committed Jun 4, 2024
1 parent 5461305 commit 3499723
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
5 changes: 5 additions & 0 deletions cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,10 @@ END;
`); err != nil {
return nil, err
}

_, _ = db.Exec(`
DELETE from issue_log
WHERE end_ts < DATE('now', '-60 days');
`)
return db, nil
}
1 change: 1 addition & 0 deletions ui/initial.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func InitialModel(db *sql.DB, jiraClient *jira.Client, jql string, jiraTimeDelta
jiraClient: jiraClient,
jql: jql,
issueList: list.New(stackItems, itemDel, listWidth, 0),
issueMap: make(map[string]*Issue),
worklogList: list.New(worklogListItems, itemDel, listWidth, 0),
syncedWorklogList: list.New(syncedWorklogListItems, itemDel, listWidth, 0),
jiraTimeDeltaMins: jiraTimeDeltaMins,
Expand Down
4 changes: 3 additions & 1 deletion ui/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type model struct {
jiraClient *jira.Client
jql string
issueList list.Model
issueMap map[string]*Issue
issuesFetched bool
worklogList list.Model
syncedWorklogList list.Model
syncedWLEntriesFetched bool
Expand All @@ -83,7 +85,7 @@ type model struct {

func (m model) Init() tea.Cmd {
return tea.Batch(
hideHelp(time.Second*15),
hideHelp(time.Minute*1),
fetchJIRAIssues(m.jiraClient, m.jql),
fetchActiveStatus(m.db, 0),
)
Expand Down
34 changes: 23 additions & 11 deletions ui/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
)

const (
ActiveIssueColor = "#d3869b"
IssueStatusColor = "#665c54"
AggTimeSpentColor = "#928374"
helpMsgColor = "#83a598"
helpViewTitleColor = "#83a598"
helpHeaderColor = "#83a598"
helpSectionColor = "#fabd2f"
trackingColor = "#fabd2f"
ActiveIssueKeyColor = "#d3869b"
ActiveIssueSummaryColor = "#8ec07c"
IssueStatusColor = "#665c54"
AggTimeSpentColor = "#928374"
helpMsgColor = "#83a598"
helpViewTitleColor = "#83a598"
helpHeaderColor = "#83a598"
helpSectionColor = "#fabd2f"
)

var (
Expand All @@ -21,7 +23,8 @@ var (
PaddingRight(1).
Foreground(lipgloss.Color("#282828"))

helpMsgStyle = baseStyle.Copy().
helpMsgStyle = lipgloss.NewStyle().
PaddingLeft(1).
Bold(true).
Foreground(lipgloss.Color("#83a598"))

Expand Down Expand Up @@ -59,9 +62,18 @@ var (
formFieldNameStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#504945"))

activeIssueMsgStyle = baseStyle.Copy().
Bold(true).
Foreground(lipgloss.Color(ActiveIssueColor))
trackingStyle = lipgloss.NewStyle().
PaddingLeft(2).
Bold(true).
Foreground(lipgloss.Color(trackingColor))

activeIssueKeyMsgStyle = trackingStyle.Copy().
PaddingLeft(1).
Foreground(lipgloss.Color(ActiveIssueKeyColor))

activeIssueSummaryMsgStyle = trackingStyle.Copy().
PaddingLeft(1).
Foreground(lipgloss.Color(ActiveIssueSummaryColor))

issueTypeColors = []string{"#928374", "#d3869b", "#fabd2f", "#8ec07c", "#83a598", "#b8bb26", "#fe8019"}

Expand Down
2 changes: 2 additions & 0 deletions ui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
issues := make([]list.Item, 0, len(msg.issues))
for _, issue := range msg.issues {
issues = append(issues, issue)
m.issueMap[issue.IssueKey] = &issue
}
m.issueList.SetItems(issues)
m.issueList.Title = "Issues"
m.issuesFetched = true
}
case InsertEntryMsg:
if msg.err != nil {
Expand Down
13 changes: 11 additions & 2 deletions ui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ func (m model) View() string {
errorMsg = "error: " + Trim(m.errorMessage, 120)
}
var activeMsg string
if m.activeIssue != "" {
activeMsg = activeIssueMsgStyle.Render("tracking: " + m.activeIssue + " ⚡️")
if m.issuesFetched && m.activeIssue != "" {
var issueSummaryMsg string
issue, ok := m.issueMap[m.activeIssue]
if ok {
issueSummaryMsg = fmt.Sprintf("(%s)", Trim(issue.Summary, 50))
}
activeMsg = fmt.Sprintf("%s%s%s ⚡️",
trackingStyle.Render("tracking:"),
activeIssueKeyMsgStyle.Render(m.activeIssue),
activeIssueSummaryMsgStyle.Render(issueSummaryMsg),
)
}

switch m.activeView {
Expand Down

0 comments on commit 3499723

Please sign in to comment.