From 8dce3ece2b68709174eff83a58b2473f954684cc Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 12 Dec 2020 21:50:08 +0200 Subject: [PATCH] Open in browser: show menu item only if web port is published --- menus.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/menus.go b/menus.go index 81e6d01..8edae80 100644 --- a/menus.go +++ b/menus.go @@ -223,7 +223,9 @@ func ContainerMenu() MenuFn { items = append(items, menu.Item{Val: "pause", Label: "[p] pause"}) items = append(items, menu.Item{Val: "restart", Label: "[r] restart"}) items = append(items, menu.Item{Val: "exec", Label: "[e] exec shell"}) - items = append(items, menu.Item{Val: "browser", Label: "[w] open in browser"}) + if c.Meta["Web Port"] != "" { + items = append(items, menu.Item{Val: "browser", Label: "[w] open in browser"}) + } } if c.Meta["state"] == "exited" || c.Meta["state"] == "created" { items = append(items, menu.Item{Val: "start", Label: "[s] start"}) @@ -280,9 +282,11 @@ func ContainerMenu() MenuFn { selected = "restart" ui.StopLoop() }) - ui.Handle("/sys/kbd/w", func(ui.Event) { - selected = "browser" - }) + if c.Meta["Web Port"] != "" { + ui.Handle("/sys/kbd/w", func(ui.Event) { + selected = "browser" + }) + } } ui.Handle("/sys/kbd/R", func(ui.Event) { selected = "remove"