Skip to content

Commit e3c1c86

Browse files
Hide project/services panels when not in a docker-compose project
Co-authored-by: jesseduffield <8456633+jesseduffield@users.noreply.github.com>
1 parent ebce4fc commit e3c1c86

4 files changed

Lines changed: 46 additions & 22 deletions

File tree

pkg/gui/arrangement.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,30 @@ func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
176176
}
177177

178178
// The project panel is compact (Size: 3) when not focused, but expands
179-
// when focused to show the list of projects.
180-
projectBox := &boxlayout.Box{
181-
Window: sideWindowNames[0],
182-
Size: 3,
183-
}
184-
if currentWindow == sideWindowNames[0] {
185-
projectBox = &boxlayout.Box{
179+
// when focused to show the list of projects. This only applies when the
180+
// project panel is actually visible (i.e. we are inside a compose project).
181+
if len(sideWindowNames) > 0 && sideWindowNames[0] == "project" {
182+
projectBox := &boxlayout.Box{
186183
Window: sideWindowNames[0],
187-
Weight: 2,
184+
Size: 3,
185+
}
186+
if currentWindow == sideWindowNames[0] {
187+
projectBox = &boxlayout.Box{
188+
Window: sideWindowNames[0],
189+
Weight: 2,
190+
}
188191
}
192+
193+
return append([]*boxlayout.Box{
194+
projectBox,
195+
}, lo.Map(sideWindowNames[1:], func(window string, _ int) *boxlayout.Box {
196+
return accordionBox(&boxlayout.Box{Window: window, Weight: 1})
197+
})...)
189198
}
190199

191-
return append([]*boxlayout.Box{
192-
projectBox,
193-
}, lo.Map(sideWindowNames[1:], func(window string, _ int) *boxlayout.Box {
200+
return lo.Map(sideWindowNames, func(window string, _ int) *boxlayout.Box {
194201
return accordionBox(&boxlayout.Box{Window: window, Weight: 1})
195-
})...)
202+
})
196203
} else {
197204
squashedHeight := 1
198205
if height >= 21 {

pkg/gui/containers_panel.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,19 @@ func (gui *Gui) getContainersPanel() *panels.SideListPanel[*commands.Container]
9494
return false
9595
}
9696

97-
// Filter by selected project. Containers with no project (truly
98-
// standalone, not from any compose project) are always shown.
99-
selectedProject := gui.getSelectedProjectName()
100-
if selectedProject == "" {
101-
selectedProject = gui.DockerCommand.LocalProjectName
102-
}
103-
if selectedProject != "" && container.ProjectName != "" && container.ProjectName != selectedProject {
104-
return false
97+
// Only apply project filtering when we are inside a docker-compose
98+
// project. Outside of a compose project all containers are shown in
99+
// a flat list regardless of which compose project they belong to.
100+
if gui.DockerCommand.InDockerComposeProject {
101+
// Filter by selected project. Containers with no project (truly
102+
// standalone, not from any compose project) are always shown.
103+
selectedProject := gui.getSelectedProjectName()
104+
if selectedProject == "" {
105+
selectedProject = gui.DockerCommand.LocalProjectName
106+
}
107+
if selectedProject != "" && container.ProjectName != "" && container.ProjectName != selectedProject {
108+
return false
109+
}
105110
}
106111

107112
return true

pkg/gui/project_panel.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ func (gui *Gui) getProjectPanel() *panels.SideListPanel[*commands.Project] {
5858
// containers to show only those belonging to the selected project.
5959
return gui.renderContainersAndServices()
6060
},
61+
Hide: func() bool {
62+
// Only show the project panel when we are inside a docker-compose
63+
// project directory. When launched outside of a compose project
64+
// there is no meaningful local project to display, so we hide the
65+
// panel and let the containers panel show all containers in a flat
66+
// list (matching the behaviour from before v0.25).
67+
return !gui.DockerCommand.InDockerComposeProject
68+
},
6169
}
6270
}
6371

pkg/gui/services_panel.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ func (gui *Gui) getServicesPanel() *panels.SideListPanel[*commands.Service] {
9090
return presentation.GetServiceDisplayStrings(&gui.Config.UserConfig.Gui, service)
9191
},
9292
Hide: func() bool {
93-
// Show services panel if there are any compose projects (local or discovered)
94-
return !gui.DockerCommand.InDockerComposeProject && len(gui.Panels.Services.List.GetAllItems()) == 0
93+
// Only show the services panel when we are inside a docker-compose
94+
// project directory. When launched outside of a compose project
95+
// there is no local project context, so the panel is hidden and
96+
// all containers are shown in a flat list (matching pre-v0.25
97+
// behaviour).
98+
return !gui.DockerCommand.InDockerComposeProject
9599
},
96100
}
97101
}

0 commit comments

Comments
 (0)