summaryrefslogtreecommitdiffstats
path: root/pkg/gui/stash_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-15 16:36:39 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-15 18:01:43 +1000
commitd9fa02c53bb9b401f1b5ca07e8ed239862052a42 (patch)
tree9ce89793ba22ffc190ab6133365035dda4ec1ade /pkg/gui/stash_panel.go
parentc44ee71ad4ca44a407613c1e91f7d720acfa84f6 (diff)
clean up interface for popup panels
Diffstat (limited to 'pkg/gui/stash_panel.go')
-rw-r--r--pkg/gui/stash_panel.go46
1 files changed, 29 insertions, 17 deletions
diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go
index a6f2d0b48..6979591ab 100644
--- a/pkg/gui/stash_panel.go
+++ b/pkg/gui/stash_panel.go
@@ -76,11 +76,15 @@ func (gui *Gui) handleStashApply(g *gocui.Gui, v *gocui.View) error {
return apply()
}
- title := gui.Tr.SLocalize("StashApply")
- message := gui.Tr.SLocalize("SureApplyStashEntry")
- return gui.createConfirmationPanel(g, v, true, title, message, func(g *gocui.Gui, v *gocui.View) error {
- return apply()
- }, nil)
+ return gui.createConfirmationPanel(createConfirmationPanelOpts{
+ returnToView: v,
+ returnFocusOnClose: true,
+ title: gui.Tr.SLocalize("StashApply"),
+ prompt: gui.Tr.SLocalize("SureApplyStashEntry"),
+ handleConfirm: func() error {
+ return apply()
+ },
+ })
}
func (gui *Gui) handleStashPop(g *gocui.Gui, v *gocui.View) error {
@@ -94,19 +98,27 @@ func (gui *Gui) handleStashPop(g *gocui.Gui, v *gocui.View) error {
return pop()
}
- title := gui.Tr.SLocalize("StashPop")
- message := gui.Tr.SLocalize("SurePopStashEntry")
- return gui.createConfirmationPanel(g, v, true, title, message, func(g *gocui.Gui, v *gocui.View) error {
- return pop()
- }, nil)
+ return gui.createConfirmationPanel(createConfirmationPanelOpts{
+ returnToView: v,
+ returnFocusOnClose: true,
+ title: gui.Tr.SLocalize("StashPop"),
+ prompt: gui.Tr.SLocalize("SurePopStashEntry"),
+ handleConfirm: func() error {
+ return pop()
+ },
+ })
}
func (gui *Gui) handleStashDrop(g *gocui.Gui, v *gocui.View) error {
- title := gui.Tr.SLocalize("StashDrop")
- message := gui.Tr.SLocalize("SureDropStashEntry")
- return gui.createConfirmationPanel(g, v, true, title, message, func(g *gocui.Gui, v *gocui.View) error {
- return gui.stashDo(g, v, "drop")
- }, nil)
+ return gui.createConfirmationPanel(createConfirmationPanelOpts{
+ returnToView: v,
+ returnFocusOnClose: true,
+ title: gui.Tr.SLocalize("StashDrop"),
+ prompt: gui.Tr.SLocalize("SureDropStashEntry"),
+ handleConfirm: func() error {
+ return gui.stashDo(g, v, "drop")
+ },
+ })
}
func (gui *Gui) stashDo(g *gocui.Gui, v *gocui.View, method string) error {
@@ -130,8 +142,8 @@ func (gui *Gui) handleStashSave(stashFunc func(message string) error) error {
if len(gui.trackedFiles()) == 0 && len(gui.stagedFiles()) == 0 {
return gui.createErrorPanel(gui.Tr.SLocalize("NoTrackedStagedFilesStash"))
}
- return gui.createPromptPanel(gui.g, gui.getFilesView(), gui.Tr.SLocalize("StashChanges"), "", func(g *gocui.Gui, v *gocui.View) error {
- if err := stashFunc(gui.trimmedContent(v)); err != nil {
+ return gui.createPromptPanel(gui.getFilesView(), gui.Tr.SLocalize("StashChanges"), "", func(stashComment string) error {
+ if err := stashFunc(stashComment); err != nil {
return gui.surfaceError(err)
}
return gui.refreshSidePanels(refreshOptions{scope: []int{STASH, FILES}})