Resolved some of suggestions from copilot
This commit is contained in:
@@ -14,10 +14,15 @@ type KanbanKeyMap struct {
|
||||
MoveColumnRight key.Binding
|
||||
MoveIssueLeft key.Binding
|
||||
MoveIssueRight key.Binding
|
||||
SubmitValidation key.Binding
|
||||
}
|
||||
|
||||
var defaultKanbanKeyMap = KanbanKeyMap{
|
||||
CommonKeyMap: components.DefaultCommonKeyMap(),
|
||||
SubmitValidation: key.NewBinding(
|
||||
key.WithKeys("S"),
|
||||
key.WithHelp("S", "submit validation"),
|
||||
),
|
||||
SwitchToDashboard: key.NewBinding(
|
||||
key.WithKeys("v"),
|
||||
key.WithHelp("v", "dashboard 1"),
|
||||
@@ -44,6 +49,13 @@ func (d *Model) handleKeyMsg(msg tea.KeyMsg) tea.Cmd {
|
||||
var cmd tea.Cmd
|
||||
|
||||
switch {
|
||||
case key.Matches(msg, d.keyMap.SubmitValidation):
|
||||
if d.submitChan != nil {
|
||||
select {
|
||||
case d.submitChan <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
case key.Matches(msg, d.keyMap.Help):
|
||||
d.helpBar.ToggleHelp()
|
||||
case key.Matches(msg, d.keyMap.Quit):
|
||||
|
||||
@@ -55,11 +55,12 @@ type Model struct {
|
||||
typeIssueID string
|
||||
feedbackChan chan models.ValidationFeedback
|
||||
quitChan chan bool
|
||||
submitChan chan<- struct{}
|
||||
currentFeedback models.ValidationFeedback
|
||||
showComplete bool
|
||||
}
|
||||
|
||||
func NewDashboard(app *app.App, feedbackChan chan models.ValidationFeedback, quitChan chan bool) *Model {
|
||||
func NewDashboard(app *app.App, feedbackChan chan models.ValidationFeedback, quitChan chan bool, submitChan chan<- struct{}) *Model {
|
||||
m := &Model{
|
||||
header: components.NewHeader("Kanban Board"),
|
||||
keyMap: defaultKanbanKeyMap,
|
||||
@@ -70,6 +71,7 @@ func NewDashboard(app *app.App, feedbackChan chan models.ValidationFeedback, qui
|
||||
focusOnDetail: false,
|
||||
feedbackChan: feedbackChan,
|
||||
quitChan: quitChan,
|
||||
submitChan: submitChan,
|
||||
}
|
||||
|
||||
allIssues, _ := app.Issues.SearchIssues(context.Background(), "", models.IssueFilter{})
|
||||
|
||||
@@ -14,6 +14,7 @@ type RootModel struct {
|
||||
app *app.App
|
||||
feedbackChan chan models.ValidationFeedback
|
||||
quitChan chan bool
|
||||
submitChan chan<- struct{}
|
||||
lastSize tea.WindowSizeMsg
|
||||
hasSize bool
|
||||
}
|
||||
@@ -25,6 +26,7 @@ func NewRootView(app *app.App, feedbackChan chan models.ValidationFeedback, quit
|
||||
app: app,
|
||||
feedbackChan: feedbackChan,
|
||||
quitChan: quitChan,
|
||||
submitChan: submitChan,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +46,7 @@ func (r *RootModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return r, cmd
|
||||
case msgs.SwitchToDashboardMsg:
|
||||
// switch back to dashboard 1 and apply the last known size.
|
||||
r.currentView = dashboard.NewDashboard(r.app, r.feedbackChan, r.quitChan, r.app.SubmitChan)
|
||||
r.currentView = dashboard.NewDashboard(r.app, r.feedbackChan, r.quitChan, r.submitChan)
|
||||
var cmds []tea.Cmd
|
||||
if r.hasSize {
|
||||
// check if there is a size, and then update it
|
||||
@@ -59,7 +61,7 @@ func (r *RootModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return r, tea.Batch(cmds...)
|
||||
case msgs.SwitchToKanbanBoardMsg:
|
||||
// switch to kanban board and apply the last known size.
|
||||
r.currentView = kanban.NewDashboard(r.app, r.feedbackChan, r.quitChan)
|
||||
r.currentView = kanban.NewDashboard(r.app, r.feedbackChan, r.quitChan, r.submitChan)
|
||||
var cmds []tea.Cmd
|
||||
if r.hasSize {
|
||||
// check if there is a size, and then update it
|
||||
|
||||
Reference in New Issue
Block a user