mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
more refactoring
This commit is contained in:
parent
751dbef42e
commit
dfff845469
3 changed files with 22 additions and 5 deletions
|
|
@ -129,11 +129,13 @@ func (gui *Gui) infoSectionChildren(informationStr string, appStatus string) []*
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) sideViewNames() []string {
|
func (gui *Gui) sideViewNames() []string {
|
||||||
if gui.DockerCommand.InDockerComposeProject {
|
visibleSidePanels := lo.Filter(gui.allSidePanels(), func(panel ISideListPanel, _ int) bool {
|
||||||
return []string{"project", "services", "containers", "images", "volumes"}
|
return !panel.IsHidden()
|
||||||
} else {
|
})
|
||||||
return []string{"project", "containers", "images", "volumes"}
|
|
||||||
}
|
return lo.Map(visibleSidePanels, func(panel ISideListPanel, _ int) string {
|
||||||
|
return panel.View().Name()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
|
func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,9 @@ type SideListPanel[T comparable] struct {
|
||||||
|
|
||||||
// set this to true if you don't want to allow manual filtering via '/'
|
// set this to true if you don't want to allow manual filtering via '/'
|
||||||
disableFilter bool
|
disableFilter bool
|
||||||
|
|
||||||
|
// This can be nil if you want to always show the panel
|
||||||
|
hide func() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ISideListPanel interface {
|
type ISideListPanel interface {
|
||||||
|
|
@ -85,6 +88,7 @@ type ISideListPanel interface {
|
||||||
Refocus()
|
Refocus()
|
||||||
RerenderList() error
|
RerenderList() error
|
||||||
IsFilterDisabled() bool
|
IsFilterDisabled() bool
|
||||||
|
IsHidden() bool
|
||||||
OnNextLine() error
|
OnNextLine() error
|
||||||
OnPrevLine() error
|
OnPrevLine() error
|
||||||
OnClick() error
|
OnClick() error
|
||||||
|
|
@ -307,3 +311,11 @@ func (self *SideListPanel[T]) SetContextIndex(index int) {
|
||||||
func (self *SideListPanel[T]) IsFilterDisabled() bool {
|
func (self *SideListPanel[T]) IsFilterDisabled() bool {
|
||||||
return self.disableFilter
|
return self.disableFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *SideListPanel[T]) IsHidden() bool {
|
||||||
|
if self.hide == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.hide()
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,9 @@ func (gui *Gui) getServicesPanel() *SideListPanel[*commands.Service] {
|
||||||
utils.ColoredString(cont.DisplayPorts(), color.FgYellow),
|
utils.ColoredString(cont.DisplayPorts(), color.FgYellow),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
hide: func() bool {
|
||||||
|
return !gui.DockerCommand.InDockerComposeProject
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue