Commit ec06449c authored by Zack Cuddy's avatar Zack Cuddy

Generalize Geo Filter Bar

As part of the effort of:
https://gitlab.com/gitlab-org/gitlab/-/issues/213219

We are combinding the views and navigation between
Geo Replicables.

To do this, we need a unified way to filter/search
the data between all views.

This MR pulls out the filter bar into its own partial,
so that it can be used for all replicables that
live in HAML.
parent 9996e3d1
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
} }
// Overrides for the generalized `shared/projects/search_form` used in Geo // Overrides for the generalized `shared/projects/search_form` used in Geo
.project-search { .replicable-search {
#project-filter-form-field { #project-filter-form-field {
width: 100%; width: 100%;
padding-left: 1.75rem; padding-left: 1.75rem;
......
...@@ -20,6 +20,8 @@ class Admin::Geo::ProjectsController < Admin::Geo::ApplicationController ...@@ -20,6 +20,8 @@ class Admin::Geo::ProjectsController < Admin::Geo::ApplicationController
if params[:name] if params[:name]
@registries = @registries.with_search(params[:name]) @registries = @registries.with_search(params[:name])
end end
@action_buttons = [helpers.resync_all_button, helpers.reverify_all_button]
end end
def destroy def destroy
...@@ -58,14 +60,14 @@ class Admin::Geo::ProjectsController < Admin::Geo::ApplicationController ...@@ -58,14 +60,14 @@ class Admin::Geo::ProjectsController < Admin::Geo::ApplicationController
def reverify_all def reverify_all
Geo::Batch::ProjectRegistrySchedulerWorker.perform_async(:reverify_repositories) # rubocop:disable CodeReuse/Worker Geo::Batch::ProjectRegistrySchedulerWorker.perform_async(:reverify_repositories) # rubocop:disable CodeReuse/Worker
flash[:toast] = s_('Geo|All projects are being scheduled for re-verify') flash[:toast] = s_('Geo|All projects are being scheduled for reverify')
redirect_back_or_default(default: admin_geo_projects_path) redirect_back_or_default(default: admin_geo_projects_path)
end end
def resync_all def resync_all
Geo::Batch::ProjectRegistrySchedulerWorker.perform_async(:resync_repositories) # rubocop:disable CodeReuse/Worker Geo::Batch::ProjectRegistrySchedulerWorker.perform_async(:resync_repositories) # rubocop:disable CodeReuse/Worker
flash[:toast] = s_('Geo|All projects are being scheduled for re-sync') flash[:toast] = s_('Geo|All projects are being scheduled for resync')
redirect_back_or_default(default: admin_geo_projects_path) redirect_back_or_default(default: admin_geo_projects_path)
end end
......
...@@ -155,5 +155,13 @@ module EE ...@@ -155,5 +155,13 @@ module EE
} }
} }
end end
def resync_all_button
button_to(s_("Geo|Resync all"), { controller: controller_name, action: :resync_all }, class: "btn btn-default mr-2")
end
def reverify_all_button
button_to(s_("Geo|Reverify all"), { controller: controller_name, action: :reverify_all }, class: "btn btn-default")
end
end end
end end
- page_title 'Geo Projects' - page_title 'Geo Projects'
- params[:sync_status] ||= [] - params[:sync_status] ||= []
%nav.row.d-flex.flex-column.flex-sm-row.align-items-center.bg-secondary.border-bottom.border-secondary-100.p-3 = render 'admin/geo/shared/filter_nav', replicable_type: _('projects'), replicable_controller: 'admin/geo/projects', action_buttons: @action_buttons
.dropdown.col.px-1.my-1.my-sm-0.w-100
%a.btn.d-flex.align-items-center.justify-content-between.w-100{ href: '#', data: { toggle: 'dropdown' }, 'aria-haspopup' => 'true', 'aria-expanded' => 'false' }
= s_('Geo|Filter by status')
= sprite_icon("chevron-down", size: 16)
%ul.dropdown-menu
= nav_link(html_options: { class: ('bg-secondary-100' if !params[:sync_status].present?) }) do
= link_to admin_geo_projects_path do
= s_('Geo|All projects')
= nav_link(html_options: { class: ('bg-secondary-100' if params[:sync_status] == 'pending') }) do
= link_to admin_geo_projects_path(sync_status: 'pending') do
= s_('Geo|In progress')
= nav_link(html_options: { class: ('bg-secondary-100' if params[:sync_status] == 'failed') }) do
= link_to admin_geo_projects_path(sync_status: 'failed') do
= s_('Geo|Failed')
= nav_link(html_options: { class: ('bg-secondary-100' if params[:sync_status] == 'synced') }) do
= link_to admin_geo_projects_path(sync_status: 'synced') do
= s_('Geo|Synced')
.col.project-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-6.d-flex.justify-content-end.my-1.my-sm-0.w-100
= button_to s_('Geo|Resync all'), resync_all_admin_geo_projects_path, method: :post, :class => "btn btn-default mr-2"
= button_to s_('Geo|Reverify all'), reverify_all_admin_geo_projects_path, method: :post, :class => "btn btn-default"
- case params[:sync_status] - case params[:sync_status]
- when 'failed' - when 'failed'
= render(partial: 'failed') = render(partial: 'failed')
......
- action_buttons = local_assigns[:action_buttons] ? action_buttons : []
%nav.row.d-flex.flex-column.flex-sm-row.align-items-center.bg-secondary.border-bottom.border-secondary-100.p-3
.dropdown.col.px-1.my-1.my-sm-0.w-100
%a.btn.d-flex.align-items-center.justify-content-between.w-100{ href: '#', data: { toggle: 'dropdown' }, 'aria-haspopup' => 'true', 'aria-expanded' => 'false' }
= s_('Geo|Filter by status')
= sprite_icon("chevron-down", size: 16)
%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_type}'), { replicable_type: replicable_type })
= 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')
.col.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-6.d-flex.justify-content-end.my-1.my-sm-0.w-100
- action_buttons.each do |action_button|
= action_button
...@@ -163,7 +163,7 @@ describe Admin::Geo::ProjectsController, :geo do ...@@ -163,7 +163,7 @@ describe Admin::Geo::ProjectsController, :geo do
it 'redirects back and display confirmation' do it 'redirects back and display confirmation' do
Sidekiq::Testing.inline! do Sidekiq::Testing.inline! do
expect(subject).to redirect_to(admin_geo_projects_path) expect(subject).to redirect_to(admin_geo_projects_path)
expect(flash[:toast]).to include('All projects are being scheduled for re-verify') expect(flash[:toast]).to include('All projects are being scheduled for reverify')
end end
end end
end end
...@@ -188,7 +188,7 @@ describe Admin::Geo::ProjectsController, :geo do ...@@ -188,7 +188,7 @@ describe Admin::Geo::ProjectsController, :geo do
it 'redirects back and display confirmation' do it 'redirects back and display confirmation' do
expect(subject).to redirect_to(admin_geo_projects_path) expect(subject).to redirect_to(admin_geo_projects_path)
expect(flash[:toast]).to include('All projects are being scheduled for re-sync') expect(flash[:toast]).to include('All projects are being scheduled for resync')
end end
end end
end end
......
...@@ -9,6 +9,10 @@ describe 'admin Geo Projects', :js, :geo do ...@@ -9,6 +9,10 @@ describe 'admin Geo Projects', :js, :geo do
let!(:sync_failed_registry) { create(:geo_project_registry, :existing_repository_sync_failed) } let!(:sync_failed_registry) { create(:geo_project_registry, :existing_repository_sync_failed) }
let!(:never_synced_registry) { create(:geo_project_registry) } let!(:never_synced_registry) { create(:geo_project_registry) }
def find_toast
page.find('.gl-toast')
end
before do before do
allow(Gitlab::Geo).to receive(:license_allows?).and_return(true) allow(Gitlab::Geo).to receive(:license_allows?).and_return(true)
sign_in(create(:admin)) sign_in(create(:admin))
...@@ -167,9 +171,35 @@ describe 'admin Geo Projects', :js, :geo do ...@@ -167,9 +171,35 @@ describe 'admin Geo Projects', :js, :geo do
page.click_button('Remove entry') page.click_button('Remove entry')
end end
# Wait for remove confirmation # Wait for remove confirmation
expect(page.find('.gl-toast')).to have_text('removed') expect(find_toast).to have_text('removed')
expect(page.all(:css, '.project-card').length).to be(card_count - 1) expect(page.all(:css, '.project-card').length).to be(card_count - 1)
end end
end end
describe 'Resync all' do
before do
visit(admin_geo_projects_path)
wait_for_requests
end
it 'fires job to resync all projects' do
page.click_button('Resync all')
expect(find_toast).to have_text('All projects are being scheduled for resync')
end
end
describe 'Reverify all' do
before do
visit(admin_geo_projects_path)
wait_for_requests
end
it 'fires job to reverify all projects' do
page.click_button('Reverify all')
expect(find_toast).to have_text('All projects are being scheduled for reverify')
end
end
end end
...@@ -9716,13 +9716,16 @@ msgstr "" ...@@ -9716,13 +9716,16 @@ msgstr ""
msgid "Geo|All" msgid "Geo|All"
msgstr "" msgstr ""
msgid "Geo|All %{replicable_type}"
msgstr ""
msgid "Geo|All projects" msgid "Geo|All projects"
msgstr "" msgstr ""
msgid "Geo|All projects are being scheduled for re-sync" msgid "Geo|All projects are being scheduled for resync"
msgstr "" msgstr ""
msgid "Geo|All projects are being scheduled for re-verify" msgid "Geo|All projects are being scheduled for reverify"
msgstr "" msgstr ""
msgid "Geo|Could not remove tracking entry for an existing project." msgid "Geo|Could not remove tracking entry for an existing project."
...@@ -25526,6 +25529,9 @@ msgstr[1] "" ...@@ -25526,6 +25529,9 @@ msgstr[1] ""
msgid "project avatar" msgid "project avatar"
msgstr "" msgstr ""
msgid "projects"
msgstr ""
msgid "push to your repository, create pipelines, create issues or add comments. To reduce storage capacity, delete unused repositories, artifacts, wikis, issues, and pipelines." msgid "push to your repository, create pipelines, create issues or add comments. To reduce storage capacity, delete unused repositories, artifacts, wikis, issues, and pipelines."
msgstr "" msgstr ""
......
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