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 {
|
func sortSitesForDisplay(allSites []models.Site, collapsed map[int]bool, sortCol int, sortAsc bool) []models.Site {
|
||||||
var groups, ungrouped []models.Site
|
var groups, ungrouped []models.Site
|
||||||
children := make(map[int][]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")
|
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{
|
return Model{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
state: stateDashboard,
|
state: stateDashboard,
|
||||||
@@ -257,7 +267,7 @@ func InitialModel(ctx context.Context, isAdmin bool, s store.Store, eng *monitor
|
|||||||
theme: theme,
|
theme: theme,
|
||||||
themeIndex: themeIdx,
|
themeIndex: themeIdx,
|
||||||
st: newStyles(theme),
|
st: newStyles(theme),
|
||||||
bottomPanel: bottomLogs,
|
bottomPanel: bp,
|
||||||
detailOpen: detailPref == "true",
|
detailOpen: detailPref == "true",
|
||||||
demoMode: os.Getenv("UPTOP_DEMO") == "1",
|
demoMode: os.Getenv("UPTOP_DEMO") == "1",
|
||||||
version: version,
|
version: version,
|
||||||
|
|||||||
@@ -662,6 +662,7 @@ func (m *Model) handleDashboardKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
m.focusedPanel = panelMaint
|
m.focusedPanel = panelMaint
|
||||||
}
|
}
|
||||||
m.recalcLayout()
|
m.recalcLayout()
|
||||||
|
return m, m.saveBottomPanelPref()
|
||||||
case "l":
|
case "l":
|
||||||
if m.bottomPanel == bottomLogs {
|
if m.bottomPanel == bottomLogs {
|
||||||
m.bottomPanel = bottomNone
|
m.bottomPanel = bottomNone
|
||||||
@@ -671,6 +672,7 @@ func (m *Model) handleDashboardKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
m.focusedPanel = panelLogs
|
m.focusedPanel = panelLogs
|
||||||
}
|
}
|
||||||
m.recalcLayout()
|
m.recalcLayout()
|
||||||
|
return m, m.saveBottomPanelPref()
|
||||||
case "up", "k":
|
case "up", "k":
|
||||||
if m.focusedPanel == panelDetail && m.detailOpen {
|
if m.focusedPanel == panelDetail && m.detailOpen {
|
||||||
m.detailScrollOffset--
|
m.detailScrollOffset--
|
||||||
|
|||||||
Reference in New Issue
Block a user