diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-11-28 13:35:58 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-11-28 20:48:17 +1100 |
commit | 5671ec5f5867c3c2b083563bac309c8616b322ae (patch) | |
tree | f0cd4ed218be9a4a87b9e60782a2fc97ba2d81cb /pkg/gui/tags_panel.go | |
parent | da3b0bf7c8aa6202d5eb9c8178f6648bc695336a (diff) |
refactor prompt opts
Diffstat (limited to 'pkg/gui/tags_panel.go')
-rw-r--r-- | pkg/gui/tags_panel.go | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/pkg/gui/tags_panel.go b/pkg/gui/tags_panel.go index 6a4ad3832..5425253f0 100644 --- a/pkg/gui/tags_panel.go +++ b/pkg/gui/tags_panel.go @@ -97,36 +97,43 @@ func (gui *Gui) handlePushTag(g *gocui.Gui, v *gocui.View) error { }, ) - return gui.prompt(title, "origin", func(response string) error { - return gui.WithWaitingStatus(gui.Tr.PushingTagStatus, func() error { - err := gui.GitCommand.PushTag(response, tag.Name, gui.promptUserForCredential) - gui.handleCredentialsPopup(err) - - return nil - }) + return gui.prompt(promptOpts{ + title: title, + initialContent: "origin", + handleConfirm: func(response string) error { + return gui.WithWaitingStatus(gui.Tr.PushingTagStatus, func() error { + err := gui.GitCommand.PushTag(response, tag.Name, gui.promptUserForCredential) + gui.handleCredentialsPopup(err) + + return nil + }) + }, }) } func (gui *Gui) handleCreateTag(g *gocui.Gui, v *gocui.View) error { - return gui.prompt(gui.Tr.CreateTagTitle, "", func(tagName string) error { - // leaving commit SHA blank so that we're just creating the tag for the current commit - if err := gui.GitCommand.CreateLightweightTag(tagName, ""); err != nil { - return gui.surfaceError(err) - } - return gui.refreshSidePanels(refreshOptions{scope: []int{COMMITS, TAGS}, then: func() { - // find the index of the tag and set that as the currently selected line - for i, tag := range gui.State.Tags { - if tag.Name == tagName { - gui.State.Panels.Tags.SelectedLineIdx = i - if err := gui.Contexts.Tags.Context.HandleRender(); err != nil { - gui.Log.Error(err) + return gui.prompt(promptOpts{ + title: gui.Tr.CreateTagTitle, + handleConfirm: func(tagName string) error { + // leaving commit SHA blank so that we're just creating the tag for the current commit + if err := gui.GitCommand.CreateLightweightTag(tagName, ""); err != nil { + return gui.surfaceError(err) + } + return gui.refreshSidePanels(refreshOptions{scope: []int{COMMITS, TAGS}, then: func() { + // find the index of the tag and set that as the currently selected line + for i, tag := range gui.State.Tags { + if tag.Name == tagName { + gui.State.Panels.Tags.SelectedLineIdx = i + if err := gui.Contexts.Tags.Context.HandleRender(); err != nil { + gui.Log.Error(err) + } + + return } - - return } - } + }, + }) }, - }) }) } |