mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-19 22:33:16 +02:00
refactor stash options menu
This commit is contained in:
parent
fd4f37b5c3
commit
6fdc1791e4
@ -548,43 +548,23 @@ func (gui *Gui) handleCustomCommand(g *gocui.Gui, v *gocui.View) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type stashOption struct {
|
|
||||||
description string
|
|
||||||
handler func() error
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetDisplayStrings is a function.
|
|
||||||
func (o *stashOption) GetDisplayStrings(isFocused bool) []string {
|
|
||||||
return []string{o.description}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) handleCreateStashMenu(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleCreateStashMenu(g *gocui.Gui, v *gocui.View) error {
|
||||||
options := []*stashOption{
|
menuItems := []*menuItem{
|
||||||
{
|
{
|
||||||
description: gui.Tr.SLocalize("stashAllChanges"),
|
displayString: gui.Tr.SLocalize("stashAllChanges"),
|
||||||
handler: func() error {
|
onPress: func() error {
|
||||||
return gui.handleStashSave(gui.GitCommand.StashSave)
|
return gui.handleStashSave(gui.GitCommand.StashSave)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: gui.Tr.SLocalize("stashStagedChanges"),
|
displayString: gui.Tr.SLocalize("stashStagedChanges"),
|
||||||
handler: func() error {
|
onPress: func() error {
|
||||||
return gui.handleStashSave(gui.GitCommand.StashSaveStagedChanges)
|
return gui.handleStashSave(gui.GitCommand.StashSaveStagedChanges)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
description: gui.Tr.SLocalize("cancel"),
|
|
||||||
handler: func() error {
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMenuPress := func(index int) error {
|
return gui.createMenuNew(gui.Tr.SLocalize("stashOptions"), menuItems, createMenuOptions{showCancel: true})
|
||||||
return options[index].handler()
|
|
||||||
}
|
|
||||||
|
|
||||||
return gui.createMenu(gui.Tr.SLocalize("stashOptions"), options, len(options), handleMenuPress)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleStashChanges(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleStashChanges(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user