From a521e88fc065242b61becbe101ced908e7dadfbd Mon Sep 17 00:00:00 2001
From: Nicolas <nicolas@gitlab.com>
Date: Tue, 16 Jun 2015 00:32:14 +0200
Subject: [PATCH] Fix consistency issue in sidebars of Project and Group
 Settings.

Fixes #2277.
---
 app/controllers/groups_controller.rb          |  2 ++
 app/helpers/groups_helper.rb                  |  8 --------
 app/views/groups/edit.html.haml               |  1 -
 app/views/layouts/group.html.haml             |  2 +-
 app/views/layouts/group_settings.html.haml    |  4 ++++
 app/views/layouts/nav/_group.html.haml        | 20 ++-----------------
 .../layouts/nav/_group_settings.html.haml     | 20 +++++++++++++++++++
 app/views/layouts/nav/_project.html.haml      |  4 ++--
 .../layouts/nav/_project_settings.html.haml   |  8 ++++----
 features/steps/project/active_tab.rb          |  4 ++--
 10 files changed, 37 insertions(+), 36 deletions(-)
 create mode 100644 app/views/layouts/group_settings.html.haml
 create mode 100644 app/views/layouts/nav/_group_settings.html.haml

diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 2e381822e42..901c1cdddcb 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -121,6 +121,8 @@ class GroupsController < Groups::ApplicationController
   def determine_layout
     if [:new, :create].include?(action_name.to_sym)
       'application'
+    elsif [:edit, :update, :projects].include?(action_name.to_sym)
+      'group_settings'
     else
       'group'
     end
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index 3569ac2af63..b067cb54a43 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -19,14 +19,6 @@ module GroupsHelper
     end
   end
 
-  def group_settings_page?
-    if current_controller?('groups')
-      current_action?('edit') || current_action?('projects')
-    else
-      false
-    end
-  end
-
   def group_icon(group)
     if group.is_a?(String)
       group = Group.find_by(path: group)
diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml
index aa13ed85b53..2ff4b7e23ea 100644
--- a/app/views/groups/edit.html.haml
+++ b/app/views/groups/edit.html.haml
@@ -1,4 +1,3 @@
-- page_title "Settings"
 .panel.panel-default
   .panel-heading
     %strong= @group.name
diff --git a/app/views/layouts/group.html.haml b/app/views/layouts/group.html.haml
index 5edc03129d2..db7dbf9bfe3 100644
--- a/app/views/layouts/group.html.haml
+++ b/app/views/layouts/group.html.haml
@@ -1,5 +1,5 @@
 - page_title    @group.name
 - header_title  @group.name, group_path(@group)
-- sidebar       "group"
+- sidebar       "group" unless sidebar
 
 = render template: "layouts/application"
diff --git a/app/views/layouts/group_settings.html.haml b/app/views/layouts/group_settings.html.haml
new file mode 100644
index 00000000000..e303a561628
--- /dev/null
+++ b/app/views/layouts/group_settings.html.haml
@@ -0,0 +1,4 @@
+- page_title    "Settings"
+- sidebar       "group_settings"
+
+= render template: "layouts/group"
diff --git a/app/views/layouts/nav/_group.html.haml b/app/views/layouts/nav/_group.html.haml
index 9f1654b25b4..9d216be151a 100644
--- a/app/views/layouts/nav/_group.html.haml
+++ b/app/views/layouts/nav/_group.html.haml
@@ -29,25 +29,9 @@
       = icon('users fw')
       %span
         Members
-
   - if can?(current_user, :admin_group, @group)
-    = nav_link(html_options: { class: "#{"active" if group_settings_page?} separate-item" }) do
-      = link_to edit_group_path(@group), title: 'Settings', class: 'tab no-highlight', data: {placement: 'right'} do
+    = nav_link(html_options: { class: "separate-item" }) do
+      = link_to edit_group_path(@group), title: 'Settings', data: {placement: 'right'} do
         = icon ('cogs fw')
         %span
           Settings
-          = icon ('angle-down fw')
-
-  - if group_settings_page?
-    %ul.sidebar-subnav
-      = nav_link(path: 'groups#edit') do
-        = link_to edit_group_path(@group), title: 'Group', data: {placement: 'right'} do
-          = icon('pencil-square-o')
-          %span
-            Group Settings
-      = nav_link(path: 'groups#projects') do
-        = link_to projects_group_path(@group), title: 'Projects', data: {placement: 'right'} do
-          = icon('folder')
-          %span
-            Projects
-
diff --git a/app/views/layouts/nav/_group_settings.html.haml b/app/views/layouts/nav/_group_settings.html.haml
new file mode 100644
index 00000000000..72ada771ca4
--- /dev/null
+++ b/app/views/layouts/nav/_group_settings.html.haml
@@ -0,0 +1,20 @@
+%ul.nav.nav-sidebar
+  = nav_link do
+    = link_to group_path(@group), title: 'Back to group', data: {placement: 'right'} do
+      = icon('caret-square-o-left fw')
+      %span
+        Back to group
+
+  %li.separate-item
+
+  %ul.sidebar-subnav
+    = nav_link(path: 'groups#edit') do
+      = link_to edit_group_path(@group), title: 'Group Settings', data: {placement: 'right'} do
+        = icon ('pencil-square-o fw')
+        %span
+          Group Settings
+    = nav_link(path: 'groups#projects') do
+      = link_to projects_group_path(@group), title: 'Projects', data: {placement: 'right'} do
+        = icon('folder fw')
+        %span
+          Projects
diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml
index cbcf560d0af..6de97302dc1 100644
--- a/app/views/layouts/nav/_project.html.haml
+++ b/app/views/layouts/nav/_project.html.haml
@@ -1,4 +1,4 @@
-%ul.project-navigation.nav.nav-sidebar
+%ul.nav.nav-sidebar
   = nav_link(path: 'projects#show', html_options: {class: 'home'}) do
     = link_to project_path(@project), title: 'Project', class: 'shortcuts-project', data: {placement: 'right'} do
       = icon('dashboard fw')
@@ -86,7 +86,7 @@
 
   - if project_nav_tab? :settings
     = nav_link(html_options: {class: "#{project_tab_class} separate-item"}) do
-      = link_to edit_project_path(@project), title: 'Settings', class: 'stat-tab tab no-highlight', data: {placement: 'right'} do
+      = link_to edit_project_path(@project), title: 'Settings', data: {placement: 'right'} do
         = icon('cogs fw')
         %span
           Settings
diff --git a/app/views/layouts/nav/_project_settings.html.haml b/app/views/layouts/nav/_project_settings.html.haml
index 633c6ae6bfb..9c86d3c09b2 100644
--- a/app/views/layouts/nav/_project_settings.html.haml
+++ b/app/views/layouts/nav/_project_settings.html.haml
@@ -1,4 +1,4 @@
-%ul.project-navigation.nav.nav-sidebar
+%ul.nav.nav-sidebar
   = nav_link do
     = link_to project_path(@project), title: 'Back to project', data: {placement: 'right'} do
       = icon('caret-square-o-left fw')
@@ -7,9 +7,9 @@
 
   %li.separate-item
 
-  %ul.project-settings-nav.sidebar-subnav
+  %ul.sidebar-subnav
     = nav_link(path: 'projects#edit') do
-      = link_to edit_project_path(@project), title: 'Project', class: 'stat-tab tab', data: {placement: 'right'} do
+      = link_to edit_project_path(@project), title: 'Project Settings', data: {placement: 'right'} do
         = icon('pencil-square-o fw')
         %span
           Project Settings
@@ -32,5 +32,5 @@
       = link_to namespace_project_protected_branches_path(@project.namespace, @project), title: 'Protected Branches', data: {placement: 'right'} do
         = icon('lock fw')
         %span
-          Protected branches
+          Protected Branches
 
diff --git a/features/steps/project/active_tab.rb b/features/steps/project/active_tab.rb
index fabbc1d3d81..9e96fa5ba49 100644
--- a/features/steps/project/active_tab.rb
+++ b/features/steps/project/active_tab.rb
@@ -20,8 +20,8 @@ class Spinach::Features::ProjectActiveTab < Spinach::FeatureSteps
   end
 
   step 'I click the "Edit" tab' do
-    page.within '.project-settings-nav' do
-      click_link('Project')
+    page.within '.sidebar-subnav' do
+      click_link('Project Settings')
     end
   end
 
-- 
GitLab