Skip to content

Commit

Permalink
add view option
Browse files Browse the repository at this point in the history
Signed-off-by: Shantanu <joshishantanu4@gmail.com>
  • Loading branch information
joshi4 committed Jan 24, 2025
1 parent ef0d17b commit 79a12c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cmd/component/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ var EditOnlineBinding = HelpBinding{
Binding: key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "edit online")),
}

var ViewAttachedLinksBinding = HelpBinding{
Binding: key.NewBinding(key.WithKeys("v"), key.WithHelp("v", "view attached links")),
}

func NewHelpBinding(k, description string) HelpBinding {
return HelpBinding{
Binding: key.NewBinding(key.WithKeys(k), key.WithHelp(k, description)),
Expand Down Expand Up @@ -140,6 +144,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, OpenBrowser(m.url, NopMsg{}, NopMsg{})
}

// Handle the "v" key Binding
if msg.String() == "v" && m.list.FilterState() == list.Unfiltered && slice.Has(m.helpKeys, "v") {
return m, OpenBrowser(m.url, NopMsg{}, NopMsg{})
}

if msg.String() == "p" && m.list.FilterState() == list.Unfiltered && slice.Has(m.helpKeys, "p") {
return m, func() tea.Msg { return RefinePromptMsg{} }
}
Expand Down
2 changes: 1 addition & 1 deletion export/savvy.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func newDisplayCommandsModel(runbook *component.Runbook) (*displayCommands, erro
}

listItems := toItems(runbook.Steps)
l := list.NewModel(listItems, runbook.Title, runbook.URL, list.EditOnlineBinding)
l := list.NewModel(listItems, runbook.Title, runbook.URL, list.EditOnlineBinding, list.ViewAttachedLinksBinding)
return &displayCommands{l: l}, nil
}

Expand Down

0 comments on commit 79a12c2

Please sign in to comment.