mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01: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 {
|
||||
if gui.DockerCommand.InDockerComposeProject {
|
||||
return []string{"project", "services", "containers", "images", "volumes"}
|
||||
} else {
|
||||
return []string{"project", "containers", "images", "volumes"}
|
||||
}
|
||||
visibleSidePanels := lo.Filter(gui.allSidePanels(), func(panel ISideListPanel, _ int) bool {
|
||||
return !panel.IsHidden()
|
||||
})
|
||||
|
||||
return lo.Map(visibleSidePanels, func(panel ISideListPanel, _ int) string {
|
||||
return panel.View().Name()
|
||||
})
|
||||
}
|
||||
|
||||
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 '/'
|
||||
disableFilter bool
|
||||
|
||||
// This can be nil if you want to always show the panel
|
||||
hide func() bool
|
||||
}
|
||||
|
||||
type ISideListPanel interface {
|
||||
|
|
@ -85,6 +88,7 @@ type ISideListPanel interface {
|
|||
Refocus()
|
||||
RerenderList() error
|
||||
IsFilterDisabled() bool
|
||||
IsHidden() bool
|
||||
OnNextLine() error
|
||||
OnPrevLine() error
|
||||
OnClick() error
|
||||
|
|
@ -307,3 +311,11 @@ func (self *SideListPanel[T]) SetContextIndex(index int) {
|
|||
func (self *SideListPanel[T]) IsFilterDisabled() bool {
|
||||
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),
|
||||
}
|
||||
},
|
||||
hide: func() bool {
|
||||
return !gui.DockerCommand.InDockerComposeProject
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue