Added configuration options to hide side panels

Every panel except "project" can be hidden. All panels are visible by default.

initiallyFocusedViewName defaults to "project" if "services" and "containers" are hidden
This commit is contained in:
Jayson Rhynas 2024-08-29 12:21:20 -04:00
parent de40167712
commit 42acc55256
10 changed files with 57 additions and 6 deletions

View file

@ -48,6 +48,13 @@ gui:
wrapMainPanel: true
# Side panel width as a ratio of the screen's width
sidePanelWidth: 0.333
# Determines whether each side panel is shown or not
sidePanelVisibility:
services: true
containers: true
images: true
volumes: true
networks: true
# Determines whether we show the bottom line (the one containing keybinding
# info and the status of the app).
showBottomLine: true

View file

@ -74,6 +74,15 @@ type ThemeConfig struct {
OptionsTextColor []string `yaml:"optionsTextColor,omitempty"`
}
// SidePanelVisibilityConfig is for toggling visiblity of side panels.
type SidePanelVisibilityConfig struct {
Services bool `yaml:"services,omitempty"`
Containers bool `yaml:"containers,omitempty"`
Images bool `yaml:"images,omitempty"`
Volumes bool `yaml:"volumes,omitempty"`
Networks bool `yaml:"networks,omitempty"`
}
// GuiConfig is for configuring visual things like colors and whether we show or
// hide things
type GuiConfig struct {
@ -123,6 +132,9 @@ type GuiConfig struct {
// If 0.333, then the side panels will be 1/3 of the screen's width
SidePanelWidth float64 `yaml:"sidePanelWidth"`
// Determines which side panels to show. Each panel defaults to `true` (visible).
SidePanelVisibility SidePanelVisibilityConfig `yaml:"sidePanelVisibility,omitempty"`
// Determines whether we show the bottom line (the one containing keybinding
// info and the status of the app).
ShowBottomLine bool `yaml:"showBottomLine"`
@ -373,6 +385,13 @@ func GetDefaultConfig() UserConfig {
WrapMainPanel: true,
LegacySortContainers: false,
SidePanelWidth: 0.3333,
SidePanelVisibility: SidePanelVisibilityConfig{
Services: true,
Containers: true,
Images: true,
Volumes: true,
Networks: true,
},
ShowBottomLine: true,
ExpandFocusedSidePanel: false,
ScreenMode: "normal",

View file

@ -175,11 +175,19 @@ func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
return defaultBox
}
return append([]*boxlayout.Box{
{
projectBox := &boxlayout.Box{
Window: sideWindowNames[0],
Size: 3,
}
if len(sideWindowNames) == 1 {
projectBox = &boxlayout.Box{
Window: sideWindowNames[0],
Size: 3,
},
Weight: 1,
}
}
return append([]*boxlayout.Box{
projectBox,
}, lo.Map(sideWindowNames[1:], func(window string, _ int) *boxlayout.Box {
return accordionBox(&boxlayout.Box{Window: window, Weight: 1})
})...)

View file

@ -96,6 +96,7 @@ func (gui *Gui) getContainersPanel() *panels.SideListPanel[*commands.Container]
return true
},
ConfigHidden: !gui.Config.UserConfig.Gui.SidePanelVisibility.Containers,
GetTableCells: func(container *commands.Container) []string {
return presentation.GetContainerDisplayStrings(&gui.Config.UserConfig.Gui, container)
},

View file

@ -459,10 +459,15 @@ func (gui *Gui) ShouldRefresh(key string) bool {
}
func (gui *Gui) initiallyFocusedViewName() string {
if gui.DockerCommand.InDockerComposeProject {
visiblePanels := gui.Config.UserConfig.Gui.SidePanelVisibility
if gui.DockerCommand.InDockerComposeProject && visiblePanels.Services {
return "services"
} else if visiblePanels.Containers {
return "containers"
} else {
return "project"
}
return "containers"
}
func (gui *Gui) IgnoreStrings() []string {

View file

@ -62,6 +62,7 @@ func (gui *Gui) getImagesPanel() *panels.SideListPanel[*commands.Image] {
return a.ID < b.ID
},
GetTableCells: presentation.GetImageDisplayStrings,
ConfigHidden: !gui.Config.UserConfig.Gui.SidePanelVisibility.Images,
}
}

View file

@ -44,6 +44,7 @@ func (gui *Gui) getNetworksPanel() *panels.SideListPanel[*commands.Network] {
return a.Name < b.Name
},
GetTableCells: presentation.GetNetworkDisplayStrings,
ConfigHidden: !gui.Config.UserConfig.Gui.SidePanelVisibility.Networks,
}
}

View file

@ -57,6 +57,9 @@ type SideListPanel[T comparable] struct {
// set this to true if you don't want to allow manual filtering via '/'
DisableFilter bool
// set to true if config file wants this panel to be hidden
ConfigHidden bool
// This can be nil if you want to always show the panel
Hide func() bool
}
@ -263,6 +266,10 @@ func (self *SideListPanel[T]) IsFilterDisabled() bool {
}
func (self *SideListPanel[T]) IsHidden() bool {
if self.ConfigHidden {
return true
}
if self.Hide == nil {
return false
}

View file

@ -77,6 +77,7 @@ func (gui *Gui) getServicesPanel() *panels.SideListPanel[*commands.Service] {
GetTableCells: func(service *commands.Service) []string {
return presentation.GetServiceDisplayStrings(&gui.Config.UserConfig.Gui, service)
},
ConfigHidden: !gui.Config.UserConfig.Gui.SidePanelVisibility.Services,
Hide: func() bool {
return !gui.DockerCommand.InDockerComposeProject
},

View file

@ -50,6 +50,7 @@ func (gui *Gui) getVolumesPanel() *panels.SideListPanel[*commands.Volume] {
return a.Name < b.Name
},
GetTableCells: presentation.GetVolumeDisplayStrings,
ConfigHidden: !gui.Config.UserConfig.Gui.SidePanelVisibility.Volumes,
}
}