diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /lib/sidebars/projects | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'lib/sidebars/projects')
-rw-r--r-- | lib/sidebars/projects/menus/analytics_menu.rb | 6 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/deployments_menu.rb | 2 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/hidden_menu.rb | 8 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/infrastructure_menu.rb | 6 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/monitor_menu.rb | 6 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/repository_menu.rb | 32 |
6 files changed, 38 insertions, 22 deletions
diff --git a/lib/sidebars/projects/menus/analytics_menu.rb b/lib/sidebars/projects/menus/analytics_menu.rb index b9bcc3267d6..643b7ebcd5a 100644 --- a/lib/sidebars/projects/menus/analytics_menu.rb +++ b/lib/sidebars/projects/menus/analytics_menu.rb @@ -45,9 +45,9 @@ module Sidebars def ci_cd_analytics_menu_item if !context.project.feature_available?(:builds, context.current_user) || - !can?(context.current_user, :read_build, context.project) || - !can?(context.current_user, :read_ci_cd_analytics, context.project) || - context.project.empty_repo? + !can?(context.current_user, :read_build, context.project) || + !can?(context.current_user, :read_ci_cd_analytics, context.project) || + context.project.empty_repo? return ::Sidebars::NilMenuItem.new(item_id: :ci_cd_analytics) end diff --git a/lib/sidebars/projects/menus/deployments_menu.rb b/lib/sidebars/projects/menus/deployments_menu.rb index 9904d533f47..5f789748288 100644 --- a/lib/sidebars/projects/menus/deployments_menu.rb +++ b/lib/sidebars/projects/menus/deployments_menu.rb @@ -62,7 +62,7 @@ module Sidebars def releases_menu_item if !can?(context.current_user, :read_release, context.project) || - context.project.empty_repo? + context.project.empty_repo? return ::Sidebars::NilMenuItem.new(item_id: :releases) end diff --git a/lib/sidebars/projects/menus/hidden_menu.rb b/lib/sidebars/projects/menus/hidden_menu.rb index c273ee8b74f..5db46a1279c 100644 --- a/lib/sidebars/projects/menus/hidden_menu.rb +++ b/lib/sidebars/projects/menus/hidden_menu.rb @@ -29,8 +29,8 @@ module Sidebars end def graph_menu_item - if !can?(context.current_user, :download_code, context.project) || - context.project.empty_repo? + if !can?(context.current_user, :read_code, context.project) || + context.project.empty_repo? return ::Sidebars::NilMenuItem.new(item_id: :graph) end @@ -72,8 +72,8 @@ module Sidebars end def commits_menu_item - if !can?(context.current_user, :download_code, context.project) || - context.project.empty_repo? + if !can?(context.current_user, :read_code, context.project) || + context.project.empty_repo? return ::Sidebars::NilMenuItem.new(item_id: :commits) end diff --git a/lib/sidebars/projects/menus/infrastructure_menu.rb b/lib/sidebars/projects/menus/infrastructure_menu.rb index a8ac3d10f83..04c9ab77729 100644 --- a/lib/sidebars/projects/menus/infrastructure_menu.rb +++ b/lib/sidebars/projects/menus/infrastructure_menu.rb @@ -35,11 +35,7 @@ module Sidebars private def feature_enabled? - if ::Feature.enabled?(:split_operations_visibility_permissions, context.project) - context.project.feature_available?(:infrastructure, context.current_user) - else - context.project.feature_available?(:operations, context.current_user) - end + context.project.feature_available?(:infrastructure, context.current_user) end def kubernetes_menu_item diff --git a/lib/sidebars/projects/menus/monitor_menu.rb b/lib/sidebars/projects/menus/monitor_menu.rb index 035634702db..fea71e4aefd 100644 --- a/lib/sidebars/projects/menus/monitor_menu.rb +++ b/lib/sidebars/projects/menus/monitor_menu.rb @@ -41,11 +41,7 @@ module Sidebars private def feature_enabled? - if ::Feature.enabled?(:split_operations_visibility_permissions, context.project) - context.project.feature_available?(:monitor, context.current_user) - else - context.project.feature_available?(:operations, context.current_user) - end + context.project.feature_available?(:monitor, context.current_user) end def metrics_dashboard_menu_item diff --git a/lib/sidebars/projects/menus/repository_menu.rb b/lib/sidebars/projects/menus/repository_menu.rb index 1b46323089c..735be5a5133 100644 --- a/lib/sidebars/projects/menus/repository_menu.rb +++ b/lib/sidebars/projects/menus/repository_menu.rb @@ -6,7 +6,7 @@ module Sidebars class RepositoryMenu < ::Sidebars::Menu override :configure_menu_items def configure_menu_items - return false unless can?(context.current_user, :download_code, context.project) + return false unless can?(context.current_user, :read_code, context.project) return false if context.project.empty_repo? add_item(files_menu_item) @@ -56,9 +56,15 @@ module Sidebars end def commits_menu_item + link = if Feature.enabled?(:use_ref_type_parameter, context.project) + project_commits_path(context.project, context.current_ref, ref_type: ref_type_from_context(context)) + else + project_commits_path(context.project, context.current_ref) + end + ::Sidebars::MenuItem.new( title: _('Commits'), - link: project_commits_path(context.project, context.current_ref), + link: link, active_routes: { controller: %w(commit commits) }, item_id: :commits, container_html_options: { id: 'js-onboarding-commits-link' } @@ -87,18 +93,30 @@ module Sidebars def contributors_menu_item return false unless context.project.analytics_enabled? + link = if Feature.enabled?(:use_ref_type_parameter, context.project) + project_graph_path(context.project, context.current_ref, ref_type: ref_type_from_context(context)) + else + project_graph_path(context.project, context.current_ref) + end + ::Sidebars::MenuItem.new( title: _('Contributors'), - link: project_graph_path(context.project, context.current_ref), + link: link, active_routes: { path: 'graphs#show' }, item_id: :contributors ) end def graphs_menu_item + link = if Feature.enabled?(:use_ref_type_parameter, context.project) + project_network_path(context.project, context.current_ref, ref_type: ref_type_from_context(context)) + else + project_network_path(context.project, context.current_ref) + end + ::Sidebars::MenuItem.new( title: _('Graph'), - link: project_network_path(context.project, context.current_ref), + link: link, active_routes: { controller: :network }, item_id: :graphs ) @@ -112,6 +130,12 @@ module Sidebars item_id: :compare ) end + + def ref_type_from_context(context) + ref_type = context.try(:ref_type) + ref_type ||= 'heads' if context.current_ref == context.project.repository.root_ref + ref_type + end end end end |