0b3479fc61764be89c7bad8ded9df801933e3c7f

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(tui): show error on empty readme and empty tree

Diff

 1diff --git a/internal/tui/bubbles/git/about/bubble.go b/internal/tui/bubbles/git/about/bubble.go
 2index 1bb36e9e071348ef856bb7879811f31f2e25ea0c..4740246b670a001a93b59c4425a34cc4820877c2 100644
 3--- a/internal/tui/bubbles/git/about/bubble.go
 4+++ b/internal/tui/bubbles/git/about/bubble.go
 5@@ -88,7 +88,11 @@ func (b *Bubble) Help() []types.HelpEntry {
 6 
 7 func (b *Bubble) glamourize() (string, error) {
 8 	w := b.width - b.widthMargin - b.styles.RepoBody.GetHorizontalFrameSize()
 9-	return types.Glamourize(w, b.repo.GetReadme())
10+	rm := b.repo.GetReadme()
11+	if rm == "" {
12+		return b.styles.AboutNoReadme.Render("No readme found."), nil
13+	}
14+	return types.Glamourize(w, rm)
15 }
16 
17 func (b *Bubble) setupCmd() tea.Msg {
18diff --git a/internal/tui/bubbles/git/tree/bubble.go b/internal/tui/bubbles/git/tree/bubble.go
19index 94c4b43eac5cd832b37a5c6fdbdadbc003b24c42..1876df204b6901eeed52f690d665fa8ef69f4d85 100644
20--- a/internal/tui/bubbles/git/tree/bubble.go
21+++ b/internal/tui/bubbles/git/tree/bubble.go
22@@ -142,6 +142,7 @@ func NewBubble(repo types.Repo, styles *style.Styles, width, widthMargin, height
23 	l.DisableQuitKeybindings()
24 	l.KeyMap.NextPage = types.NextPage
25 	l.KeyMap.PrevPage = types.PrevPage
26+	l.Styles.NoItems = styles.TreeNoItems
27 	b := &Bubble{
28 		fileViewport: &vp.ViewportBubble{
29 			Viewport: &viewport.Model{},
30diff --git a/internal/tui/style/style.go b/internal/tui/style/style.go
31index e7c386fc4fa2cc00b05a3ca735dfc81d3afefb73..ab2063e27124d16bdf97126c87286ef01d38b3bf 100644
32--- a/internal/tui/style/style.go
33+++ b/internal/tui/style/style.go
34@@ -40,6 +40,8 @@ type Styles struct {
35 	ErrorTitle lipgloss.Style
36 	ErrorBody  lipgloss.Style
37 
38+	AboutNoReadme lipgloss.Style
39+
40 	LogItemSelector   lipgloss.Style
41 	LogItemActive     lipgloss.Style
42 	LogItemInactive   lipgloss.Style
43@@ -67,6 +69,8 @@ type Styles struct {
44 	TreeFileMode     lipgloss.Style
45 	TreeFileSize     lipgloss.Style
46 	TreeFileContent  lipgloss.Style
47+	TreePaginator    lipgloss.Style
48+	TreeNoItems      lipgloss.Style
49 
50 	Spinner lipgloss.Style
51 }
52@@ -193,6 +197,10 @@ func DefaultStyles() *Styles {
53 		MarginLeft(2).
54 		Width(52) // for now
55 
56+	s.AboutNoReadme = lipgloss.NewStyle().
57+		MarginLeft(1).
58+		Foreground(lipgloss.Color("#626262"))
59+
60 	s.LogItemInactive = lipgloss.NewStyle().
61 		MarginLeft(1)
62 
63@@ -262,6 +270,10 @@ func DefaultStyles() *Styles {
64 
65 	s.TreeFileContent = lipgloss.NewStyle()
66 
67+	s.TreePaginator = s.LogPaginator.Copy()
68+
69+	s.TreeNoItems = s.AboutNoReadme.Copy()
70+
71 	s.Spinner = lipgloss.NewStyle().
72 		MarginLeft(1).
73 		Foreground(lipgloss.Color("205"))