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
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
......@@ -131,7 +139,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
......@@ -107,7 +115,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
context 'when feature flag :sidebar_refactor is disabled' do
before do
stub_feature_flags(sidebar_refactor: false)
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
......@@ -122,10 +122,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: settings_menu_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,12 +1094,20 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
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
stub_feature_flags(sidebar_refactor: false)
render
end
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
......@@ -1091,6 +1120,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
end
end
describe 'Settings' 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