Rearrange 'Security & Compliance' menu items

In this commit we're rearranging the Audit Events
menu item in the 'Security & Compliance menu', in order
to match the link set in the main menu.

Changelog: changed
EE: true
parent 0c81941b
......@@ -65,8 +65,8 @@ RSpec.describe 'Project navbar' do
_('Security Dashboard'),
_('Vulnerability Report'),
s_('OnDemandScans|On-demand Scans'),
_('Configuration'),
_('Audit Events')
_('Audit Events'),
_('Configuration')
]
}
end
......
......@@ -10,44 +10,20 @@ RSpec.describe Sidebars::Projects::Menus::SecurityComplianceMenu do
let(:show_discover_project_security) { true }
let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project, show_promotions: show_promotions, show_discover_project_security: show_discover_project_security) }
subject(:menu) { described_class.new(context) }
describe 'render?' do
subject { menu.render? }
context 'when user is not authenticated' do
let(:user) { nil }
it { is_expected.to be_falsey }
end
context 'when user is authenticated' do
context 'when the Security & Compliance is disabled' do
before do
allow(Ability).to receive(:allowed?).with(user, :access_security_and_compliance, project).and_return(false)
end
it { is_expected.to be_falsey }
end
context 'when the Security & Compliance is not disabled' do
it { is_expected.to be_truthy }
end
end
end
describe '#link' do
subject { described_class.new(context) }
let(:show_promotions) { false }
let(:show_discover_project_security) { false }
using RSpec::Parameterized::TableSyntax
where(:security_dashboard_feature, :audit_events_feature, :dependency_scanning_feature, :show_discover_project_security, :expected_link) do
true | true | true | false | "/-/security/dashboard"
false | true | true | false | "/-/audit_events"
false | false | true | false | "/-/dependencies"
false | false | true | true | "/-/security/discover"
false | false | false | false | "/-/security/configuration"
where(:show_discover_project_security, :security_dashboard_feature, :dependency_scanning_feature, :audit_events_feature, :expected_link) do
true | true | true | true | '/-/security/discover'
false | true | true | true | '/-/security/dashboard'
false | false | true | true | '/-/dependencies'
false | false | false | true | '/-/audit_events'
false | false | false | false | '/-/security/configuration'
end
with_them do
......
......@@ -17,7 +17,7 @@ module Sidebars
override :link
def link
project_security_configuration_path(context.project)
renderable_items.first&.link
end
override :title
......@@ -33,18 +33,16 @@ module Sidebars
private
def configuration_menu_item
strong_memoize(:configuration_menu_item) do
unless render_configuration_menu_item?
next ::Sidebars::NilMenuItem.new(item_id: :configuration)
end
::Sidebars::MenuItem.new(
title: _('Configuration'),
link: project_security_configuration_path(context.project),
active_routes: { path: configuration_menu_item_paths },
item_id: :configuration
)
unless render_configuration_menu_item?
return ::Sidebars::NilMenuItem.new(item_id: :configuration)
end
::Sidebars::MenuItem.new(
title: _('Configuration'),
link: project_security_configuration_path(context.project),
active_routes: { path: configuration_menu_item_paths },
item_id: :configuration
)
end
def render_configuration_menu_item?
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Sidebars::Projects::Menus::SecurityComplianceMenu do
let_it_be(:project) { create(:project) }
let(:user) { project.owner }
let(:show_promotions) { true }
let(:show_discover_project_security) { true }
let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project, show_promotions: show_promotions, show_discover_project_security: show_discover_project_security) }
describe 'render?' do
subject { described_class.new(context).render? }
context 'when user is not authenticated' do
let(:user) { nil }
it { is_expected.to be_falsey }
end
context 'when user is authenticated' do
context 'when the Security & Compliance is disabled' do
before do
allow(Ability).to receive(:allowed?).with(user, :access_security_and_compliance, project).and_return(false)
end
it { is_expected.to be_falsey }
end
context 'when the Security & Compliance is not disabled' do
it { is_expected.to be_truthy }
end
end
end
end
......@@ -18,8 +18,8 @@ RSpec.shared_context 'project navbar structure' do
{
nav_item: _('Security & Compliance'),
nav_sub_items: [
_('Configuration'),
(_('Audit Events') if Gitlab.ee?)
(_('Audit Events') if Gitlab.ee?),
_('Configuration')
]
}
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