Commit 2bdb960f authored by Brandon Labuschagne's avatar Brandon Labuschagne

Migrate snippets tabs to rails helper

Changelog: changed
parent e8c59dbe
- subject = local_assigns.fetch(:subject, current_user) - subject = local_assigns.fetch(:subject, current_user)
- include_private = local_assigns.fetch(:include_private, false) - include_private = local_assigns.fetch(:include_private, false)
- params[:scope] ||= []
.nav-links.snippet-scope-menu.mobile-separator.nav.nav-tabs = gl_tabs_nav({ class: 'js-snippets-nav-tabs gl-border-b-0 gl-overflow-x-auto gl-flex-grow-1 gl-flex-nowrap' }) do
%li{ class: active_when(params[:scope].nil?) } = gl_tab_link_to subject_snippets_path(subject), { item_active: params[:scope].empty? } do
= link_to subject_snippets_path(subject) do = _('All')
= _("All") = gl_tab_counter_badge(include_private ? counts[:total] : counts[:are_public_or_internal])
%span.badge.badge-muted.badge-pill.gl-badge.sm
- if include_private - if include_private
= counts[:total] = gl_tab_link_to subject_snippets_path(subject, scope: 'are_private') do
- else = _('Private')
= counts[:are_public_or_internal] = gl_tab_counter_badge(counts[:are_private])
= gl_tab_link_to subject_snippets_path(subject, scope: 'are_internal') do
- if include_private = _('Internal')
%li{ class: active_when(params[:scope] == "are_private") } = gl_tab_counter_badge(counts[:are_internal])
= link_to subject_snippets_path(subject, scope: 'are_private') do = gl_tab_link_to subject_snippets_path(subject, scope: 'are_public') do
= _("Private") = _('Public')
%span.badge.badge-muted.badge-pill.gl-badge.sm = gl_tab_counter_badge(counts[:are_public])
= counts[:are_private]
%li{ class: active_when(params[:scope] == "are_internal") }
= link_to subject_snippets_path(subject, scope: 'are_internal') do
= _("Internal")
%span.badge.badge-muted.badge-pill.gl-badge.sm
= counts[:are_internal]
%li{ class: active_when(params[:scope] == "are_public") }
= link_to subject_snippets_path(subject, scope: 'are_public') do
= _("Public")
%span.badge.badge-muted.badge-pill.gl-badge.sm
= counts[:are_public]
...@@ -20,7 +20,7 @@ RSpec.describe 'User Snippets' do ...@@ -20,7 +20,7 @@ RSpec.describe 'User Snippets' do
end end
it 'view my public snippets' do it 'view my public snippets' do
page.within('.snippet-scope-menu') do page.within('.js-snippets-nav-tabs') do
click_link "Public" click_link "Public"
end end
...@@ -30,7 +30,7 @@ RSpec.describe 'User Snippets' do ...@@ -30,7 +30,7 @@ RSpec.describe 'User Snippets' do
end end
it 'view my internal snippets' do it 'view my internal snippets' do
page.within('.snippet-scope-menu') do page.within('.js-snippets-nav-tabs') do
click_link "Internal" click_link "Internal"
end end
...@@ -40,7 +40,7 @@ RSpec.describe 'User Snippets' do ...@@ -40,7 +40,7 @@ RSpec.describe 'User Snippets' do
end end
it 'view my private snippets' do it 'view my private snippets' do
page.within('.snippet-scope-menu') do page.within('.js-snippets-nav-tabs') do
click_link "Private" click_link "Private"
end end
......
...@@ -20,7 +20,7 @@ RSpec.shared_examples 'paginated snippets' do |remote: false| ...@@ -20,7 +20,7 @@ RSpec.shared_examples 'paginated snippets' do |remote: false|
end end
RSpec.shared_examples 'tabs with counts' do RSpec.shared_examples 'tabs with counts' do
let(:tabs) { page.all('.snippet-scope-menu li') } let(:tabs) { page.all('.js-snippets-nav-tabs li') }
it 'shows a tab for All snippets and count' do it 'shows a tab for All snippets and count' do
tab = tabs[0] tab = tabs[0]
......
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