diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/context/menu_context.go | 4 | ||||
-rw-r--r-- | pkg/gui/controllers/local_commits_controller.go | 2 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 4 | ||||
-rw-r--r-- | pkg/gui/types/common.go | 6 | ||||
-rw-r--r-- | pkg/integration/tests/interactive_rebase/quick_start.go | 5 |
5 files changed, 19 insertions, 2 deletions
diff --git a/pkg/gui/context/menu_context.go b/pkg/gui/context/menu_context.go index d7c982651..b5c1a3c20 100644 --- a/pkg/gui/context/menu_context.go +++ b/pkg/gui/context/menu_context.go @@ -173,6 +173,10 @@ func (self *MenuContext) GetKeybindings(opts types.KeybindingsOpts) []*types.Bin func (self *MenuContext) OnMenuPress(selectedItem *types.MenuItem) error { if selectedItem != nil && selectedItem.DisabledReason != nil { + if selectedItem.DisabledReason.ShowErrorInPanel { + return self.c.ErrorMsg(selectedItem.DisabledReason.Text) + } + self.c.ErrorToast(self.c.Tr.DisabledMenuItemPrefix + selectedItem.DisabledReason.Text) return nil } diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index ea2038f71..97151f4fe 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -890,7 +890,7 @@ func (self *LocalCommitsController) notMidRebase() *types.DisabledReason { // For getting disabled reason func (self *LocalCommitsController) canFindCommitForQuickStart() *types.DisabledReason { if _, err := self.findCommitForQuickStartInteractiveRebase(); err != nil { - return &types.DisabledReason{Text: err.Error()} + return &types.DisabledReason{Text: err.Error(), ShowErrorInPanel: true} } return nil diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 4a64dbde5..26ce8ec91 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -416,6 +416,10 @@ func (gui *Gui) callKeybindingHandler(binding *types.Binding) error { disabledReason = binding.GetDisabledReason() } if disabledReason != nil { + if disabledReason.ShowErrorInPanel { + return gui.c.ErrorMsg(disabledReason.Text) + } + gui.c.ErrorToast(gui.Tr.DisabledMenuItemPrefix + disabledReason.Text) return nil } diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 79b4e153c..9053e43f9 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -203,6 +203,12 @@ type MenuSection struct { type DisabledReason struct { Text string + + // When trying to invoke a disabled key binding or menu item, we normally + // show the disabled reason as a toast; setting this to true shows it as an + // error panel instead. This is useful if the text is very long, or if it is + // important enough to show it more prominently, or both. + ShowErrorInPanel bool } type MenuItem struct { diff --git a/pkg/integration/tests/interactive_rebase/quick_start.go b/pkg/integration/tests/interactive_rebase/quick_start.go index 9e95f961e..d0454d6cf 100644 --- a/pkg/integration/tests/interactive_rebase/quick_start.go +++ b/pkg/integration/tests/interactive_rebase/quick_start.go @@ -52,7 +52,10 @@ var QuickStart = NewIntegrationTest(NewIntegrationTestArgs{ // Verify we can't quick start from main Press(keys.Commits.StartInteractiveRebase) - t.ExpectToast(Equals("Disabled: Cannot start interactive rebase: the HEAD commit is a merge commit or is present on the main branch, so there is no appropriate base commit to start the rebase from. You can start an interactive rebase from a specific commit by selecting the commit and pressing `e`.")) + t.ExpectPopup().Alert(). + Title(Equals("Error")). + Content(Equals("Cannot start interactive rebase: the HEAD commit is a merge commit or is present on the main branch, so there is no appropriate base commit to start the rebase from. You can start an interactive rebase from a specific commit by selecting the commit and pressing `e`.")). + Confirm() t.Views().Branches(). Focus(). |