Commit 51c1e499006df02ff3dfc2a781457a01cc77550f

Authored by Robert Speicher
1 parent adcc6a0b

Change active tab and nav class to "active"

The main nav used active, the sub nav used current. This normalizes it.
app/assets/stylesheets/sections/nav.scss
@@ -53,7 +53,7 @@ ul.main_menu { @@ -53,7 +53,7 @@ ul.main_menu {
53 border-left: 0; 53 border-left: 0;
54 } 54 }
55 55
56 - &.current { 56 + &.active {
57 background-color:#D5D5D5; 57 background-color:#D5D5D5;
58 border-right: 1px solid #BBB; 58 border-right: 1px solid #BBB;
59 border-left: 1px solid #BBB; 59 border-left: 1px solid #BBB;
app/helpers/tab_helper.rb
@@ -5,7 +5,6 @@ module TabHelper @@ -5,7 +5,6 @@ module TabHelper
5 # Project Area 5 # Project Area
6 when :wall; wall_tab? 6 when :wall; wall_tab?
7 when :wiki; controller.controller_name == "wikis" 7 when :wiki; controller.controller_name == "wikis"
8 - when :issues; issues_tab?  
9 when :network; current_page?(controller: "projects", action: "graph", id: @project) 8 when :network; current_page?(controller: "projects", action: "graph", id: @project)
10 when :merge_requests; controller.controller_name == "merge_requests" 9 when :merge_requests; controller.controller_name == "merge_requests"
11 10
@@ -35,11 +34,7 @@ module TabHelper @@ -35,11 +34,7 @@ module TabHelper
35 else 34 else
36 false 35 false
37 end 36 end
38 - active ? "current" : nil  
39 - end  
40 -  
41 - def issues_tab?  
42 - controller.controller_name == "issues" || controller.controller_name == "milestones" 37 + active ? "active" : nil
43 end 38 end
44 39
45 def wall_tab? 40 def wall_tab?
@@ -48,21 +43,17 @@ module TabHelper @@ -48,21 +43,17 @@ module TabHelper
48 43
49 def project_tab_class 44 def project_tab_class
50 [:show, :files, :edit, :update].each do |action| 45 [:show, :files, :edit, :update].each do |action|
51 - return "current" if current_page?(controller: "projects", action: action, id: @project) 46 + return "active" if current_page?(controller: "projects", action: action, id: @project)
52 end 47 end
53 48
54 if ['snippets', 'hooks', 'deploy_keys', 'team_members'].include? controller.controller_name 49 if ['snippets', 'hooks', 'deploy_keys', 'team_members'].include? controller.controller_name
55 - "current" 50 + "active"
56 end 51 end
57 end 52 end
58 53
59 - def tree_tab_class  
60 - controller.controller_name == "refs" ? "current" : nil  
61 - end  
62 -  
63 def commit_tab_class 54 def commit_tab_class
64 if ['commits', 'repositories', 'protected_branches'].include? controller.controller_name 55 if ['commits', 'repositories', 'protected_branches'].include? controller.controller_name
65 - "current" 56 + "active"
66 end 57 end
67 end 58 end
68 59
app/views/layouts/_project_menu.html.haml
@@ -4,17 +4,15 @@ @@ -4,17 +4,15 @@
4 4
5 - if @project.repo_exists? 5 - if @project.repo_exists?
6 - if can? current_user, :download_code, @project 6 - if can? current_user, :download_code, @project
7 - %li{class: tree_tab_class}  
8 - = link_to project_tree_path(@project, @project.root_ref) do  
9 - Files 7 + %li{class: current_controller?(:tree, :blob, :blame) ? 'active' : ''}
  8 + = link_to 'Files', project_tree_path(@project, @project.root_ref)
10 %li{class: commit_tab_class} 9 %li{class: commit_tab_class}
11 = link_to "Commits", project_commits_path(@project, @project.root_ref) 10 = link_to "Commits", project_commits_path(@project, @project.root_ref)
12 -  
13 %li{class: tab_class(:network)} 11 %li{class: tab_class(:network)}
14 = link_to "Network", graph_project_path(@project) 12 = link_to "Network", graph_project_path(@project)
15 13
16 - if @project.issues_enabled 14 - if @project.issues_enabled
17 - %li{class: tab_class(:issues)} 15 + %li{class: current_controller?(:issues, :milestones, :labels) ? 'active' : ''}
18 = link_to project_issues_filter_path(@project) do 16 = link_to project_issues_filter_path(@project) do
19 Issues 17 Issues
20 %span.count.issue_counter= @project.issues.opened.count 18 %span.count.issue_counter= @project.issues.opened.count
features/steps/shared/active_tab.rb
@@ -2,10 +2,18 @@ module SharedActiveTab @@ -2,10 +2,18 @@ module SharedActiveTab
2 include Spinach::DSL 2 include Spinach::DSL
3 3
4 def ensure_active_main_tab(content) 4 def ensure_active_main_tab(content)
5 - page.find('ul.main_menu li.current').should have_content(content) 5 + page.find('ul.main_menu li.active').should have_content(content)
  6 + end
  7 +
  8 + def ensure_active_sub_tab(content)
  9 + page.find('div.content ul.nav-tabs li.active').should have_content(content)
6 end 10 end
7 11
8 And 'no other main tabs should be active' do 12 And 'no other main tabs should be active' do
9 - page.should have_selector('ul.main_menu li.current', count: 1) 13 + page.should have_selector('ul.main_menu li.active', count: 1)
  14 + end
  15 +
  16 + And 'no other sub tabs should be active' do
  17 + page.should have_selector('div.content ul.nav-tabs li.active', count: 1)
10 end 18 end
11 end 19 end