From 5ec0201942735979c2f7389ae5bae3965a44800d Mon Sep 17 00:00:00 2001 From: Dolev Hadar Date: Sat, 9 Nov 2024 13:06:42 +0200 Subject: [PATCH] fix: error color missing crashes the app --- config/parser.go | 11 +++++++++-- ui/components/branch/branch.go | 6 +++--- ui/components/pr/pr.go | 4 ++-- ui/components/prsidebar/prsidebar.go | 2 +- ui/components/reposection/reposection.go | 2 +- ui/ui.go | 4 ++-- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/config/parser.go b/config/parser.go index 34c67fd5..276e93b0 100644 --- a/config/parser.go +++ b/config/parser.go @@ -142,13 +142,13 @@ type Pager struct { type HexColor string type ColorThemeText struct { - Primary HexColor `yaml:"primary" validate:"hexcolor"` + Primary HexColor `yaml:"primary" validate:"omitempty,hexcolor"` Secondary HexColor `yaml:"secondary" validate:"hexcolor"` Inverted HexColor `yaml:"inverted" validate:"hexcolor"` Faint HexColor `yaml:"faint" validate:"hexcolor"` Warning HexColor `yaml:"warning" validate:"hexcolor"` Success HexColor `yaml:"success" validate:"hexcolor"` - Error HexColor `yaml:"error" validate:"hexcolor"` + Error HexColor `yaml:"error" validate:"omitempty,hexcolor"` } type ColorThemeBorder struct { @@ -296,6 +296,13 @@ func (parser ConfigParser) getDefaultConfig() Config { }, RepoPaths: map[string]string{}, Theme: &ThemeConfig{ + Colors: &ColorThemeConfig{ + Inline: ColorTheme{ + Text: ColorThemeText{ + Error: "#F7768E", + }, + }, + }, Ui: UIThemeConfig{ SectionsShowCount: true, Table: TableUIThemeConfig{ diff --git a/ui/components/branch/branch.go b/ui/components/branch/branch.go index 3b6d476f..b731e66b 100644 --- a/ui/components/branch/branch.go +++ b/ui/components/branch/branch.go @@ -40,7 +40,7 @@ func (b *Branch) renderReviewStatus() string { if b.PR.ReviewDecision == "CHANGES_REQUESTED" { reviewCellStyle = reviewCellStyle.Foreground( - b.Ctx.Theme.WarningText, + b.Ctx.Theme.ErrorText, ) return reviewCellStyle.Render("󰌑") } @@ -125,7 +125,7 @@ func (b *Branch) renderCiStatus() string { return ciCellStyle.Render(b.Ctx.Styles.Common.WaitingGlyph) } - ciCellStyle = ciCellStyle.Foreground(b.Ctx.Theme.WarningText) + ciCellStyle = ciCellStyle.Foreground(b.Ctx.Theme.ErrorText) return ciCellStyle.Render(constants.FailureIcon) } @@ -140,7 +140,7 @@ func (b *Branch) renderLines(isSelected bool) string { var additionsFg, deletionsFg lipgloss.AdaptiveColor additionsFg = b.Ctx.Theme.SuccessText - deletionsFg = b.Ctx.Theme.WarningText + deletionsFg = b.Ctx.Theme.ErrorText baseStyle := lipgloss.NewStyle() if isSelected { diff --git a/ui/components/pr/pr.go b/ui/components/pr/pr.go index 2e1cbd8a..7d1cbb30 100644 --- a/ui/components/pr/pr.go +++ b/ui/components/pr/pr.go @@ -40,7 +40,7 @@ func (pr *PullRequest) renderReviewStatus() string { if pr.Data.ReviewDecision == "CHANGES_REQUESTED" { reviewCellStyle = reviewCellStyle.Foreground( - pr.Ctx.Theme.WarningText, + pr.Ctx.Theme.ErrorText, ) return reviewCellStyle.Render("󰌑") } @@ -125,7 +125,7 @@ func (pr *PullRequest) renderCiStatus() string { return ciCellStyle.Render(pr.Ctx.Styles.Common.WaitingGlyph) } - ciCellStyle = ciCellStyle.Foreground(pr.Ctx.Theme.WarningText) + ciCellStyle = ciCellStyle.Foreground(pr.Ctx.Theme.ErrorText) return ciCellStyle.Render(constants.FailureIcon) } diff --git a/ui/components/prsidebar/prsidebar.go b/ui/components/prsidebar/prsidebar.go index e6e7418d..c17231de 100644 --- a/ui/components/prsidebar/prsidebar.go +++ b/ui/components/prsidebar/prsidebar.go @@ -218,7 +218,7 @@ func (m *Model) renderMergeablePill() string { status := m.pr.Data.Mergeable if status == "CONFLICTING" { return m.ctx.Styles.PrSidebar.PillStyle. - Background(m.ctx.Theme.WarningText). + Background(m.ctx.Theme.ErrorText). Render("󰅖 Merge Conflicts") } else if status == "MERGEABLE" { return m.ctx.Styles.PrSidebar.PillStyle. diff --git a/ui/components/reposection/reposection.go b/ui/components/reposection/reposection.go index 49a09571..bcb29ed0 100644 --- a/ui/components/reposection/reposection.go +++ b/ui/components/reposection/reposection.go @@ -561,7 +561,7 @@ func (m *Model) GetPagerContent() string { s := lipgloss.NewStyle().Background(m.Ctx.Styles.ListViewPort.PagerStyle.GetBackground()) mod := s.Foreground(lipgloss.Color("#e0af68")).Render(fmt.Sprintf(" %d", len(m.repo.Status.Modified))) plus := s.Foreground(m.Ctx.Theme.SuccessText).Render(fmt.Sprintf(" %d", len(m.repo.Status.Added))) - minus := s.Foreground(m.Ctx.Theme.WarningText).Render(fmt.Sprintf(" %d", len(m.repo.Status.Removed))) + minus := s.Foreground(m.Ctx.Theme.ErrorText).Render(fmt.Sprintf(" %d", len(m.repo.Status.Removed))) spacer := s.Render(" ") return m.Ctx.Styles.ListViewPort.PagerStyle.Render(lipgloss.JoinHorizontal(lipgloss.Top, plus, spacer, minus, spacer, mod)) } diff --git a/ui/ui.go b/ui/ui.go index 545c8ef4..f81a9b3f 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -631,7 +631,7 @@ func (m Model) View() string { Render(fmt.Sprintf("%s %s", m.ctx.Styles.Common.FailureGlyph, lipgloss.NewStyle(). - Foreground(m.ctx.Theme.WarningText). + Foreground(m.ctx.Theme.ErrorText). Render(m.ctx.Error.Error()), )), ) @@ -898,7 +898,7 @@ func (m *Model) renderRunningTask() string { )) case context.TaskError: currTaskStatus = lipgloss.NewStyle(). - Foreground(m.ctx.Theme.WarningText). + Foreground(m.ctx.Theme.ErrorText). Background(m.ctx.Theme.SelectedBackground). Render(fmt.Sprintf("%s %s", constants.FailureIcon, task.Error.Error())) case context.TaskFinished: