2021-06-08 01:23:25 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Sidebars
|
|
|
|
module Projects
|
|
|
|
module Menus
|
|
|
|
class SecurityComplianceMenu < ::Sidebars::Menu
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
|
|
|
override :configure_menu_items
|
|
|
|
def configure_menu_items
|
|
|
|
return false unless can?(context.current_user, :access_security_and_compliance, context.project)
|
|
|
|
|
|
|
|
add_item(configuration_menu_item)
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
override :title
|
|
|
|
def title
|
2023-05-27 22:25:52 +05:30
|
|
|
_('Security and Compliance')
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
override :sprite_icon
|
|
|
|
def sprite_icon
|
|
|
|
'shield'
|
|
|
|
end
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
override :pick_into_super_sidebar?
|
|
|
|
def pick_into_super_sidebar?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def configuration_menu_item
|
2021-09-04 01:27:46 +05:30
|
|
|
unless render_configuration_menu_item?
|
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :configuration)
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
2023-05-27 22:25:52 +05:30
|
|
|
title: _('Security configuration'),
|
2021-09-04 01:27:46 +05:30
|
|
|
link: project_security_configuration_path(context.project),
|
|
|
|
active_routes: { path: configuration_menu_item_paths },
|
|
|
|
item_id: :configuration
|
|
|
|
)
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def render_configuration_menu_item?
|
|
|
|
can?(context.current_user, :read_security_configuration, context.project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def configuration_menu_item_paths
|
|
|
|
%w[
|
|
|
|
projects/security/configuration#show
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Sidebars::Projects::Menus::SecurityComplianceMenu.prepend_mod_with('Sidebars::Projects::Menus::SecurityComplianceMenu')
|