mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-06 23:46:13 +02:00
refactor reflog reset options panel
This commit is contained in:
parent
27c7aeb117
commit
8ef3297b11
@ -20,6 +20,7 @@ func (r *reflogResetOption) GetDisplayStrings(isFocused bool) []string {
|
|||||||
|
|
||||||
func (gui *Gui) handleCreateReflogResetMenu(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleCreateReflogResetMenu(g *gocui.Gui, v *gocui.View) error {
|
||||||
commit := gui.getSelectedReflogCommit()
|
commit := gui.getSelectedReflogCommit()
|
||||||
|
red := color.New(color.FgRed)
|
||||||
|
|
||||||
resetFunction := func(reset func(string) error) func() error {
|
resetFunction := func(reset func(string) error) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
@ -33,28 +34,22 @@ func (gui *Gui) handleCreateReflogResetMenu(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options := []*reflogResetOption{
|
menuItems := []*menuItem{
|
||||||
{
|
{
|
||||||
description: gui.Tr.SLocalize("hardReset"),
|
displayStrings: []string{
|
||||||
command: fmt.Sprintf("reset --hard %s", commit.Sha),
|
gui.Tr.SLocalize("hardReset"),
|
||||||
handler: resetFunction(gui.GitCommand.ResetHard),
|
red.Sprint(fmt.Sprintf("reset --hard %s", commit.Sha)),
|
||||||
|
},
|
||||||
|
onPress: resetFunction(gui.GitCommand.ResetHard),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: gui.Tr.SLocalize("softReset"),
|
displayStrings: []string{
|
||||||
command: fmt.Sprintf("reset --soft %s", commit.Sha),
|
gui.Tr.SLocalize("softReset"),
|
||||||
handler: resetFunction(gui.GitCommand.ResetSoft),
|
red.Sprint(fmt.Sprintf("reset --soft %s", commit.Sha)),
|
||||||
},
|
|
||||||
{
|
|
||||||
description: gui.Tr.SLocalize("cancel"),
|
|
||||||
handler: func() error {
|
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
|
onPress: resetFunction(gui.GitCommand.ResetSoft),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMenuPress := func(index int) error {
|
return gui.createMenuNew("", menuItems, createMenuOptions{showCancel: true})
|
||||||
return options[index].handler()
|
|
||||||
}
|
|
||||||
|
|
||||||
return gui.createMenu("", options, len(options), handleMenuPress)
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user