Skip to content

Commit

Permalink
remove startMenu fn
Browse files Browse the repository at this point in the history
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
  • Loading branch information
jhrotko committed Mar 28, 2024
1 parent 3436537 commit 5d9fa4b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 32 deletions.
8 changes: 4 additions & 4 deletions cmd/compose/up.go
Expand Up @@ -80,13 +80,13 @@ func (opts upOptions) apply(project *types.Project, services []string) (*types.P
}

func (opts *upOptions) validateNavigationMenu(dockerCli command.Cli, experimentals *experimental.State) {
if !dockerCli.Out().IsTerminal() {
opts.navigationMenu = false
return
}
if !opts.navigationMenuChanged {
opts.navigationMenu = SetUnchangedOption(ComposeMenu, experimentals.NavBar())
}

if opts.navigationMenu && !dockerCli.Out().IsTerminal() {
opts.navigationMenu = false
}
}

func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service, experiments *experimental.State) *cobra.Command {
Expand Down
44 changes: 16 additions & 28 deletions pkg/compose/up.go
Expand Up @@ -90,7 +90,22 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
first = false
}

kEvents := s.startMenu(ctx, project, options, signalChan)
var kEvents <-chan keyboard.KeyEvent
if options.Start.NavigationMenu {
kEvents, err = keyboard.GetKeys(100)
if err != nil {
logrus.Warn("could not start menu, an error occurred while starting.")
} else {
isWatchConfigured := s.shouldWatch(project)
isDockerDesktopActive := s.isDesktopIntegrationActive()
tracing.KeyboardMetrics(ctx, options.Start.NavigationMenu, isDockerDesktopActive, isWatchConfigured)

formatter.NewKeyboardManager(ctx, isDockerDesktopActive, isWatchConfigured, signalChan, s.Watch)
if options.Start.Watch {
formatter.KeyboardManager.StartWatch(ctx, project, options)
}
}
}
for {
select {
case <-doneCh:
Expand Down Expand Up @@ -165,30 +180,3 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
}
return err
}

func (s *composeService) startMenu(
ctx context.Context,
project *types.Project,
options api.UpOptions,
sc chan<- os.Signal,
) <-chan keyboard.KeyEvent {
if !options.Start.NavigationMenu {
return nil
}
kEvents, err := keyboard.GetKeys(100)
keyboardInitiated := err == nil
if !keyboardInitiated {
logrus.Warn("Could not start Menu - an error occurred while starting.")
return nil
}

isWatchConfigured := s.shouldWatch(project)
isDockerDesktopActive := s.isDesktopIntegrationActive()
tracing.KeyboardMetrics(ctx, options.Start.NavigationMenu, isDockerDesktopActive, isWatchConfigured)

formatter.NewKeyboardManager(ctx, isDockerDesktopActive, isWatchConfigured, sc, s.Watch)
if options.Start.Watch {
formatter.KeyboardManager.StartWatch(ctx, project, options)
}
return kEvents
}

0 comments on commit 5d9fa4b

Please sign in to comment.