Commit 36f68140 authored by Robert Speicher's avatar Robert Speicher

Replace various "active tab" checks with nav_link

Also remove now-unused tab_class helper
parent f064c840
......@@ -67,48 +67,6 @@ module TabHelper
end
end
def tab_class(tab_key)
active = case tab_key
# Project Area
when :wall; wall_tab?
when :wiki; controller.controller_name == "wikis"
when :network; current_page?(controller: "projects", action: "graph", id: @project)
when :merge_requests; controller.controller_name == "merge_requests"
# Dashboard Area
when :help; controller.controller_name == "help"
when :search; current_page?(search_path)
when :dash_issues; current_page?(dashboard_issues_path)
when :dash_mr; current_page?(dashboard_merge_requests_path)
when :root; current_page?(dashboard_path) || current_page?(root_path)
# Profile Area
when :profile; current_page?(controller: "profile", action: :show)
when :history; current_page?(controller: "profile", action: :history)
when :account; current_page?(controller: "profile", action: :account)
when :token; current_page?(controller: "profile", action: :token)
when :design; current_page?(controller: "profile", action: :design)
when :ssh_keys; controller.controller_name == "keys"
# Admin Area
when :admin_root; controller.controller_name == "dashboard"
when :admin_users; controller.controller_name == 'users'
when :admin_projects; controller.controller_name == "projects"
when :admin_hooks; controller.controller_name == 'hooks'
when :admin_resque; controller.controller_name == 'resque'
when :admin_logs; controller.controller_name == 'logs'
else
false
end
active ? "active" : nil
end
def wall_tab?
current_page?(controller: "projects", action: "wall", id: @project)
end
def project_tab_class
[:show, :files, :edit, :update].each do |action|
return "active" if current_page?(controller: "projects", action: action, id: @project)
......@@ -121,7 +79,7 @@ module TabHelper
def branches_tab_class
if current_page?(branches_project_repository_path(@project)) ||
controller.controller_name == "protected_branches" ||
current_controller?(:protected_branches) ||
current_page?(project_repository_path(@project))
'active'
end
......
%ul.nav.nav-tabs
%li
= render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]}
%li{class: "#{'active' if (controller.controller_name == "refs") }"}
= link_to project_tree_path(@project, @ref) do
Source
= nav_link(controller: :refs) do
= link_to 'Source', project_tree_path(@project, @ref)
%li.right
.input-prepend.project_clone_holder
%button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH
......
%ul.nav.nav-tabs
%li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'}
%li{class: "#{'active' if current_controller?(:commit, :commits)}"}
= link_to project_commits_path(@project, @project.root_ref) do
Commits
%li{class: "#{'active' if current_controller?(:compare)}"}
= link_to project_compare_index_path(@project) do
Compare
%li{class: "#{branches_tab_class}"}
= nav_link(controller: [:commit, :commits]) do
= link_to 'Commits', project_commits_path(@project, @project.root_ref)
= nav_link(controller: :compare) do
= link_to 'Compare', project_compare_index_path(@project)
= nav_link(html_options: {class: branches_tab_class}) do
= link_to project_repository_path(@project) do
Branches
%span.badge= @project.repo.branch_count
%li{class: "#{'active' if current_page?(tags_project_repository_path(@project)) }"}
= nav_link(controller: :repositories, action: :tags) do
= link_to tags_project_repository_path(@project) do
Tags
%span.badge= @project.repo.tag_count
......
%ul.nav.nav-tabs
%li{class: "#{'active' if current_page?(project_issues_path(@project))}"}
= link_to project_issues_path(@project), class: "tab" do
Browse Issues
%li{class: "#{'active' if current_page?(project_milestones_path(@project))}"}
= link_to project_milestones_path(@project), class: "tab" do
Milestones
%li{class: "#{'active' if current_page?(project_labels_path(@project))}"}
= link_to project_labels_path(@project), class: "tab" do
Labels
= nav_link(controller: :issues) do
= link_to 'Browse Issues', project_issues_path(@project), class: "tab"
= nav_link(controller: :milestones) do
= link_to 'Milestones', project_milestones_path(@project), class: "tab"
= nav_link(controller: :labels) do
= link_to 'Labels', project_labels_path(@project), class: "tab"
%li.right
%span.rss-icon
= link_to project_issues_path(@project, :atom, { private_token: current_user.private_token }) do
......
%ul.main_menu
%li.home{class: tab_class(:root)}
= nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do
= link_to "Home", root_path, title: "Home"
%li{class: tab_class(:dash_issues)}
= nav_link(path: 'dashboard#issues') do
= link_to dashboard_issues_path do
Issues
%span.count= current_user.assigned_issues.opened.count
%li{class: tab_class(:dash_mr)}
= nav_link(path: 'dashboard#merge_requests') do
= link_to dashboard_merge_requests_path do
Merge Requests
%span.count= current_user.cared_merge_requests.count
%li{class: tab_class(:search)}
= nav_link(path: 'search#show') do
= link_to "Search", search_path
%li{class: tab_class(:help)}
= nav_link(path: 'help#index') do
= link_to "Help", help_path
%ul.main_menu
%li.home{class: project_tab_class}
= nav_link(html_options: {class: "home #{project_tab_class}"}) do
= link_to @project.code, project_path(@project), title: "Project"
- if @project.repo_exists?
- if can? current_user, :download_code, @project
%li{class: current_controller?(:tree, :blob, :blame) ? 'active' : ''}
= nav_link(controller: %w(tree blob blame)) do
= link_to 'Files', project_tree_path(@project, @ref || @project.root_ref)
%li{class: current_controller?(:commit, :commits, :compare, :repositories, :protected_branches) ? 'active' : ''}
= nav_link(controller: %w(commit commits compare repositories protected_branches)) do
= link_to "Commits", project_commits_path(@project, @ref || @project.root_ref)
%li{class: tab_class(:network)}
= nav_link(path: 'projects#graph') do
= link_to "Network", graph_project_path(@project)
- if @project.issues_enabled
%li{class: current_controller?(:issues, :milestones, :labels) ? 'active' : ''}
= nav_link(controller: %w(issues milestones labels)) do
= link_to project_issues_filter_path(@project) do
Issues
%span.count.issue_counter= @project.issues.opened.count
- if @project.repo_exists?
- if @project.merge_requests_enabled
%li{class: tab_class(:merge_requests)}
= nav_link(controller: :merge_requests) do
= link_to project_merge_requests_path(@project) do
Merge Requests
%span.count.merge_counter= @project.merge_requests.opened.count
- if @project.wall_enabled
%li{class: tab_class(:wall)}
= link_to wall_project_path(@project) do
Wall
= nav_link(path: 'projects#wall') do
= link_to 'Wall', wall_project_path(@project)
- if @project.wiki_enabled
%li{class: tab_class(:wiki)}
= link_to project_wiki_path(@project, :index) do
Wiki
= nav_link(controller: :wikis) do
= link_to 'Wiki', project_wiki_path(@project, :index)
......@@ -6,17 +6,17 @@
= render "layouts/head_panel", title: "Admin area"
.container
%ul.main_menu
%li.home{class: tab_class(:admin_root)}
= nav_link(controller: :dashboard, html_options: {class: 'home'}) do
= link_to "Stats", admin_root_path
%li{class: tab_class(:admin_projects)}
= nav_link(controller: :projects) do
= link_to "Projects", admin_projects_path
%li{class: tab_class(:admin_users)}
= nav_link(controller: :users) do
= link_to "Users", admin_users_path
%li{class: tab_class(:admin_logs)}
= nav_link(controller: :logs) do
= link_to "Logs", admin_logs_path
%li{class: tab_class(:admin_hooks)}
= nav_link(controller: :hooks) do
= link_to "Hooks", admin_hooks_path
%li{class: tab_class(:admin_resque)}
= nav_link(controller: :resque) do
= link_to "Resque", admin_resque_path
.content= yield
......@@ -6,23 +6,17 @@
= render "layouts/head_panel", title: "Profile"
.container
%ul.main_menu
%li.home{class: tab_class(:profile)}
= nav_link(path: 'profile#show', html_options: {class: 'home'}) do
= link_to "Profile", profile_path
%li{class: tab_class(:account)}
= nav_link(path: 'profile#account') do
= link_to "Account", profile_account_path
%li{class: tab_class(:ssh_keys)}
= nav_link(controller: :keys) do
= link_to keys_path do
SSH Keys
%span.count= current_user.keys.count
%li{class: tab_class(:design)}
= nav_link(path: 'profile#design') do
= link_to "Design", profile_design_path
%li{class: tab_class(:history)}
= nav_link(path: 'profile#history') do
= link_to "History", profile_history_path
.content
= yield
.content= yield
%ul.nav.nav-tabs
%li{ class: "#{'active' if current_page?(project_path(@project)) }" }
= nav_link(path: 'projects#show') do
= link_to project_path(@project), class: "activities-tab tab" do
%i.icon-home
Show
%li{ class: " #{'active' if (controller.controller_name == "team_members") || current_page?(project_team_index_path(@project)) }" }
= nav_link(controller: :team_members) do
= link_to project_team_index_path(@project), class: "team-tab tab" do
%i.icon-user
Team
%li{ class: "#{'active' if current_page?(files_project_path(@project)) }" }
= link_to files_project_path(@project), class: "files-tab tab " do
Attachments
%li{ class: " #{'active' if (controller.controller_name == "snippets") }" }
= link_to project_snippets_path(@project), class: "snippets-tab tab" do
Snippets
= nav_link(path: 'projects#files') do
= link_to 'Attachments', files_project_path(@project), class: "files-tab tab"
= nav_link(controller: :snippets) do
= link_to 'Snippets', project_snippets_path(@project), class: "snippets-tab tab"
- if can? current_user, :admin_project, @project
%li.right{class: "#{'active' if controller.controller_name == "deploy_keys"}"}
= nav_link(controller: :deploy_keys, html_options: {class: 'right'}) do
= link_to project_deploy_keys_path(@project) do
%span
Deploy Keys
%li.right{class: "#{'active' if controller.controller_name == "hooks" }"}
= nav_link(controller: :hooks, html_options: {class: 'right'}) do
= link_to project_hooks_path(@project) do
%span
Hooks
%li.right{ class: "#{'active' if current_page?(edit_project_path(@project)) }" }
= nav_link(path: 'projects#edit', html_options: {class: 'right'}) do
= link_to edit_project_path(@project), class: "stat-tab tab " do
%i.icon-edit
Edit
= render "commits/head"
%ul.nav.nav-pills
%li{class: ("active" if current_page?(project_repository_path(@project)))}
= link_to project_repository_path(@project) do
Recent
%li{class: ("active" if current_page?(project_protected_branches_path(@project)))}
= link_to project_protected_branches_path(@project) do
Protected
%li{class: ("active" if current_page?(branches_project_repository_path(@project)))}
= link_to branches_project_repository_path(@project) do
All
= nav_link(path: 'repositories#show') do
= link_to 'Recent', project_repository_path(@project)
= nav_link(path: 'protected_branches#index') do
= link_to 'Protected', project_protected_branches_path(@project)
= nav_link(path: 'repositories#branches') do
= link_to 'All', branches_project_repository_path(@project)
%ul.nav.nav-tabs
%li
= render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: @path}
%li{class: "#{'active' if (controller.controller_name == "tree") }"}
= link_to project_tree_path(@project, @ref) do
Source
= nav_link(controller: :tree) do
= link_to 'Source', project_tree_path(@project, @ref)
%li.right
.input-prepend.project_clone_holder
%button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment