summaryrefslogtreecommitdiffstats
path: root/pkg/gui/patch_options_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-02-14 23:32:52 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-02-15 08:47:36 +1100
commitd76e8887e506eace806b03d674e164aba2086123 (patch)
treed1ea3430a09961b744e5ae3c3ce06fb0270d43c1 /pkg/gui/patch_options_panel.go
parenteb9134685a0ffd89771fb0d68b3c3ca33f06445f (diff)
refactor patch options menu panel
Diffstat (limited to 'pkg/gui/patch_options_panel.go')
-rw-r--r--pkg/gui/patch_options_panel.go35
1 files changed, 20 insertions, 15 deletions
diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go
index 00801a203..68c6a0355 100644
--- a/pkg/gui/patch_options_panel.go
+++ b/pkg/gui/patch_options_panel.go
@@ -21,33 +21,38 @@ func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error
return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("NoPatchError"))
}
- options := []*patchMenuOption{
- {displayName: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.CommitSha), function: gui.handleDeletePatchFromCommit},
- {displayName: "pull patch out into index", function: gui.handlePullPatchIntoWorkingTree},
- {displayName: "reset patch", function: gui.handleResetPatch},
+ menuItems := []*menuItem{
+ {
+ displayString: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.CommitSha),
+ onPress: gui.handleDeletePatchFromCommit,
+ },
+ {
+ displayString: "pull patch out into index",
+ onPress: gui.handlePullPatchIntoWorkingTree,
+ },
+ {
+ displayString: "reset patch",
+ onPress: gui.handleResetPatch,
+ },
}
selectedCommit := gui.getSelectedCommit(gui.g)
if selectedCommit != nil && gui.GitCommand.PatchManager.CommitSha != selectedCommit.Sha {
// adding this option to index 1
- options = append(
- options[:1],
+ menuItems = append(
+ menuItems[:1],
append(
- []*patchMenuOption{
+ []*menuItem{
{
- displayName: fmt.Sprintf("move patch to selected commit (%s)", selectedCommit.Sha),
- function: gui.handleMovePatchToSelectedCommit,
+ displayString: fmt.Sprintf("move patch to selected commit (%s)", selectedCommit.Sha),
+ onPress: gui.handleMovePatchToSelectedCommit,
},
- }, options[1:]...,
+ }, menuItems[1:]...,
)...,
)
}
- handleMenuPress := func(index int) error {
- return options[index].function()
- }
-
- return gui.createMenu(gui.Tr.SLocalize("PatchOptionsTitle"), options, len(options), handleMenuPress)
+ return gui.createMenuNew(gui.Tr.SLocalize("PatchOptionsTitle"), menuItems, createMenuOptions{showCancel: true})
}
func (gui *Gui) getPatchCommitIndex() int {