mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Add a prompt for the sort order menus for branches
This commit is contained in:
@ -673,7 +673,10 @@ 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 {
|
||||
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)
|
||||
|
@ -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
|
||||
@ -224,6 +224,7 @@ func (self *RefsHelper) CreateSortOrderMenu(sortOptionsOrder []string, onSelecte
|
||||
return self.c.Menu(types.CreateMenuOptions{
|
||||
Title: self.c.Tr.SortOrder,
|
||||
Items: menuItems,
|
||||
Prompt: menuPrompt,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,10 @@ 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 {
|
||||
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)
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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"),
|
||||
|
@ -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"),
|
||||
|
Reference in New Issue
Block a user