default to container view when not in docker-compose context

This commit is contained in:
Jesse Duffield 2019-07-01 23:30:51 +10:00
parent 750437d572
commit 344e5ecda5
2 changed files with 13 additions and 8 deletions

View file

@ -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"
}

View file

@ -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 {