remove submission keybind as its now automatic
This commit is contained in:
@@ -2,14 +2,13 @@ package dashboard
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"charm.land/bubbles/v2/key"
|
"charm.land/bubbles/v2/key"
|
||||||
"charm.land/bubbletea/v2"
|
tea "charm.land/bubbletea/v2"
|
||||||
"github.com/LazyBachelor/LazyPM/pkg/tui/components"
|
"github.com/LazyBachelor/LazyPM/pkg/tui/components"
|
||||||
"github.com/LazyBachelor/LazyPM/pkg/tui/msgs"
|
"github.com/LazyBachelor/LazyPM/pkg/tui/msgs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DashboardKeyMap struct {
|
type DashboardKeyMap struct {
|
||||||
components.CommonKeyMap
|
components.CommonKeyMap
|
||||||
SwitchWindow key.Binding
|
|
||||||
SwitchToKanbanBoard key.Binding
|
SwitchToKanbanBoard key.Binding
|
||||||
Quit key.Binding
|
Quit key.Binding
|
||||||
SelectIssue key.Binding
|
SelectIssue key.Binding
|
||||||
@@ -25,15 +24,10 @@ type DashboardKeyMap struct {
|
|||||||
AddComment key.Binding
|
AddComment key.Binding
|
||||||
AddIssue key.Binding
|
AddIssue key.Binding
|
||||||
DeleteIssue key.Binding
|
DeleteIssue key.Binding
|
||||||
SubmitValidation key.Binding
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultDashboardKeyMap = DashboardKeyMap{
|
var defaultDashboardKeyMap = DashboardKeyMap{
|
||||||
CommonKeyMap: components.DefaultCommonKeyMap(),
|
CommonKeyMap: components.DefaultCommonKeyMap(),
|
||||||
SwitchWindow: key.NewBinding(
|
|
||||||
key.WithKeys("tab"),
|
|
||||||
key.WithHelp("tab", "switch window"),
|
|
||||||
),
|
|
||||||
SwitchToKanbanBoard: key.NewBinding(
|
SwitchToKanbanBoard: key.NewBinding(
|
||||||
key.WithKeys("v"),
|
key.WithKeys("v"),
|
||||||
key.WithHelp("v", "switch to kanban")),
|
key.WithHelp("v", "switch to kanban")),
|
||||||
@@ -73,10 +67,6 @@ var defaultDashboardKeyMap = DashboardKeyMap{
|
|||||||
key.WithKeys("x"),
|
key.WithKeys("x"),
|
||||||
key.WithHelp("x", "delete issue"),
|
key.WithHelp("x", "delete issue"),
|
||||||
),
|
),
|
||||||
SubmitValidation: key.NewBinding(
|
|
||||||
key.WithKeys("S"),
|
|
||||||
key.WithHelp("S", "submit validation"),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Model) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
|
func (d *Model) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
|
||||||
@@ -89,16 +79,8 @@ func (d *Model) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
|
|||||||
case key.Matches(msg, d.keyMap.Quit):
|
case key.Matches(msg, d.keyMap.Quit):
|
||||||
d.logAction("tui quit requested")
|
d.logAction("tui quit requested")
|
||||||
return tea.Quit
|
return tea.Quit
|
||||||
case key.Matches(msg, d.keyMap.SwitchWindow):
|
|
||||||
d.ToggleFocusedWindow()
|
|
||||||
case !d.IsInModal() && key.Matches(msg, d.keyMap.SwitchToKanbanBoard):
|
case !d.IsInModal() && key.Matches(msg, d.keyMap.SwitchToKanbanBoard):
|
||||||
return func() tea.Msg { return msgs.SwitchToKanbanBoardMsg{} }
|
return func() tea.Msg { return msgs.SwitchToKanbanBoardMsg{} }
|
||||||
case d.IsFocusedOnList() && key.Matches(msg, d.keyMap.SelectIssue):
|
|
||||||
d.FocusDetail()
|
|
||||||
d.logAction("tui opened issue detail")
|
|
||||||
case d.IsFocusedOnDetail() && (key.Matches(msg, d.keyMap.BackToList) || key.Matches(msg, d.keyMap.SelectIssue)):
|
|
||||||
d.FocusList()
|
|
||||||
d.logAction("tui returned to issue list")
|
|
||||||
case d.IsFocusedOnDetail() && key.Matches(msg, d.keyMap.ScrollUp):
|
case d.IsFocusedOnDetail() && key.Matches(msg, d.keyMap.ScrollUp):
|
||||||
d.issueDetail.ScrollUp(1)
|
d.issueDetail.ScrollUp(1)
|
||||||
d.logAction("tui scrolled issue detail up")
|
d.logAction("tui scrolled issue detail up")
|
||||||
@@ -106,40 +88,40 @@ func (d *Model) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
|
|||||||
d.issueDetail.ScrollDown(1)
|
d.issueDetail.ScrollDown(1)
|
||||||
d.logAction("tui scrolled issue detail down")
|
d.logAction("tui scrolled issue detail down")
|
||||||
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.EditTitle):
|
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.EditTitle):
|
||||||
if selected := d.FocusedIssueList().SelectedItem(); selected.ID != "" {
|
if selected := d.issueList.SelectedItem(); selected.ID != "" {
|
||||||
d.startEditTitle(selected)
|
d.startEditTitle(selected)
|
||||||
cmd = d.titleInput.Focus()
|
cmd = d.titleInput.Focus()
|
||||||
d.logAction("tui started editing issue title")
|
d.logAction("tui started editing issue title")
|
||||||
}
|
}
|
||||||
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.EditDescription):
|
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.EditDescription):
|
||||||
if selected := d.FocusedIssueList().SelectedItem(); selected.ID != "" {
|
if selected := d.issueList.SelectedItem(); selected.ID != "" {
|
||||||
d.startEditDescription(selected)
|
d.startEditDescription(selected)
|
||||||
cmd = d.descriptionInput.Focus()
|
cmd = d.descriptionInput.Focus()
|
||||||
d.logAction("tui started editing issue description")
|
d.logAction("tui started editing issue description")
|
||||||
}
|
}
|
||||||
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.ChangeStatus):
|
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.ChangeStatus):
|
||||||
if selected := d.FocusedIssueList().SelectedItem(); selected.ID != "" {
|
if selected := d.issueList.SelectedItem(); selected.ID != "" {
|
||||||
d.startChooseStatus(selected)
|
d.startChooseStatus(selected)
|
||||||
d.logAction("tui opened status picker")
|
d.logAction("tui opened status picker")
|
||||||
}
|
}
|
||||||
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.ChangePriority):
|
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.ChangePriority):
|
||||||
if selected := d.FocusedIssueList().SelectedItem(); selected.ID != "" {
|
if selected := d.issueList.SelectedItem(); selected.ID != "" {
|
||||||
d.startChoosePriority(selected)
|
d.startChoosePriority(selected)
|
||||||
d.logAction("tui opened priority picker")
|
d.logAction("tui opened priority picker")
|
||||||
}
|
}
|
||||||
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.ChangeType):
|
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.ChangeType):
|
||||||
if selected := d.FocusedIssueList().SelectedItem(); selected.ID != "" {
|
if selected := d.issueList.SelectedItem(); selected.ID != "" {
|
||||||
d.startChooseType(selected)
|
d.startChooseType(selected)
|
||||||
d.logAction("tui opened type picker")
|
d.logAction("tui opened type picker")
|
||||||
}
|
}
|
||||||
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.ChangeAssignee):
|
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.ChangeAssignee):
|
||||||
if selected := d.FocusedIssueList().SelectedItem(); selected.ID != "" {
|
if selected := d.issueList.SelectedItem(); selected.ID != "" {
|
||||||
d.startEditAssignee(selected)
|
d.startEditAssignee(selected)
|
||||||
cmd = d.assigneeInput.Focus()
|
cmd = d.assigneeInput.Focus()
|
||||||
d.logAction("tui started editing assignee")
|
d.logAction("tui started editing assignee")
|
||||||
}
|
}
|
||||||
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.AddComment):
|
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.AddComment):
|
||||||
if selected := d.FocusedIssueList().SelectedItem(); selected.ID != "" {
|
if selected := d.issueList.SelectedItem(); selected.ID != "" {
|
||||||
d.startAddComment(selected)
|
d.startAddComment(selected)
|
||||||
cmd = d.commentInput.Focus()
|
cmd = d.commentInput.Focus()
|
||||||
}
|
}
|
||||||
@@ -148,19 +130,11 @@ func (d *Model) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
|
|||||||
cmd = d.createTitleInput.Focus()
|
cmd = d.createTitleInput.Focus()
|
||||||
d.logAction("tui started creating issue")
|
d.logAction("tui started creating issue")
|
||||||
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.DeleteIssue):
|
case !d.IsInModal() && !d.addingComment && key.Matches(msg, d.keyMap.DeleteIssue):
|
||||||
fl := d.FocusedIssueList()
|
fl := d.issueList
|
||||||
if selected := fl.SelectedItem(); selected.ID != "" {
|
if selected := fl.SelectedItem(); selected.ID != "" {
|
||||||
d.startConfirmDelete(selected.ID, fl.Index())
|
d.startConfirmDelete(selected.ID, fl.Index())
|
||||||
d.logAction("tui opened delete confirmation")
|
d.logAction("tui opened delete confirmation")
|
||||||
}
|
}
|
||||||
case key.Matches(msg, d.keyMap.SubmitValidation):
|
|
||||||
if d.submitChan != nil {
|
|
||||||
select {
|
|
||||||
case d.submitChan <- struct{}{}:
|
|
||||||
d.logAction("tui submitted validation")
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
Reference in New Issue
Block a user