diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /app/controllers/projects/branches_controller.rb | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) | |
download | gitlab-ce-a7b3560714b4d9cc4ab32dffcd1f74a284b93580.tar.gz |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'app/controllers/projects/branches_controller.rb')
-rw-r--r-- | app/controllers/projects/branches_controller.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 63ac5f97420..dad73c37fea 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -131,11 +131,28 @@ class Projects::BranchesController < Projects::ApplicationController private def sort_value_for_mode - return params[:sort] if params[:sort].present? + custom_sort || default_sort + end + + def custom_sort + sort = params[:sort].presence + + unless sort.in?(supported_sort_options) + flash.now[:alert] = _("Unsupported sort value.") + sort = nil + end + sort + end + + def default_sort 'stale' == @mode ? sort_value_oldest_updated : sort_value_recently_updated end + def supported_sort_options + [nil, sort_value_name, sort_value_oldest_updated, sort_value_recently_updated] + end + # It can be expensive to calculate the diverging counts for each # branch. Normally the frontend should be specifying a set of branch # names, but prior to |