From a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 16 Jun 2021 18:25:58 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-0-stable-ee --- lib/sidebars/projects/menus/infrastructure_menu.rb | 2 +- lib/sidebars/projects/menus/issues_menu.rb | 2 +- lib/sidebars/projects/menus/labels_menu.rb | 2 +- lib/sidebars/projects/menus/learn_gitlab_menu.rb | 9 +++---- lib/sidebars/projects/menus/monitor_menu.rb | 6 ++--- .../projects/menus/packages_registries_menu.rb | 2 +- .../projects/menus/project_information_menu.rb | 29 +++++++++------------- lib/sidebars/projects/menus/scope_menu.rb | 26 +++++++++++++++++++ .../projects/menus/security_compliance_menu.rb | 22 ++++++++-------- lib/sidebars/projects/menus/settings_menu.rb | 2 +- 10 files changed, 60 insertions(+), 42 deletions(-) (limited to 'lib/sidebars/projects') diff --git a/lib/sidebars/projects/menus/infrastructure_menu.rb b/lib/sidebars/projects/menus/infrastructure_menu.rb index 75b6cae295f..8cf7abc613c 100644 --- a/lib/sidebars/projects/menus/infrastructure_menu.rb +++ b/lib/sidebars/projects/menus/infrastructure_menu.rb @@ -6,7 +6,7 @@ module Sidebars class InfrastructureMenu < ::Sidebars::Menu override :configure_menu_items def configure_menu_items - return false if Feature.disabled?(:sidebar_refactor, context.current_user) + return false if Feature.disabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) return false unless context.project.feature_available?(:operations, context.current_user) add_item(kubernetes_menu_item) diff --git a/lib/sidebars/projects/menus/issues_menu.rb b/lib/sidebars/projects/menus/issues_menu.rb index 9840f644179..79603803b8f 100644 --- a/lib/sidebars/projects/menus/issues_menu.rb +++ b/lib/sidebars/projects/menus/issues_menu.rb @@ -98,7 +98,7 @@ module Sidebars end def labels_menu_item - if Feature.enabled?(:sidebar_refactor, context.current_user) + if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) return ::Sidebars::NilMenuItem.new(item_id: :labels) end diff --git a/lib/sidebars/projects/menus/labels_menu.rb b/lib/sidebars/projects/menus/labels_menu.rb index 12cf0444994..7cb28ababdb 100644 --- a/lib/sidebars/projects/menus/labels_menu.rb +++ b/lib/sidebars/projects/menus/labels_menu.rb @@ -40,7 +40,7 @@ module Sidebars override :render? def render? - return false if Feature.enabled?(:sidebar_refactor, context.current_user) + return false if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) can?(context.current_user, :read_label, context.project) && !context.project.issues_enabled? end diff --git a/lib/sidebars/projects/menus/learn_gitlab_menu.rb b/lib/sidebars/projects/menus/learn_gitlab_menu.rb index e3fcd8f25d5..f29f4a6eed6 100644 --- a/lib/sidebars/projects/menus/learn_gitlab_menu.rb +++ b/lib/sidebars/projects/menus/learn_gitlab_menu.rb @@ -35,14 +35,13 @@ module Sidebars end end - override :extra_container_html_options - def nav_link_html_options + override :extra_nav_link_html_options + def extra_nav_link_html_options { class: 'home', data: { - track_action: 'click_menu', - track_property: context.learn_gitlab_experiment_tracking_category, - track_label: 'learn_gitlab' + track_label: 'learn_gitlab', + track_property: context.learn_gitlab_experiment_tracking_category } } end diff --git a/lib/sidebars/projects/menus/monitor_menu.rb b/lib/sidebars/projects/menus/monitor_menu.rb index 18c990d0e1f..8ebdacc7c7e 100644 --- a/lib/sidebars/projects/menus/monitor_menu.rb +++ b/lib/sidebars/projects/menus/monitor_menu.rb @@ -139,7 +139,7 @@ module Sidebars end def serverless_menu_item - if Feature.enabled?(:sidebar_refactor, context.current_user) || + if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) || !can?(context.current_user, :read_cluster, context.project) return ::Sidebars::NilMenuItem.new(item_id: :serverless) end @@ -153,7 +153,7 @@ module Sidebars end def terraform_menu_item - if Feature.enabled?(:sidebar_refactor, context.current_user) || + if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) || !can?(context.current_user, :read_terraform_state, context.project) return ::Sidebars::NilMenuItem.new(item_id: :terraform) end @@ -167,7 +167,7 @@ module Sidebars end def kubernetes_menu_item - if Feature.enabled?(:sidebar_refactor, context.current_user) || + if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) || !can?(context.current_user, :read_cluster, context.project) return ::Sidebars::NilMenuItem.new(item_id: :kubernetes) end diff --git a/lib/sidebars/projects/menus/packages_registries_menu.rb b/lib/sidebars/projects/menus/packages_registries_menu.rb index 7087916bb04..27e318d73c5 100644 --- a/lib/sidebars/projects/menus/packages_registries_menu.rb +++ b/lib/sidebars/projects/menus/packages_registries_menu.rb @@ -58,7 +58,7 @@ module Sidebars end def infrastructure_registry_menu_item - if Feature.disabled?(:infrastructure_registry_page, context.current_user) + if Feature.disabled?(:infrastructure_registry_page, context.current_user, default_enabled: :yaml) return ::Sidebars::NilMenuItem.new(item_id: :infrastructure_registry) end diff --git a/lib/sidebars/projects/menus/project_information_menu.rb b/lib/sidebars/projects/menus/project_information_menu.rb index cbb34714087..c148e7cf931 100644 --- a/lib/sidebars/projects/menus/project_information_menu.rb +++ b/lib/sidebars/projects/menus/project_information_menu.rb @@ -17,24 +17,26 @@ module Sidebars override :link def link - project_path(context.project) + renderable_items.first.link end override :extra_container_html_options def extra_container_html_options - { - class: 'shortcuts-project rspec-project-link' - } + if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) + { class: 'shortcuts-project-information' } + else + { class: 'shortcuts-project rspec-project-link' } + end end - override :nav_link_html_options - def nav_link_html_options + override :extra_nav_link_html_options + def extra_nav_link_html_options { class: 'home' } end override :title def title - if Feature.enabled?(:sidebar_refactor, context.current_user) + if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) _('Project information') else _('Project overview') @@ -43,24 +45,17 @@ module Sidebars override :sprite_icon def sprite_icon - if Feature.enabled?(:sidebar_refactor, context.current_user) + if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) 'project' else 'home' end end - override :active_routes - def active_routes - return {} if Feature.disabled?(:sidebar_refactor, context.current_user) - - { path: 'projects#show' } - end - private def details_menu_item - return if Feature.enabled?(:sidebar_refactor, context.current_user) + return if Feature.enabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) ::Sidebars::MenuItem.new( title: _('Details'), @@ -103,7 +98,7 @@ module Sidebars end def labels_menu_item - if Feature.disabled?(:sidebar_refactor, context.current_user) + if Feature.disabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) return ::Sidebars::NilMenuItem.new(item_id: :labels) end diff --git a/lib/sidebars/projects/menus/scope_menu.rb b/lib/sidebars/projects/menus/scope_menu.rb index 1d1cf11b271..1cd0218d4ac 100644 --- a/lib/sidebars/projects/menus/scope_menu.rb +++ b/lib/sidebars/projects/menus/scope_menu.rb @@ -13,6 +13,32 @@ module Sidebars def title context.project.name end + + override :active_routes + def active_routes + { path: 'projects#show' } + end + + override :extra_container_html_options + def extra_container_html_options + return {} if Feature.disabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) + + { + class: 'shortcuts-project rspec-project-link' + } + end + + override :extra_nav_link_html_options + def extra_nav_link_html_options + return {} if Feature.disabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) + + { class: 'context-header' } + end + + override :render? + def render? + true + end end end end diff --git a/lib/sidebars/projects/menus/security_compliance_menu.rb b/lib/sidebars/projects/menus/security_compliance_menu.rb index 6c9fb8312bd..5616b466560 100644 --- a/lib/sidebars/projects/menus/security_compliance_menu.rb +++ b/lib/sidebars/projects/menus/security_compliance_menu.rb @@ -17,7 +17,7 @@ module Sidebars override :link def link - project_security_configuration_path(context.project) + renderable_items.first&.link end override :title @@ -33,18 +33,16 @@ module Sidebars private def configuration_menu_item - strong_memoize(:configuration_menu_item) do - unless render_configuration_menu_item? - next ::Sidebars::NilMenuItem.new(item_id: :configuration) - end - - ::Sidebars::MenuItem.new( - title: _('Configuration'), - link: project_security_configuration_path(context.project), - active_routes: { path: configuration_menu_item_paths }, - item_id: :configuration - ) + unless render_configuration_menu_item? + return ::Sidebars::NilMenuItem.new(item_id: :configuration) end + + ::Sidebars::MenuItem.new( + title: _('Configuration'), + link: project_security_configuration_path(context.project), + active_routes: { path: configuration_menu_item_paths }, + item_id: :configuration + ) end def render_configuration_menu_item? diff --git a/lib/sidebars/projects/menus/settings_menu.rb b/lib/sidebars/projects/menus/settings_menu.rb index 4ea6f5e298a..c9d7e736b21 100644 --- a/lib/sidebars/projects/menus/settings_menu.rb +++ b/lib/sidebars/projects/menus/settings_menu.rb @@ -136,7 +136,7 @@ module Sidebars def packages_and_registries_menu_item if !Gitlab.config.registry.enabled || - Feature.disabled?(:sidebar_refactor, context.current_user) || + Feature.disabled?(:sidebar_refactor, context.current_user, default_enabled: :yaml) || !can?(context.current_user, :destroy_container_image, context.project) return ::Sidebars::NilMenuItem.new(item_id: :packages_and_registries) end -- cgit v1.2.1