mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Allow showing Disabled errors as error panel instead of toast
This commit is contained in:
@ -173,6 +173,10 @@ func (self *MenuContext) GetKeybindings(opts types.KeybindingsOpts) []*types.Bin
|
|||||||
|
|
||||||
func (self *MenuContext) OnMenuPress(selectedItem *types.MenuItem) error {
|
func (self *MenuContext) OnMenuPress(selectedItem *types.MenuItem) error {
|
||||||
if selectedItem != nil && selectedItem.DisabledReason != nil {
|
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)
|
self.c.ErrorToast(self.c.Tr.DisabledMenuItemPrefix + selectedItem.DisabledReason.Text)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -890,7 +890,7 @@ func (self *LocalCommitsController) notMidRebase() *types.DisabledReason {
|
|||||||
// For getting disabled reason
|
// For getting disabled reason
|
||||||
func (self *LocalCommitsController) canFindCommitForQuickStart() *types.DisabledReason {
|
func (self *LocalCommitsController) canFindCommitForQuickStart() *types.DisabledReason {
|
||||||
if _, err := self.findCommitForQuickStartInteractiveRebase(); err != nil {
|
if _, err := self.findCommitForQuickStartInteractiveRebase(); err != nil {
|
||||||
return &types.DisabledReason{Text: err.Error()}
|
return &types.DisabledReason{Text: err.Error(), ShowErrorInPanel: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -416,6 +416,10 @@ func (gui *Gui) callKeybindingHandler(binding *types.Binding) error {
|
|||||||
disabledReason = binding.GetDisabledReason()
|
disabledReason = binding.GetDisabledReason()
|
||||||
}
|
}
|
||||||
if disabledReason != nil {
|
if disabledReason != nil {
|
||||||
|
if disabledReason.ShowErrorInPanel {
|
||||||
|
return gui.c.ErrorMsg(disabledReason.Text)
|
||||||
|
}
|
||||||
|
|
||||||
gui.c.ErrorToast(gui.Tr.DisabledMenuItemPrefix + disabledReason.Text)
|
gui.c.ErrorToast(gui.Tr.DisabledMenuItemPrefix + disabledReason.Text)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,12 @@ type MenuSection struct {
|
|||||||
|
|
||||||
type DisabledReason struct {
|
type DisabledReason struct {
|
||||||
Text string
|
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 {
|
type MenuItem struct {
|
||||||
|
@ -52,7 +52,10 @@ var QuickStart = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
// Verify we can't quick start from main
|
// Verify we can't quick start from main
|
||||||
Press(keys.Commits.StartInteractiveRebase)
|
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().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
|
Reference in New Issue
Block a user