Commit 1cff7c62 authored by Michael Kozono's avatar Michael Kozono

Merge branch '6953-instance-security-dashboard-menu-entry-ee' into 'master'

Add link to Instance Security Dashboard in nav

See merge request gitlab-org/gitlab!17389
parents 2b0a4131 3bf0267a
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
= render_if_exists 'layouts/nav/sidebar/analytics_more_link' = render_if_exists 'layouts/nav/sidebar/analytics_more_link'
%li.dropdown.d-lg-none %li.dropdown.d-lg-none
= render_if_exists 'dashboard/operations/nav_link_list' = render_if_exists 'dashboard/nav_link_list'
- if can?(current_user, :read_instance_statistics) - if can?(current_user, :read_instance_statistics)
= nav_link(controller: [:conversational_development_index, :cohorts], html_options: { class: 'd-lg-none' }) do = nav_link(controller: [:conversational_development_index, :cohorts], html_options: { class: 'd-lg-none' }) do
= link_to instance_statistics_root_path do = link_to instance_statistics_root_path do
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
= _('Web IDE') = _('Web IDE')
%li.dropdown{ class: 'd-none d-lg-block' } %li.dropdown{ class: 'd-none d-lg-block' }
= render_if_exists 'dashboard/operations/nav_link' = render_if_exists 'dashboard/nav_link'
- if can?(current_user, :read_instance_statistics) - if can?(current_user, :read_instance_statistics)
= nav_link(controller: [:conversational_development_index, :cohorts], html_options: { class: "d-none d-lg-block d-xl-block"}) do = nav_link(controller: [:conversational_development_index, :cohorts], html_options: { class: "d-none d-lg-block d-xl-block"}) do
= link_to instance_statistics_root_path, title: _('Instance Statistics'), aria: { label: _('Instance Statistics') }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to instance_statistics_root_path, title: _('Instance Statistics'), aria: { label: _('Instance Statistics') }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
......
...@@ -37,6 +37,15 @@ module EE ...@@ -37,6 +37,15 @@ module EE
def get_dashboard_nav_links def get_dashboard_nav_links
super.tap do |links| super.tap do |links|
links << :analytics if ::Gitlab::Analytics.any_features_enabled? links << :analytics if ::Gitlab::Analytics.any_features_enabled?
if can?(current_user, :read_operations_dashboard)
links << :environments if ::Feature.enabled?(:environments_dashboard)
links << :operations
end
if ::Feature.enabled?(:security_dashboard) && can?(current_user, :read_security_dashboard)
links << :security
end
end end
end end
end end
......
- if can?(current_user, :read_operations_dashboard) - if any_dashboard_nav_link?([:environments, :operations, :security])
%button#js-dashboards-menu.btn-link{ type: 'button', data: { toggle: 'dropdown' }, 'aria-label': _('Operations Dashboard'), 'aria-haspopup': true, 'aria-expanded': false } %button#js-dashboards-menu.btn-link{ type: 'button', data: { toggle: 'dropdown' }, 'aria-label': _('Dashboards'), 'aria-haspopup': true, 'aria-expanded': false }
= sprite_icon('dashboard', size: 18) = sprite_icon('dashboard', size: 18)
= sprite_icon('angle-down', css_class: 'caret-down') = sprite_icon('angle-down', css_class: 'caret-down')
.dropdown-menu{ 'aria-labelledby': "js-dashboards-menu" } .dropdown-menu{ 'aria-labelledby': "js-dashboards-menu" }
.dropdown-bold-header .dropdown-bold-header
= _('Dashboards') = _('Dashboards')
= render_if_exists 'dashboard/operations/nav_link_list' = render_if_exists 'dashboard/nav_link_list'
- if dashboard_nav_link?(:environments)
= link_to operations_environments_path, class: 'dropdown-item' do
= _('Environments')
- if dashboard_nav_link?(:operations)
= link_to operations_path, class: 'dropdown-item' do
= _('Operations')
- if dashboard_nav_link?(:security)
= link_to security_path, class: 'dropdown-item' do
= _('Security')
- if Feature.enabled?('environments_dashboard')
= link_to operations_environments_path, class: 'dropdown-item' do
= _('Environments')
= link_to operations_path, class: 'dropdown-item' do
= _('Operations')
...@@ -7,29 +7,69 @@ describe DashboardHelper, type: :helper do ...@@ -7,29 +7,69 @@ describe DashboardHelper, type: :helper do
let(:user) { build(:user) } let(:user) { build(:user) }
before do
allow(helper).to receive(:current_user).and_return(user)
allow(helper).to receive(:can?) { true }
end
describe '#dashboard_nav_links' do describe '#dashboard_nav_links' do
context 'when at least one analytics feature is enabled' do before do
allow(helper).to receive(:current_user).and_return(user)
end
describe 'analytics' do
before do before do
enable_only_one_analytics_feature_flag allow(helper).to receive(:can?) { true }
end end
it 'includes analytics' do context 'when at least one analytics feature is enabled' do
expect(helper.dashboard_nav_links).to include(:analytics) before do
enable_only_one_analytics_feature_flag
end
it 'includes analytics' do
expect(helper.dashboard_nav_links).to include(:analytics)
end
end
context 'when all analytics features are disabled' do
before do
disable_all_analytics_feature_flags
end
it 'does not include analytics' do
expect(helper.dashboard_nav_links).not_to include(:analytics)
end
end end
end end
context 'when all analytics features are disabled' do describe 'operations, environments and security' do
before do using RSpec::Parameterized::TableSyntax
disable_all_analytics_feature_flags
where(:ability, :feature_flag, :nav_link) do
:read_operations_dashboard | nil | :operations
:read_operations_dashboard | :environments_dashboard | :environments
:read_security_dashboard | :security_dashboard | :security
end end
it 'does not include analytics' do with_them do
expect(helper.dashboard_nav_links).not_to include(:analytics) describe 'when the feature is enabled' do
before do
stub_feature_flags(feature_flag => true) unless feature_flag.nil?
allow(helper).to receive(:can?).and_return(false)
allow(helper).to receive(:can?).with(user, ability).and_return(true)
end
it 'includes the nav link' do
expect(helper.dashboard_nav_links).to include(nav_link)
end
end
describe 'when the feature is disabled' do
before do
stub_feature_flags(feature_flag => false) unless feature_flag.nil?
allow(helper).to receive(:can?).and_return(false)
end
it 'does not include the nav link' do
expect(helper.dashboard_nav_links).not_to include(nav_link)
end
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