Skip to content

Commit

Permalink
Simplify help, disable navigation options on config repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby Padilla authored and aymanbagabas committed Feb 14, 2022
1 parent 078761f commit 8511038
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 47 deletions.
4 changes: 1 addition & 3 deletions internal/tui/bubbles/git/about/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
39 changes: 16 additions & 23 deletions internal/tui/bubbles/git/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
11 changes: 1 addition & 10 deletions internal/tui/bubbles/git/log/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 1 addition & 3 deletions internal/tui/bubbles/git/refs/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 1 addition & 8 deletions internal/tui/bubbles/git/tree/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8511038

Please sign in to comment.