diff options
author | Moritz Haase <Moritz.Haase@bmw.de> | 2022-03-30 08:48:29 +0200 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-30 20:13:43 +1100 |
commit | 8fb2acc2244ae0364fa20288bfcf70deed3ae974 (patch) | |
tree | 02c132565c7b87bf54f895fbc0d815efce867cd1 /pkg/gui/controllers | |
parent | f2fb6453a13d7e609bb8456843e208e8e3e7901a (diff) |
pkg/gui: Rename IPopupHandler::Ask() to Confirm()
Follow the JavaScript naming scheme for user interaction (alert, prompt,
confirm) as discussed in #1832.
Diffstat (limited to 'pkg/gui/controllers')
18 files changed, 44 insertions, 44 deletions
diff --git a/pkg/gui/controllers/basic_commits_controller.go b/pkg/gui/controllers/basic_commits_controller.go index bfc9655de..a951349cc 100644 --- a/pkg/gui/controllers/basic_commits_controller.go +++ b/pkg/gui/controllers/basic_commits_controller.go @@ -208,7 +208,7 @@ func (self *BasicCommitsController) createResetMenu(commit *models.Commit) error } func (self *BasicCommitsController) checkout(commit *models.Commit) error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.LcCheckoutCommit, Prompt: self.c.Tr.SureCheckoutThisCommit, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index 67975f129..168076135 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -168,7 +168,7 @@ func (self *BisectController) showBisectCompleteMessage(candidateShas []string) return self.c.Error(err) } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Bisect.CompleteTitle, Prompt: fmt.Sprintf(prompt, strings.TrimSpace(formattedCommits)), HandleConfirm: func() error { diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index c578a405b..2caa30525 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -155,7 +155,7 @@ func (self *BranchesController) forceCheckout() error { message := self.c.Tr.SureForceCheckout title := self.c.Tr.ForceCheckoutBranch - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: title, Prompt: message, HandleConfirm: func() error { @@ -176,7 +176,7 @@ func (self *BranchesController) checkoutByName() error { self.c.LogAction("Checkout branch") return self.helpers.Refs.CheckoutRef(response, types.CheckoutRefOptions{ OnRefNotFound: func(ref string) error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.BranchNotFoundTitle, Prompt: fmt.Sprintf("%s %s%s", self.c.Tr.BranchNotFoundPrompt, ref, "?"), HandleConfirm: func() error { @@ -227,7 +227,7 @@ func (self *BranchesController) deleteWithForce(selectedBranch *models.Branch, f }, ) - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: title, Prompt: message, HandleConfirm: func() error { @@ -344,7 +344,7 @@ func (self *BranchesController) rename(branch *models.Branch) error { return promptForNewName() } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.LcRenameBranch, Prompt: self.c.Tr.RenameBranchWarning, HandleConfirm: promptForNewName, diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 65b930ef6..b28578822 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -124,7 +124,7 @@ func (self *CommitFilesController) discard(node *filetree.CommitFileNode) error return err } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardFileChangesTitle, Prompt: self.c.Tr.DiscardFileChangesPrompt, HandleConfirm: func() error { @@ -189,7 +189,7 @@ func (self *CommitFilesController) toggleForPatch(node *filetree.CommitFileNode) } if self.git.Patch.PatchManager.Active() && self.git.Patch.PatchManager.To != self.context().GetRefName() { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardPatch, Prompt: self.c.Tr.DiscardPatchConfirm, HandleConfirm: func() error { @@ -240,7 +240,7 @@ func (self *CommitFilesController) enterCommitFile(node *filetree.CommitFileNode } if self.git.Patch.PatchManager.Active() && self.git.Patch.PatchManager.To != self.context().GetRefName() { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardPatch, Prompt: self.c.Tr.DiscardPatchConfirm, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index d88554aae..764c9753b 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -320,7 +320,7 @@ func (self *FilesController) ignore(node *filetree.FileNode) error { } if node.GetIsTracked() { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.IgnoreTracked, Prompt: self.c.Tr.IgnoreTrackedPrompt, HandleConfirm: func() error { @@ -437,7 +437,7 @@ func (self *FilesController) HandleCommitPress() error { } func (self *FilesController) promptToStageAllAndRetry(retry func() error) error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.NoFilesStagedTitle, Prompt: self.c.Tr.NoFilesStagedPrompt, HandleConfirm: func() error { @@ -467,7 +467,7 @@ func (self *FilesController) handleAmendCommitPress() error { return self.c.ErrorMsg(self.c.Tr.NoCommitToAmend) } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: strings.Title(self.c.Tr.AmendLastCommit), Prompt: self.c.Tr.SureToAmend, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/helpers/bisect_helper.go b/pkg/gui/controllers/helpers/bisect_helper.go index 401d01b0c..65fb781d4 100644 --- a/pkg/gui/controllers/helpers/bisect_helper.go +++ b/pkg/gui/controllers/helpers/bisect_helper.go @@ -21,7 +21,7 @@ func NewBisectHelper( } func (self *BisectHelper) Reset() error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Bisect.ResetTitle, Prompt: self.c.Tr.Bisect.ResetPrompt, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go index 2c9ca301a..a5c4427a7 100644 --- a/pkg/gui/controllers/helpers/cherry_pick_helper.go +++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go @@ -87,7 +87,7 @@ func (self *CherryPickHelper) CopyRange(selectedIndex int, commitsList []*models // HandlePasteCommits begins a cherry-pick rebase with the commits the user has copied. // Only to be called from the branch commits controller func (self *CherryPickHelper) Paste() error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.CherryPick, Prompt: self.c.Tr.SureCherryPick, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index 9b45ca1a9..4484e4fc8 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -148,7 +148,7 @@ func (self *MergeAndRebaseHelper) CheckMergeOrRebase(result error) error { // assume in this case that we're already done return nil } else if isMergeConflictErr(result.Error()) { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.FoundConflictsTitle, Prompt: self.c.Tr.FoundConflicts, HandlersManageFocus: true, @@ -171,7 +171,7 @@ func (self *MergeAndRebaseHelper) CheckMergeOrRebase(result error) error { func (self *MergeAndRebaseHelper) AbortMergeOrRebaseWithConfirm() error { // prompt user to confirm that they want to abort, then do it mode := self.workingTreeStateNoun() - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: fmt.Sprintf(self.c.Tr.AbortTitle, mode), Prompt: fmt.Sprintf(self.c.Tr.AbortPrompt, mode), HandleConfirm: func() error { @@ -196,7 +196,7 @@ func (self *MergeAndRebaseHelper) workingTreeStateNoun() string { func (self *MergeAndRebaseHelper) PromptToContinueRebase() error { self.takeOverMergeConflictScrolling() - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: "continue", Prompt: self.c.Tr.ConflictsResolved, HandleConfirm: func() error { @@ -218,7 +218,7 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error { }, ) - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.RebasingTitle, Prompt: prompt, HandleConfirm: func() error { @@ -245,7 +245,7 @@ func (self *MergeAndRebaseHelper) MergeRefIntoCheckedOutBranch(refName string) e }, ) - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.MergeConfirmTitle, Prompt: prompt, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index 134112fb5..d96fa795b 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -71,7 +71,7 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions if strings.Contains(err.Error(), "Please commit your changes or stash them before you switch branch") { // offer to autostash changes - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AutoStashTitle, Prompt: self.c.Tr.AutoStashPrompt, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go index 3d79ebbc1..ab52a37c7 100644 --- a/pkg/gui/controllers/helpers/working_tree_helper.go +++ b/pkg/gui/controllers/helpers/working_tree_helper.go @@ -61,7 +61,7 @@ func (self *WorkingTreeHelper) FileForSubmodule(submodule *models.SubmoduleConfi } func (self *WorkingTreeHelper) OpenMergeTool() error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.MergeToolTitle, Prompt: self.c.Tr.MergeToolPrompt, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index dee876bf3..022ff1fa3 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -155,7 +155,7 @@ func (self *LocalCommitsController) squashDown(commit *models.Commit) error { return nil } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Squash, Prompt: self.c.Tr.SureSquashThisCommit, HandleConfirm: func() error { @@ -180,7 +180,7 @@ func (self *LocalCommitsController) fixup(commit *models.Commit) error { return nil } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Fixup, Prompt: self.c.Tr.SureFixupThisCommit, HandleConfirm: func() error { @@ -230,7 +230,7 @@ func (self *LocalCommitsController) rewordEditor(commit *models.Commit) error { return nil } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.RewordInEditorTitle, Prompt: self.c.Tr.RewordInEditorPrompt, HandleConfirm: func() error { @@ -259,7 +259,7 @@ func (self *LocalCommitsController) drop(commit *models.Commit) error { return nil } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DeleteCommitTitle, Prompt: self.c.Tr.DeleteCommitPrompt, HandleConfirm: func() error { @@ -405,7 +405,7 @@ func (self *LocalCommitsController) moveUp(commit *models.Commit) error { } func (self *LocalCommitsController) amendTo(commit *models.Commit) error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AmendCommitTitle, Prompt: self.c.Tr.AmendCommitPrompt, HandleConfirm: func() error { @@ -422,7 +422,7 @@ func (self *LocalCommitsController) revert(commit *models.Commit) error { if commit.IsMerge() { return self.createRevertMergeCommitMenu(commit) } else { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.RevertCommit, Prompt: utils.ResolvePlaceholderString( self.c.Tr.ConfirmRevertCommit, @@ -480,7 +480,7 @@ func (self *LocalCommitsController) createFixupCommit(commit *models.Commit) err }, ) - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.CreateFixupCommit, Prompt: prompt, HandleConfirm: func() error { @@ -500,7 +500,7 @@ func (self *LocalCommitsController) squashAllAboveFixupCommits(commit *models.Co map[string]string{"commit": commit.Sha}, ) - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.SquashAboveCommits, Prompt: prompt, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/remote_branches_controller.go b/pkg/gui/controllers/remote_branches_controller.go index d469f5657..b75cf3b13 100644 --- a/pkg/gui/controllers/remote_branches_controller.go +++ b/pkg/gui/controllers/remote_branches_controller.go @@ -99,7 +99,7 @@ func (self *RemoteBranchesController) escape() error { func (self *RemoteBranchesController) delete(selectedBranch *models.RemoteBranch) error { message := fmt.Sprintf("%s '%s'?", self.c.Tr.DeleteRemoteBranchMessage, selectedBranch.FullName()) - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DeleteRemoteBranch, Prompt: message, HandleConfirm: func() error { @@ -139,7 +139,7 @@ func (self *RemoteBranchesController) setAsUpstream(selectedBranch *models.Remot }, ) - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.SetUpstreamTitle, Prompt: message, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/remotes_controller.go b/pkg/gui/controllers/remotes_controller.go index 208f36af7..03427b9b7 100644 --- a/pkg/gui/controllers/remotes_controller.go +++ b/pkg/gui/controllers/remotes_controller.go @@ -101,7 +101,7 @@ func (self *RemotesController) add() error { } func (self *RemotesController) remove(remote *models.Remote) error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.LcRemoveRemote, Prompt: self.c.Tr.LcRemoveRemotePrompt + " '" + remote.Name + "'?", HandleConfirm: func() error { diff --git a/pkg/gui/controllers/stash_controller.go b/pkg/gui/controllers/stash_controller.go index 2ff9e1cfb..6c8e7c349 100644 --- a/pkg/gui/controllers/stash_controller.go +++ b/pkg/gui/controllers/stash_controller.go @@ -83,7 +83,7 @@ func (self *StashController) handleStashApply(stashEntry *models.StashEntry) err return apply() } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.StashApply, Prompt: self.c.Tr.SureApplyStashEntry, HandleConfirm: func() error { @@ -107,7 +107,7 @@ func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error return pop() } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.StashPop, Prompt: self.c.Tr.SurePopStashEntry, HandleConfirm: func() error { @@ -117,7 +117,7 @@ func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error } func (self *StashController) handleStashDrop(stashEntry *models.StashEntry) error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.StashDrop, Prompt: self.c.Tr.SureDropStashEntry, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/submodules_controller.go b/pkg/gui/controllers/submodules_controller.go index 33f0febc3..b0a8f6116 100644 --- a/pkg/gui/controllers/submodules_controller.go +++ b/pkg/gui/controllers/submodules_controller.go @@ -205,7 +205,7 @@ func (self *SubmodulesController) update(submodule *models.SubmoduleConfig) erro } func (self *SubmodulesController) remove(submodule *models.SubmoduleConfig) error { - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.RemoveSubmodule, Prompt: fmt.Sprintf(self.c.Tr.RemoveSubmodulePrompt, submodule.Name), HandleConfirm: func() error { diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index 38f8db733..69663f32e 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -210,7 +210,7 @@ func (self *SyncController) pushAux(opts pushOpts) error { _ = self.c.ErrorMsg(self.c.Tr.UpdatesRejectedAndForcePushDisabled) return nil } - _ = self.c.Ask(types.AskOpts{ + _ = self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.ForcePush, Prompt: self.c.Tr.ForcePushPrompt, HandleConfirm: func() error { @@ -234,7 +234,7 @@ func (self *SyncController) requestToForcePush(opts pushOpts) error { return self.c.ErrorMsg(self.c.Tr.ForcePushDisabled) } - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.ForcePush, Prompt: self.c.Tr.ForcePushPrompt, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/tags_controller.go b/pkg/gui/controllers/tags_controller.go index 0ec153025..f4b23374c 100644 --- a/pkg/gui/controllers/tags_controller.go +++ b/pkg/gui/controllers/tags_controller.go @@ -72,7 +72,7 @@ func (self *TagsController) delete(tag *models.Tag) error { }, ) - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DeleteTagTitle, Prompt: prompt, HandleConfirm: func() error { diff --git a/pkg/gui/controllers/undo_controller.go b/pkg/gui/controllers/undo_controller.go index ba54f4201..5e4c2043b 100644 --- a/pkg/gui/controllers/undo_controller.go +++ b/pkg/gui/controllers/undo_controller.go @@ -85,7 +85,7 @@ func (self *UndoController) reflogUndo() error { switch action.kind { case COMMIT, REBASE: - return true, self.c.Ask(types.AskOpts{ + return true, self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Undo, Prompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, action.from), HandleConfirm: func() error { @@ -97,7 +97,7 @@ func (self *UndoController) reflogUndo() error { }, }) case CHECKOUT: - return true, self.c.Ask(types.AskOpts{ + return true, self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Undo, Prompt: fmt.Sprintf(self.c.Tr.CheckoutPrompt, action.from), HandleConfirm: func() error { @@ -136,7 +136,7 @@ func (self *UndoController) reflogRedo() error { switch action.kind { case COMMIT, REBASE: - return true, self.c.Ask(types.AskOpts{ + return true, self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Redo, Prompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, action.to), HandleConfirm: func() error { @@ -149,7 +149,7 @@ func (self *UndoController) reflogRedo() error { }) case CHECKOUT: - return true, self.c.Ask(types.AskOpts{ + return true, self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Redo, Prompt: fmt.Sprintf(self.c.Tr.CheckoutPrompt, action.to), HandleConfirm: func() error { @@ -241,7 +241,7 @@ func (self *UndoController) hardResetWithAutoStash(commitSha string, options har dirtyWorkingTree := self.helpers.WorkingTree.IsWorkingTreeDirty() if dirtyWorkingTree { // offer to autostash changes - return self.c.Ask(types.AskOpts{ + return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AutoStashTitle, Prompt: self.c.Tr.AutoStashPrompt, HandleConfirm: func() error { |