feat(tui): responsive table layout for all tabs
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:
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user