Skip to content

Commit

Permalink
fix: error color missing crashes the app
Browse files Browse the repository at this point in the history
  • Loading branch information
dlvhdr committed Nov 9, 2024
1 parent 4028f62 commit 5ec0201
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
11 changes: 9 additions & 2 deletions config/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down
6 changes: 3 additions & 3 deletions ui/components/branch/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("󰌑")
}
Expand Down Expand Up @@ -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)
}

Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions ui/components/pr/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("󰌑")
}
Expand Down Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion ui/components/prsidebar/prsidebar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ui/components/reposection/reposection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
4 changes: 2 additions & 2 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
)),
)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5ec0201

Please sign in to comment.