2018-08-18 11:19:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2012-11-21 05:24:05 +00:00
|
|
|
module DashboardHelper
|
2019-04-19 09:44:21 +00:00
|
|
|
include IconsHelper
|
|
|
|
|
2014-12-26 16:33:53 +00:00
|
|
|
def assigned_issues_dashboard_path
|
2018-10-27 17:24:30 +00:00
|
|
|
issues_dashboard_path(assignee_username: current_user.username)
|
2014-07-10 14:54:31 +00:00
|
|
|
end
|
|
|
|
|
2014-12-26 16:33:53 +00:00
|
|
|
def assigned_mrs_dashboard_path
|
2018-10-27 17:24:30 +00:00
|
|
|
merge_requests_dashboard_path(assignee_username: current_user.username)
|
2014-07-10 14:54:31 +00:00
|
|
|
end
|
2017-12-11 14:21:06 +00:00
|
|
|
|
|
|
|
def dashboard_nav_links
|
|
|
|
@dashboard_nav_links ||= get_dashboard_nav_links
|
|
|
|
end
|
|
|
|
|
|
|
|
def dashboard_nav_link?(link)
|
|
|
|
dashboard_nav_links.include?(link)
|
|
|
|
end
|
|
|
|
|
|
|
|
def any_dashboard_nav_link?(links)
|
|
|
|
links.any? { |link| dashboard_nav_link?(link) }
|
|
|
|
end
|
|
|
|
|
2019-05-11 04:16:19 +00:00
|
|
|
def has_start_trial?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2019-10-29 09:06:10 +00:00
|
|
|
def feature_entry(title, href: nil, enabled: true, doc_href: nil)
|
2019-04-19 09:44:21 +00:00
|
|
|
enabled_text = enabled ? 'on' : 'off'
|
|
|
|
label = "#{title}: status #{enabled_text}"
|
|
|
|
link_or_title = href && enabled ? tag.a(title, href: href) : title
|
|
|
|
|
|
|
|
tag.p(aria: { label: label }) do
|
|
|
|
concat(link_or_title)
|
2019-10-29 09:06:10 +00:00
|
|
|
|
2019-12-20 09:24:38 +00:00
|
|
|
concat(tag.span(class: %w[light float-right]) do
|
2019-10-29 09:06:10 +00:00
|
|
|
boolean_to_icon(enabled)
|
2019-04-19 09:44:21 +00:00
|
|
|
end)
|
2019-10-29 09:06:10 +00:00
|
|
|
|
|
|
|
if doc_href.present?
|
2020-08-10 18:09:54 +00:00
|
|
|
link_to_doc = link_to(sprite_icon('question'), doc_href,
|
2020-07-14 06:09:17 +00:00
|
|
|
class: 'gl-ml-2', title: _('Documentation'),
|
2019-10-29 09:06:10 +00:00
|
|
|
target: '_blank', rel: 'noopener noreferrer')
|
|
|
|
|
|
|
|
concat(link_to_doc)
|
|
|
|
end
|
2019-04-19 09:44:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-11 14:21:06 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def get_dashboard_nav_links
|
|
|
|
links = [:projects, :groups, :snippets]
|
|
|
|
|
|
|
|
if can?(current_user, :read_cross_project)
|
|
|
|
links += [:activity, :milestones]
|
|
|
|
end
|
|
|
|
|
|
|
|
links
|
|
|
|
end
|
2012-11-21 05:24:05 +00:00
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
|
|
|
DashboardHelper.prepend_if_ee('EE::DashboardHelper')
|