2021-06-08 01:23:25 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Sidebars
|
|
|
|
module Projects
|
|
|
|
module Menus
|
|
|
|
class MergeRequestsMenu < ::Sidebars::Menu
|
|
|
|
override :link
|
|
|
|
def link
|
|
|
|
project_merge_requests_path(context.project)
|
|
|
|
end
|
|
|
|
|
|
|
|
override :extra_container_html_options
|
|
|
|
def extra_container_html_options
|
|
|
|
{
|
|
|
|
class: 'shortcuts-merge_requests'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
override :title
|
|
|
|
def title
|
|
|
|
_('Merge requests')
|
|
|
|
end
|
|
|
|
|
|
|
|
override :title_html_options
|
|
|
|
def title_html_options
|
|
|
|
{
|
|
|
|
id: 'js-onboarding-mr-link'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
override :sprite_icon
|
|
|
|
def sprite_icon
|
|
|
|
'git-merge'
|
|
|
|
end
|
|
|
|
|
|
|
|
override :render?
|
|
|
|
def render?
|
|
|
|
can?(context.current_user, :read_merge_request, context.project) &&
|
|
|
|
context.project.repo_exists?
|
|
|
|
end
|
|
|
|
|
|
|
|
override :has_pill?
|
|
|
|
def has_pill?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
override :pill_count
|
|
|
|
def pill_count
|
2023-06-20 00:43:36 +05:30
|
|
|
count = @pill_count ||= context.project.open_merge_requests_count
|
|
|
|
format_cached_count(1000, count)
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
override :pill_html_options
|
|
|
|
def pill_html_options
|
|
|
|
{
|
|
|
|
class: 'merge_counter js-merge-counter'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
override :active_routes
|
|
|
|
def active_routes
|
|
|
|
if context.project.issues_enabled?
|
2023-07-09 08:55:56 +05:30
|
|
|
{ controller: ['projects/merge_requests', :conflicts] }
|
2021-06-08 01:23:25 +05:30
|
|
|
else
|
2023-07-09 08:55:56 +05:30
|
|
|
{ controller: ['projects/merge_requests', :milestones, :conflicts] }
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
end
|
2023-05-27 22:25:52 +05:30
|
|
|
|
|
|
|
override :serialize_as_menu_item_args
|
|
|
|
def serialize_as_menu_item_args
|
|
|
|
super.merge({
|
|
|
|
pill_count: pill_count,
|
|
|
|
has_pill: has_pill?,
|
2023-07-09 08:55:56 +05:30
|
|
|
super_sidebar_parent: ::Sidebars::Projects::SuperSidebarMenus::CodeMenu,
|
2023-05-27 22:25:52 +05:30
|
|
|
item_id: :project_merge_request_list
|
|
|
|
})
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|