2015-04-26 12:48:37 +05:30
|
|
|
module NavHelper
|
2018-03-27 19:54:05 +05:30
|
|
|
def header_links
|
|
|
|
@header_links ||= get_header_links
|
|
|
|
end
|
|
|
|
|
|
|
|
def header_link?(link)
|
|
|
|
header_links.include?(link)
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
def page_with_sidebar_class
|
|
|
|
class_name = page_gutter_class
|
2018-03-17 18:26:18 +05:30
|
|
|
class_name << 'page-with-contextual-sidebar' if defined?(@left_sidebar) && @left_sidebar
|
|
|
|
class_name << 'page-with-icon-sidebar' if collapsed_sidebar? && @left_sidebar
|
2018-11-08 19:23:39 +05:30
|
|
|
class_name -= ['right-sidebar-expanded'] if defined?(@right_sidebar) && !@right_sidebar
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
class_name
|
|
|
|
end
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
def page_gutter_class
|
|
|
|
if current_path?('merge_requests#show') ||
|
2017-09-10 17:25:29 +05:30
|
|
|
current_path?('projects/merge_requests/conflicts#show') ||
|
2017-08-17 22:00:37 +05:30
|
|
|
current_path?('issues#show') ||
|
|
|
|
current_path?('milestones#show')
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
if cookies[:collapsed_gutter] == 'true'
|
2017-09-10 17:25:29 +05:30
|
|
|
%w[page-gutter right-sidebar-collapsed]
|
2016-04-02 18:10:28 +05:30
|
|
|
else
|
2017-09-10 17:25:29 +05:30
|
|
|
%w[page-gutter right-sidebar-expanded]
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
elsif current_path?('jobs#show')
|
|
|
|
%w[page-gutter build-sidebar right-sidebar-expanded]
|
2018-10-15 14:42:47 +05:30
|
|
|
elsif current_controller?('wikis') && current_action?('show', 'create', 'edit', 'update', 'history', 'git_access', 'destroy')
|
2017-09-10 17:25:29 +05:30
|
|
|
%w[page-gutter wiki-sidebar right-sidebar-expanded]
|
|
|
|
else
|
|
|
|
[]
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def nav_control_class
|
|
|
|
"nav-control" if current_user
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def user_dropdown_class
|
2017-09-10 17:25:29 +05:30
|
|
|
class_names = []
|
2018-03-17 18:26:18 +05:30
|
|
|
class_names << 'header-user-dropdown-toggle'
|
|
|
|
class_names << 'impersonated-user' if session[:impersonator_id]
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
class_names
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
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-04-26 12:48:37 +05:30
|
|
|
end
|