Commit 869075d7 authored by Max Woolf's avatar Max Woolf

Merge branch 'admin-panel-migration-actions' into 'master'

Add pause and resume to background migrations admin page

See merge request gitlab-org/gitlab!65512
parents 660e5c2e 32f6ba04
...@@ -15,6 +15,20 @@ class Admin::BackgroundMigrationsController < Admin::ApplicationController ...@@ -15,6 +15,20 @@ class Admin::BackgroundMigrationsController < Admin::ApplicationController
@successful_rows_counts = batched_migration_class.successful_rows_counts(@migrations.map(&:id)) @successful_rows_counts = batched_migration_class.successful_rows_counts(@migrations.map(&:id))
end end
def pause
migration = batched_migration_class.find(params[:id])
migration.paused!
redirect_back fallback_location: { action: 'index' }
end
def resume
migration = batched_migration_class.find(params[:id])
migration.active!
redirect_back fallback_location: { action: 'index' }
end
private private
def batched_migration_class def batched_migration_class
......
...@@ -8,3 +8,12 @@ ...@@ -8,3 +8,12 @@
= _('Unknown') = _('Unknown')
%td{ role: 'cell', data: { label: _('Status') } } %td{ role: 'cell', data: { label: _('Status') } }
%span.badge.badge-pill.gl-badge.sm{ class: batched_migration_status_badge_class_name(migration) }= migration.status.humanize %span.badge.badge-pill.gl-badge.sm{ class: batched_migration_status_badge_class_name(migration) }= migration.status.humanize
%td{ role: 'cell', data: { label: _('Action') } }
- if migration.active?
= button_to pause_admin_background_migration_path(migration),
class: 'gl-button btn btn-icon has-tooltip', title: _('Pause'), 'aria-label' => _('Pause') do
= sprite_icon('pause', css_class: 'gl-button-icon gl-icon')
- elsif migration.paused?
= button_to resume_admin_background_migration_path(migration),
class: 'gl-button btn btn-icon has-tooltip', title: _('Resume'), 'aria-label' => _('Resume') do
= sprite_icon('play', css_class: 'gl-button-icon gl-icon')
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
%th.table-th-transparent.border-bottom{ role: 'cell' }= _('Migration') %th.table-th-transparent.border-bottom{ role: 'cell' }= _('Migration')
%th.table-th-transparent.border-bottom{ role: 'cell' }= _('Progress') %th.table-th-transparent.border-bottom{ role: 'cell' }= _('Progress')
%th.table-th-transparent.border-bottom{ role: 'cell' }= _('Status') %th.table-th-transparent.border-bottom{ role: 'cell' }= _('Status')
%th.table-th-transparent.border-bottom{ role: 'cell' }
%tbody{ role: 'rowgroup' } %tbody{ role: 'rowgroup' }
= render partial: 'migration', collection: @migrations = render partial: 'migration', collection: @migrations
......
...@@ -89,7 +89,13 @@ namespace :admin do ...@@ -89,7 +89,13 @@ namespace :admin do
get :instance_review, to: 'instance_review#index' get :instance_review, to: 'instance_review#index'
resources :background_migrations, only: [:index] resources :background_migrations, only: [:index] do
member do
post :pause
post :resume
end
end
resource :health_check, controller: 'health_check', only: [:show] resource :health_check, controller: 'health_check', only: [:show]
resource :background_jobs, controller: 'background_jobs', only: [:show] resource :background_jobs, controller: 'background_jobs', only: [:show]
......
...@@ -31,7 +31,7 @@ RSpec.describe "Admin > Admin sees background migrations" do ...@@ -31,7 +31,7 @@ RSpec.describe "Admin > Admin sees background migrations" do
end end
end end
it 'can view queued migrations' do it 'can view queued migrations and pause and resume them' do
visit admin_background_migrations_path visit admin_background_migrations_path
within '#content-body' do within '#content-body' do
...@@ -40,7 +40,16 @@ RSpec.describe "Admin > Admin sees background migrations" do ...@@ -40,7 +40,16 @@ RSpec.describe "Admin > Admin sees background migrations" do
expect(page).to have_content(active_migration.job_class_name) expect(page).to have_content(active_migration.job_class_name)
expect(page).to have_content(active_migration.table_name) expect(page).to have_content(active_migration.table_name)
expect(page).to have_content('0.00%') expect(page).to have_content('0.00%')
expect(page).to have_content(active_migration.status.humanize) expect(page).not_to have_content('Paused')
expect(page).to have_content('Active')
click_button('Pause')
expect(page).not_to have_content('Active')
expect(page).to have_content('Paused')
click_button('Resume')
expect(page).not_to have_content('Paused')
expect(page).to have_content('Active')
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