Commit ef09a654 authored by Nourdin el Bacha's avatar Nourdin el Bacha Committed by Paul Slaughter

Conditionally render create group buttons

- This is added to the old and new top nav

Changelog: fixed
parent 91604ec8
......@@ -276,7 +276,11 @@ module Nav
builder = ::Gitlab::Nav::TopNavMenuBuilder.new
builder.add_primary_menu_item(id: 'your', title: _('Your groups'), href: dashboard_groups_path)
builder.add_primary_menu_item(id: 'explore', title: _('Explore groups'), href: explore_groups_path)
if current_user.can_create_group?
builder.add_secondary_menu_item(id: 'create', title: _('Create group'), href: new_group_path)
end
builder.build
end
end
......
......@@ -12,6 +12,7 @@
= nav_link(path: 'groups#explore') do
= link_to explore_groups_path, data: { track_label: "groups_dropdown_explore_groups", track_event: "click_link" } do
= _('Explore groups')
- if current_user.can_create_group?
= nav_link(path: 'groups/new#create-group-pane', html_options: { class: 'gl-border-0 gl-border-t-1 gl-border-solid gl-border-gray-100' }) do
= link_to new_group_path(anchor: 'create-group-pane'), data: { track_label: "groups_dropdown_create_group", track_event: "click_link" } do
= _('Create group')
......
......@@ -7,6 +7,7 @@ RSpec.describe Nav::TopNavHelper do
let_it_be(:user) { build_stubbed(:user) }
let_it_be(:admin) { build_stubbed(:user, :admin) }
let_it_be(:external_user) { build_stubbed(:user, :external, can_create_group: false) }
let(:current_user) { nil }
......@@ -305,6 +306,14 @@ RSpec.describe Nav::TopNavHelper do
expect(groups_view[:linksSecondary]).to eq(expected_links_secondary)
end
context 'with external user' do
let(:current_user) { external_user }
it 'does not have create group link' do
expect(groups_view[:linksSecondary]).to eq([])
end
end
context 'with current nav as group' do
before do
helper.nav('group')
......
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