Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configuration options to hide side panels #576

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions pkg/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 12 additions & 4 deletions pkg/gui/arrangement.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
})...)
Expand Down
1 change: 1 addition & 0 deletions pkg/gui/containers_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down
9 changes: 7 additions & 2 deletions pkg/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/gui/images_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/gui/networks_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/gui/panels/side_list_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions pkg/gui/services_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
1 change: 1 addition & 0 deletions pkg/gui/volumes_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down