Skip to content

Update background migration buttons

Alexander Turinske requested to merge 384451-update-migration-buttons into master

What does this MR do and why?

Describe in detail what your merge request does and why.

Update background migration buttons

  • move them to pajamas
  • explicitly add method: :post as the rails docs say :method - Symbol of HTTP verb. Supported verbs are :post, :get, :delete, :patch, and :put. By default it will be :post.

Changelog: changed

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screenshot_2023-01-20_at_10.55.00 pause_-play-_a
Screenshot_2023-01-20_at_10.55.18 retry_-_a

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Navigate to http://gdk.test:3443/admin/background_migrations?database=main
  2. Run the below commands in the rails console (rails c) to generate some data
migration  = FactoryBot.create(:batched_background_migration, :active, table_name: 'Example')
job = FactoryBot.create(:batched_background_migration_job, :running, batched_migration: migration)
job.failure!(error: RuntimeError.new('exampleeee'))
  1. Use the below patch to create a failed data
diff --git a/app/views/admin/background_migrations/_migration.html.haml b/app/views/admin/background_migrations/_migration.html.haml
index 99cb63709f5d..4d67904f1966 100644
--- a/app/views/admin/background_migrations/_migration.html.haml
+++ b/app/views/admin/background_migrations/_migration.html.haml
@@ -16,12 +16,12 @@
         method: :post,
         href: pause_admin_background_migration_path(migration, database: params[:database]),
         button_options: { class: 'has-tooltip', title: _('Pause'), 'aria-label' => _('Pause') })
-    - elsif migration.paused?
+    - elsif !migration.paused?
       = render Pajamas::ButtonComponent.new(icon: 'play',
         method: :post,
         href: resume_admin_background_migration_path(migration, database: params[:database]),
         button_options: { class: 'has-tooltip', title: _('Resume'), 'aria-label' => _('Resume') })
-    - elsif migration.failed?
+    - elsif migration.paused?
       = render Pajamas::ButtonComponent.new(icon: 'retry',
         method: :post,
         href: retry_admin_background_migration_path(migration, database: params[:database]),

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #384451 (closed)

Edited by Alexander Turinske

Merge request reports

Loading