From e95f81d2271f0b82f63e16cd6c7e3d0734084e03 Mon Sep 17 00:00:00 2001
From: Phil Hughes <me@iamphill.com>
Date: Mon, 3 Jul 2017 10:45:40 +0100
Subject: [PATCH] Contextual breadcrumb title fixes

Also moves action buttons into the new breadcrumbs

Closes #34030, #34033
---
 app/assets/stylesheets/new_nav.scss               |  2 +-
 app/views/groups/show.html.haml                   |  1 +
 app/views/layouts/nav/_new_dashboard.html.haml    |  2 +-
 app/views/projects/labels/index.html.haml         | 10 +++++++---
 app/views/projects/milestones/index.html.haml     |  8 ++++++--
 .../projects/pipeline_schedules/index.html.haml   | 10 +++++++---
 app/views/projects/show.html.haml                 |  1 +
 app/views/projects/snippets/index.html.haml       | 15 ++++++---------
 app/views/projects/tree/show.html.haml            |  1 +
 9 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/app/assets/stylesheets/new_nav.scss b/app/assets/stylesheets/new_nav.scss
index bfb7a0c7e25..c7ef5a5ae1f 100644
--- a/app/assets/stylesheets/new_nav.scss
+++ b/app/assets/stylesheets/new_nav.scss
@@ -323,7 +323,7 @@ header.navbar-gitlab-new {
     white-space: nowrap;
 
     > a {
-      &:last-of-type {
+      &:last-of-type:not(:first-child) {
         font-weight: 600;
       }
     }
diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml
index 80a8ba4a755..fcdd0a84990 100644
--- a/app/views/groups/show.html.haml
+++ b/app/views/groups/show.html.haml
@@ -1,4 +1,5 @@
 - @no_container = true
+- @breadcrumb_title = "Group"
 
 = content_for :meta_tags do
   = auto_discovery_link_tag(:atom, group_url(@group, rss_url_options), title: "#{@group.name} activity")
diff --git a/app/views/layouts/nav/_new_dashboard.html.haml b/app/views/layouts/nav/_new_dashboard.html.haml
index 7109baa4dad..cfdfcbebc9f 100644
--- a/app/views/layouts/nav/_new_dashboard.html.haml
+++ b/app/views/layouts/nav/_new_dashboard.html.haml
@@ -3,7 +3,7 @@
     = link_to dashboard_projects_path, title: 'Projects', class: 'dashboard-shortcuts-projects' do
       Projects
 
-  = nav_link(controller: [:groups, 'groups/milestones', 'groups/group_members']) do
+  = nav_link(controller: ['dashboard/groups', 'explore/groups']) do
     = link_to dashboard_groups_path, class: 'dashboard-shortcuts-groups', title: 'Groups' do
       Groups
 
diff --git a/app/views/projects/labels/index.html.haml b/app/views/projects/labels/index.html.haml
index fc72c4fb635..0a63325f26e 100644
--- a/app/views/projects/labels/index.html.haml
+++ b/app/views/projects/labels/index.html.haml
@@ -1,6 +1,11 @@
 - @no_container = true
 - page_title "Labels"
 - hide_class = ''
+
+- if show_new_nav? && can?(current_user, :admin_label, @project)
+  - content_for :breadcrumbs_extra do
+    = link_to "New label", new_namespace_project_label_path(@project.namespace, @project), class: "btn btn-new"
+
 = render "shared/mr_head"
 
 - if @labels.exists? || @prioritized_labels.exists?
@@ -9,10 +14,9 @@
       .nav-text
         Labels can be applied to issues and merge requests. Star a label to make it a priority label. Order the prioritized labels to change their relative priority, by dragging.
 
-      .nav-controls
+      .nav-controls{ class: ("visible-xs" if show_new_nav?) }
         - if can?(current_user, :admin_label, @project)
-          = link_to new_namespace_project_label_path(@project.namespace, @project), class: "btn btn-new" do
-            New label
+          = link_to "New label", new_namespace_project_label_path(@project.namespace, @project), class: "btn btn-new"
 
     .labels
       - if can?(current_user, :admin_label, @project)
diff --git a/app/views/projects/milestones/index.html.haml b/app/views/projects/milestones/index.html.haml
index e1096bd1d67..63522a11b9d 100644
--- a/app/views/projects/milestones/index.html.haml
+++ b/app/views/projects/milestones/index.html.haml
@@ -1,5 +1,10 @@
 - @no_container = true
 - page_title 'Milestones'
+
+- if show_new_nav?
+  - content_for :breadcrumbs_extra do
+    = link_to "New milestone", new_namespace_project_milestone_path(@project.namespace, @project), class: 'btn btn-new', title: 'New milestone'
+
 = render "shared/mr_head"
 
 %div{ class: container_class }
@@ -9,8 +14,7 @@
     .nav-controls
       = render 'shared/milestones_sort_dropdown'
       - if can?(current_user, :admin_milestone, @project)
-        = link_to new_namespace_project_milestone_path(@project.namespace, @project), class: 'btn btn-new', title: 'New milestone' do
-          New milestone
+        = link_to "New milestone", new_namespace_project_milestone_path(@project.namespace, @project), class: "btn btn-new #{("visible-xs hidden-sm hidden-md hidden-lg" if show_new_nav?)}", title: 'New milestone'
 
   .milestones
     %ul.content-list
diff --git a/app/views/projects/pipeline_schedules/index.html.haml b/app/views/projects/pipeline_schedules/index.html.haml
index c296152e54f..127f26899ea 100644
--- a/app/views/projects/pipeline_schedules/index.html.haml
+++ b/app/views/projects/pipeline_schedules/index.html.haml
@@ -4,6 +4,11 @@
 
 - @no_container = true
 - page_title _("Pipeline Schedules")
+
+- if show_new_nav?
+  - content_for :breadcrumbs_extra do
+    = link_to _('New schedule'), new_namespace_project_pipeline_schedule_path(@project.namespace, @project), class: 'btn btn-create'
+
 = render "projects/pipelines/head"
 
 %div{ class: container_class }
@@ -12,9 +17,8 @@
     - schedule_path_proc = ->(scope) { pipeline_schedules_path(@project, scope: scope) }
     = render "tabs", schedule_path_proc: schedule_path_proc, all_schedules: @all_schedules, scope: @scope
 
-    .nav-controls
-      = link_to new_namespace_project_pipeline_schedule_path(@project.namespace, @project), class: 'btn btn-create' do
-        %span= _('New schedule')
+    .nav-controls{ class: ("visible-xs" if show_new_nav?) }
+      = link_to _('New schedule'), new_namespace_project_pipeline_schedule_path(@project.namespace, @project), class: 'btn btn-create'
 
   - if @schedules.present?
     %ul.content-list
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index e1e70a53709..cbf28a61870 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -1,4 +1,5 @@
 - @no_container = true
+- @breadcrumb_title = "Project"
 
 = content_for :meta_tags do
   = auto_discovery_link_tag(:atom, namespace_project_path(@project.namespace, @project, rss_url_options), title: "#{@project.name} activity")
diff --git a/app/views/projects/snippets/index.html.haml b/app/views/projects/snippets/index.html.haml
index 84e05cd6d88..f6d8f5e8c4f 100644
--- a/app/views/projects/snippets/index.html.haml
+++ b/app/views/projects/snippets/index.html.haml
@@ -1,19 +1,16 @@
 - page_title "Snippets"
 
+- if show_new_nav? && can?(current_user, :create_project_snippet, @project)
+  - content_for :breadcrumbs_extra do
+    = link_to "New snippet", new_namespace_project_snippet_path(@project.namespace, @project), class: "btn btn-new", title: "New snippet"
+
 - if current_user
   .top-area
     - include_private = @project.team.member?(current_user) || current_user.admin?
     = render partial: 'snippets/snippets_scope_menu', locals: { subject: @project, include_private: include_private }
 
-    .nav-controls.hidden-xs
+    .nav-controls{ class: ("visible-xs" if show_new_nav?) }
       - if can?(current_user, :create_project_snippet, @project)
-        = link_to new_namespace_project_snippet_path(@project.namespace, @project), class: "btn btn-new", title: "New snippet" do
-          New snippet
-
-- if can?(current_user, :create_project_snippet, @project)
-  .visible-xs
-    &nbsp;
-    = link_to new_namespace_project_snippet_path(@project.namespace, @project), class: "btn btn-new btn-block", title: "New snippet" do
-      New snippet
+        = link_to "New snippet", new_namespace_project_snippet_path(@project.namespace, @project), class: "btn btn-new", title: "New snippet"
 
 = render 'snippets/snippets'
diff --git a/app/views/projects/tree/show.html.haml b/app/views/projects/tree/show.html.haml
index 96a08f9f8be..722e20763c8 100644
--- a/app/views/projects/tree/show.html.haml
+++ b/app/views/projects/tree/show.html.haml
@@ -1,4 +1,5 @@
 - @no_container = true
+- @breadcrumb_title = _("Files")
 
 - page_title @path.presence || _("Files"), @ref
 = content_for :meta_tags do
-- 
GitLab