mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
Hide project/services panels when not in a docker-compose project
Co-authored-by: jesseduffield <8456633+jesseduffield@users.noreply.github.com>
This commit is contained in:
parent
ebce4fc631
commit
e3c1c8630a
4 changed files with 46 additions and 22 deletions
|
|
@ -176,23 +176,30 @@ func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The project panel is compact (Size: 3) when not focused, but expands
|
// The project panel is compact (Size: 3) when not focused, but expands
|
||||||
// when focused to show the list of projects.
|
// when focused to show the list of projects. This only applies when the
|
||||||
projectBox := &boxlayout.Box{
|
// project panel is actually visible (i.e. we are inside a compose project).
|
||||||
Window: sideWindowNames[0],
|
if len(sideWindowNames) > 0 && sideWindowNames[0] == "project" {
|
||||||
Size: 3,
|
projectBox := &boxlayout.Box{
|
||||||
}
|
|
||||||
if currentWindow == sideWindowNames[0] {
|
|
||||||
projectBox = &boxlayout.Box{
|
|
||||||
Window: sideWindowNames[0],
|
Window: sideWindowNames[0],
|
||||||
Weight: 2,
|
Size: 3,
|
||||||
}
|
}
|
||||||
|
if currentWindow == sideWindowNames[0] {
|
||||||
|
projectBox = &boxlayout.Box{
|
||||||
|
Window: sideWindowNames[0],
|
||||||
|
Weight: 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return append([]*boxlayout.Box{
|
||||||
|
projectBox,
|
||||||
|
}, lo.Map(sideWindowNames[1:], func(window string, _ int) *boxlayout.Box {
|
||||||
|
return accordionBox(&boxlayout.Box{Window: window, Weight: 1})
|
||||||
|
})...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return append([]*boxlayout.Box{
|
return lo.Map(sideWindowNames, func(window string, _ int) *boxlayout.Box {
|
||||||
projectBox,
|
|
||||||
}, lo.Map(sideWindowNames[1:], func(window string, _ int) *boxlayout.Box {
|
|
||||||
return accordionBox(&boxlayout.Box{Window: window, Weight: 1})
|
return accordionBox(&boxlayout.Box{Window: window, Weight: 1})
|
||||||
})...)
|
})
|
||||||
} else {
|
} else {
|
||||||
squashedHeight := 1
|
squashedHeight := 1
|
||||||
if height >= 21 {
|
if height >= 21 {
|
||||||
|
|
|
||||||
|
|
@ -94,14 +94,19 @@ func (gui *Gui) getContainersPanel() *panels.SideListPanel[*commands.Container]
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by selected project. Containers with no project (truly
|
// Only apply project filtering when we are inside a docker-compose
|
||||||
// standalone, not from any compose project) are always shown.
|
// project. Outside of a compose project all containers are shown in
|
||||||
selectedProject := gui.getSelectedProjectName()
|
// a flat list regardless of which compose project they belong to.
|
||||||
if selectedProject == "" {
|
if gui.DockerCommand.InDockerComposeProject {
|
||||||
selectedProject = gui.DockerCommand.LocalProjectName
|
// Filter by selected project. Containers with no project (truly
|
||||||
}
|
// standalone, not from any compose project) are always shown.
|
||||||
if selectedProject != "" && container.ProjectName != "" && container.ProjectName != selectedProject {
|
selectedProject := gui.getSelectedProjectName()
|
||||||
return false
|
if selectedProject == "" {
|
||||||
|
selectedProject = gui.DockerCommand.LocalProjectName
|
||||||
|
}
|
||||||
|
if selectedProject != "" && container.ProjectName != "" && container.ProjectName != selectedProject {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,14 @@ func (gui *Gui) getProjectPanel() *panels.SideListPanel[*commands.Project] {
|
||||||
// containers to show only those belonging to the selected project.
|
// containers to show only those belonging to the selected project.
|
||||||
return gui.renderContainersAndServices()
|
return gui.renderContainersAndServices()
|
||||||
},
|
},
|
||||||
|
Hide: func() bool {
|
||||||
|
// Only show the project panel when we are inside a docker-compose
|
||||||
|
// project directory. When launched outside of a compose project
|
||||||
|
// there is no meaningful local project to display, so we hide the
|
||||||
|
// panel and let the containers panel show all containers in a flat
|
||||||
|
// list (matching the behaviour from before v0.25).
|
||||||
|
return !gui.DockerCommand.InDockerComposeProject
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,12 @@ func (gui *Gui) getServicesPanel() *panels.SideListPanel[*commands.Service] {
|
||||||
return presentation.GetServiceDisplayStrings(&gui.Config.UserConfig.Gui, service)
|
return presentation.GetServiceDisplayStrings(&gui.Config.UserConfig.Gui, service)
|
||||||
},
|
},
|
||||||
Hide: func() bool {
|
Hide: func() bool {
|
||||||
// Show services panel if there are any compose projects (local or discovered)
|
// Only show the services panel when we are inside a docker-compose
|
||||||
return !gui.DockerCommand.InDockerComposeProject && len(gui.Panels.Services.List.GetAllItems()) == 0
|
// project directory. When launched outside of a compose project
|
||||||
|
// there is no local project context, so the panel is hidden and
|
||||||
|
// all containers are shown in a flat list (matching pre-v0.25
|
||||||
|
// behaviour).
|
||||||
|
return !gui.DockerCommand.InDockerComposeProject
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue