use the cyclableViewsList to determine what views to show

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit 2019-08-17 09:31:59 +10:00
parent ec76d0ed6f
commit 601f178b0d
2 changed files with 13 additions and 9 deletions

View file

@ -148,11 +148,7 @@ func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand
}
cyclableViews := []string{"project", "containers", "images"}
if config.DockerSwarm {
dockerCommand.InDockerComposeProject = true
}
if dockerCommand.InDockerComposeProject {
// Frustratingly, this is not actually the driver for what views are shown - the InDOckerComposeProject var is used inside the gui code
if dockerCommand.InDockerComposeProject || config.DockerSwarm {
cyclableViews = []string{"project", "services", "containers", "images", "volumes"}
}

View file

@ -93,6 +93,14 @@ func (gui *Gui) layout(g *gocui.Gui) error {
return nil
}
// TODO: should do this once only..
showServicesPanel := false
for _, view := range gui.CyclableViews {
if view == "services" {
showServicesPanel = true
}
}
currView := gui.g.CurrentView()
currentCyclebleView := gui.State.PreviousView
if currView != nil {
@ -114,7 +122,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
tallPanels := 3
var vHeights map[string]int
if gui.DockerCommand.InDockerComposeProject {
if showServicesPanel {
tallPanels++
vHeights = map[string]int{
"project": 3,
@ -146,7 +154,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
"volumes": defaultHeight,
"options": defaultHeight,
}
if gui.DockerCommand.InDockerComposeProject {
if showServicesPanel {
vHeights["services"] = defaultHeight
}
vHeights[currentCyclebleView] = height - defaultHeight*tallPanels - 1
@ -186,7 +194,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
var servicesView *gocui.View
aboveContainersView := "project"
if gui.DockerCommand.InDockerComposeProject {
if showServicesPanel {
aboveContainersView = "services"
servicesView, err = g.SetViewBeneath("services", "project", vHeights["services"])
if err != nil {
@ -205,7 +213,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
return err
}
containersView.Highlight = true
if gui.Config.UserConfig.Gui.ShowAllContainers || !gui.DockerCommand.InDockerComposeProject {
if gui.Config.UserConfig.Gui.ShowAllContainers || !showServicesPanel {
containersView.Title = gui.Tr.ContainersTitle
} else {
containersView.Title = gui.Tr.StandaloneContainersTitle