diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-07 12:10:27 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-07 12:10:27 +0000 |
commit | 53f456b167f19877d663ee6ed510673cebee0f91 (patch) | |
tree | fcc0bb52b79c195bf0eda100cc5d7e7a16dc0c0b /lib/sidebars/projects | |
parent | e8a31d8dc2afd673ca50d74d26edab0a0fec83ca (diff) | |
download | gitlab-ce-53f456b167f19877d663ee6ed510673cebee0f91.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/sidebars/projects')
-rw-r--r-- | lib/sidebars/projects/menus/settings_menu.rb | 145 | ||||
-rw-r--r-- | lib/sidebars/projects/panel.rb | 1 |
2 files changed, 146 insertions, 0 deletions
diff --git a/lib/sidebars/projects/menus/settings_menu.rb b/lib/sidebars/projects/menus/settings_menu.rb new file mode 100644 index 00000000000..8aec769d8d5 --- /dev/null +++ b/lib/sidebars/projects/menus/settings_menu.rb @@ -0,0 +1,145 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + class SettingsMenu < ::Sidebars::Menu + override :configure_menu_items + def configure_menu_items + return false unless can?(context.current_user, :admin_project, context.project) + + add_item(general_menu_item) + add_item(integrations_menu_item) + add_item(webhooks_menu_item) + add_item(access_tokens_menu_item) + add_item(repository_menu_item) + add_item(ci_cd_menu_item) + add_item(operations_menu_item) + add_item(pages_menu_item) + add_item(packages_and_registries_menu_item) + + true + end + + override :link + def link + edit_project_path(context.project) + end + + override :title + def title + _('Settings') + end + + override :title_html_options + def title_html_options + { + id: 'js-onboarding-settings-link' + } + end + + override :sprite_icon + def sprite_icon + 'settings' + end + + private + + def general_menu_item + ::Sidebars::MenuItem.new( + title: _('General'), + link: edit_project_path(context.project), + active_routes: { path: 'projects#edit' }, + item_id: :general + ) + end + + def integrations_menu_item + ::Sidebars::MenuItem.new( + title: _('Integrations'), + link: project_settings_integrations_path(context.project), + active_routes: { path: %w[integrations#show services#edit] }, + item_id: :integrations + ) + end + + def webhooks_menu_item + ::Sidebars::MenuItem.new( + title: _('Webhooks'), + link: project_hooks_path(context.project), + active_routes: { path: %w[hooks#index hooks#edit hook_logs#show] }, + item_id: :webhooks + ) + end + + def access_tokens_menu_item + return unless can?(context.current_user, :read_resource_access_tokens, context.project) + + ::Sidebars::MenuItem.new( + title: _('Access Tokens'), + link: project_settings_access_tokens_path(context.project), + active_routes: { path: 'access_tokens#index' }, + item_id: :access_tokens + ) + end + + def repository_menu_item + ::Sidebars::MenuItem.new( + title: _('Repository'), + link: project_settings_repository_path(context.project), + active_routes: { path: 'repository#show' }, + item_id: :repository + ) + end + + def ci_cd_menu_item + return if context.project.archived? + return unless context.project.feature_available?(:builds, context.current_user) + + ::Sidebars::MenuItem.new( + title: _('CI/CD'), + link: project_settings_ci_cd_path(context.project), + active_routes: { path: 'ci_cd#show' }, + item_id: :ci_cd + ) + end + + def operations_menu_item + return if context.project.archived? + return unless can?(context.current_user, :admin_operations, context.project) + + ::Sidebars::MenuItem.new( + title: _('Operations'), + link: project_settings_operations_path(context.project), + active_routes: { path: 'operations#show' }, + item_id: :operations + ) + end + + def pages_menu_item + return unless context.project.pages_available? + + ::Sidebars::MenuItem.new( + title: _('Pages'), + link: project_pages_path(context.project), + active_routes: { path: 'pages#show' }, + item_id: :pages + ) + end + + def packages_and_registries_menu_item + return unless Gitlab.config.registry.enabled + return if Feature.disabled?(:sidebar_refactor, context.current_user) + return unless can?(context.current_user, :destroy_container_image, context.project) + + ::Sidebars::MenuItem.new( + title: _('Packages & Registries'), + link: project_settings_packages_and_registries_path(context.project), + active_routes: { path: 'packages_and_registries#index' }, + item_id: :packages_and_registries + ) + end + end + end + end +end diff --git a/lib/sidebars/projects/panel.rb b/lib/sidebars/projects/panel.rb index bc37eb262b8..3be2a2b2b71 100644 --- a/lib/sidebars/projects/panel.rb +++ b/lib/sidebars/projects/panel.rb @@ -24,6 +24,7 @@ module Sidebars add_menu(Sidebars::Projects::Menus::ExternalWikiMenu.new(context)) add_menu(Sidebars::Projects::Menus::SnippetsMenu.new(context)) add_menu(Sidebars::Projects::Menus::MembersMenu.new(context)) + add_menu(Sidebars::Projects::Menus::SettingsMenu.new(context)) end override :render_raw_menus_partial |