debian-mirror-gitlab/lib/sidebars/projects/menus/issues_menu.rb

137 lines
3.7 KiB
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
module Sidebars
module Projects
module Menus
class IssuesMenu < ::Sidebars::Menu
include Gitlab::Utils::StrongMemoize
override :configure_menu_items
def configure_menu_items
2022-03-02 08:16:31 +05:30
return false unless show_issues_menu_items?
2021-06-08 01:23:25 +05:30
add_item(list_menu_item)
add_item(boards_menu_item)
add_item(service_desk_menu_item)
add_item(milestones_menu_item)
true
end
override :extra_container_html_options
def extra_container_html_options
{
class: 'shortcuts-issues'
}
end
override :title
def title
_('Issues')
end
override :title_html_options
def title_html_options
{
id: 'js-onboarding-issues-link'
}
end
override :sprite_icon
def sprite_icon
'issues'
end
override :active_routes
def active_routes
{ controller: 'projects/issues' }
end
override :has_pill?
def has_pill?
strong_memoize(:has_pill) do
context.project.issues_enabled?
end
end
override :pill_count
def pill_count
strong_memoize(:pill_count) do
context.project.open_issues_count(context.current_user)
end
end
override :pill_html_options
def pill_html_options
{
class: 'issue_counter'
}
end
2023-05-27 22:25:52 +05:30
override :serialize_as_menu_item_args
def serialize_as_menu_item_args
super.merge({
sprite_icon: sprite_icon,
pill_count: pill_count,
has_pill: has_pill?,
super_sidebar_parent: ::Sidebars::StaticMenu,
item_id: :project_issue_list
})
end
2021-06-08 01:23:25 +05:30
private
2022-03-02 08:16:31 +05:30
def show_issues_menu_items?
can?(context.current_user, :read_issue, context.project)
end
2021-06-08 01:23:25 +05:30
def list_menu_item
::Sidebars::MenuItem.new(
title: _('List'),
link: project_issues_path(context.project),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: ::Sidebars::NilMenuItem,
2021-06-08 01:23:25 +05:30
active_routes: { path: 'projects/issues#index' },
container_html_options: { aria: { label: _('Issues') } },
item_id: :issue_list
)
end
def boards_menu_item
title = context.project.multiple_issue_boards_available? ? s_('IssueBoards|Boards') : s_('IssueBoards|Board')
::Sidebars::MenuItem.new(
title: title,
link: project_boards_path(context.project),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: ::Sidebars::Projects::SuperSidebarMenus::PlanMenu,
2021-06-08 01:23:25 +05:30
active_routes: { controller: :boards },
item_id: :boards
)
end
def service_desk_menu_item
::Sidebars::MenuItem.new(
title: _('Service Desk'),
link: service_desk_project_issues_path(context.project),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: ::Sidebars::Projects::SuperSidebarMenus::PlanMenu,
2021-06-08 01:23:25 +05:30
active_routes: { path: 'issues#service_desk' },
item_id: :service_desk
)
end
def milestones_menu_item
::Sidebars::MenuItem.new(
title: _('Milestones'),
link: project_milestones_path(context.project),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: ::Sidebars::Projects::SuperSidebarMenus::PlanMenu,
super_sidebar_before: :service_desk,
2021-06-08 01:23:25 +05:30
active_routes: { controller: :milestones },
item_id: :milestones
)
end
end
end
end
end
Sidebars::Projects::Menus::IssuesMenu.prepend_mod_with('Sidebars::Projects::Menus::IssuesMenu')