summaryrefslogtreecommitdiffstats
path: root/pkg/gui/git_flow.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-28 20:44:36 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commita90b6efded49abcfa2516db794d7875b0396f558 (patch)
treead9c3738830437064ada223f0978dab1d726b479 /pkg/gui/git_flow.go
parentfa8571e1f4c349e401542285ea238acdbd9d17ec (diff)
start refactoring gui
Diffstat (limited to 'pkg/gui/git_flow.go')
-rw-r--r--pkg/gui/git_flow.go62
1 files changed, 32 insertions, 30 deletions
diff --git a/pkg/gui/git_flow.go b/pkg/gui/git_flow.go
index e89c7637c..ab58adfe8 100644
--- a/pkg/gui/git_flow.go
+++ b/pkg/gui/git_flow.go
@@ -3,6 +3,7 @@ package gui
import (
"fmt"
+ "github.com/jesseduffield/lazygit/pkg/gui/popup"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -13,16 +14,16 @@ func (gui *Gui) handleCreateGitFlowMenu() error {
}
if !gui.Git.Flow.GitFlowEnabled() {
- return gui.createErrorPanel("You need to install git-flow and enable it in this repo to use git-flow features")
+ return gui.PopupHandler.ErrorMsg("You need to install git-flow and enable it in this repo to use git-flow features")
}
startHandler := func(branchType string) func() error {
return func() error {
title := utils.ResolvePlaceholderString(gui.Tr.NewGitFlowBranchPrompt, map[string]string{"branchType": branchType})
- return gui.prompt(promptOpts{
- title: title,
- handleConfirm: func(name string) error {
+ return gui.PopupHandler.Prompt(popup.PromptOpts{
+ Title: title,
+ HandleConfirm: func(name string) error {
gui.logAction(gui.Tr.Actions.GitFlowStart)
return gui.runSubprocessWithSuspenseAndRefresh(
gui.Git.Flow.StartCmdObj(branchType, name),
@@ -32,39 +33,40 @@ func (gui *Gui) handleCreateGitFlowMenu() error {
}
}
- menuItems := []*menuItem{
- {
- // not localising here because it's one to one with the actual git flow commands
- displayString: fmt.Sprintf("finish branch '%s'", branch.Name),
- onPress: func() error {
- return gui.gitFlowFinishBranch(branch.Name)
+ return gui.PopupHandler.Menu(popup.CreateMenuOptions{
+ Title: "git flow",
+ Items: []*popup.MenuItem{
+ {
+ // not localising here because it's one to one with the actual git flow commands
+ DisplayString: fmt.Sprintf("finish branch '%s'", branch.Name),
+ OnPress: func() error {
+ return gui.gitFlowFinishBranch(branch.Name)
+ },
+ },
+ {
+ DisplayString: "start feature",
+ OnPress: startHandler("feature"),
+ },
+ {
+ DisplayString: "start hotfix",
+ OnPress: startHandler("hotfix"),
+ },
+ {
+ DisplayString: "start bugfix",
+ OnPress: startHandler("bugfix"),
+ },
+ {
+ DisplayString: "start release",
+ OnPress: startHandler("release"),
},
},
- {
- displayString: "start feature",
- onPress: startHandler("feature"),
- },
- {
- displayString: "start hotfix",
- onPress: startHandler("hotfix"),
- },
- {
- displayString: "start bugfix",
- onPress: startHandler("bugfix"),
- },
- {
- displayString: "start release",
- onPress: startHandler("release"),
- },
- }
-
- return gui.createMenu("git flow", menuItems, createMenuOptions{})
+ })
}
func (gui *Gui) gitFlowFinishBranch(branchName string) error {
cmdObj, err := gui.Git.Flow.FinishCmdObj(branchName)
if err != nil {
- return gui.surfaceError(err)
+ return gui.PopupHandler.Error(err)
}
gui.logAction(gui.Tr.Actions.GitFlowFinish)