refactor: split jobs_view, drop YAML migration, update docs (T6.1-T6.4)
T6.1: split jobs_view.go into three files — jobs_view_helpers.go (pure helpers) and jobs_view_details.go (detailsPanel struct with widget creation, update, clear, and container methods) — bringing jobs_view.go from 459 to ~200 lines. T6.2: remove stale YAML upgrade note from README; drop *.yaml from .dockerignore. T6.3: delete YAML shadow structs (yamlConfig/yamlJob/yamlJobsFile), importYAMLConfig/importYAMLJobs, legacy path constants, and all YAML-import tests; run go mod tidy to remove go.yaml.in/yaml/v4. T6.4: refresh ARCHITECTURE.md — JSON storage references, new Key Domain Concepts section (per-job overlap policy, run-time statistics + log seeding, persisted pause flag, jobs_view split). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package ui
|
||||
|
||||
import "strings"
|
||||
|
||||
// lastJobLogs returns a fresh slice of the most recent activity entries for the
|
||||
// "Selected job activity" panel. Logs are stored newest-first (see
|
||||
// app.Service.recordRun), so the leading entries are the latest; the result is
|
||||
// capped at maxJobActivityRows.
|
||||
func lastJobLogs(logs []event) []event {
|
||||
n := len(logs)
|
||||
if n > maxJobActivityRows {
|
||||
n = maxJobActivityRows
|
||||
}
|
||||
return append([]event(nil), logs[:n]...)
|
||||
}
|
||||
|
||||
func filteredJobIndexes(jobs []job, folder string) []int {
|
||||
indexes := make([]int, 0, len(jobs))
|
||||
for index, current := range jobs {
|
||||
if folder == allFolders || filterValue(current.Folder) == folder {
|
||||
indexes = append(indexes, index)
|
||||
}
|
||||
}
|
||||
return indexes
|
||||
}
|
||||
|
||||
func folderOptions(jobs []job) []string {
|
||||
// "All" and "No folder" are always present so the filter UI is stable even
|
||||
// before the user creates folders.
|
||||
options := []string{allFolders, noFolder}
|
||||
seen := map[string]bool{allFolders: true, noFolder: true}
|
||||
for _, current := range jobs {
|
||||
folder := strings.TrimSpace(current.Folder)
|
||||
if folder == "" || seen[folder] {
|
||||
continue
|
||||
}
|
||||
seen[folder] = true
|
||||
options = append(options, folder)
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
func filterValue(folder string) string {
|
||||
if strings.TrimSpace(folder) == "" {
|
||||
return noFolder
|
||||
}
|
||||
return strings.TrimSpace(folder)
|
||||
}
|
||||
|
||||
func indexOfID(jobs []job, id int) int {
|
||||
for index, current := range jobs {
|
||||
if current.ID == id {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user