mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
refactor: reuse the existing service and rendering helpers
services.IsNotFound replaces the hand-rolled 404 checks, convertPage the copied page conversions and lastPathNumber the comment's own number parser. The List wrappers around ListPage of releases, branches, wiki pages, secrets and variables go, pull request filters resolve milestones through Milestones.FindOne like issues, and localFlagsChanged, boolOrder, Cell.Render, stateBadge and dueText replace their copies. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
33 files changed
+85
-212
No files matched your search
@@ -262,7 +262,7 @@ func renderRun(run services.Run, d terminal.Display, hints []string) string {
|
||||
if !d.TTY {
|
||||
return runRecord(run, d, now)
|
||||
}
|
||||
style := func(cell terminal.Cell) string { return paintActionCell(cell, d.Color) }
|
||||
style := func(cell terminal.Cell) string { return cell.Render(d) }
|
||||
muted := func(text string) string { return style(terminal.Cell{Text: text, Muted: true}) }
|
||||
var b strings.Builder
|
||||
heading := run.Workflow
|
||||
@@ -321,15 +321,6 @@ func renderRun(run services.Run, d terminal.Display, hints []string) string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// paintActionCell styles a cell's safe text outside a table: its color, muted or bold.
|
||||
func paintActionCell(cell terminal.Cell, color bool) string {
|
||||
name := cell.Color
|
||||
if cell.Muted {
|
||||
name = "muted"
|
||||
}
|
||||
return terminal.Emphasis(terminal.Colorize(name, terminal.SafeLine(cell.Text), color), cell.Bold && color)
|
||||
}
|
||||
|
||||
// jobLines lists jobs, each followed by its steps, for the run view.
|
||||
func jobLines(jobs []services.Job, now time.Time) [][]terminal.Cell {
|
||||
var rows [][]terminal.Cell
|
||||
|
||||
Reference in new issue
Block a user