2021-10-27 15:23:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Sidebars
|
|
|
|
module Groups
|
|
|
|
module Menus
|
|
|
|
class SettingsMenu < ::Sidebars::Menu
|
|
|
|
override :configure_menu_items
|
|
|
|
def configure_menu_items
|
2022-10-11 01:57:18 +05:30
|
|
|
if can?(context.current_user, :admin_group, context.group)
|
|
|
|
add_item(general_menu_item)
|
|
|
|
add_item(integrations_menu_item)
|
|
|
|
add_item(access_tokens_menu_item)
|
|
|
|
add_item(group_projects_menu_item)
|
|
|
|
add_item(repository_menu_item)
|
|
|
|
add_item(ci_cd_menu_item)
|
|
|
|
add_item(applications_menu_item)
|
|
|
|
add_item(packages_and_registries_menu_item)
|
|
|
|
return true
|
|
|
|
elsif Gitlab.ee? && can?(context.current_user, :change_push_rules, context.group)
|
|
|
|
# Push Rules are the only group setting that can also be edited by maintainers.
|
|
|
|
# Create an empty sub-menu here and EE adds Repository menu item (with only Push Rules).
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
false
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
override :title
|
|
|
|
def title
|
|
|
|
_('Settings')
|
|
|
|
end
|
|
|
|
|
|
|
|
override :sprite_icon
|
|
|
|
def sprite_icon
|
|
|
|
'settings'
|
|
|
|
end
|
|
|
|
|
|
|
|
override :extra_nav_link_html_options
|
|
|
|
def extra_nav_link_html_options
|
|
|
|
{
|
|
|
|
class: 'shortcuts-settings'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def general_menu_item
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('General'),
|
|
|
|
link: edit_group_path(context.group),
|
|
|
|
active_routes: { path: 'groups#edit' },
|
|
|
|
item_id: :general
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def integrations_menu_item
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Integrations'),
|
|
|
|
link: group_settings_integrations_path(context.group),
|
|
|
|
active_routes: { controller: :integrations },
|
|
|
|
item_id: :integrations
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
def access_tokens_menu_item
|
|
|
|
unless can?(context.current_user, :read_resource_access_tokens, context.group)
|
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :access_tokens)
|
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Access Tokens'),
|
|
|
|
link: group_settings_access_tokens_path(context.group),
|
|
|
|
active_routes: { path: 'access_tokens#index' },
|
|
|
|
item_id: :access_tokens
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
def group_projects_menu_item
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Projects'),
|
|
|
|
link: projects_group_path(context.group),
|
|
|
|
active_routes: { path: 'groups#projects' },
|
|
|
|
item_id: :group_projects
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def repository_menu_item
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Repository'),
|
|
|
|
link: group_settings_repository_path(context.group),
|
|
|
|
active_routes: { controller: :repository },
|
|
|
|
item_id: :repository
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def ci_cd_menu_item
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('CI/CD'),
|
|
|
|
link: group_settings_ci_cd_path(context.group),
|
2022-07-16 23:28:13 +05:30
|
|
|
active_routes: { path: 'ci_cd#show' },
|
2021-10-27 15:23:28 +05:30
|
|
|
item_id: :ci_cd
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def applications_menu_item
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Applications'),
|
|
|
|
link: group_settings_applications_path(context.group),
|
|
|
|
active_routes: { controller: :applications },
|
|
|
|
item_id: :applications
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def packages_and_registries_menu_item
|
|
|
|
unless context.group.packages_feature_enabled?
|
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :packages_and_registries)
|
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
2022-10-11 01:57:18 +05:30
|
|
|
title: _('Packages and registries'),
|
2021-10-27 15:23:28 +05:30
|
|
|
link: group_settings_packages_and_registries_path(context.group),
|
|
|
|
active_routes: { controller: :packages_and_registries },
|
|
|
|
item_id: :packages_and_registries
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Sidebars::Groups::Menus::SettingsMenu.prepend_mod_with('Sidebars::Groups::Menus::SettingsMenu')
|