diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index abd724b9212..c76c1b6f83d 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -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 diff --git a/app/views/blame/_head.html.haml b/app/views/blame/_head.html.haml index 2a6052a1122..3b027bdaf18 100644 --- a/app/views/blame/_head.html.haml +++ b/app/views/blame/_head.html.haml @@ -1,9 +1,8 @@ %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 diff --git a/app/views/commits/_head.html.haml b/app/views/commits/_head.html.haml index edaf8b8672c..26ae32ed144 100644 --- a/app/views/commits/_head.html.haml +++ b/app/views/commits/_head.html.haml @@ -1,17 +1,17 @@ %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 diff --git a/app/views/issues/_head.html.haml b/app/views/issues/_head.html.haml index 8ebe3e057bc..4294503c211 100644 --- a/app/views/issues/_head.html.haml +++ b/app/views/issues/_head.html.haml @@ -1,13 +1,10 @@ %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 diff --git a/app/views/layouts/_app_menu.html.haml b/app/views/layouts/_app_menu.html.haml index 025314891f8..8fac1b39172 100644 --- a/app/views/layouts/_app_menu.html.haml +++ b/app/views/layouts/_app_menu.html.haml @@ -1,19 +1,19 @@ %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 diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index d69f9a0b3e8..72c39619c91 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -1,35 +1,33 @@ %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) diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 6af0f641fc4..dbb6939dd61 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -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 diff --git a/app/views/layouts/profile.html.haml b/app/views/layouts/profile.html.haml index 62c8db5be12..7a54bb7cf2f 100644 --- a/app/views/layouts/profile.html.haml +++ b/app/views/layouts/profile.html.haml @@ -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 diff --git a/app/views/projects/_project_head.html.haml b/app/views/projects/_project_head.html.haml index 4f38bef8b48..47a790735f3 100644 --- a/app/views/projects/_project_head.html.haml +++ b/app/views/projects/_project_head.html.haml @@ -1,29 +1,27 @@ %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 diff --git a/app/views/repositories/_branches_head.html.haml b/app/views/repositories/_branches_head.html.haml index 6afff627b94..25a988cf01b 100644 --- a/app/views/repositories/_branches_head.html.haml +++ b/app/views/repositories/_branches_head.html.haml @@ -1,11 +1,8 @@ = 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) diff --git a/app/views/tree/_head.html.haml b/app/views/tree/_head.html.haml index c7ebbf8832d..f1b3f63fedf 100644 --- a/app/views/tree/_head.html.haml +++ b/app/views/tree/_head.html.haml @@ -1,9 +1,8 @@ %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