6fdb4bbbf8
The module path, the CI pipeline and the self-updater all named GitHub. They now name the Gitea instance everything else already runs on. The workflows are rewritten rather than translated, for the reason recorded in ci.yaml: Gitea's runner image is ubuntu:22.04, whose nodejs is Node 12, so no JS action runs there -- actions/checkout@v4 dies with a SyntaxError before doing anything. Every step is shell and checkout is a plain clone, which this public repo needs no credential for. upload-artifact/download-artifact are JS actions too, and there is no artifact store here, so the job that builds the binaries is the job that publishes them. internal/updater keeps its release and asset types unchanged: Gitea's release payload carries the same tag_name, and its attachments the same name and browser_download_url, so only the URL, the Accept header and one error string move. The asset naming in release.yaml is load-bearing for that matching. This does strand already-installed binaries, which still poll api.github.com. The GitHub repository is left in place and untouched, so they report themselves up to date rather than erroring; its last release is the bridge, and crossing it is a one-time manual download.
100 lines
3.0 KiB
Go
100 lines
3.0 KiB
Go
package tui
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
|
"git.ryuvia.com/niklas/terdut-tui/internal/api"
|
|
)
|
|
|
|
var (
|
|
colorPrimary = lipgloss.Color("69") // blue
|
|
colorMuted = lipgloss.Color("240") // gray
|
|
colorFiring = lipgloss.Color("196") // red
|
|
colorResolved = lipgloss.Color("70") // green
|
|
colorAccent = lipgloss.Color("214") // orange
|
|
|
|
colorSevCritical = lipgloss.Color("196") // red
|
|
colorSevError = lipgloss.Color("202") // dark orange
|
|
colorSevWarning = lipgloss.Color("214") // orange
|
|
colorSevInfo = lipgloss.Color("39") // cyan
|
|
|
|
styleHeader = lipgloss.NewStyle().
|
|
Bold(true).
|
|
Foreground(colorPrimary).
|
|
Padding(0, 1)
|
|
|
|
styleTabActive = lipgloss.NewStyle().
|
|
Bold(true).
|
|
Foreground(lipgloss.Color("0")).
|
|
Background(colorPrimary).
|
|
Padding(0, 2)
|
|
|
|
styleTabInactive = lipgloss.NewStyle().
|
|
Foreground(colorMuted).
|
|
Padding(0, 2)
|
|
|
|
styleFooter = lipgloss.NewStyle().
|
|
Foreground(colorMuted)
|
|
|
|
styleStatus = lipgloss.NewStyle().
|
|
Foreground(colorAccent).
|
|
Bold(true)
|
|
|
|
styleError = lipgloss.NewStyle().
|
|
Foreground(colorFiring).
|
|
Bold(true)
|
|
|
|
styleFiring = lipgloss.NewStyle().Foreground(colorFiring).Bold(true)
|
|
styleResolved = lipgloss.NewStyle().Foreground(colorResolved)
|
|
styleMuted = lipgloss.NewStyle().Foreground(colorMuted)
|
|
styleAlertName = lipgloss.NewStyle().Bold(true)
|
|
styleBold = lipgloss.NewStyle().Bold(true)
|
|
styleSelected = lipgloss.NewStyle().Foreground(colorPrimary).Bold(true)
|
|
styleAccent = lipgloss.NewStyle().Foreground(colorAccent)
|
|
|
|
// Incident status. Triggered is unclaimed work and reads as loudly as a
|
|
// firing alert; acknowledged means somebody has it.
|
|
styleTriggered = lipgloss.NewStyle().Foreground(colorFiring).Bold(true)
|
|
styleAcknowledged = lipgloss.NewStyle().Foreground(colorAccent).Bold(true)
|
|
styleSnoozed = lipgloss.NewStyle().Foreground(colorMuted).Italic(true)
|
|
|
|
// Severity, over the conventional Alertmanager label values.
|
|
styleSevCritical = lipgloss.NewStyle().Foreground(colorSevCritical).Bold(true)
|
|
styleSevError = lipgloss.NewStyle().Foreground(colorSevError).Bold(true)
|
|
styleSevWarning = lipgloss.NewStyle().Foreground(colorSevWarning)
|
|
styleSevInfo = lipgloss.NewStyle().Foreground(colorSevInfo)
|
|
)
|
|
|
|
// severityStyle picks the style for a severity label, falling back to muted for
|
|
// values this client does not recognise rather than dropping them.
|
|
func severityStyle(severity string) lipgloss.Style {
|
|
switch strings.ToLower(severity) {
|
|
case "critical":
|
|
return styleSevCritical
|
|
case "error":
|
|
return styleSevError
|
|
case "warning":
|
|
return styleSevWarning
|
|
case "info":
|
|
return styleSevInfo
|
|
default:
|
|
return styleMuted
|
|
}
|
|
}
|
|
|
|
// incidentStatusStyle picks the style for an incident status, falling back to
|
|
// muted for statuses added after this client was built.
|
|
func incidentStatusStyle(status string) lipgloss.Style {
|
|
switch status {
|
|
case api.StatusTriggered:
|
|
return styleTriggered
|
|
case api.StatusAcknowledged:
|
|
return styleAcknowledged
|
|
case api.StatusResolved:
|
|
return styleResolved
|
|
default:
|
|
return styleMuted
|
|
}
|
|
}
|