diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index b49a5f6f3..ef27ba01d 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -673,15 +673,18 @@ func (self *BranchesController) createTag(branch *models.Branch) error { } func (self *BranchesController) createSortMenu() error { - return self.c.Helpers().Refs.CreateSortOrderMenu([]string{"recency", "alphabetical", "date"}, func(sortOrder string) error { - if self.c.UserConfig().Git.LocalBranchSortOrder != sortOrder { - self.c.UserConfig().Git.LocalBranchSortOrder = sortOrder - self.c.Contexts().Branches.SetSelection(0) - self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES}}) + return self.c.Helpers().Refs.CreateSortOrderMenu( + []string{"recency", "alphabetical", "date"}, + self.c.Tr.SortOrderPromptLocalBranches, + func(sortOrder string) error { + if self.c.UserConfig().Git.LocalBranchSortOrder != sortOrder { + self.c.UserConfig().Git.LocalBranchSortOrder = sortOrder + self.c.Contexts().Branches.SetSelection(0) + self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES}}) + return nil + } return nil - } - return nil - }, + }, self.c.UserConfig().Git.LocalBranchSortOrder) } diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index 68bcbbc33..d5140bb1e 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -186,7 +186,7 @@ func (self *RefsHelper) ResetToRef(ref string, strength string, envVars []string return nil } -func (self *RefsHelper) CreateSortOrderMenu(sortOptionsOrder []string, onSelected func(sortOrder string) error, currentValue string) error { +func (self *RefsHelper) CreateSortOrderMenu(sortOptionsOrder []string, menuPrompt string, onSelected func(sortOrder string) error, currentValue string) error { type sortMenuOption struct { key types.Key label string @@ -222,8 +222,9 @@ func (self *RefsHelper) CreateSortOrderMenu(sortOptionsOrder []string, onSelecte } }) return self.c.Menu(types.CreateMenuOptions{ - Title: self.c.Tr.SortOrder, - Items: menuItems, + Title: self.c.Tr.SortOrder, + Items: menuItems, + Prompt: menuPrompt, }) } diff --git a/pkg/gui/controllers/remote_branches_controller.go b/pkg/gui/controllers/remote_branches_controller.go index 3bb99380a..3a0350477 100644 --- a/pkg/gui/controllers/remote_branches_controller.go +++ b/pkg/gui/controllers/remote_branches_controller.go @@ -145,14 +145,17 @@ func (self *RemoteBranchesController) rebase(selectedBranch *models.RemoteBranch } func (self *RemoteBranchesController) createSortMenu() error { - return self.c.Helpers().Refs.CreateSortOrderMenu([]string{"alphabetical", "date"}, func(sortOrder string) error { - if self.c.UserConfig().Git.RemoteBranchSortOrder != sortOrder { - self.c.UserConfig().Git.RemoteBranchSortOrder = sortOrder - self.c.Contexts().RemoteBranches.SetSelection(0) - self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.REMOTES}}) - } - return nil - }, + return self.c.Helpers().Refs.CreateSortOrderMenu( + []string{"alphabetical", "date"}, + self.c.Tr.SortOrderPromptRemoteBranches, + func(sortOrder string) error { + if self.c.UserConfig().Git.RemoteBranchSortOrder != sortOrder { + self.c.UserConfig().Git.RemoteBranchSortOrder = sortOrder + self.c.Contexts().RemoteBranches.SetSelection(0) + self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.REMOTES}}) + } + return nil + }, self.c.UserConfig().Git.RemoteBranchSortOrder) } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 44ed670aa..bfac1fc20 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -760,10 +760,13 @@ type TranslationSet struct { ShowGitGraph string ShowGitGraphTooltip string SortOrder string + SortOrderPromptLocalBranches string + SortOrderPromptRemoteBranches string SortAlphabetical string SortByDate string SortByRecency string SortBasedOnReflog string + SortOrderPrompt string SortCommits string SortCommitsTooltip string CantChangeContextSizeError string @@ -1807,6 +1810,8 @@ func EnglishTranslationSet() *TranslationSet { ShowGitGraph: "Show git graph", ShowGitGraphTooltip: "Show or hide the git graph in the commit log.\n\nThe default can be changed in the config file with the key 'git.log.showGraph'.", SortOrder: "Sort order", + SortOrderPromptLocalBranches: "The default sort order for local branches can be set in the config file with the key 'git.localBranchSortOrder'.", + SortOrderPromptRemoteBranches: "The default sort order for remote branches can be set in the config file with the key 'git.remoteBranchSortOrder'.", SortAlphabetical: "Alphabetical", SortByDate: "Date", SortByRecency: "Recency", diff --git a/pkg/integration/components/menu_driver.go b/pkg/integration/components/menu_driver.go index 2f93df82d..eb7392d5a 100644 --- a/pkg/integration/components/menu_driver.go +++ b/pkg/integration/components/menu_driver.go @@ -50,6 +50,12 @@ func (self *MenuDriver) TopLines(matchers ...*TextMatcher) *MenuDriver { return self } +func (self *MenuDriver) ContainsLines(matchers ...*TextMatcher) *MenuDriver { + self.getViewDriver().ContainsLines(matchers...) + + return self +} + func (self *MenuDriver) Filter(text string) *MenuDriver { self.getViewDriver().FilterOrSearch(text) diff --git a/pkg/integration/tests/branch/sort_local_branches.go b/pkg/integration/tests/branch/sort_local_branches.go index 9c29e17bf..fbc5776ba 100644 --- a/pkg/integration/tests/branch/sort_local_branches.go +++ b/pkg/integration/tests/branch/sort_local_branches.go @@ -37,7 +37,7 @@ var SortLocalBranches = NewIntegrationTest(NewIntegrationTestArgs{ Press(keys.Branches.SortOrder) t.ExpectPopup().Menu().Title(Equals("Sort order")). - Lines( + ContainsLines( Contains("r ( ) Recency").IsSelected(), Contains("a ( ) Alphabetical"), Contains("d (•) Date"), @@ -59,7 +59,7 @@ var SortLocalBranches = NewIntegrationTest(NewIntegrationTestArgs{ Press(keys.Branches.SortOrder) t.ExpectPopup().Menu().Title(Equals("Sort order")). - Lines( + ContainsLines( Contains("r (•) Recency").IsSelected(), Contains("a ( ) Alphabetical"), Contains("d ( ) Date"), diff --git a/pkg/integration/tests/branch/sort_remote_branches.go b/pkg/integration/tests/branch/sort_remote_branches.go index 90c787f41..7cf78cf15 100644 --- a/pkg/integration/tests/branch/sort_remote_branches.go +++ b/pkg/integration/tests/branch/sort_remote_branches.go @@ -41,7 +41,7 @@ var SortRemoteBranches = NewIntegrationTest(NewIntegrationTestArgs{ Press(keys.Branches.SortOrder) t.ExpectPopup().Menu().Title(Equals("Sort order")). - Lines( + ContainsLines( Contains("a ( ) Alphabetical").IsSelected(), Contains("d (•) Date"), Contains(" Cancel"),