diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-02-14 23:36:55 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-02-15 08:47:36 +1100 |
commit | 6fdc1791e4197a4149e80323c72ea00d6317bd74 (patch) | |
tree | 1c56b7fea220afccbe1a8cc8291cb7c013bce430 /pkg/gui/files_panel.go | |
parent | fd4f37b5c323a4cc303c521c59d63f973ba3047e (diff) |
refactor stash options menu
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r-- | pkg/gui/files_panel.go | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index c2f3b9206..a92561a50 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -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 { - options := []*stashOption{ + menuItems := []*menuItem{ { - description: gui.Tr.SLocalize("stashAllChanges"), - handler: func() error { + displayString: gui.Tr.SLocalize("stashAllChanges"), + onPress: func() error { return gui.handleStashSave(gui.GitCommand.StashSave) }, }, { - description: gui.Tr.SLocalize("stashStagedChanges"), - handler: func() error { + displayString: gui.Tr.SLocalize("stashStagedChanges"), + onPress: func() error { return gui.handleStashSave(gui.GitCommand.StashSaveStagedChanges) }, }, - { - description: gui.Tr.SLocalize("cancel"), - handler: func() error { - return nil - }, - }, - } - - handleMenuPress := func(index int) error { - return options[index].handler() } - return gui.createMenu(gui.Tr.SLocalize("stashOptions"), options, len(options), handleMenuPress) + return gui.createMenuNew(gui.Tr.SLocalize("stashOptions"), menuItems, createMenuOptions{showCancel: true}) } func (gui *Gui) handleStashChanges(g *gocui.Gui, v *gocui.View) error { |