Skip to content

Commit

Permalink
fix: hide apply key for non-applyable runs
Browse files Browse the repository at this point in the history
  • Loading branch information
leg100 committed May 2, 2024
1 parent 1c752a1 commit f021870
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions internal/tui/run/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.KeyMsg:
switch {
case key.Matches(msg, keys.Common.Apply):
// Only run an apply if run is in the planned state
if m.run.Status != run.Planned {
return m, nil
}
return m, tui.RequestConfirmation(
"Proceed with apply",
func() tea.Msg {
Expand Down Expand Up @@ -165,14 +169,17 @@ func (m model) TabSetInfo() string {
case "apply":
return m.helpers.RunReport(m.run.ApplyReport)
default:
return ""
return activeTab.Title
}
}

func (m model) HelpBindings() (bindings []key.Binding) {
return []key.Binding{
keys.Common.Apply,
keys.Common.Module,
keys.Common.Workspace,
if m.run.Status == run.Planned {
bindings = append(bindings, keys.Common.Apply)
}
bindings = append(bindings,
keys.Common.Workspace,
keys.Common.Module,
)
return
}

0 comments on commit f021870

Please sign in to comment.