Skip to content

Commit

Permalink
Add open watch docs in up menu
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 Jun 18, 2024
1 parent 24a281f commit ffbc204
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions cmd/formatter/shortcut.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,25 @@ func (lk *LogKeyboard) navigationMenu() string {
}

var openDDUI string
var openDDWatchDocs string
if openDDInfo != "" {
openDDUI = navColor(" ")
openDDWatchDocs = navColor(" ")
}
if lk.IsDDComposeUIActive {
openDDUI = openDDUI + shortcutKeyColor("o") + navColor(" View Config")
openDDWatchDocs = openDDWatchDocs + shortcutKeyColor("i") + navColor(" Watch Docs")
}
var watchInfo string
if openDDInfo != "" || openDDUI != "" {
if openDDInfo != "" || openDDUI != "" || openDDWatchDocs != "" {
watchInfo = navColor(" ")
}
var isEnabled = " Enable"
if lk.Watch.Watching {
isEnabled = " Disable"
}
watchInfo = watchInfo + shortcutKeyColor("w") + navColor(isEnabled+" Watch")
return openDDInfo + openDDUI + watchInfo
return openDDInfo + openDDUI + watchInfo + openDDWatchDocs
}

func (lk *LogKeyboard) clearNavigationMenu() {
Expand Down Expand Up @@ -261,6 +264,22 @@ func (lk *LogKeyboard) openDDComposeUI(ctx context.Context, project *types.Proje
}),
)
}
func (lk *LogKeyboard) openDDWatchDocs(ctx context.Context, project *types.Project) {
if !lk.IsDDComposeUIActive {
return
}
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/gui/watch", tracing.SpanOptions{},
func(ctx context.Context) error {
link := fmt.Sprintf("docker-desktop://dashboard/docker-compose/%s/watch", project.Name)
err := open.Run(link)
if err != nil {
err = fmt.Errorf("Could not open Docker Desktop Compose UI")
lk.keyboardError("Watch Docs", err)
}
return err
}),
)
}

func (lk *LogKeyboard) keyboardError(prefix string, err error) {
lk.kError.addError(prefix, err)
Expand Down Expand Up @@ -314,6 +333,8 @@ func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Cont
lk.StartWatch(ctx, doneCh, project, options)
case 'o':
lk.openDDComposeUI(ctx, project)
case 'i':
lk.openDDWatchDocs(ctx, project)
}
switch key := event.Key; key {
case keyboard.KeyCtrlC:
Expand Down

0 comments on commit ffbc204

Please sign in to comment.