Commit 0d58b7ab authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '224701-fj-move-members-to-project-information' into 'master'

Move Members menu item to Project information menu

See merge request gitlab-org/gitlab!61458
parents 695d8df3 5eb9afc8
...@@ -27,6 +27,14 @@ RSpec.describe 'Project navbar' do ...@@ -27,6 +27,14 @@ RSpec.describe 'Project navbar' do
within: _('Issues'), within: _('Issues'),
new_sub_nav_item_name: _('Labels') new_sub_nav_item_name: _('Labels')
) )
insert_after_nav_item(
_('Snippets'),
new_nav_item: {
nav_item: _('Members'),
nav_sub_items: []
}
)
end end
context 'when issue analytics is available' do context 'when issue analytics is available' do
...@@ -131,7 +139,8 @@ RSpec.describe 'Project navbar' do ...@@ -131,7 +139,8 @@ RSpec.describe 'Project navbar' do
nav_item: _('Project information'), nav_item: _('Project information'),
nav_sub_items: [ nav_sub_items: [
_('Activity'), _('Activity'),
_('Labels') _('Labels'),
_('Members')
] ]
} }
end end
......
...@@ -28,6 +28,8 @@ module Sidebars ...@@ -28,6 +28,8 @@ module Sidebars
override :render? override :render?
def render? def render?
return false if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml)
can?(context.current_user, :read_project_member, context.project) can?(context.current_user, :read_project_member, context.project)
end end
......
...@@ -10,6 +10,7 @@ module Sidebars ...@@ -10,6 +10,7 @@ module Sidebars
add_item(activity_menu_item) add_item(activity_menu_item)
add_item(releases_menu_item) add_item(releases_menu_item)
add_item(labels_menu_item) add_item(labels_menu_item)
add_item(members_menu_item)
true true
end end
...@@ -113,6 +114,22 @@ module Sidebars ...@@ -113,6 +114,22 @@ module Sidebars
item_id: :labels item_id: :labels
) )
end end
def members_menu_item
if Feature.disabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml)
return ::Sidebars::NilMenuItem.new(item_id: :members)
end
::Sidebars::MenuItem.new(
title: _('Members'),
link: project_project_members_path(context.project),
active_routes: { controller: :project_members },
item_id: :members,
container_html_options: {
id: 'js-onboarding-members-link'
}
)
end
end end
end end
end end
......
...@@ -28,6 +28,14 @@ RSpec.describe 'Project navbar' do ...@@ -28,6 +28,14 @@ RSpec.describe 'Project navbar' do
new_sub_nav_item_name: _('Labels') new_sub_nav_item_name: _('Labels')
) )
insert_after_nav_item(
_('Snippets'),
new_nav_item: {
nav_item: _('Members'),
nav_sub_items: []
}
)
stub_config(registry: { enabled: false }) stub_config(registry: { enabled: false })
end end
...@@ -107,7 +115,8 @@ RSpec.describe 'Project navbar' do ...@@ -107,7 +115,8 @@ RSpec.describe 'Project navbar' do
nav_item: _('Project information'), nav_item: _('Project information'),
nav_sub_items: [ nav_sub_items: [
_('Activity'), _('Activity'),
_('Labels') _('Labels'),
_('Members')
] ]
} }
end end
......
...@@ -10,18 +10,26 @@ RSpec.describe Sidebars::Projects::Menus::MembersMenu do ...@@ -10,18 +10,26 @@ RSpec.describe Sidebars::Projects::Menus::MembersMenu do
subject { described_class.new(context) } subject { described_class.new(context) }
describe '#render?' do describe '#render?' do
context 'when user cannot access members' do
let(:user) { nil }
it 'returns false' do it 'returns false' do
expect(subject.render?).to eq false expect(subject.render?).to eq false
end end
context 'when feature flag :sidebar_refactor is disabled' do
before do
stub_feature_flags(sidebar_refactor: false)
end end
context 'when user can access members' do
it 'returns true' do it 'returns true' do
expect(subject.render?).to eq true expect(subject.render?).to eq true
end end
context 'when user cannot access members' do
let(:user) { nil }
it 'returns false' do
expect(subject.render?).to eq false
end
end
end end
end end
end end
...@@ -56,5 +56,19 @@ RSpec.describe Sidebars::Projects::Menus::ProjectInformationMenu do ...@@ -56,5 +56,19 @@ RSpec.describe Sidebars::Projects::Menus::ProjectInformationMenu do
specify { is_expected.to be_nil } specify { is_expected.to be_nil }
end end
end end
describe 'Members' do
let(:item_id) { :members }
specify { is_expected.not_to be_nil }
context 'when feature flag :sidebar_refactor is disabled' do
before do
stub_feature_flags(sidebar_refactor: false)
end
specify { is_expected.to be_nil }
end
end
end end
end end
...@@ -122,10 +122,6 @@ RSpec.shared_context 'project navbar structure' do ...@@ -122,10 +122,6 @@ RSpec.shared_context 'project navbar structure' do
nav_item: _('Snippets'), nav_item: _('Snippets'),
nav_sub_items: [] nav_sub_items: []
}, },
{
nav_item: _('Members'),
nav_sub_items: []
},
{ {
nav_item: _('Settings'), nav_item: _('Settings'),
nav_sub_items: settings_menu_items nav_sub_items: settings_menu_items
......
...@@ -103,6 +103,27 @@ RSpec.describe 'layouts/nav/sidebar/_project' do ...@@ -103,6 +103,27 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end end
end end
end end
describe 'Members' do
let(:page) { Nokogiri::HTML.parse(rendered) }
it 'has a link to the members page' do
render
expect(page.at_css('.shortcuts-project').parent.css('[aria-label="Members"]')).not_to be_empty
expect(rendered).to have_link('Members', href: project_project_members_path(project))
end
context 'when feature flag :sidebar_refactor is disabled' do
it 'does not have a link to the members page' do
stub_feature_flags(sidebar_refactor: false)
render
expect(page.at_css('.shortcuts-project').parent.css('[aria-label="Members"]')).to be_empty
end
end
end
end end
describe 'Learn GitLab' do describe 'Learn GitLab' do
...@@ -1073,12 +1094,20 @@ RSpec.describe 'layouts/nav/sidebar/_project' do ...@@ -1073,12 +1094,20 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end end
describe 'Members' do describe 'Members' do
it 'does not show the Member menu item' do
expect(rendered).not_to have_selector('.sidebar-top-level-items > li > a[aria-label="Members"]')
end
context 'when feature flag :sidebar_refactor is disabled' do
before do before do
stub_feature_flags(sidebar_refactor: false)
render render
end end
context 'when user can access members' do context 'when user can access members' do
it 'show Members link' do it 'show Members link' do
expect(rendered).to have_selector('.sidebar-top-level-items > li > a[aria-label="Members"]')
expect(rendered).to have_link('Members', href: project_project_members_path(project)) expect(rendered).to have_link('Members', href: project_project_members_path(project))
end end
end end
...@@ -1091,6 +1120,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do ...@@ -1091,6 +1120,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end end
end end
end end
end
describe 'Settings' do describe 'Settings' do
describe 'General' do describe 'General' do
......
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