mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
default to container view when not in docker-compose context
This commit is contained in:
parent
750437d572
commit
344e5ecda5
2 changed files with 13 additions and 8 deletions
|
|
@ -131,14 +131,8 @@ type guiState struct {
|
|||
|
||||
// NewGui builds a new gui handler
|
||||
func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand *commands.OSCommand, tr *i18n.TranslationSet, config *config.AppConfig, errorChan chan error) (*Gui, error) {
|
||||
previousView := "containers"
|
||||
if dockerCommand.InDockerComposeProject {
|
||||
previousView = "services"
|
||||
}
|
||||
|
||||
initialState := guiState{
|
||||
PreviousView: previousView,
|
||||
Platform: *oSCommand.Platform,
|
||||
Platform: *oSCommand.Platform,
|
||||
Panels: &panelStates{
|
||||
Services: &servicePanelState{SelectedLine: -1, ContextIndex: 0},
|
||||
Containers: &containerPanelState{SelectedLine: -1, ContextIndex: 0},
|
||||
|
|
@ -390,3 +384,10 @@ func (gui *Gui) shouldRefresh(key string) bool {
|
|||
gui.State.Panels.Main.ObjectKey = key
|
||||
return true
|
||||
}
|
||||
|
||||
func (gui *Gui) initiallyFocusedViewName() string {
|
||||
if gui.DockerCommand.InDockerComposeProject {
|
||||
return "services"
|
||||
}
|
||||
return "containers"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -275,7 +275,11 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||
if gui.g.CurrentView() == nil {
|
||||
v, err := gui.g.View(gui.State.PreviousView)
|
||||
if err != nil {
|
||||
v = gui.getServicesView()
|
||||
viewName := gui.initiallyFocusedViewName()
|
||||
v, err = gui.g.View(viewName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := gui.switchFocus(gui.g, nil, v); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue