Merge pull request #73 from LazyBachelor/LPM-138
LPM-138 Refactor Tui with composable modals and use canvas Refactors the TUI (dashboard + kanban) to use a shared, composable modal system with canvas-based overlay rendering, while consolidating styling into internal/style and expanding issue interactions (e.g., comments). Changes: Introduces a new pkg/tui/modal system (manager/stack + multiple modal types) and overlays modals using Lipgloss compositor layers. Refactors dashboard/kanban views and input handling to use the modal manager + focus manager instead of per-modal boolean state. Consolidates TUI styling by moving from pkg/tui/styles to internal/style and updates components to use the new style package; adds a shared footer renderer.
This commit is contained in:
@@ -2,33 +2,18 @@ package dashboard
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/user"
|
||||
"strconv"
|
||||
|
||||
"charm.land/bubbles/v2/list"
|
||||
tea "charm.land/bubbletea/v2"
|
||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||
"github.com/LazyBachelor/LazyPM/internal/utils/user"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/tui/components"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/tui/modal"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/tui/msgs"
|
||||
)
|
||||
|
||||
func defaultCommentAuthor() string {
|
||||
if u, err := user.Current(); err == nil && u.Username != "" {
|
||||
return u.Username
|
||||
}
|
||||
if s := os.Getenv("USER"); s != "" {
|
||||
return s
|
||||
}
|
||||
if s := os.Getenv("USERNAME"); s != "" {
|
||||
return s
|
||||
}
|
||||
return "user"
|
||||
}
|
||||
|
||||
func (m *Model) refreshIssueListsAndSelectIssue(issueID string) tea.Cmd {
|
||||
/* update handler for issueTitleUpdatedMsg, issueDescriptionUpdatedMsg, and issueStatusUpdatedMsg to avoid using nearly identical code for refreshing the issue lists and updating the detail view
|
||||
Fetch all issues, update both lists, set the detail view for the given issue, and return a command to select that issue. Returns nil if fetch fails.
|
||||
*/
|
||||
allIssues, err := m.app.Issues.SearchIssues(context.Background(), "", models.IssueFilter{})
|
||||
if err != nil {
|
||||
return nil
|
||||
@@ -40,24 +25,228 @@ func (m *Model) refreshIssueListsAndSelectIssue(issueID string) tea.Cmd {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return tea.Sequence(setItemsCmd, func() tea.Msg { return msgs.SelectIssueMsg{IssueID: issueID} })
|
||||
}
|
||||
|
||||
// refreshAndSubmit refreshes the issue lists and submits validation.
|
||||
// This is a wrapper that should be used after any successful user action.
|
||||
func (m *Model) refreshAndSubmit(issueID string) tea.Cmd {
|
||||
refreshCmd := m.refreshIssueListsAndSelectIssue(issueID)
|
||||
m.submitValidation()
|
||||
return refreshCmd
|
||||
}
|
||||
|
||||
func (m *Model) startEditTitle(selected ListIssue) tea.Cmd {
|
||||
m.currentIssueID = selected.ID
|
||||
titleModal := m.modalManager.GetTextInputModal(modal.ModalEditTitle)
|
||||
if titleModal != nil {
|
||||
titleModal.SetValue(selected.Issue.Title)
|
||||
titleModal.CursorEnd()
|
||||
return m.modalManager.ShowModal(modal.ModalEditTitle)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Model) startEditDescription(selected ListIssue) tea.Cmd {
|
||||
m.currentIssueID = selected.ID
|
||||
descModal := m.modalManager.GetTextAreaModal(modal.ModalEditDescription)
|
||||
if descModal != nil {
|
||||
descModal.SetValue(selected.Issue.Description)
|
||||
return m.modalManager.ShowModal(modal.ModalEditDescription)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Model) startCreateIssue() tea.Cmd {
|
||||
createModal := m.modalManager.GetTextInputModal(modal.ModalCreateIssue)
|
||||
if createModal != nil {
|
||||
createModal.Reset()
|
||||
return m.modalManager.ShowModal(modal.ModalCreateIssue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Model) startConfirmDelete(issueID string, index int) tea.Cmd {
|
||||
m.currentIssueID = issueID
|
||||
m.deleteIndex = index
|
||||
deleteModal := m.modalManager.GetConfirmModal(modal.ModalConfirmDelete)
|
||||
if deleteModal != nil {
|
||||
return m.modalManager.ShowModal(modal.ModalConfirmDelete)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Model) startChooseStatus(selected ListIssue) tea.Cmd {
|
||||
m.currentIssueID = selected.ID
|
||||
return m.modalManager.ShowModal(modal.ModalSelectStatus)
|
||||
}
|
||||
|
||||
func (m *Model) startChoosePriority(selected ListIssue) tea.Cmd {
|
||||
m.currentIssueID = selected.ID
|
||||
return m.modalManager.ShowModal(modal.ModalSelectPriority)
|
||||
}
|
||||
|
||||
func (m *Model) startChooseType(selected ListIssue) tea.Cmd {
|
||||
m.currentIssueID = selected.ID
|
||||
return m.modalManager.ShowModal(modal.ModalSelectType)
|
||||
}
|
||||
|
||||
func (m *Model) startEditAssignee(selected ListIssue) tea.Cmd {
|
||||
m.currentIssueID = selected.ID
|
||||
assigneeModal := m.modalManager.GetTextInputModal(modal.ModalEditAssignee)
|
||||
if assigneeModal != nil {
|
||||
assigneeModal.SetValue(selected.Assignee)
|
||||
assigneeModal.CursorEnd()
|
||||
return m.modalManager.ShowModal(modal.ModalEditAssignee)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Model) startAddComment(selected ListIssue) tea.Cmd {
|
||||
m.currentIssueID = selected.ID
|
||||
commentModal := m.modalManager.GetTextAreaModal(modal.ModalAddComment)
|
||||
if commentModal != nil {
|
||||
commentModal.Reset()
|
||||
return m.modalManager.ShowModal(modal.ModalAddComment)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// handleModalCompleted handles all modal completion messages
|
||||
func (m *Model) handleModalCompleted(msg modal.ModalCompletedMsg) tea.Cmd {
|
||||
switch msg.ModalID {
|
||||
case modal.ModalEditTitle:
|
||||
if r, ok := msg.Value.(modal.TextInputResult); ok {
|
||||
m.logAction("tui submitted issue title edit")
|
||||
cmd := msgs.UpdateIssueTitleCmd(m.app, m.currentIssueID, r.Value)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalCreateIssue:
|
||||
if r, ok := msg.Value.(modal.TextInputResult); ok && r.Value != "" {
|
||||
m.logAction("tui submitted new issue")
|
||||
cmd := msgs.CreateIssueCmd(m.app, r.Value)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalEditAssignee:
|
||||
if r, ok := msg.Value.(modal.TextInputResult); ok {
|
||||
m.logAction("tui submitted assignee edit")
|
||||
cmd := msgs.UpdateIssueAssigneeCmd(m.app, m.currentIssueID, r.Value)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalEditDescription:
|
||||
if r, ok := msg.Value.(modal.TextAreaResult); ok {
|
||||
m.logAction("tui submitted issue description edit")
|
||||
cmd := msgs.UpdateIssueDescriptionCmd(m.app, m.currentIssueID, r.Value)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalAddComment:
|
||||
if r, ok := msg.Value.(modal.TextAreaResult); ok && r.Value != "" {
|
||||
cmd := msgs.AddIssueCommentCmd(m.app, m.currentIssueID, user.GetOsUsername(), r.Value)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalCloseReason:
|
||||
if r, ok := msg.Value.(modal.TextAreaResult); ok && r.Value != "" {
|
||||
m.logAction("tui submitted custom close reason")
|
||||
cmd := msgs.CloseIssueCmd(m.app, m.currentIssueID, r.Value)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalConfirmDelete:
|
||||
if r, ok := msg.Value.(modal.ConfirmResult); ok && r.Confirmed {
|
||||
m.logAction("tui confirmed issue deletion")
|
||||
idx := m.deleteIndex
|
||||
issueID := m.currentIssueID
|
||||
m.deleteIndex = -1
|
||||
m.currentIssueID = ""
|
||||
cmd := msgs.DeleteIssueCmd(m.app, issueID, idx)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalSelectStatus:
|
||||
if r, ok := msg.Value.(modal.SelectResult); ok {
|
||||
m.logAction("tui selected issue status")
|
||||
if r.SelectedValue == "closing" {
|
||||
return m.modalManager.ShowModal(modal.ModalSelectCloseReason)
|
||||
}
|
||||
cmd := msgs.UpdateIssueStatusCmd(m.app, m.currentIssueID, r.SelectedValue)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalSelectCloseReason:
|
||||
if r, ok := msg.Value.(modal.SelectResult); ok {
|
||||
if r.SelectedValue == "other" {
|
||||
return m.modalManager.ShowModal(modal.ModalCloseReason)
|
||||
}
|
||||
cmd := msgs.CloseIssueCmd(m.app, m.currentIssueID, r.SelectedValue)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalSelectPriority:
|
||||
if r, ok := msg.Value.(modal.SelectResult); ok {
|
||||
m.logAction("tui selected issue priority")
|
||||
priority, _ := strconv.Atoi(r.SelectedValue)
|
||||
cmd := msgs.UpdateIssuePriorityCmd(m.app, m.currentIssueID, priority)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
case modal.ModalSelectType:
|
||||
if r, ok := msg.Value.(modal.SelectResult); ok {
|
||||
m.logAction("tui selected issue type")
|
||||
issueType := models.IssueType(r.SelectedValue)
|
||||
cmd := msgs.UpdateIssueTypeCmd(m.app, m.currentIssueID, issueType)
|
||||
return func() tea.Msg { return cmd() }
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// handleModalCancelled handles all modal cancellation messages
|
||||
func (m *Model) handleModalCancelled(msg modal.ModalCancelledMsg) {
|
||||
switch msg.ModalID {
|
||||
case modal.ModalEditTitle:
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled issue title edit")
|
||||
case modal.ModalCreateIssue:
|
||||
m.logAction("tui canceled issue creation")
|
||||
case modal.ModalEditAssignee:
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled assignee edit")
|
||||
case modal.ModalEditDescription:
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled issue description edit")
|
||||
case modal.ModalAddComment:
|
||||
m.currentIssueID = ""
|
||||
case modal.ModalCloseReason:
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled close reason")
|
||||
case modal.ModalConfirmDelete:
|
||||
m.deleteIndex = -1
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled issue deletion")
|
||||
case modal.ModalSelectStatus:
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled status picker")
|
||||
case modal.ModalSelectCloseReason:
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled close reason")
|
||||
case modal.ModalSelectPriority:
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled priority picker")
|
||||
case modal.ModalSelectType:
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled type picker")
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
if cmd, handled := m.modalManager.Update(msg); handled {
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case modal.ModalCompletedMsg:
|
||||
return m, m.handleModalCompleted(msg)
|
||||
|
||||
case modal.ModalCancelledMsg:
|
||||
m.handleModalCancelled(msg)
|
||||
return m, nil
|
||||
|
||||
case msgs.TitleUpdatedMsg:
|
||||
m.editingTitle = false
|
||||
m.editingIssueID = ""
|
||||
m.titleInput.Blur()
|
||||
m.modalManager.GetTextInputModal(modal.ModalEditTitle).Reset()
|
||||
m.currentIssueID = ""
|
||||
if msg.Err != nil {
|
||||
m.logAction("tui failed to update issue title")
|
||||
return m, nil
|
||||
@@ -66,9 +255,8 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, m.refreshAndSubmit(msg.IssueID)
|
||||
|
||||
case msgs.DescriptionUpdatedMsg:
|
||||
m.editingDescription = false
|
||||
m.editingDescIssueID = ""
|
||||
m.descriptionInput.Blur()
|
||||
m.modalManager.GetTextAreaModal(modal.ModalEditDescription).Reset()
|
||||
m.currentIssueID = ""
|
||||
if msg.Err != nil {
|
||||
m.logAction("tui failed to update issue description")
|
||||
return m, nil
|
||||
@@ -77,8 +265,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, m.refreshAndSubmit(msg.IssueID)
|
||||
|
||||
case msgs.StatusUpdatedMsg:
|
||||
m.choosingStatus = false
|
||||
m.statusIssueID = ""
|
||||
m.currentIssueID = ""
|
||||
if msg.Err != nil {
|
||||
m.logAction("tui failed to update issue status")
|
||||
return m, nil
|
||||
@@ -87,8 +274,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, m.refreshAndSubmit(msg.IssueID)
|
||||
|
||||
case msgs.PriorityUpdatedMsg:
|
||||
m.choosingPriority = false
|
||||
m.priorityIssueID = ""
|
||||
m.currentIssueID = ""
|
||||
if msg.Err != nil {
|
||||
m.logAction("tui failed to update issue priority")
|
||||
return m, nil
|
||||
@@ -97,8 +283,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, m.refreshAndSubmit(msg.IssueID)
|
||||
|
||||
case msgs.TypeUpdatedMsg:
|
||||
m.choosingType = false
|
||||
m.typeIssueID = ""
|
||||
m.currentIssueID = ""
|
||||
if msg.Err != nil {
|
||||
m.logAction("tui failed to update issue type")
|
||||
return m, nil
|
||||
@@ -107,9 +292,8 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, m.refreshAndSubmit(msg.IssueID)
|
||||
|
||||
case msgs.AssigneeUpdatedMsg:
|
||||
m.editingAssignee = false
|
||||
m.assigneeIssueID = ""
|
||||
m.assigneeInput.Blur()
|
||||
m.modalManager.GetTextInputModal(modal.ModalEditAssignee).Reset()
|
||||
m.currentIssueID = ""
|
||||
if msg.Err != nil {
|
||||
m.logAction("tui failed to update issue assignee")
|
||||
return m, nil
|
||||
@@ -123,9 +307,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
|
||||
case msgs.CreatedMsg:
|
||||
m.creatingIssue = false
|
||||
m.createTitleInput.Blur()
|
||||
m.createTitleInput.Reset()
|
||||
m.modalManager.GetTextInputModal(modal.ModalCreateIssue).Reset()
|
||||
if msg.Err != nil || msg.Issue == nil {
|
||||
m.logAction("tui failed to create issue")
|
||||
return m, nil
|
||||
@@ -136,11 +318,9 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
setItemsCmd := m.issueList.SetIssues(components.SortedIssues(allIssues))
|
||||
|
||||
// Determine the created issue from the refreshed list to ensure all fields (like ID) are populated.
|
||||
selectedIssue := msg.Issue
|
||||
if selectedIssue.ID == "" {
|
||||
for _, issue := range allIssues {
|
||||
// Prefer an issue that matches the created issue's title when ID is not yet known.
|
||||
if issue.Title == msg.Issue.Title {
|
||||
selectedIssue = issue
|
||||
break
|
||||
@@ -152,19 +332,19 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.logAction("tui created issue")
|
||||
m.submitValidation()
|
||||
return m, tea.Sequence(setItemsCmd, func() tea.Msg { return msgs.SelectIssueMsg{IssueID: selectedIssue.ID} })
|
||||
|
||||
case msgs.IssueCommentAddedMsg:
|
||||
m.addingComment = false
|
||||
m.commentIssueID = ""
|
||||
m.commentInput.Blur()
|
||||
m.commentInput.Reset()
|
||||
m.modalManager.GetTextAreaModal(modal.ModalAddComment).Reset()
|
||||
m.currentIssueID = ""
|
||||
if msg.Err != nil {
|
||||
return m, nil
|
||||
}
|
||||
m.submitValidation()
|
||||
return m, m.refreshIssueListsAndSelectIssue(msg.IssueID)
|
||||
|
||||
case msgs.DeletedMsg:
|
||||
m.confirmingDelete = false
|
||||
m.deleteConfirmID = ""
|
||||
m.deleteIndex = -1
|
||||
m.currentIssueID = ""
|
||||
if msg.Err != nil {
|
||||
m.logAction("tui failed to delete issue")
|
||||
return m, nil
|
||||
@@ -174,297 +354,11 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, m.refreshIssueListsAndSelectIssue(msg.IssueID)
|
||||
|
||||
case tea.KeyPressMsg:
|
||||
if m.confirmingDelete {
|
||||
switch msg.String() {
|
||||
case "y", "Y":
|
||||
m.logAction("tui confirmed issue deletion")
|
||||
issueID := m.deleteConfirmID
|
||||
idx := m.deleteConfirmIndex
|
||||
m.confirmingDelete = false
|
||||
m.deleteConfirmID = ""
|
||||
return m, msgs.DeleteIssueCmd(m.app, issueID, idx)
|
||||
case "n", "N", "esc":
|
||||
m.logAction("tui canceled issue deletion")
|
||||
m.confirmingDelete = false
|
||||
m.deleteConfirmID = ""
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
|
||||
if m.choosingStatus {
|
||||
switch msg.String() {
|
||||
case "o":
|
||||
m.logAction("tui selected issue status open")
|
||||
issueID := m.statusIssueID
|
||||
m.choosingStatus = false
|
||||
m.statusIssueID = ""
|
||||
return m, msgs.UpdateIssueStatusCmd(m.app, issueID, string(models.StatusOpen))
|
||||
case "i":
|
||||
m.logAction("tui selected issue status in_progress")
|
||||
issueID := m.statusIssueID
|
||||
m.choosingStatus = false
|
||||
m.statusIssueID = ""
|
||||
return m, msgs.UpdateIssueStatusCmd(m.app, issueID, string(models.StatusInProgress))
|
||||
case "b":
|
||||
m.logAction("tui selected issue status blocked")
|
||||
issueID := m.statusIssueID
|
||||
m.choosingStatus = false
|
||||
m.statusIssueID = ""
|
||||
return m, msgs.UpdateIssueStatusCmd(m.app, issueID, string(models.StatusBlocked))
|
||||
case "r":
|
||||
m.logAction("tui selected issue status ready_to_sprint")
|
||||
issueID := m.statusIssueID
|
||||
m.choosingStatus = false
|
||||
m.statusIssueID = ""
|
||||
return m, msgs.UpdateIssueStatusCmd(m.app, issueID, string(models.StatusReadyToSprint))
|
||||
case "c":
|
||||
m.logAction("tui selected issue status closing")
|
||||
issueID := m.statusIssueID
|
||||
m.choosingStatus = false
|
||||
m.statusIssueID = ""
|
||||
m.choosingCloseReason = true
|
||||
m.closeReasonIssueID = issueID
|
||||
return m, nil
|
||||
case "esc":
|
||||
m.logAction("tui canceled status picker")
|
||||
m.choosingStatus = false
|
||||
m.statusIssueID = ""
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
|
||||
if m.choosingCloseReason {
|
||||
var reason string
|
||||
switch msg.String() {
|
||||
case "d":
|
||||
m.logAction("tui selected close reason done")
|
||||
reason = "Done"
|
||||
case "u":
|
||||
m.logAction("tui selected close reason duplicate issue")
|
||||
reason = "Duplicate issue"
|
||||
case "w":
|
||||
m.logAction("tui selected close reason won't fix")
|
||||
reason = "Won't fix"
|
||||
case "o":
|
||||
m.logAction("tui selected close reason obsolete")
|
||||
reason = "Obsolete"
|
||||
case "h":
|
||||
m.logAction("tui selected close reason other")
|
||||
m.choosingCloseReason = false
|
||||
m.closingOtherReason = true
|
||||
m.closeReasonInput.SetValue("")
|
||||
m.closeReasonInput.Focus()
|
||||
return m, nil
|
||||
case "esc":
|
||||
m.logAction("tui canceled close reason picker")
|
||||
m.choosingCloseReason = false
|
||||
m.closeReasonIssueID = ""
|
||||
return m, nil
|
||||
}
|
||||
|
||||
if reason != "" {
|
||||
issueID := m.closeReasonIssueID
|
||||
m.choosingCloseReason = false
|
||||
m.closeReasonIssueID = ""
|
||||
return m, msgs.CloseIssueCmd(m.app, issueID, reason)
|
||||
}
|
||||
}
|
||||
|
||||
if m.closingOtherReason {
|
||||
switch msg.String() {
|
||||
case "enter", "ctrl+s":
|
||||
reason := m.closeReasonInput.Value()
|
||||
if reason != "" {
|
||||
m.logAction("tui submitted custom close reason")
|
||||
issueID := m.closeReasonIssueID
|
||||
m.closingOtherReason = false
|
||||
m.closeReasonIssueID = ""
|
||||
m.closeReasonInput.Blur()
|
||||
return m, msgs.CloseIssueCmd(m.app, issueID, reason)
|
||||
}
|
||||
case "esc":
|
||||
m.logAction("tui canceled custom close reason")
|
||||
m.closingOtherReason = false
|
||||
m.closeReasonIssueID = ""
|
||||
m.closeReasonInput.Blur()
|
||||
return m, nil
|
||||
}
|
||||
var cmd tea.Cmd
|
||||
m.closeReasonInput, cmd = m.closeReasonInput.Update(msg)
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
if m.choosingPriority {
|
||||
switch msg.String() {
|
||||
case "0", "1", "2", "3", "4":
|
||||
m.logAction("tui selected issue priority")
|
||||
issueID := m.priorityIssueID
|
||||
priority := int(msg.String()[0] - '0')
|
||||
m.choosingPriority = false
|
||||
m.priorityIssueID = ""
|
||||
return m, msgs.UpdateIssuePriorityCmd(m.app, issueID, priority)
|
||||
case "esc":
|
||||
m.logAction("tui canceled priority picker")
|
||||
m.choosingPriority = false
|
||||
m.priorityIssueID = ""
|
||||
return m, nil
|
||||
default:
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
|
||||
if m.choosingType {
|
||||
switch msg.String() {
|
||||
case "b":
|
||||
m.logAction("tui selected issue type bug")
|
||||
issueID := m.typeIssueID
|
||||
m.choosingType = false
|
||||
m.typeIssueID = ""
|
||||
return m, msgs.UpdateIssueTypeCmd(m.app, issueID, models.TypeBug)
|
||||
case "f":
|
||||
m.logAction("tui selected issue type feature")
|
||||
issueID := m.typeIssueID
|
||||
m.choosingType = false
|
||||
m.typeIssueID = ""
|
||||
return m, msgs.UpdateIssueTypeCmd(m.app, issueID, models.TypeFeature)
|
||||
case "t":
|
||||
m.logAction("tui selected issue type task")
|
||||
issueID := m.typeIssueID
|
||||
m.choosingType = false
|
||||
m.typeIssueID = ""
|
||||
return m, msgs.UpdateIssueTypeCmd(m.app, issueID, models.TypeTask)
|
||||
case "e":
|
||||
m.logAction("tui selected issue type epic")
|
||||
issueID := m.typeIssueID
|
||||
m.choosingType = false
|
||||
m.typeIssueID = ""
|
||||
return m, msgs.UpdateIssueTypeCmd(m.app, issueID, models.TypeEpic)
|
||||
case "c":
|
||||
m.logAction("tui selected issue type chore")
|
||||
issueID := m.typeIssueID
|
||||
m.choosingType = false
|
||||
m.typeIssueID = ""
|
||||
return m, msgs.UpdateIssueTypeCmd(m.app, issueID, models.TypeChore)
|
||||
case "esc":
|
||||
m.logAction("tui canceled type picker")
|
||||
m.choosingType = false
|
||||
m.typeIssueID = ""
|
||||
return m, nil
|
||||
default:
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
|
||||
if m.creatingIssue {
|
||||
if msg.String() == "enter" {
|
||||
title := m.createTitleInput.Value()
|
||||
if title != "" {
|
||||
m.logAction("tui submitted new issue")
|
||||
return m, msgs.CreateIssueCmd(m.app, title)
|
||||
}
|
||||
}
|
||||
if msg.String() == "esc" {
|
||||
m.logAction("tui canceled issue creation")
|
||||
m.creatingIssue = false
|
||||
m.createTitleInput.Blur()
|
||||
m.createTitleInput.Reset()
|
||||
return m, nil
|
||||
}
|
||||
var cmd tea.Cmd
|
||||
m.createTitleInput, cmd = m.createTitleInput.Update(msg)
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
if m.editingAssignee {
|
||||
if msg.String() == "enter" {
|
||||
assignee := m.assigneeInput.Value()
|
||||
m.logAction("tui submitted assignee edit")
|
||||
return m, msgs.UpdateIssueAssigneeCmd(m.app, m.assigneeIssueID, 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.editingTitle {
|
||||
if msg.String() == "enter" {
|
||||
newTitle := m.titleInput.Value()
|
||||
if newTitle != "" {
|
||||
m.logAction("tui submitted issue title edit")
|
||||
return m, msgs.UpdateIssueTitleCmd(m.app, m.editingIssueID, newTitle)
|
||||
}
|
||||
}
|
||||
if msg.String() == "esc" {
|
||||
m.logAction("tui canceled issue title edit")
|
||||
m.editingTitle = false
|
||||
m.editingIssueID = ""
|
||||
m.titleInput.Blur()
|
||||
return m, nil
|
||||
}
|
||||
var cmd tea.Cmd
|
||||
m.titleInput, cmd = m.titleInput.Update(msg)
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
if m.addingComment {
|
||||
if msg.String() == "ctrl+s" || msg.String() == "enter" {
|
||||
text := m.commentInput.Value()
|
||||
if text != "" {
|
||||
issueID := m.commentIssueID
|
||||
m.addingComment = false
|
||||
m.commentIssueID = ""
|
||||
m.commentInput.Blur()
|
||||
m.commentInput.Reset()
|
||||
return m, msgs.AddIssueCommentCmd(m.app, issueID, defaultCommentAuthor(), text)
|
||||
}
|
||||
}
|
||||
if msg.String() == "esc" {
|
||||
m.addingComment = false
|
||||
m.commentIssueID = ""
|
||||
m.commentInput.Blur()
|
||||
m.commentInput.Reset()
|
||||
return m, nil
|
||||
}
|
||||
var cmd tea.Cmd
|
||||
m.commentInput, cmd = m.commentInput.Update(msg)
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
if m.editingDescription {
|
||||
if msg.String() == "ctrl+s" {
|
||||
m.logAction("tui submitted issue description edit")
|
||||
issueID := m.editingDescIssueID
|
||||
newDesc := m.descriptionInput.Value()
|
||||
m.editingDescription = false
|
||||
m.editingDescIssueID = ""
|
||||
m.descriptionInput.Blur()
|
||||
return m, msgs.UpdateIssueDescriptionCmd(m.app, issueID, newDesc)
|
||||
}
|
||||
if msg.String() == "esc" {
|
||||
m.logAction("tui canceled issue description edit")
|
||||
m.editingDescription = false
|
||||
m.editingDescIssueID = ""
|
||||
m.descriptionInput.Blur()
|
||||
return m, nil
|
||||
}
|
||||
var cmd tea.Cmd
|
||||
m.descriptionInput, cmd = m.descriptionInput.Update(msg)
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
if m.issueList.FilterState() == list.Filtering {
|
||||
cmd, _ := m.issueList.Update(msg)
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
// On main dashboard, ESC does nothing; only q quits; like in lazybeads.
|
||||
if msg.String() == "esc" {
|
||||
return m, nil
|
||||
}
|
||||
@@ -473,6 +367,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
if cmd != nil {
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
case components.ValidationFeedbackMsg:
|
||||
m.currentFeedback = msg.Feedback
|
||||
if msg.Feedback.Success {
|
||||
@@ -484,10 +379,11 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case tea.WindowSizeMsg:
|
||||
m.width = msg.Width
|
||||
m.height = msg.Height
|
||||
m.modalManager.SetSize(msg.Width, msg.Height)
|
||||
return m, nil
|
||||
}
|
||||
|
||||
if m.focusedWindow == 0 {
|
||||
if m.focusManager.IsFocused(modal.FocusList) {
|
||||
cmd, changed := m.issueList.Update(msg)
|
||||
if changed {
|
||||
if selected := m.issueList.SelectedItem(); selected.ID != "" {
|
||||
|
||||
Reference in New Issue
Block a user