From c60b347de476a9fa208284288ec82b835d4e7585 Mon Sep 17 00:00:00 2001 From: Andre Azzolini Date: Wed, 16 Aug 2023 10:10:12 -0600 Subject: [PATCH 1/3] chore: fix panic when pressing tab if no secrets are visible --- pkg/tui/gui/cmp_secrets.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/tui/gui/cmp_secrets.go b/pkg/tui/gui/cmp_secrets.go index 9edbde99..83c6c10d 100644 --- a/pkg/tui/gui/cmp_secrets.go +++ b/pkg/tui/gui/cmp_secrets.go @@ -219,6 +219,10 @@ func (self *SecretsComponent) createSVMs() error { } func (self *SecretsComponent) ToggleNameValue() error { + if len(self.visibleSVMs()) == 0 { + return nil + } + isNameFocused := strings.Index(self.gui.g.CurrentView().Name(), "SVM:Name:") == 0 isEditing := self.gui.g.CurrentView().Editable From 1f047a0abb68d831b2aa1a22769884cc613a084e Mon Sep 17 00:00:00 2001 From: Andre Azzolini Date: Wed, 16 Aug 2023 10:23:25 -0600 Subject: [PATCH 2/3] chore: require project to launch the TUI --- pkg/tui/tui_app.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/tui/tui_app.go b/pkg/tui/tui_app.go index 485fe27c..9a614c6a 100644 --- a/pkg/tui/tui_app.go +++ b/pkg/tui/tui_app.go @@ -17,10 +17,12 @@ package tui import ( "log" + "os" "github.com/DopplerHQ/cli/pkg/models" "github.com/DopplerHQ/cli/pkg/tui/common" "github.com/DopplerHQ/cli/pkg/tui/gui" + "github.com/DopplerHQ/cli/pkg/utils" ) type App struct { @@ -34,6 +36,11 @@ func Start(opts models.ScopedOptions) { log.Fatal(err) } + if cmn.Opts.EnclaveProject.Value == "" { + utils.Log("You must run `doppler setup` prior to launching the TUI") + os.Exit(1) + } + gui, err := gui.NewGui(cmn) if err != nil { log.Fatal(err) From 5c2922ce45e653d85b56cffec7d19c90e314fa13 Mon Sep 17 00:00:00 2001 From: Andre Azzolini Date: Wed, 16 Aug 2023 10:32:54 -0600 Subject: [PATCH 3/3] chore: focus first visible SVM when secrets change Previously, if there was a filter applied that hid the first SVM, we would incorrectly focus that hidden secret, which would prevent the ability to select secrets. --- pkg/tui/gui/cmp_secrets.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/tui/gui/cmp_secrets.go b/pkg/tui/gui/cmp_secrets.go index 83c6c10d..fb05a08f 100644 --- a/pkg/tui/gui/cmp_secrets.go +++ b/pkg/tui/gui/cmp_secrets.go @@ -204,8 +204,9 @@ func (self *SecretsComponent) createSVMs() error { } } - if len(self.secretVMs) > 0 { - self.activeSVM = self.secretVMs[0] + visibleSVMs := self.visibleSVMs() + if len(visibleSVMs) > 0 { + self.activeSVM = visibleSVMs[0] } curViewName := self.gui.g.CurrentView().Name()