adding assignee to tui
This commit is contained in:
@@ -49,6 +49,11 @@ type issueTypeUpdatedMsg struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
type issueAssigneeUpdatedMsg struct {
|
||||
IssueID string
|
||||
Err error
|
||||
}
|
||||
|
||||
type selectIssueMsg struct {
|
||||
IssueID string
|
||||
}
|
||||
@@ -116,6 +121,14 @@ func updateIssueTypeCmd(app *app.App, issueID string, issueType models.IssueType
|
||||
}
|
||||
}
|
||||
|
||||
func updateIssueAssigneeCmd(app *app.App, issueID, assignee string) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
updates := map[string]interface{}{"assignee": assignee}
|
||||
err := app.Issues.UpdateIssue(context.Background(), issueID, updates, "tui")
|
||||
return issueAssigneeUpdatedMsg{IssueID: issueID, Err: err}
|
||||
}
|
||||
}
|
||||
|
||||
func createIssueCmd(app *app.App, title string) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
issue := &models.Issue{
|
||||
@@ -209,6 +222,17 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.logAction("tui updated issue type")
|
||||
return m, m.refreshIssueListsAndSelectIssue(msg.IssueID)
|
||||
|
||||
case issueAssigneeUpdatedMsg:
|
||||
m.editingAssignee = false
|
||||
m.assigneeIssueID = ""
|
||||
m.assigneeInput.Blur()
|
||||
if msg.Err != nil {
|
||||
m.logAction("tui failed to update issue assignee")
|
||||
return m, nil
|
||||
}
|
||||
m.logAction("tui updated issue assignee")
|
||||
return m, m.refreshIssueListsAndSelectIssue(msg.IssueID)
|
||||
|
||||
case selectIssueMsg:
|
||||
m.issueList.SelectIssueID(msg.IssueID)
|
||||
m.closedIssueList.SelectIssueID(msg.IssueID)
|
||||
@@ -480,6 +504,27 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
if m.editingAssignee {
|
||||
if msg.String() == "enter" {
|
||||
assignee := m.assigneeInput.Value()
|
||||
issueID := m.assigneeIssueID
|
||||
m.editingAssignee = false
|
||||
m.assigneeIssueID = ""
|
||||
m.assigneeInput.Blur()
|
||||
return m, updateIssueAssigneeCmd(m.app, issueID, assignee)
|
||||
}
|
||||
if msg.String() == "esc" {
|
||||
m.logAction("tui canceled assignee edit")
|
||||
m.editingAssignee = false
|
||||
m.assigneeIssueID = ""
|
||||
m.assigneeInput.Blur()
|
||||
return m, nil
|
||||
}
|
||||
var cmd tea.Cmd
|
||||
m.assigneeInput, cmd = m.assigneeInput.Update(msg)
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
if m.editingDescription {
|
||||
if msg.String() == "ctrl+s" {
|
||||
m.logAction("tui submitted issue description edit")
|
||||
|
||||
Reference in New Issue
Block a user