diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-06-13 22:58:27 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-06-13 22:58:27 +0300 |
commit | 74c8a635ce27336cd385d438291b22e921f88e1c (patch) | |
tree | 1397df200d706c371fb46cd95908d69d5a74177d /app/helpers | |
parent | 313ac55539ab93110d070e17811480092d55d8ce (diff) | |
download | gitlab-ce-74c8a635ce27336cd385d438291b22e921f88e1c.tar.gz |
Move project nav checks to helper
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/projects_helper.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 9b142714980..878b0913769 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -48,4 +48,36 @@ module ProjectsHelper def remove_project_message(project) "You are going to remove #{project.name_with_namespace}.\n Removed project CANNOT be restored!\n Are you ABSOLUTELY sure?" end + + def project_nav_tabs + @nav_tabs ||= get_project_nav_tabs(@project, current_user) + end + + def project_nav_tab?(name) + project_nav_tabs.include? name + end + + private + + def get_project_nav_tabs(project, current_user) + nav_tabs = [:home] + + if project.repo_exists? && can?(current_user, :download_code, project) + nav_tabs << [:files, :commits, :network, :graphs] + end + + if project.repo_exists? && project.merge_requests_enabled + nav_tabs << :merge_requests + end + + if can?(current_user, :admin_project, project) + nav_tabs << :settings + end + + [:issues, :wiki, :wall, :snippets].each do |feature| + nav_tabs << feature if project.send :"#{feature}_enabled" + end + + nav_tabs.flatten + end end |