From 68c966567cbff30dddfa2a30c8b2518f30498b58 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 1 Jun 2024 20:21:43 +0200 Subject: Show radio buttons in the sort order menu for branches --- pkg/gui/controllers/branches_controller.go | 3 ++- pkg/gui/controllers/helpers/refs_helper.go | 5 +++-- pkg/gui/controllers/remote_branches_controller.go | 3 ++- pkg/integration/tests/branch/sort_local_branches.go | 12 ++++++++++++ pkg/integration/tests/branch/sort_remote_branches.go | 5 +++++ 5 files changed, 24 insertions(+), 4 deletions(-) (limited to 'pkg') 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() -- cgit v1.2.3