feat(tui): consolidate 6 tabs to 3, add log sidebar
Tab bar: Monitors | Maint | Settings (was 6 tabs). Settings tab merges Alerts, Nodes, Users as sub-sections with left/right arrow navigation. Each section keeps its own cursor, keybindings, and CRUD operations. Monitors tab now shows a log sidebar at >= 120 cols (70/30 split). Under 120 cols, monitors render full-width without logs. - Introduced tab constants (tabMonitors, tabMaint, tabSettings) - Introduced section constants (sectionAlerts, sectionNodes, sectionUsers) - Removed stateLogs and stateUsers states - All magic tab numbers replaced with named constants
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
func (m Model) viewSettingsTab() string {
|
||||
maxSections := 2
|
||||
if m.isAdmin {
|
||||
maxSections = 3
|
||||
}
|
||||
|
||||
sections := []string{"Alerts", "Nodes"}
|
||||
if m.isAdmin {
|
||||
sections = append(sections, "Users")
|
||||
}
|
||||
_ = maxSections
|
||||
|
||||
var tabs []string
|
||||
for i, name := range sections {
|
||||
if i == m.settingsSection {
|
||||
tabs = append(tabs, m.st.activeTab.Render(name))
|
||||
} else {
|
||||
tabs = append(tabs, m.st.inactiveTab.Render(name))
|
||||
}
|
||||
}
|
||||
header := lipgloss.JoinHorizontal(lipgloss.Top, tabs...)
|
||||
|
||||
var content string
|
||||
switch m.settingsSection {
|
||||
case sectionAlerts:
|
||||
content = m.viewAlertsTab()
|
||||
case sectionNodes:
|
||||
content = m.viewNodesTab()
|
||||
case sectionUsers:
|
||||
if m.isAdmin {
|
||||
content = m.viewUsersTab()
|
||||
}
|
||||
}
|
||||
|
||||
return header + "\n" + content
|
||||
}
|
||||
|
||||
func (m *Model) switchSettingsSection(idx int) {
|
||||
max := 1
|
||||
if m.isAdmin {
|
||||
max = 2
|
||||
}
|
||||
if idx > max {
|
||||
idx = 0
|
||||
}
|
||||
if idx < 0 {
|
||||
idx = max
|
||||
}
|
||||
m.settingsSection = idx
|
||||
m.cursor = 0
|
||||
m.tableOffset = 0
|
||||
}
|
||||
Reference in New Issue
Block a user