summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-06-01 20:21:43 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-06-23 12:53:15 +0200
commit68c966567cbff30dddfa2a30c8b2518f30498b58 (patch)
treebaa5db8b9fe8bd7268c4d1d5484334cf850decbb /pkg
parent20a4aeab6e92c8f16fa02783c750b86558d8fb51 (diff)
Show radio buttons in the sort order menu for branches
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/controllers/branches_controller.go3
-rw-r--r--pkg/gui/controllers/helpers/refs_helper.go5
-rw-r--r--pkg/gui/controllers/remote_branches_controller.go3
-rw-r--r--pkg/integration/tests/branch/sort_local_branches.go12
-rw-r--r--pkg/integration/tests/branch/sort_remote_branches.go5
5 files changed, 24 insertions, 4 deletions
diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go
index 62eda703e..8b4a5d395 100644
--- a/pkg/gui/controllers/branches_controller.go
+++ b/pkg/gui/controllers/branches_controller.go
@@ -696,7 +696,8 @@ func (self *BranchesController) createSortMenu() error {
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES}})
}
return nil
- })
+ },
+ self.c.GetAppState().LocalBranchSortOrder)
}
func (self *BranchesController) createResetMenu(selectedBranch *models.Branch) error {
diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go
index ccfe71799..08c6e173a 100644
--- a/pkg/gui/controllers/helpers/refs_helper.go
+++ b/pkg/gui/controllers/helpers/refs_helper.go
@@ -190,7 +190,7 @@ func (self *RefsHelper) ResetToRef(ref string, strength string, envVars []string
return nil
}
-func (self *RefsHelper) CreateSortOrderMenu(sortOptionsOrder []string, onSelected func(sortOrder string) error) error {
+func (self *RefsHelper) CreateSortOrderMenu(sortOptionsOrder []string, onSelected func(sortOrder string) error, currentValue string) error {
type sortMenuOption struct {
key types.Key
label string
@@ -221,7 +221,8 @@ func (self *RefsHelper) CreateSortOrderMenu(sortOptionsOrder []string, onSelecte
OnPress: func() error {
return onSelected(opt.sortOrder)
},
- Key: opt.key,
+ Key: opt.key,
+ Widget: types.MakeMenuRadioButton(opt.sortOrder == currentValue),
}
})
return self.c.Menu(types.CreateMenuOptions{
diff --git a/pkg/gui/controllers/remote_branches_controller.go b/pkg/gui/controllers/remote_branches_controller.go
index 97dbf56b0..d793c6148 100644
--- a/pkg/gui/controllers/remote_branches_controller.go
+++ b/pkg/gui/controllers/remote_branches_controller.go
@@ -145,7 +145,8 @@ func (self *RemoteBranchesController) createSortMenu() error {
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.REMOTES}})
}
return nil
- })
+ },
+ self.c.GetAppState().RemoteBranchSortOrder)
}
func (self *RemoteBranchesController) createResetMenu(selectedBranch *models.RemoteBranch) error {
diff --git a/pkg/integration/tests/branch/sort_local_branches.go b/pkg/integration/tests/branch/sort_local_branches.go
index 9daf28424..ceff654be 100644
--- a/pkg/integration/tests/branch/sort_local_branches.go
+++ b/pkg/integration/tests/branch/sort_local_branches.go
@@ -37,6 +37,12 @@ var SortLocalBranches = NewIntegrationTest(NewIntegrationTestArgs{
Press(keys.Branches.SortOrder)
t.ExpectPopup().Menu().Title(Equals("Sort order")).
+ Lines(
+ Contains("r (•) Recency").IsSelected(),
+ Contains("a ( ) Alphabetical"),
+ Contains("d ( ) Date"),
+ Contains(" Cancel"),
+ ).
Select(Contains("-committerdate")).
Confirm()
@@ -53,6 +59,12 @@ var SortLocalBranches = NewIntegrationTest(NewIntegrationTestArgs{
Press(keys.Branches.SortOrder)
t.ExpectPopup().Menu().Title(Equals("Sort order")).
+ Lines(
+ Contains("r ( ) Recency").IsSelected(),
+ Contains("a ( ) Alphabetical"),
+ Contains("d (•) Date"),
+ Contains(" Cancel"),
+ ).
Select(Contains("refname")).
Confirm()
diff --git a/pkg/integration/tests/branch/sort_remote_branches.go b/pkg/integration/tests/branch/sort_remote_branches.go
index 35e2f700a..2cbbdb31d 100644
--- a/pkg/integration/tests/branch/sort_remote_branches.go
+++ b/pkg/integration/tests/branch/sort_remote_branches.go
@@ -41,6 +41,11 @@ var SortRemoteBranches = NewIntegrationTest(NewIntegrationTestArgs{
Press(keys.Branches.SortOrder)
t.ExpectPopup().Menu().Title(Equals("Sort order")).
+ Lines(
+ Contains("a (•) Alphabetical").IsSelected(),
+ Contains("d ( ) Date"),
+ Contains(" Cancel"),
+ ).
Select(Contains("-committerdate")).
Confirm()