Commit ff470db2 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'Conditionally-render-create-group-buttons' into 'master'

Conditionally render create group buttons

See merge request gitlab-org/gitlab!63871
parents 40154e7a ef09a654
...@@ -276,7 +276,11 @@ module Nav ...@@ -276,7 +276,11 @@ module Nav
builder = ::Gitlab::Nav::TopNavMenuBuilder.new 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: 'your', title: _('Your groups'), href: dashboard_groups_path)
builder.add_primary_menu_item(id: 'explore', title: _('Explore groups'), href: explore_groups_path) builder.add_primary_menu_item(id: 'explore', title: _('Explore groups'), href: explore_groups_path)
builder.add_secondary_menu_item(id: 'create', title: _('Create group'), href: new_group_path)
if current_user.can_create_group?
builder.add_secondary_menu_item(id: 'create', title: _('Create group'), href: new_group_path)
end
builder.build builder.build
end end
end end
......
...@@ -12,11 +12,12 @@ ...@@ -12,11 +12,12 @@
= nav_link(path: 'groups#explore') do = nav_link(path: 'groups#explore') do
= link_to explore_groups_path, data: { track_label: "groups_dropdown_explore_groups", track_event: "click_link" } do = link_to explore_groups_path, data: { track_label: "groups_dropdown_explore_groups", track_event: "click_link" } do
= _('Explore groups') = _('Explore groups')
= 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 - if current_user.can_create_group?
= link_to new_group_path(anchor: 'create-group-pane'), data: { track_label: "groups_dropdown_create_group", track_event: "click_link" } do = 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
= _('Create group') = link_to new_group_path(anchor: 'create-group-pane'), data: { track_label: "groups_dropdown_create_group", track_event: "click_link" } do
= nav_link(path: 'groups/new#import-group-pane') do = _('Create group')
= link_to new_group_path(anchor: 'import-group-pane'), data: { track_label: "groups_dropdown_import_group", track_event: "click_link" } do = nav_link(path: 'groups/new#import-group-pane') do
= _('Import group') = link_to new_group_path(anchor: 'import-group-pane'), data: { track_label: "groups_dropdown_import_group", track_event: "click_link" } do
= _('Import group')
.frequent-items-dropdown-content .frequent-items-dropdown-content
#js-groups-dropdown{ data: { user_name: current_user.username, group: group_meta } } #js-groups-dropdown{ data: { user_name: current_user.username, group: group_meta } }
...@@ -7,6 +7,7 @@ RSpec.describe Nav::TopNavHelper do ...@@ -7,6 +7,7 @@ RSpec.describe Nav::TopNavHelper do
let_it_be(:user) { build_stubbed(:user) } let_it_be(:user) { build_stubbed(:user) }
let_it_be(:admin) { build_stubbed(:user, :admin) } 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 } let(:current_user) { nil }
...@@ -305,6 +306,14 @@ RSpec.describe Nav::TopNavHelper do ...@@ -305,6 +306,14 @@ RSpec.describe Nav::TopNavHelper do
expect(groups_view[:linksSecondary]).to eq(expected_links_secondary) expect(groups_view[:linksSecondary]).to eq(expected_links_secondary)
end 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 context 'with current nav as group' do
before do before do
helper.nav('group') 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