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 ...@@ -67,48 +67,6 @@ module TabHelper
end end
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 def project_tab_class
[:show, :files, :edit, :update].each do |action| [:show, :files, :edit, :update].each do |action|
return "active" if current_page?(controller: "projects", action: action, id: @project) return "active" if current_page?(controller: "projects", action: action, id: @project)
...@@ -121,7 +79,7 @@ module TabHelper ...@@ -121,7 +79,7 @@ module TabHelper
def branches_tab_class def branches_tab_class
if current_page?(branches_project_repository_path(@project)) || if current_page?(branches_project_repository_path(@project)) ||
controller.controller_name == "protected_branches" || current_controller?(:protected_branches) ||
current_page?(project_repository_path(@project)) current_page?(project_repository_path(@project))
'active' 'active'
end end
......
%ul.nav.nav-tabs %ul.nav.nav-tabs
%li %li
= render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]}
%li{class: "#{'active' if (controller.controller_name == "refs") }"} = nav_link(controller: :refs) do
= link_to project_tree_path(@project, @ref) do = link_to 'Source', project_tree_path(@project, @ref)
Source
%li.right %li.right
.input-prepend.project_clone_holder .input-prepend.project_clone_holder
%button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH %button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH
......
%ul.nav.nav-tabs %ul.nav.nav-tabs
%li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} %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 = nav_link(controller: [:commit, :commits]) do
Commits = link_to 'Commits', project_commits_path(@project, @project.root_ref)
%li{class: "#{'active' if current_controller?(:compare)}"} = nav_link(controller: :compare) do
= link_to project_compare_index_path(@project) do = link_to 'Compare', project_compare_index_path(@project)
Compare
%li{class: "#{branches_tab_class}"} = nav_link(html_options: {class: branches_tab_class}) do
= link_to project_repository_path(@project) do = link_to project_repository_path(@project) do
Branches Branches
%span.badge= @project.repo.branch_count %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 = link_to tags_project_repository_path(@project) do
Tags Tags
%span.badge= @project.repo.tag_count %span.badge= @project.repo.tag_count
......
%ul.nav.nav-tabs %ul.nav.nav-tabs
%li{class: "#{'active' if current_page?(project_issues_path(@project))}"} = nav_link(controller: :issues) do
= link_to project_issues_path(@project), class: "tab" do = link_to 'Browse Issues', project_issues_path(@project), class: "tab"
Browse Issues = nav_link(controller: :milestones) do
%li{class: "#{'active' if current_page?(project_milestones_path(@project))}"} = link_to 'Milestones', project_milestones_path(@project), class: "tab"
= link_to project_milestones_path(@project), class: "tab" do = nav_link(controller: :labels) do
Milestones = link_to 'Labels', project_labels_path(@project), class: "tab"
%li{class: "#{'active' if current_page?(project_labels_path(@project))}"}
= link_to project_labels_path(@project), class: "tab" do
Labels
%li.right %li.right
%span.rss-icon %span.rss-icon
= link_to project_issues_path(@project, :atom, { private_token: current_user.private_token }) do = link_to project_issues_path(@project, :atom, { private_token: current_user.private_token }) do
......
%ul.main_menu %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" = 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 = link_to dashboard_issues_path do
Issues Issues
%span.count= current_user.assigned_issues.opened.count %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 = link_to dashboard_merge_requests_path do
Merge Requests Merge Requests
%span.count= current_user.cared_merge_requests.count %span.count= current_user.cared_merge_requests.count
%li{class: tab_class(:search)} = nav_link(path: 'search#show') do
= link_to "Search", search_path = link_to "Search", search_path
%li{class: tab_class(:help)} = nav_link(path: 'help#index') do
= link_to "Help", help_path = link_to "Help", help_path
%ul.main_menu %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" = link_to @project.code, project_path(@project), title: "Project"
- if @project.repo_exists? - if @project.repo_exists?
- if can? current_user, :download_code, @project - 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) = 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) = 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) = link_to "Network", graph_project_path(@project)
- if @project.issues_enabled - 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 = link_to project_issues_filter_path(@project) do
Issues Issues
%span.count.issue_counter= @project.issues.opened.count %span.count.issue_counter= @project.issues.opened.count
- if @project.repo_exists? - if @project.repo_exists?
- if @project.merge_requests_enabled - 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 = link_to project_merge_requests_path(@project) do
Merge Requests Merge Requests
%span.count.merge_counter= @project.merge_requests.opened.count %span.count.merge_counter= @project.merge_requests.opened.count
- if @project.wall_enabled - if @project.wall_enabled
%li{class: tab_class(:wall)} = nav_link(path: 'projects#wall') do
= link_to wall_project_path(@project) do = link_to 'Wall', wall_project_path(@project)
Wall
- if @project.wiki_enabled - if @project.wiki_enabled
%li{class: tab_class(:wiki)} = nav_link(controller: :wikis) do
= link_to project_wiki_path(@project, :index) do = link_to 'Wiki', project_wiki_path(@project, :index)
Wiki
...@@ -6,17 +6,17 @@ ...@@ -6,17 +6,17 @@
= render "layouts/head_panel", title: "Admin area" = render "layouts/head_panel", title: "Admin area"
.container .container
%ul.main_menu %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 = link_to "Stats", admin_root_path
%li{class: tab_class(:admin_projects)} = nav_link(controller: :projects) do
= link_to "Projects", admin_projects_path = link_to "Projects", admin_projects_path
%li{class: tab_class(:admin_users)} = nav_link(controller: :users) do
= link_to "Users", admin_users_path = link_to "Users", admin_users_path
%li{class: tab_class(:admin_logs)} = nav_link(controller: :logs) do
= link_to "Logs", admin_logs_path = link_to "Logs", admin_logs_path
%li{class: tab_class(:admin_hooks)} = nav_link(controller: :hooks) do
= link_to "Hooks", admin_hooks_path = link_to "Hooks", admin_hooks_path
%li{class: tab_class(:admin_resque)} = nav_link(controller: :resque) do
= link_to "Resque", admin_resque_path = link_to "Resque", admin_resque_path
.content= yield .content= yield
...@@ -6,23 +6,17 @@ ...@@ -6,23 +6,17 @@
= render "layouts/head_panel", title: "Profile" = render "layouts/head_panel", title: "Profile"
.container .container
%ul.main_menu %ul.main_menu
%li.home{class: tab_class(:profile)} = nav_link(path: 'profile#show', html_options: {class: 'home'}) do
= link_to "Profile", profile_path = link_to "Profile", profile_path
= nav_link(path: 'profile#account') do
%li{class: tab_class(:account)}
= link_to "Account", profile_account_path = link_to "Account", profile_account_path
= nav_link(controller: :keys) do
%li{class: tab_class(:ssh_keys)}
= link_to keys_path do = link_to keys_path do
SSH Keys SSH Keys
%span.count= current_user.keys.count %span.count= current_user.keys.count
= nav_link(path: 'profile#design') do
%li{class: tab_class(:design)}
= link_to "Design", profile_design_path = link_to "Design", profile_design_path
= nav_link(path: 'profile#history') do
%li{class: tab_class(:history)}
= link_to "History", profile_history_path = link_to "History", profile_history_path
.content= yield
.content
= yield
%ul.nav.nav-tabs %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 = link_to project_path(@project), class: "activities-tab tab" do
%i.icon-home %i.icon-home
Show 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 = link_to project_team_index_path(@project), class: "team-tab tab" do
%i.icon-user %i.icon-user
Team Team
%li{ class: "#{'active' if current_page?(files_project_path(@project)) }" } = nav_link(path: 'projects#files') do
= link_to files_project_path(@project), class: "files-tab tab " do = link_to 'Attachments', files_project_path(@project), class: "files-tab tab"
Attachments = nav_link(controller: :snippets) do
%li{ class: " #{'active' if (controller.controller_name == "snippets") }" } = link_to 'Snippets', project_snippets_path(@project), class: "snippets-tab tab"
= link_to project_snippets_path(@project), class: "snippets-tab tab" do
Snippets
- if can? current_user, :admin_project, @project - 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 = link_to project_deploy_keys_path(@project) do
%span %span
Deploy Keys 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 = link_to project_hooks_path(@project) do
%span %span
Hooks 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 = link_to edit_project_path(@project), class: "stat-tab tab " do
%i.icon-edit %i.icon-edit
Edit Edit
= render "commits/head" = render "commits/head"
%ul.nav.nav-pills %ul.nav.nav-pills
%li{class: ("active" if current_page?(project_repository_path(@project)))} = nav_link(path: 'repositories#show') do
= link_to project_repository_path(@project) do = link_to 'Recent', project_repository_path(@project)
Recent = nav_link(path: 'protected_branches#index') do
%li{class: ("active" if current_page?(project_protected_branches_path(@project)))} = link_to 'Protected', project_protected_branches_path(@project)
= link_to project_protected_branches_path(@project) do = nav_link(path: 'repositories#branches') do
Protected = link_to 'All', branches_project_repository_path(@project)
%li{class: ("active" if current_page?(branches_project_repository_path(@project)))}
= link_to branches_project_repository_path(@project) do
All
%ul.nav.nav-tabs %ul.nav.nav-tabs
%li %li
= render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: @path} = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: @path}
%li{class: "#{'active' if (controller.controller_name == "tree") }"} = nav_link(controller: :tree) do
= link_to project_tree_path(@project, @ref) do = link_to 'Source', project_tree_path(@project, @ref)
Source
%li.right %li.right
.input-prepend.project_clone_holder .input-prepend.project_clone_holder
%button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH %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