From 1744b45765d2aa78c3454180d2bce4cc66f60cdd Mon Sep 17 00:00:00 2001 From: Joana Hrotko Date: Thu, 26 Sep 2024 09:48:37 +0100 Subject: [PATCH] Show watch error message and open DD only when w is pressed Signed-off-by: Joana Hrotko --- cmd/formatter/shortcut.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cmd/formatter/shortcut.go b/cmd/formatter/shortcut.go index 1a4d73355..625ffc44e 100644 --- a/cmd/formatter/shortcut.go +++ b/cmd/formatter/shortcut.go @@ -288,19 +288,7 @@ func (lk *LogKeyboard) keyboardError(prefix string, err error) { func (lk *LogKeyboard) StartWatch(ctx context.Context, doneCh chan bool, project *types.Project, options api.UpOptions) { if !lk.IsWatchConfigured { - if lk.IsDDComposeUIActive { - // we try to open watch docs - lk.openDDWatchDocs(ctx, project) - } - // either way we mark menu/watch as an error - eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{}, - func(ctx context.Context) error { - err := fmt.Errorf("Watch is not yet configured. Learn more: %s", ansiColor(CYAN, "https://docs.docker.com/compose/file-watch/")) - lk.keyboardError("Watch", err) - return err - })) return - } lk.Watch.switchWatching() if !lk.Watch.isWatching() { @@ -330,6 +318,20 @@ func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Cont case 'v': lk.openDockerDesktop(ctx, project) case 'w': + if !lk.IsWatchConfigured { + if lk.IsDDComposeUIActive { + // we try to open watch docs + lk.openDDWatchDocs(ctx, project) + } + // either way we mark menu/watch as an error + eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{}, + func(ctx context.Context) error { + err := fmt.Errorf("watch is not yet configured. Learn more: %s", ansiColor(CYAN, "https://docs.docker.com/compose/file-watch/")) + lk.keyboardError("Watch", err) + return err + })) + return + } lk.StartWatch(ctx, doneCh, project, options) case 'o': lk.openDDComposeUI(ctx, project)