Commit b24ccd4a authored by Rémy Coutable's avatar Rémy Coutable

Merge branch...

Merge branch '20308-fix-title-that-is-show-in-the-dropdown-toggle-button-on-projects-branches' into 'master'

Fix the title of the toggle dropdown button

## What does this MR do?

Fix the dropdown-button toggle displaying the correctly title.

## Are there points in the code the reviewer needs to double check?

See if the title is displaying correctly and if the code is acceptable.

## Why was this MR needed?

When you choose `Last updated` it should display the title `Last updated` instead of `Recently updated`. This fix makes this correctly displays the title.

## What are the relevant issue numbers?
Closes #20308.

## Screenshots (if relevant)
![filter-gitlab-ce](/uploads/52838679d134d57c6ff6120260806fda/filter-gitlab-ce.gif)

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5515
parents 273bea97 94e6d51e
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.11.0 (unreleased) v 8.11.0 (unreleased)
- Fix the title of the toggle dropdown button. !5515 (herminiotorres)
- Remove magic comments (`# encoding: UTF-8`) from Ruby files. !5456 (winniehell) - Remove magic comments (`# encoding: UTF-8`) from Ruby files. !5456 (winniehell)
- Fix CI status icon link underline (ClemMakesApps) - Fix CI status icon link underline (ClemMakesApps)
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI' - Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
......
...@@ -6,6 +6,7 @@ class Projects::BranchesController < Projects::ApplicationController ...@@ -6,6 +6,7 @@ class Projects::BranchesController < Projects::ApplicationController
before_action :authorize_push_code!, only: [:new, :create, :destroy] before_action :authorize_push_code!, only: [:new, :create, :destroy]
def index def index
@sort = params[:sort].presence || 'name'
@branches = BranchesFinder.new(@repository, params).execute @branches = BranchesFinder.new(@repository, params).execute
@branches = Kaminari.paginate_array(@branches).page(params[:page]) @branches = Kaminari.paginate_array(@branches).page(params[:page])
......
...@@ -615,11 +615,11 @@ class Repository ...@@ -615,11 +615,11 @@ class Repository
case value case value
when 'name' when 'name'
branches.sort_by(&:name) branches.sort_by(&:name)
when 'recently_updated' when 'updated_desc'
branches.sort do |a, b| branches.sort do |a, b|
commit(b.target).committed_date <=> commit(a.target).committed_date commit(b.target).committed_date <=> commit(a.target).committed_date
end end
when 'last_updated' when 'updated_asc'
branches.sort do |a, b| branches.sort do |a, b|
commit(a.target).committed_date <=> commit(b.target).committed_date commit(a.target).committed_date <=> commit(b.target).committed_date
end end
......
...@@ -14,18 +14,15 @@ ...@@ -14,18 +14,15 @@
.dropdown.inline .dropdown.inline
%button.dropdown-toggle.btn{type: 'button', 'data-toggle' => 'dropdown'} %button.dropdown-toggle.btn{type: 'button', 'data-toggle' => 'dropdown'}
%span.light %span.light
- if params[:sort].present? = projects_sort_options_hash[@sort]
= params[:sort].humanize
- else
Name
%b.caret %b.caret
%ul.dropdown-menu.dropdown-menu-align-right %ul.dropdown-menu.dropdown-menu-align-right
%li %li
= link_to filter_branches_path(sort: nil) do = link_to filter_branches_path(sort: sort_value_name) do
= sort_title_name = sort_title_name
= link_to filter_branches_path(sort: 'recently_updated') do = link_to filter_branches_path(sort: sort_value_recently_updated) do
= sort_title_recently_updated = sort_title_recently_updated
= link_to filter_branches_path(sort: 'last_updated') do = link_to filter_branches_path(sort: sort_value_oldest_updated) do
= sort_title_oldest_updated = sort_title_oldest_updated
- if can? current_user, :push_code, @project - if can? current_user, :push_code, @project
......
...@@ -16,7 +16,7 @@ describe BranchesFinder do ...@@ -16,7 +16,7 @@ describe BranchesFinder do
end end
it 'sorts by recently_updated' do it 'sorts by recently_updated' do
branches_finder = described_class.new(repository, { sort: 'recently_updated' }) branches_finder = described_class.new(repository, { sort: 'updated_desc' })
result = branches_finder.execute result = branches_finder.execute
...@@ -24,7 +24,7 @@ describe BranchesFinder do ...@@ -24,7 +24,7 @@ describe BranchesFinder do
end end
it 'sorts by last_updated' do it 'sorts by last_updated' do
branches_finder = described_class.new(repository, { sort: 'last_updated' }) branches_finder = described_class.new(repository, { sort: 'updated_asc' })
result = branches_finder.execute result = branches_finder.execute
...@@ -53,7 +53,7 @@ describe BranchesFinder do ...@@ -53,7 +53,7 @@ describe BranchesFinder do
context 'filter and sort' do context 'filter and sort' do
it 'filters branches by name and sorts by recently_updated' do it 'filters branches by name and sorts by recently_updated' do
params = { sort: 'recently_updated', search: 'feature' } params = { sort: 'updated_desc', search: 'feature' }
branches_finder = described_class.new(repository, params) branches_finder = described_class.new(repository, params)
result = branches_finder.execute result = branches_finder.execute
...@@ -63,7 +63,7 @@ describe BranchesFinder do ...@@ -63,7 +63,7 @@ describe BranchesFinder do
end end
it 'filters branches by name and sorts by last_updated' do it 'filters branches by name and sorts by last_updated' do
params = { sort: 'last_updated', search: 'feature' } params = { sort: 'updated_asc', search: 'feature' }
branches_finder = described_class.new(repository, params) branches_finder = described_class.new(repository, params)
result = branches_finder.execute result = branches_finder.execute
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment