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
within: _('Issues'),
new_sub_nav_item_name: _('Labels')
)
insert_after_nav_item(
_('Snippets'),
new_nav_item: {
nav_item: _('Members'),
nav_sub_items: []
}
)
end
context 'when issue analytics is available' do
......@@ -124,7 +132,8 @@ RSpec.describe 'Project navbar' do
nav_item: _('Project information'),
nav_sub_items: [
_('Activity'),
_('Labels')
_('Labels'),
_('Members')
]
}
end
......
......@@ -28,6 +28,8 @@ module Sidebars
override :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)
end
......
......@@ -10,6 +10,7 @@ module Sidebars
add_item(activity_menu_item)
add_item(releases_menu_item)
add_item(labels_menu_item)
add_item(members_menu_item)
true
end
......@@ -113,6 +114,22 @@ module Sidebars
item_id: :labels
)
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
......
......@@ -28,6 +28,14 @@ RSpec.describe 'Project navbar' do
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 })
end
......@@ -100,7 +108,8 @@ RSpec.describe 'Project navbar' do
nav_item: _('Project information'),
nav_sub_items: [
_('Activity'),
_('Labels')
_('Labels'),
_('Members')
]
}
end
......
......@@ -10,18 +10,26 @@ RSpec.describe Sidebars::Projects::Menus::MembersMenu do
subject { described_class.new(context) }
describe '#render?' do
context 'when user cannot access members' do
let(:user) { nil }
it 'returns false' do
expect(subject.render?).to eq false
end
it 'returns false' do
expect(subject.render?).to eq false
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
expect(subject.render?).to eq true
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
......@@ -56,5 +56,19 @@ RSpec.describe Sidebars::Projects::Menus::ProjectInformationMenu do
specify { is_expected.to be_nil }
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
......@@ -106,10 +106,6 @@ RSpec.shared_context 'project navbar structure' do
nav_item: _('Snippets'),
nav_sub_items: []
},
{
nav_item: _('Members'),
nav_sub_items: []
},
{
nav_item: _('Settings'),
nav_sub_items: [
......
......@@ -103,6 +103,27 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
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
describe 'Learn GitLab' do
......@@ -1073,21 +1094,30 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
describe 'Members' do
before do
render
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 user can access members' do
it 'show Members link' do
expect(rendered).to have_link('Members', href: project_project_members_path(project))
context 'when feature flag :sidebar_refactor is disabled' do
before do
stub_feature_flags(sidebar_refactor: false)
render
end
end
context 'when user cannot access members' do
let(:user) { nil }
context 'when user can access members' 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))
end
end
it 'show Members link' do
expect(rendered).not_to have_link('Members')
context 'when user cannot access members' do
let(:user) { nil }
it 'show Members link' do
expect(rendered).not_to have_link('Members')
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