more refactoring

pull/392/head
Jesse Duffield 2 years ago
parent 751dbef42e
commit dfff845469

@ -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…
Cancel
Save