summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-02-14 23:16:14 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-02-15 08:47:36 +1100
commit8ef3297b11c3ab14221a50a49c0660be1257e58c (patch)
treee282a65c8db67b8a83a7457c35df653db0ad76a8 /pkg/gui
parent27c7aeb1177f95f63e49af3fea5844acf4e01d64 (diff)
refactor reflog reset options panel
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/reflog_reset_options_panel.go29
1 files changed, 12 insertions, 17 deletions
diff --git a/pkg/gui/reflog_reset_options_panel.go b/pkg/gui/reflog_reset_options_panel.go
index c76dfed81..11315a901 100644
--- a/pkg/gui/reflog_reset_options_panel.go
+++ b/pkg/gui/reflog_reset_options_panel.go
@@ -20,6 +20,7 @@ func (r *reflogResetOption) GetDisplayStrings(isFocused bool) []string {
func (gui *Gui) handleCreateReflogResetMenu(g *gocui.Gui, v *gocui.View) error {
commit := gui.getSelectedReflogCommit()
+ red := color.New(color.FgRed)
resetFunction := func(reset func(string) error) 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"),
- command: fmt.Sprintf("reset --hard %s", commit.Sha),
- handler: resetFunction(gui.GitCommand.ResetHard),
- },
- {
- description: gui.Tr.SLocalize("softReset"),
- command: fmt.Sprintf("reset --soft %s", commit.Sha),
- handler: resetFunction(gui.GitCommand.ResetSoft),
+ displayStrings: []string{
+ gui.Tr.SLocalize("hardReset"),
+ red.Sprint(fmt.Sprintf("reset --hard %s", commit.Sha)),
+ },
+ onPress: resetFunction(gui.GitCommand.ResetHard),
},
{
- description: gui.Tr.SLocalize("cancel"),
- handler: func() error {
- return nil
+ displayStrings: []string{
+ gui.Tr.SLocalize("softReset"),
+ red.Sprint(fmt.Sprintf("reset --soft %s", commit.Sha)),
},
+ onPress: resetFunction(gui.GitCommand.ResetSoft),
},
}
- handleMenuPress := func(index int) error {
- return options[index].handler()
- }
-
- return gui.createMenu("", options, len(options), handleMenuPress)
+ return gui.createMenuNew("", menuItems, createMenuOptions{showCancel: true})
}