Commit cfbd2cb2 authored by Alex Pooley's avatar Alex Pooley

Merge branch...

Merge branch '263161-replace-bootstrap-dropdown-in-app-views-groups-runners-_sort_dropdown-html-haml' into 'master'

Make group runners sorting Pajamas compliant

See merge request gitlab-org/gitlab!82787
parents 7fd24446 0266e1b3
...@@ -186,6 +186,13 @@ module SortingHelper ...@@ -186,6 +186,13 @@ module SortingHelper
} }
end end
def runners_sort_options_hash
{
sort_value_created_date => sort_title_created_date,
sort_value_contacted_date => sort_title_contacted_date
}
end
def starrers_sort_options_hash def starrers_sort_options_hash
{ {
sort_value_name => sort_title_name, sort_value_name => sort_title_name,
......
- sorted_by = sort_options_hash[@sort] || sort_title_created_date - runners_sort_options = runners_sort_options_hash.map { |value, text| { value: value, text: text, href: page_filter_path(sort: value) } }
.dropdown.inline.gl-ml-3 = gl_redirect_listbox_tag runners_sort_options, @sort, class: 'gl-ml-3', data: { display: 'static' }
%button.dropdown-menu-toggle{ type: 'button', data: { toggle: 'dropdown', display: 'static' } }
= sorted_by
= sprite_icon('chevron-down', css_class: 'dropdown-menu-toggle-icon gl-top-3')
%ul.dropdown-menu.dropdown-menu-right.dropdown-menu-selectable.dropdown-menu-sort
%li
= sortable_item(sort_title_created_date, page_filter_path(sort: sort_value_created_date), sorted_by)
= sortable_item(sort_title_contacted_date, page_filter_path(sort: sort_value_contacted_date), sorted_by)
...@@ -13,4 +13,11 @@ RSpec.describe SortingHelper do ...@@ -13,4 +13,11 @@ RSpec.describe SortingHelper do
expect(sort_direction_icon('last_joined')).to eq('sort-highest') expect(sort_direction_icon('last_joined')).to eq('sort-highest')
end end
end end
describe '#runners_sort_options_hash' do
it 'behaves like non-ee for other sort values' do
expect(runners_sort_options_hash['created_date']).to eq('Created date')
expect(runners_sort_options_hash['contacted_asc']).to eq('Last Contact')
end
end
end end
...@@ -4,27 +4,22 @@ require 'spec_helper' ...@@ -4,27 +4,22 @@ require 'spec_helper'
RSpec.describe 'groups/runners/sort_dropdown.html.haml' do RSpec.describe 'groups/runners/sort_dropdown.html.haml' do
describe 'render' do describe 'render' do
let_it_be(:sort_options_hash) { { by_title: 'Title' } }
let_it_be(:sort_title_created_date) { 'Created date' }
before do
allow(view).to receive(:sort).and_return('by_title')
end
describe 'when a sort option is not selected' do describe 'when a sort option is not selected' do
it 'renders a default sort option' do it 'renders a default sort option' do
render 'groups/runners/sort_dropdown', sort_options_hash: sort_options_hash, sort_title_created_date: sort_title_created_date render 'groups/runners/sort_dropdown'
expect(rendered).to have_content 'Created date' expect(rendered).to have_content _('Created date')
end end
end end
describe 'when a sort option is selected' do describe 'when a sort option is selected' do
it 'renders the selected sort option' do before do
@sort = :by_title assign(:sort, 'contacted_asc')
render 'groups/runners/sort_dropdown', sort_options_hash: sort_options_hash, sort_title_created_date: sort_title_created_date render 'groups/runners/sort_dropdown'
end
expect(rendered).to have_content 'Title' it 'renders the selected sort option' do
expect(rendered).to have_content _('Last Contact')
end end
end end
end end
......
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