Commit fe09fb84 authored by Alper Akgun's avatar Alper Akgun Committed by Mayra Cabrera

Make Geo filter nav pajamas compliant

parent 96067b66
......@@ -248,5 +248,30 @@ module EE
def enabled_replicator_classes
::Gitlab::Geo.enabled_replicator_classes
end
def geo_filter_nav_options(replicable_controller, replicable_name)
[
{
value: '',
text: sprintf(s_('Geo|All %{replicable_name}'), { replicable_name: replicable_name }),
href: url_for(controller: replicable_controller)
},
{
value: 'pending',
text: s_('Geo|In progress'),
href: url_for(controller: replicable_controller, sync_status: 'pending')
},
{
value: 'failed',
text: s_('Geo|Failed'),
href: url_for(controller: replicable_controller, sync_status: 'failed')
},
{
value: 'synced',
text: s_('Geo|Synced'),
href: url_for(controller: replicable_controller, sync_status: 'synced')
}
]
end
end
end
- action_buttons = local_assigns[:action_buttons] ? action_buttons : []
- params[:sync_status] ||= []
- filter_by = params[:sync_status] || []
%nav.bg-secondary.border-bottom.border-secondary-100.p-3
.row.d-flex.flex-column.flex-sm-row
.col
.gl-sm-display-flex.gl-mx-n1
.dropdown.gl-px-2.gl-my-2.my-sm-0.gl-w-full
%a.gl-button.btn.gl-sm-display-flex.gl-align-items-center.gl-justify-content-space-between.gl-w-full{ href: '#', data: { toggle: 'dropdown' }, 'aria-haspopup' => 'true', 'aria-expanded' => 'false' }
= s_('Geo|Filter by status')
= sprite_icon("chevron-down")
%ul.dropdown-menu
= nav_link(html_options: { class: ('bg-secondary-100' if !params[:sync_status].present?) }) do
= link_to controller: replicable_controller do
= sprintf(s_('Geo|All %{replicable_name}'), { replicable_name: replicable_name })
= nav_link(html_options: { class: ('bg-secondary-100' if params[:sync_status] == 'pending') }) do
= link_to controller: replicable_controller, sync_status: 'pending' do
= s_('Geo|In progress')
= nav_link(html_options: { class: ('bg-secondary-100' if params[:sync_status] == 'failed') }) do
= link_to controller: replicable_controller, sync_status: 'failed' do
= s_('Geo|Failed')
= nav_link(html_options: { class: ('bg-secondary-100' if params[:sync_status] == 'synced') }) do
= link_to controller: replicable_controller, sync_status: 'synced' do
= s_('Geo|Synced')
= gl_redirect_listbox_tag geo_filter_nav_options(replicable_controller, replicable_name), filter_by, class: 'gl-px-2 gl-my-2 my-sm-0 gl-w-full'
.replicable-search.px-1.my-1.my-sm-0.w-100
= render 'shared/projects/search_form', autofocus: true, search_form_placeholder: _("Filter by name"), icon: true
.col.col-sm-5.d-flex.justify-content-end.my-1.my-sm-0.w-100
......
......@@ -81,7 +81,7 @@ RSpec.describe 'admin Geo Projects', :js, :geo do
visit(page_url)
wait_for_requests
click_link_or_button('Filter by status')
click_link_or_button('All projects')
click_link_or_button('In progress')
wait_for_requests
end
......
......@@ -58,4 +58,23 @@ RSpec.describe EE::GeoHelper do
expect(data_type_titles).to include(*expected_data_type_titles)
end
end
describe '#geo_filter_nav_options' do
let(:replicable_controller) { 'admin/geo/projects' }
let(:replicable_name) { 'projects' }
let(:expected_nav_options) do
[
{ value: "", text: "All projects", href: "/admin/geo/replication/projects" },
{ value: "pending", text: "In progress", href: "/admin/geo/replication/projects?sync_status=pending" },
{ value: "failed", text: "Failed", href: "/admin/geo/replication/projects?sync_status=failed" },
{ value: "synced", text: "Synced", href: "/admin/geo/replication/projects?sync_status=synced" }
]
end
subject(:geo_filter_nav_options) { helper.geo_filter_nav_options(replicable_controller, replicable_name) }
it 'returns correct urls' do
expect(geo_filter_nav_options).to eq(expected_nav_options)
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