2021-06-08 01:23:25 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Sidebars
|
|
|
|
module Projects
|
|
|
|
module Menus
|
|
|
|
class ProjectInformationMenu < ::Sidebars::Menu
|
|
|
|
override :configure_menu_items
|
|
|
|
def configure_menu_items
|
|
|
|
add_item(activity_menu_item)
|
|
|
|
add_item(labels_menu_item)
|
|
|
|
add_item(members_menu_item)
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
override :extra_container_html_options
|
|
|
|
def extra_container_html_options
|
2021-09-30 23:02:18 +05:30
|
|
|
{ class: 'shortcuts-project-information' }
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
override :extra_nav_link_html_options
|
|
|
|
def extra_nav_link_html_options
|
2021-06-08 01:23:25 +05:30
|
|
|
{ class: 'home' }
|
|
|
|
end
|
|
|
|
|
|
|
|
override :title
|
|
|
|
def title
|
2021-09-30 23:02:18 +05:30
|
|
|
_('Project information')
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
override :sprite_icon
|
|
|
|
def sprite_icon
|
2021-09-30 23:02:18 +05:30
|
|
|
'project'
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def activity_menu_item
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Activity'),
|
|
|
|
link: activity_project_path(context.project),
|
|
|
|
active_routes: { path: 'projects#activity' },
|
|
|
|
item_id: :activity,
|
|
|
|
container_html_options: { class: 'shortcuts-project-activity' }
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def labels_menu_item
|
2021-09-30 23:02:18 +05:30
|
|
|
unless can?(context.current_user, :read_label, context.project)
|
2021-06-08 01:23:25 +05:30
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :labels)
|
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Labels'),
|
|
|
|
link: project_labels_path(context.project),
|
|
|
|
active_routes: { controller: :labels },
|
|
|
|
item_id: :labels
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def members_menu_item
|
2021-09-30 23:02:18 +05:30
|
|
|
unless can?(context.current_user, :read_project_member, context.project)
|
2021-06-08 01:23:25 +05:30
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :members)
|
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Members'),
|
|
|
|
link: project_project_members_path(context.project),
|
|
|
|
active_routes: { controller: :project_members },
|
|
|
|
item_id: :members,
|
|
|
|
container_html_options: {
|
|
|
|
id: 'js-onboarding-members-link'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|