You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TUI: collapse repeated sort-order blocks in JobsData::sort_jobs and share table scrolling helpers #2605
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Two small duplication spots in the ballista-cli TUI domain types:
JobsData::sort_jobs (tui/domain/jobs.rs#L98-L175) repeats the same let cmp = ...; if sort_order == Descending { cmp.reverse() } else { cmp } block in six match arms. That is why it scores cognitive complexity 42 for what is really six key extractors, and a new column means pasting the block again.
In sort_jobs, match on the column once to pick a comparator closure, then call sort_by once and apply .reverse() for Descending.
Add a small shared helper (e.g. scroll_down(&mut TableState, &mut ScrollbarState, len) / scroll_up(...), or a ScrollableTable struct) in tui/domain/mod.rs and have the three types delegate to it. Move the scroll tests to the helper.
Describe alternatives you've considered
None.
Additional context
This is small and self-contained, a good first issue. Line references are pinned to commit ea1126c.
I can simplify JobsData::sort_jobs, extract shared scrolling helpers for the three table types, and add regression tests covering sorting, wraparound, and empty tables.
Would you prefer both refactorings in one PR, or two smaller PRs?
Activity
milenkovicm commentedon Oct 14, 2026
cc @martin-g
med9110 commentedon Oct 15, 2026
Hi @andygrove, I'd be interested in contributing to #2605.
I can simplify
JobsData::sort_jobs, extract shared scrolling helpers for the three table types, and add regression tests covering sorting, wraparound, and empty tables.Would you prefer both refactorings in one PR, or two smaller PRs?
martin-g commentedon Oct 16, 2026
@med9110 One PR is OK! Thanks !