2018-08-18 11:19:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-30 19:23:35 +00:00
|
|
|
module NavHelper
|
2017-12-11 14:21:06 +00:00
|
|
|
def header_links
|
|
|
|
@header_links ||= get_header_links
|
|
|
|
end
|
|
|
|
|
|
|
|
def header_link?(link)
|
|
|
|
header_links.include?(link)
|
|
|
|
end
|
|
|
|
|
2017-07-31 08:07:51 +00:00
|
|
|
def page_with_sidebar_class
|
|
|
|
class_name = page_gutter_class
|
2017-10-20 22:57:24 +00:00
|
|
|
class_name << 'page-with-contextual-sidebar' if defined?(@left_sidebar) && @left_sidebar
|
2017-09-06 10:58:24 +00:00
|
|
|
class_name << 'page-with-icon-sidebar' if collapsed_sidebar? && @left_sidebar
|
2018-05-29 07:28:49 +00:00
|
|
|
class_name -= ['right-sidebar-expanded'] if defined?(@right_sidebar) && !@right_sidebar
|
2017-07-31 08:07:51 +00:00
|
|
|
|
|
|
|
class_name
|
|
|
|
end
|
|
|
|
|
2016-01-27 22:38:19 +00:00
|
|
|
def page_gutter_class
|
2018-11-09 12:17:00 +00:00
|
|
|
if page_has_markdown?
|
2018-01-11 16:34:01 +00:00
|
|
|
|
2016-01-28 23:26:47 +00:00
|
|
|
if cookies[:collapsed_gutter] == 'true'
|
2017-07-31 08:07:51 +00:00
|
|
|
%w[page-gutter right-sidebar-collapsed]
|
2016-01-28 23:26:47 +00:00
|
|
|
else
|
2017-07-31 08:07:51 +00:00
|
|
|
%w[page-gutter right-sidebar-expanded]
|
2016-01-28 23:26:47 +00:00
|
|
|
end
|
2017-06-08 12:21:03 +00:00
|
|
|
elsif current_path?('jobs#show')
|
2017-07-31 08:07:51 +00:00
|
|
|
%w[page-gutter build-sidebar right-sidebar-expanded]
|
2018-04-18 17:50:56 +00:00
|
|
|
elsif current_controller?('wikis') && current_action?('show', 'create', 'edit', 'update', 'history', 'git_access', 'destroy')
|
2017-07-31 08:07:51 +00:00
|
|
|
%w[page-gutter wiki-sidebar right-sidebar-expanded]
|
|
|
|
else
|
|
|
|
[]
|
2016-01-27 22:38:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-16 19:58:15 +00:00
|
|
|
def nav_control_class
|
|
|
|
"nav-control" if current_user
|
|
|
|
end
|
2017-08-10 20:13:38 +00:00
|
|
|
|
|
|
|
def user_dropdown_class
|
|
|
|
class_names = []
|
|
|
|
class_names << 'header-user-dropdown-toggle'
|
|
|
|
class_names << 'impersonated-user' if session[:impersonator_id]
|
|
|
|
|
|
|
|
class_names
|
|
|
|
end
|
2017-12-11 14:21:06 +00:00
|
|
|
|
2018-11-26 11:38:34 +00:00
|
|
|
def has_extra_nav_icons?
|
|
|
|
Gitlab::Sherlock.enabled? || can?(current_user, :read_instance_statistics) || current_user.admin?
|
2018-11-09 12:17:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def page_has_markdown?
|
|
|
|
current_path?('merge_requests#show') ||
|
|
|
|
current_path?('projects/merge_requests/conflicts#show') ||
|
|
|
|
current_path?('issues#show') ||
|
|
|
|
current_path?('milestones#show')
|
|
|
|
end
|
|
|
|
|
2019-05-08 05:26:10 +00:00
|
|
|
def admin_monitoring_nav_links
|
|
|
|
%w(system_info background_jobs logs health_check requests_profiles)
|
|
|
|
end
|
|
|
|
|
|
|
|
def group_issues_sub_menu_items
|
|
|
|
%w(groups#issues labels#index milestones#index boards#index boards#show)
|
|
|
|
end
|
|
|
|
|
2017-12-11 14:21:06 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def get_header_links
|
|
|
|
links = if current_user
|
|
|
|
[:user_dropdown]
|
|
|
|
else
|
|
|
|
[:sign_in]
|
|
|
|
end
|
|
|
|
|
|
|
|
if can?(current_user, :read_cross_project)
|
|
|
|
links += [:issues, :merge_requests, :todos] if current_user.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
if @project&.persisted? || can?(current_user, :read_cross_project)
|
|
|
|
links << :search
|
|
|
|
end
|
|
|
|
|
|
|
|
if session[:impersonator_id]
|
|
|
|
links << :admin_impersonation
|
|
|
|
end
|
|
|
|
|
|
|
|
links
|
|
|
|
end
|
2015-01-30 19:23:35 +00:00
|
|
|
end
|