Move members to Project information menu

In this commit, we're moving the `Members` menu in
the project sidebar, to the `Project Information` menu.
parent c6a85564
...@@ -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
...@@ -124,7 +132,8 @@ RSpec.describe 'Project navbar' do ...@@ -124,7 +132,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
...@@ -100,7 +108,8 @@ RSpec.describe 'Project navbar' do ...@@ -100,7 +108,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 it 'returns false' do
let(:user) { nil } expect(subject.render?).to eq false
end
it 'returns false' do context 'when feature flag :sidebar_refactor is disabled' do
expect(subject.render?).to eq false before do
stub_feature_flags(sidebar_refactor: false)
end 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
...@@ -106,10 +106,6 @@ RSpec.shared_context 'project navbar structure' do ...@@ -106,10 +106,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: [ nav_sub_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,21 +1094,30 @@ RSpec.describe 'layouts/nav/sidebar/_project' do ...@@ -1073,21 +1094,30 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end end
describe 'Members' do describe 'Members' do
before do it 'does not show the Member menu item' do
render expect(rendered).not_to have_selector('.sidebar-top-level-items > li > a[aria-label="Members"]')
end end
context 'when user can access members' do context 'when feature flag :sidebar_refactor is disabled' do
it 'show Members link' do before do
expect(rendered).to have_link('Members', href: project_project_members_path(project)) stub_feature_flags(sidebar_refactor: false)
render
end end
end
context 'when user cannot access members' do context 'when user can access members' do
let(:user) { nil } 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))
end
end
it 'show Members link' do context 'when user cannot access members' do
expect(rendered).not_to have_link('Members') let(:user) { nil }
it 'show Members link' do
expect(rendered).not_to have_link('Members')
end
end end
end end
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