diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 13:49:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 13:49:51 +0000 |
commit | 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch) | |
tree | 6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /lib/sidebars | |
parent | a7253423e3403b8c08f8a161e5937e1488f5f407 (diff) | |
download | gitlab-ce-a36f25615e8226344d87b692ccf3e543d5d81712.tar.gz |
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'lib/sidebars')
-rw-r--r-- | lib/sidebars/menu_item.rb | 9 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/learn_gitlab_menu.rb | 63 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/monitor_menu.rb | 15 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/repository_menu.rb | 18 | ||||
-rw-r--r-- | lib/sidebars/projects/panel.rb | 1 | ||||
-rw-r--r-- | lib/sidebars/your_work/menus/merge_requests_menu.rb | 42 |
6 files changed, 64 insertions, 84 deletions
diff --git a/lib/sidebars/menu_item.rb b/lib/sidebars/menu_item.rb index 7ed3e47ae34..efdedf6c3bd 100644 --- a/lib/sidebars/menu_item.rb +++ b/lib/sidebars/menu_item.rb @@ -4,9 +4,11 @@ module Sidebars class MenuItem include ::Sidebars::Concerns::LinkWithHtmlOptions - attr_reader :title, :link, :active_routes, :item_id, :container_html_options, :sprite_icon, :sprite_icon_html_options, :hint_html_options + attr_reader :title, :link, :active_routes, :item_id, :container_html_options, :sprite_icon, :sprite_icon_html_options, :hint_html_options, :has_pill, :pill_count + alias_method :has_pill?, :has_pill - def initialize(title:, link:, active_routes:, item_id: nil, container_html_options: {}, sprite_icon: nil, sprite_icon_html_options: {}, hint_html_options: {}) + # rubocop: disable Metrics/ParameterLists + def initialize(title:, link:, active_routes:, item_id: nil, container_html_options: {}, sprite_icon: nil, sprite_icon_html_options: {}, hint_html_options: {}, has_pill: false, pill_count: nil) @title = title @link = link @active_routes = active_routes @@ -15,7 +17,10 @@ module Sidebars @sprite_icon = sprite_icon @sprite_icon_html_options = sprite_icon_html_options @hint_html_options = hint_html_options + @has_pill = has_pill + @pill_count = pill_count end + # rubocop: enable Metrics/ParameterLists def show_hint? hint_html_options.present? diff --git a/lib/sidebars/projects/menus/learn_gitlab_menu.rb b/lib/sidebars/projects/menus/learn_gitlab_menu.rb deleted file mode 100644 index b6fae2af93d..00000000000 --- a/lib/sidebars/projects/menus/learn_gitlab_menu.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -module Sidebars - module Projects - module Menus - class LearnGitlabMenu < ::Sidebars::Menu - include Gitlab::Utils::StrongMemoize - - override :link - def link - project_learn_gitlab_path(context.project) - end - - override :active_routes - def active_routes - { controller: :learn_gitlab } - end - - override :title - def title - _('Learn GitLab') - end - - override :has_pill? - def has_pill? - context.learn_gitlab_enabled - end - - override :pill_count - def pill_count - strong_memoize(:pill_count) do - percentage = Onboarding::Completion.new( - context.project.namespace, - context.current_user - ).percentage - - "#{percentage}%" - end - end - - override :extra_nav_link_html_options - def extra_nav_link_html_options - { - class: 'home', - data: { - track_label: 'learn_gitlab' - } - } - end - - override :sprite_icon - def sprite_icon - 'bulb' - end - - override :render? - def render? - context.learn_gitlab_enabled - end - end - end - end -end diff --git a/lib/sidebars/projects/menus/monitor_menu.rb b/lib/sidebars/projects/menus/monitor_menu.rb index fea71e4aefd..7d1fa8b8fa7 100644 --- a/lib/sidebars/projects/menus/monitor_menu.rb +++ b/lib/sidebars/projects/menus/monitor_menu.rb @@ -12,6 +12,7 @@ module Sidebars add_item(error_tracking_menu_item) add_item(alert_management_menu_item) add_item(incidents_menu_item) + add_item(airflow_dashboard_menu_item) true end @@ -96,6 +97,20 @@ module Sidebars item_id: :incidents ) end + + def airflow_dashboard_menu_item + unless can?(context.current_user, :read_airflow_dags, context.project) && + Feature.enabled?(:airflow_dags, context.project) + return ::Sidebars::NilMenuItem.new(item_id: :airflow) + end + + ::Sidebars::MenuItem.new( + title: _('Airflow'), + link: project_airflow_dags_path(context.project), + active_routes: { path: 'airflow/dags#show' }, + item_id: :airflow_dags + ) + end end end end diff --git a/lib/sidebars/projects/menus/repository_menu.rb b/lib/sidebars/projects/menus/repository_menu.rb index 735be5a5133..ec91ae741fe 100644 --- a/lib/sidebars/projects/menus/repository_menu.rb +++ b/lib/sidebars/projects/menus/repository_menu.rb @@ -56,11 +56,7 @@ 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 + link = project_commits_path(context.project, context.current_ref, ref_type: ref_type_from_context(context)) ::Sidebars::MenuItem.new( title: _('Commits'), @@ -93,11 +89,7 @@ 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 + link = project_graph_path(context.project, context.current_ref, ref_type: ref_type_from_context(context)) ::Sidebars::MenuItem.new( title: _('Contributors'), @@ -108,11 +100,7 @@ module Sidebars 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 + link = project_network_path(context.project, context.current_ref, ref_type: ref_type_from_context(context)) ::Sidebars::MenuItem.new( title: _('Graph'), diff --git a/lib/sidebars/projects/panel.rb b/lib/sidebars/projects/panel.rb index 8ae8f931aab..9d0f5eb87bd 100644 --- a/lib/sidebars/projects/panel.rb +++ b/lib/sidebars/projects/panel.rb @@ -19,7 +19,6 @@ module Sidebars def add_menus add_menu(Sidebars::Projects::Menus::ProjectInformationMenu.new(context)) - add_menu(Sidebars::Projects::Menus::LearnGitlabMenu.new(context)) add_menu(Sidebars::Projects::Menus::RepositoryMenu.new(context)) add_menu(Sidebars::Projects::Menus::IssuesMenu.new(context)) add_menu(Sidebars::Projects::Menus::ExternalIssueTrackerMenu.new(context)) diff --git a/lib/sidebars/your_work/menus/merge_requests_menu.rb b/lib/sidebars/your_work/menus/merge_requests_menu.rb index 695c2ffdf46..09c84666258 100644 --- a/lib/sidebars/your_work/menus/merge_requests_menu.rb +++ b/lib/sidebars/your_work/menus/merge_requests_menu.rb @@ -4,7 +4,8 @@ module Sidebars module YourWork module Menus class MergeRequestsMenu < ::Sidebars::Menu - include Gitlab::Utils::StrongMemoize + include IssuablesHelper + include MergeRequestsHelper override :link def link @@ -21,6 +22,14 @@ module Sidebars 'merge-request' end + override :configure_menu_items + def configure_menu_items + add_item(assigned_mrs_menu_item) + add_item(reviewer_mrs_menu_item) + + true + end + override :render? def render? !!context.current_user @@ -38,9 +47,36 @@ module Sidebars override :pill_count def pill_count - context.current_user.assigned_open_merge_requests_count + user_merge_requests_counts[:total] + end + + private + + def assigned_mrs_menu_item + link = merge_requests_dashboard_path(assignee_username: context.current_user.username) + + ::Sidebars::MenuItem.new( + title: _('Assigned'), + link: link, + active_routes: { page: link }, + has_pill: true, + pill_count: user_merge_requests_counts[:assigned], + item_id: :merge_requests_assigned + ) + end + + def reviewer_mrs_menu_item + link = merge_requests_dashboard_path(reviewer_username: context.current_user.username) + + ::Sidebars::MenuItem.new( + title: _('Review requests'), + link: link, + active_routes: { page: link }, + has_pill: true, + pill_count: user_merge_requests_counts[:review_requested], + item_id: :merge_requests_to_review + ) end - strong_memoize_attr :pill_count end end end |