diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /lib/sidebars/groups/menus/settings_menu.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'lib/sidebars/groups/menus/settings_menu.rb')
-rw-r--r-- | lib/sidebars/groups/menus/settings_menu.rb | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/lib/sidebars/groups/menus/settings_menu.rb b/lib/sidebars/groups/menus/settings_menu.rb new file mode 100644 index 00000000000..8bc6077d302 --- /dev/null +++ b/lib/sidebars/groups/menus/settings_menu.rb @@ -0,0 +1,117 @@ +# frozen_string_literal: true + +module Sidebars + module Groups + module Menus + class SettingsMenu < ::Sidebars::Menu + override :configure_menu_items + def configure_menu_items + return false unless can?(context.current_user, :admin_group, context.group) + + add_item(general_menu_item) + add_item(integrations_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) + + true + end + + override :link + def link + edit_group_path(context.group) + 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 + + 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), + active_routes: { path: %w[ci_cd#show groups/runners#show groups/runners#edit] }, + 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( + title: _('Packages & Registries'), + 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') |