From 85110381ef0c79d78cb70bc2904849243c1bdf46 Mon Sep 17 00:00:00 2001 From: Toby Padilla Date: Thu, 10 Feb 2022 16:46:56 -0600 Subject: [PATCH] Simplify help, disable navigation options on config repo --- internal/tui/bubbles/git/about/bubble.go | 4 +-- internal/tui/bubbles/git/bubble.go | 39 ++++++++++-------------- internal/tui/bubbles/git/log/bubble.go | 11 +------ internal/tui/bubbles/git/refs/bubble.go | 4 +-- internal/tui/bubbles/git/tree/bubble.go | 9 +----- 5 files changed, 20 insertions(+), 47 deletions(-) diff --git a/internal/tui/bubbles/git/about/bubble.go b/internal/tui/bubbles/git/about/bubble.go index 07fa8a8c1..199f864cf 100644 --- a/internal/tui/bubbles/git/about/bubble.go +++ b/internal/tui/bubbles/git/about/bubble.go @@ -78,9 +78,7 @@ func (b *Bubble) View() string { } func (b *Bubble) Help() []types.HelpEntry { - return []types.HelpEntry{ - {"f/b", "pgup/pgdown"}, - } + return nil } func (b *Bubble) setupCmd() tea.Msg { diff --git a/internal/tui/bubbles/git/bubble.go b/internal/tui/bubbles/git/bubble.go index c6780f26a..aa27c2f6b 100644 --- a/internal/tui/bubbles/git/bubble.go +++ b/internal/tui/bubbles/git/bubble.go @@ -63,15 +63,17 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) { cmds := make([]tea.Cmd, 0) switch msg := msg.(type) { case tea.KeyMsg: - switch msg.String() { - case "A": - b.state = aboutPage - case "R": - b.state = refsPage - case "L": - b.state = logPage - case "T": - b.state = treePage + if b.repo.Name() != "config" { + switch msg.String() { + case "r", "R": + b.state = aboutPage + case "b", "B": + b.state = refsPage + case "c", "C": + b.state = logPage + case "f", "F": + b.state = treePage + } } case tea.WindowSizeMsg: b.width = msg.Width @@ -105,21 +107,12 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (b *Bubble) Help() []types.HelpEntry { h := []types.HelpEntry{} - if b.state != treePage { - h = append(h, types.HelpEntry{"↑/↓", "navigate"}) - } h = append(h, b.boxes[b.state].(types.HelpableBubble).Help()...) - if b.state != aboutPage { - h = append(h, types.HelpEntry{"A", "about"}) - } - if b.state != refsPage { - h = append(h, types.HelpEntry{"R", "refs"}) - } - if b.state != logPage { - h = append(h, types.HelpEntry{"L", "log"}) - } - if b.state != treePage { - h = append(h, types.HelpEntry{"T", "tree"}) + if b.repo.Name() != "config" { + h = append(h, types.HelpEntry{"r", "readme"}) + h = append(h, types.HelpEntry{"f", "files"}) + h = append(h, types.HelpEntry{"c", "commits"}) + h = append(h, types.HelpEntry{"b", "branches/tags"}) } return h } diff --git a/internal/tui/bubbles/git/log/bubble.go b/internal/tui/bubbles/git/log/bubble.go index ccee7889c..7d075953a 100644 --- a/internal/tui/bubbles/git/log/bubble.go +++ b/internal/tui/bubbles/git/log/bubble.go @@ -140,16 +140,7 @@ func (b *Bubble) updateItems() tea.Cmd { } func (b *Bubble) Help() []types.HelpEntry { - switch b.state { - case logState: - return []types.HelpEntry{ - {"enter", "select"}, - } - default: - return []types.HelpEntry{ - {"esc", "back"}, - } - } + return nil } func (b *Bubble) GotoTop() { diff --git a/internal/tui/bubbles/git/refs/bubble.go b/internal/tui/bubbles/git/refs/bubble.go index 543410b47..211025847 100644 --- a/internal/tui/bubbles/git/refs/bubble.go +++ b/internal/tui/bubbles/git/refs/bubble.go @@ -110,9 +110,7 @@ func (b *Bubble) SetSize(width, height int) { } func (b *Bubble) Help() []types.HelpEntry { - return []types.HelpEntry{ - {"enter", "select"}, - } + return nil } func (b *Bubble) updateItems() tea.Cmd { diff --git a/internal/tui/bubbles/git/tree/bubble.go b/internal/tui/bubbles/git/tree/bubble.go index e69bb28d3..9a60fb80a 100644 --- a/internal/tui/bubbles/git/tree/bubble.go +++ b/internal/tui/bubbles/git/tree/bubble.go @@ -175,14 +175,7 @@ func (b *Bubble) SetSize(width, height int) { } func (b *Bubble) Help() []types.HelpEntry { - h := []types.HelpEntry{} - switch b.state { - case errorState: - h = append(h, types.HelpEntry{"esc", "back"}) - default: - h = append(h, types.HelpEntry{"←/↑/→/↓", "navigate"}) - } - return h + return nil } func (b *Bubble) updateItems() tea.Cmd {