feat(tui): persist bottom panel preference across restarts
Save bottom_panel pref (logs/maint/none) to store on toggle. Restore on startup via InitialModel, same pattern as detail_open.
This commit is contained in:
@@ -50,6 +50,21 @@ func writeCmd(op string, fn func() error) tea.Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Model) saveBottomPanelPref() tea.Cmd {
|
||||
v := "logs"
|
||||
switch m.bottomPanel {
|
||||
case bottomNone:
|
||||
v = "none"
|
||||
case bottomMaint:
|
||||
v = "maint"
|
||||
}
|
||||
st := m.store
|
||||
ctx := m.ctx
|
||||
return writeCmd("Save bottom panel preference", func() error {
|
||||
return st.SetPreference(ctx, "bottom_panel", v)
|
||||
})
|
||||
}
|
||||
|
||||
func sortSitesForDisplay(allSites []models.Site, collapsed map[int]bool, sortCol int, sortAsc bool) []models.Site {
|
||||
var groups, ungrouped []models.Site
|
||||
children := make(map[int][]models.Site)
|
||||
|
||||
+11
-1
@@ -243,6 +243,16 @@ func InitialModel(ctx context.Context, isAdmin bool, s store.Store, eng *monitor
|
||||
|
||||
detailPref, _ := s.GetPreference(ctx, "detail_open")
|
||||
|
||||
bp := bottomLogs
|
||||
if bpPref, _ := s.GetPreference(ctx, "bottom_panel"); bpPref != "" {
|
||||
switch bpPref {
|
||||
case "none":
|
||||
bp = bottomNone
|
||||
case "maint":
|
||||
bp = bottomMaint
|
||||
}
|
||||
}
|
||||
|
||||
return Model{
|
||||
ctx: ctx,
|
||||
state: stateDashboard,
|
||||
@@ -257,7 +267,7 @@ func InitialModel(ctx context.Context, isAdmin bool, s store.Store, eng *monitor
|
||||
theme: theme,
|
||||
themeIndex: themeIdx,
|
||||
st: newStyles(theme),
|
||||
bottomPanel: bottomLogs,
|
||||
bottomPanel: bp,
|
||||
detailOpen: detailPref == "true",
|
||||
demoMode: os.Getenv("UPTOP_DEMO") == "1",
|
||||
version: version,
|
||||
|
||||
@@ -662,6 +662,7 @@ func (m *Model) handleDashboardKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
m.focusedPanel = panelMaint
|
||||
}
|
||||
m.recalcLayout()
|
||||
return m, m.saveBottomPanelPref()
|
||||
case "l":
|
||||
if m.bottomPanel == bottomLogs {
|
||||
m.bottomPanel = bottomNone
|
||||
@@ -671,6 +672,7 @@ func (m *Model) handleDashboardKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
m.focusedPanel = panelLogs
|
||||
}
|
||||
m.recalcLayout()
|
||||
return m, m.saveBottomPanelPref()
|
||||
case "up", "k":
|
||||
if m.focusedPanel == panelDetail && m.detailOpen {
|
||||
m.detailScrollOffset--
|
||||
|
||||
Reference in New Issue
Block a user