From 51c1e499006df02ff3dfc2a781457a01cc77550f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 22:07:41 -0400 Subject: [PATCH] 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 | 2 +- app/helpers/tab_helper.rb | 17 ++++------------- app/views/layouts/_project_menu.html.haml | 8 +++----- features/steps/shared/active_tab.rb | 12 ++++++++++-- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/sections/nav.scss b/app/assets/stylesheets/sections/nav.scss index 2d902918..98bc7275 100644 --- a/app/assets/stylesheets/sections/nav.scss +++ b/app/assets/stylesheets/sections/nav.scss @@ -53,7 +53,7 @@ ul.main_menu { border-left: 0; } - &.current { + &.active { background-color:#D5D5D5; border-right: 1px solid #BBB; border-left: 1px solid #BBB; diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index 4cc97b11..9491e277 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -5,7 +5,6 @@ module TabHelper # Project Area when :wall; wall_tab? when :wiki; controller.controller_name == "wikis" - when :issues; issues_tab? when :network; current_page?(controller: "projects", action: "graph", id: @project) when :merge_requests; controller.controller_name == "merge_requests" @@ -35,11 +34,7 @@ module TabHelper else false end - active ? "current" : nil - end - - def issues_tab? - controller.controller_name == "issues" || controller.controller_name == "milestones" + active ? "active" : nil end def wall_tab? @@ -48,21 +43,17 @@ module TabHelper def project_tab_class [:show, :files, :edit, :update].each do |action| - return "current" if current_page?(controller: "projects", action: action, id: @project) + return "active" if current_page?(controller: "projects", action: action, id: @project) end if ['snippets', 'hooks', 'deploy_keys', 'team_members'].include? controller.controller_name - "current" + "active" end end - def tree_tab_class - controller.controller_name == "refs" ? "current" : nil - end - def commit_tab_class if ['commits', 'repositories', 'protected_branches'].include? controller.controller_name - "current" + "active" end end diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index 13a4d037..e2575646 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -4,17 +4,15 @@ - if @project.repo_exists? - if can? current_user, :download_code, @project - %li{class: tree_tab_class} - = link_to project_tree_path(@project, @project.root_ref) do - Files + %li{class: current_controller?(:tree, :blob, :blame) ? 'active' : ''} + = link_to 'Files', project_tree_path(@project, @project.root_ref) %li{class: commit_tab_class} = link_to "Commits", project_commits_path(@project, @project.root_ref) - %li{class: tab_class(:network)} = link_to "Network", graph_project_path(@project) - if @project.issues_enabled - %li{class: tab_class(:issues)} + %li{class: current_controller?(:issues, :milestones, :labels) ? 'active' : ''} = link_to project_issues_filter_path(@project) do Issues %span.count.issue_counter= @project.issues.opened.count diff --git a/features/steps/shared/active_tab.rb b/features/steps/shared/active_tab.rb index 33ac5cf5..884f2d5f 100644 --- a/features/steps/shared/active_tab.rb +++ b/features/steps/shared/active_tab.rb @@ -2,10 +2,18 @@ module SharedActiveTab include Spinach::DSL def ensure_active_main_tab(content) - page.find('ul.main_menu li.current').should have_content(content) + page.find('ul.main_menu li.active').should have_content(content) + end + + def ensure_active_sub_tab(content) + page.find('div.content ul.nav-tabs li.active').should have_content(content) end And 'no other main tabs should be active' do - page.should have_selector('ul.main_menu li.current', count: 1) + page.should have_selector('ul.main_menu li.active', count: 1) + end + + And 'no other sub tabs should be active' do + page.should have_selector('div.content ul.nav-tabs li.active', count: 1) end end