feat(tui): responsive table layout for all tabs
CI / test (pull_request) Successful in 2m45s
CI / lint (pull_request) Successful in 1m12s
CI / vulncheck (pull_request) Successful in 1m6s

Extract shared computeTableLayout() into table_helpers.go — takes column
definitions with short/full headers, min/max widths, and a flex column
that absorbs surplus space. All tabs now use it:

- Alerts: CONFIG column is flex, NAME/TYPE/SENT expand with width
- Maint: TITLE column is flex, TYPE/MONITORS/STATUS/dates expand
- Nodes: NAME column is flex, REGION/LAST SEEN/VERSION expand
- Users: PUBLIC KEY column is flex, USERNAME expands
- Sites: uses same colDef type (keeps special dual-flex for NAME+HISTORY)

Headers auto-switch short/full based on available width across all tabs.
This commit is contained in:
2026-05-28 15:20:12 -04:00
parent 217276ca18
commit d05bbd007b
6 changed files with 144 additions and 30 deletions
+12 -3
View File
@@ -32,8 +32,17 @@ func (m Model) viewUsersTab() string {
return "\n No users configured. Press [n] to add one."
}
cols := []colDef{
{"#", "#", 4, 4, false},
{"USER", "USERNAME", 10, 18, false},
{"ROLE", "ROLE", 8, 10, false},
{"KEY", "PUBLIC KEY", 20, 60, true},
}
headers, widths := m.computeTableLayout(cols, 0)
userW := widths[1]
return m.renderTable(
[]string{"#", "USERNAME", "ROLE", "PUBLIC KEY"},
headers,
len(m.users),
func(start, end int) [][]string {
var rows [][]string
@@ -41,14 +50,14 @@ func (m Model) viewUsersTab() string {
u := m.users[i]
rows = append(rows, []string{
fmt.Sprintf("%d", i+1),
m.zones.Mark(fmt.Sprintf("user-%d", i), limitStr(u.Username, 15)),
m.zones.Mark(fmt.Sprintf("user-%d", i), limitStr(u.Username, userW-2)),
fmtRole(u.Role),
fmtKey(u.PublicKey),
})
}
return rows
},
nil, nil,
widths, nil,
)
}