Commit df90f2c1 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch...

Merge branch '344378-make-badges-in-app-views-admin-background_migrations-index-html-haml-pajamas-compliant' into 'master'

Make badges in app/views/admin/background_migrations/ Pajamas-compliant

See merge request gitlab-org/gitlab!76980
parents 30367dc6 de7c91b6
......@@ -2,15 +2,15 @@
module Admin
module BackgroundMigrationsHelper
def batched_migration_status_badge_class_name(migration)
class_names = {
'active' => 'badge-info',
'paused' => 'badge-warning',
'failed' => 'badge-danger',
'finished' => 'badge-success'
def batched_migration_status_badge_variant(migration)
variants = {
'active' => :info,
'paused' => :warning,
'failed' => :danger,
'finished' => :success
}
class_names[migration.status]
variants[migration.status]
end
# The extra logic here is needed because total_tuple_count is just
......
......@@ -7,7 +7,7 @@
- else
= _('Unknown')
%td{ role: 'cell', data: { label: _('Status') } }
%span.badge.badge-pill.gl-badge.sm{ class: batched_migration_status_badge_class_name(migration) }= migration.status.humanize
= gl_badge_tag migration.status.humanize, { size: :sm, variant: batched_migration_status_badge_variant(migration) }
%td{ role: 'cell', data: { label: _('Action') } }
- if migration.active?
= button_to pause_admin_background_migration_path(migration),
......
......@@ -8,18 +8,15 @@
%li.nav-item{ role: 'presentation' }
%a.nav-link.gl-tab-nav-item{ href: admin_background_migrations_path, class: (active_tab_classes if @current_tab == 'queued'), role: 'tab' }
= _('Queued')
%span.badge.gl-tab-counter-badge.badge-muted.badge-pill.gl-badge.sm
= limited_counter_with_delimiter(@relations_by_tab['queued'])
= gl_tab_counter_badge limited_counter_with_delimiter(@relations_by_tab['queued'])
%li.nav-item{ role: 'presentation' }
%a.nav-link.gl-tab-nav-item{ href: admin_background_migrations_path(tab: 'failed'), class: (active_tab_classes if @current_tab == 'failed'), role: 'tab' }
= _('Failed')
%span.badge.gl-tab-counter-badge.badge-muted.badge-pill.gl-badge.sm
= limited_counter_with_delimiter(@relations_by_tab['failed'])
= gl_tab_counter_badge limited_counter_with_delimiter(@relations_by_tab['failed'])
%li.nav-item{ role: 'presentation' }
%a.nav-link.gl-tab-nav-item{ href: admin_background_migrations_path(tab: 'finished'), class: (active_tab_classes if @current_tab == 'finished'), role: 'tab' }
= _('Finished')
%span.badge.gl-tab-counter-badge.badge-muted.badge-pill.gl-badge.sm
= limited_counter_with_delimiter(@relations_by_tab['finished'])
= gl_tab_counter_badge limited_counter_with_delimiter(@relations_by_tab['finished'])
.tab-content.gl-tab-content
.tab-pane.active{ role: 'tabpanel' }
......
......@@ -3,22 +3,22 @@
require "spec_helper"
RSpec.describe Admin::BackgroundMigrationsHelper do
describe '#batched_migration_status_badge_class_name' do
describe '#batched_migration_status_badge_variant' do
using RSpec::Parameterized::TableSyntax
where(:status, :class_name) do
:active | 'badge-info'
:paused | 'badge-warning'
:failed | 'badge-danger'
:finished | 'badge-success'
where(:status, :variant) do
:active | :info
:paused | :warning
:failed | :danger
:finished | :success
end
subject { helper.batched_migration_status_badge_class_name(migration) }
subject { helper.batched_migration_status_badge_variant(migration) }
with_them do
let(:migration) { build(:batched_background_migration, status: status) }
it { is_expected.to eq(class_name) }
it { is_expected.to eq(variant) }
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