From 13cc761a09a88138294300cdcc26a6db28f3d67d Mon Sep 17 00:00:00 2001 From: Phil Hughes <me@iamphill.com> Date: Wed, 12 Jul 2017 09:16:32 +0100 Subject: [PATCH] moved `@breadcrumb_title` out of the HAML & into a helper method --- app/helpers/breadcrumbs_helper.rb | 6 ++++++ app/helpers/page_layout_helper.rb | 2 +- app/views/admin/applications/edit.html.haml | 2 +- app/views/admin/applications/new.html.haml | 2 +- app/views/admin/broadcast_messages/edit.html.haml | 2 +- app/views/admin/broadcast_messages/index.html.haml | 2 +- app/views/admin/services/edit.html.haml | 2 +- app/views/groups/new.html.haml | 1 + app/views/groups/show.html.haml | 2 +- app/views/layouts/nav/_breadcrumbs.html.haml | 3 +-- app/views/profiles/show.html.haml | 2 +- app/views/projects/blob/edit.html.haml | 2 +- app/views/projects/blob/new.html.haml | 2 +- app/views/projects/blob/show.html.haml | 2 +- app/views/projects/issues/new.html.haml | 1 + app/views/projects/merge_requests/creations/new.html.haml | 2 +- app/views/projects/new.html.haml | 1 + app/views/projects/pipeline_schedules/index.html.haml | 2 +- app/views/projects/pipeline_schedules/new.html.haml | 2 +- app/views/projects/services/edit.html.haml | 2 +- app/views/projects/show.html.haml | 2 +- app/views/projects/tree/show.html.haml | 2 +- app/views/projects/wikis/show.html.haml | 2 +- app/views/snippets/new.html.haml | 1 + 24 files changed, 29 insertions(+), 20 deletions(-) diff --git a/app/helpers/breadcrumbs_helper.rb b/app/helpers/breadcrumbs_helper.rb index 6eb1060ed4..abe8edd6a8 100644 --- a/app/helpers/breadcrumbs_helper.rb +++ b/app/helpers/breadcrumbs_helper.rb @@ -16,4 +16,10 @@ module BreadcrumbsHelper request.path end end + + def breadcrumb_title(title) + return if defined?(@breadcrumb_title) + + @breadcrumb_title = title + end end diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb index c9f5166d0a..73b2ec66ee 100644 --- a/app/helpers/page_layout_helper.rb +++ b/app/helpers/page_layout_helper.rb @@ -5,7 +5,7 @@ module PageLayoutHelper @page_title.push(*titles.compact) if titles.any? if show_new_nav? && titles.any? && !defined?(@breadcrumb_title) - @breadcrumb_title = @page_title.first + @breadcrumb_title = @page_title[-1] end # Segments are seperated by middot diff --git a/app/views/admin/applications/edit.html.haml b/app/views/admin/applications/edit.html.haml index c9ad44be1e..1d28d1c6c5 100644 --- a/app/views/admin/applications/edit.html.haml +++ b/app/views/admin/applications/edit.html.haml @@ -1,5 +1,5 @@ - page_title "Edit", @application.name, "Applications" -- @breadcrumb_title = "Applications" +- breadcrumb_title "Applications" %h3.page-title Edit application - @url = admin_application_path(@application) diff --git a/app/views/admin/applications/new.html.haml b/app/views/admin/applications/new.html.haml index a5d89ed985..af0cc63967 100644 --- a/app/views/admin/applications/new.html.haml +++ b/app/views/admin/applications/new.html.haml @@ -1,5 +1,5 @@ - page_title "New Application" -- @breadcrumb_title = "Applications" +- breadcrumb_title "Applications" %h3.page-title New application - @url = admin_applications_path diff --git a/app/views/admin/broadcast_messages/edit.html.haml b/app/views/admin/broadcast_messages/edit.html.haml index d0e4d4435d..8cbc4597e3 100644 --- a/app/views/admin/broadcast_messages/edit.html.haml +++ b/app/views/admin/broadcast_messages/edit.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Messages" +- breadcrumb_title "Messages" - page_title "Broadcast Messages" = render 'form' diff --git a/app/views/admin/broadcast_messages/index.html.haml b/app/views/admin/broadcast_messages/index.html.haml index 2e4390c361..b806882eee 100644 --- a/app/views/admin/broadcast_messages/index.html.haml +++ b/app/views/admin/broadcast_messages/index.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Messages" +- breadcrumb_title "Messages" - page_title "Broadcast Messages" %h3.page-title diff --git a/app/views/admin/services/edit.html.haml b/app/views/admin/services/edit.html.haml index 0a641c3f7a..30a759f991 100644 --- a/app/views/admin/services/edit.html.haml +++ b/app/views/admin/services/edit.html.haml @@ -1,3 +1,3 @@ -- @breadcrumb_title = "Service Templates" +- breadcrumb_title "Service Templates" - page_title @service.title, "Service Templates" = render 'form' diff --git a/app/views/groups/new.html.haml b/app/views/groups/new.html.haml index 10eb8ce6cc..e9daac95ca 100644 --- a/app/views/groups/new.html.haml +++ b/app/views/groups/new.html.haml @@ -1,4 +1,5 @@ - @breadcrumb_link = dashboard_groups_path +- breadcrumb_title "Groups" - @hide_top_links = true - page_title 'New Group' - header_title "Groups", dashboard_groups_path diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index fcdd0a8499..e07f61c94e 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -1,5 +1,5 @@ - @no_container = true -- @breadcrumb_title = "Group" +- 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/_breadcrumbs.html.haml b/app/views/layouts/nav/_breadcrumbs.html.haml index 0bdf781954..9aed0efae1 100644 --- a/app/views/layouts/nav/_breadcrumbs.html.haml +++ b/app/views/layouts/nav/_breadcrumbs.html.haml @@ -1,4 +1,3 @@ -- breadcrumb_title = @breadcrumb_title || controller.controller_name.humanize - breadcrumb_link = breadcrumb_title_link - hide_top_links = @hide_top_links || false @@ -18,7 +17,7 @@ - if @breadcrumbs_extra_links - @breadcrumbs_extra_links.each do |extra| %li= link_to extra[:text], extra[:link] - %li= link_to breadcrumb_title, breadcrumb_link + %li= link_to @breadcrumb_title, breadcrumb_link - if content_for?(:breadcrumbs_extra) .breadcrumbs-extra.hidden-xs= yield :breadcrumbs_extra = yield :header_content diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 6d97d08ed1..a8ae0b9233 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Profile" +- breadcrumb_title "Profile" - @content_class = "limit-container-width" unless fluid_layout = render 'profiles/head' diff --git a/app/views/projects/blob/edit.html.haml b/app/views/projects/blob/edit.html.haml index 43fef9f134..992fe7f717 100644 --- a/app/views/projects/blob/edit.html.haml +++ b/app/views/projects/blob/edit.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Repository" +- breadcrumb_title "Repository" - @no_container = true - page_title "Edit", @blob.path, @ref - content_for :page_specific_javascripts do diff --git a/app/views/projects/blob/new.html.haml b/app/views/projects/blob/new.html.haml index 4433aed202..a4263774df 100644 --- a/app/views/projects/blob/new.html.haml +++ b/app/views/projects/blob/new.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Repository" +- breadcrumb_title "Repository" - page_title "New File", @path.presence, @ref - content_for :page_specific_javascripts do = page_specific_javascript_tag('lib/ace.js') diff --git a/app/views/projects/blob/show.html.haml b/app/views/projects/blob/show.html.haml index a3c6c57607..7dd834e84b 100644 --- a/app/views/projects/blob/show.html.haml +++ b/app/views/projects/blob/show.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Repository" +- breadcrumb_title "Repository" - @no_container = true - page_title @blob.path, @ref diff --git a/app/views/projects/issues/new.html.haml b/app/views/projects/issues/new.html.haml index e8aae0f47e..60fe442014 100644 --- a/app/views/projects/issues/new.html.haml +++ b/app/views/projects/issues/new.html.haml @@ -1,3 +1,4 @@ +- breadcrumb_title "Issues" - page_title "New Issue" %h3.page-title diff --git a/app/views/projects/merge_requests/creations/new.html.haml b/app/views/projects/merge_requests/creations/new.html.haml index 59a88c6800..3220512d60 100644 --- a/app/views/projects/merge_requests/creations/new.html.haml +++ b/app/views/projects/merge_requests/creations/new.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Merge Requests" +- breadcrumb_title "Merge Requests" - page_title "New Merge Request" - if @merge_request.can_be_created && !params[:change_branches] diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index 8faa49d822..a2d7a21d5f 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -1,4 +1,5 @@ - @breadcrumb_link = dashboard_projects_path +- breadcrumb_title "Projects" - @hide_top_links = true - page_title 'New Project' - header_title "Projects", dashboard_projects_path diff --git a/app/views/projects/pipeline_schedules/index.html.haml b/app/views/projects/pipeline_schedules/index.html.haml index 89042ef4a0..8426b29bb1 100644 --- a/app/views/projects/pipeline_schedules/index.html.haml +++ b/app/views/projects/pipeline_schedules/index.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Schedules" +- breadcrumb_title "Schedules" - content_for :page_specific_javascripts do = webpack_bundle_tag 'common_vue' diff --git a/app/views/projects/pipeline_schedules/new.html.haml b/app/views/projects/pipeline_schedules/new.html.haml index 115c43a0ae..c7237cb96d 100644 --- a/app/views/projects/pipeline_schedules/new.html.haml +++ b/app/views/projects/pipeline_schedules/new.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Schedules" +- breadcrumb_title "Schedules" - @breadcrumb_link = namespace_project_pipeline_schedules_path(@project.namespace, @project) - page_title _("New Pipeline Schedule") diff --git a/app/views/projects/services/edit.html.haml b/app/views/projects/services/edit.html.haml index 3d1d62b886..8056217bb1 100644 --- a/app/views/projects/services/edit.html.haml +++ b/app/views/projects/services/edit.html.haml @@ -1,4 +1,4 @@ -- @breadcrumb_title = "Integrations" +- breadcrumb_title "Integrations" - page_title @service.title, "Services" - if show_new_nav? diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index c366fb334f..49d0a6828f 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -1,5 +1,5 @@ - @no_container = true -- @breadcrumb_title = "Project" +- breadcrumb_title "Project" - @content_class = "limit-container-width" unless fluid_layout - flash_message_container = show_new_nav? ? :new_global_flash : :flash_message diff --git a/app/views/projects/tree/show.html.haml b/app/views/projects/tree/show.html.haml index 2de6d50da3..c8587245f8 100644 --- a/app/views/projects/tree/show.html.haml +++ b/app/views/projects/tree/show.html.haml @@ -1,5 +1,5 @@ - @no_container = true -- @breadcrumb_title = _("Repository") +- breadcrumb_title _("Repository") - @content_class = "limit-container-width" unless fluid_layout - page_title @path.presence || _("Files"), @ref diff --git a/app/views/projects/wikis/show.html.haml b/app/views/projects/wikis/show.html.haml index 42602c6366..9dadd685ea 100644 --- a/app/views/projects/wikis/show.html.haml +++ b/app/views/projects/wikis/show.html.haml @@ -1,5 +1,5 @@ - @content_class = "limit-container-width limit-container-width-sm" unless fluid_layout -- @breadcrumb_title = "Wiki" +- breadcrumb_title "Wiki" - page_title @page.title.capitalize, "Wiki" .wiki-page-header.has-sidebar-toggle diff --git a/app/views/snippets/new.html.haml b/app/views/snippets/new.html.haml index 513e26e1d8..f01915107e 100644 --- a/app/views/snippets/new.html.haml +++ b/app/views/snippets/new.html.haml @@ -1,4 +1,5 @@ - @hide_top_links = true +- breadcrumb_title "Snippets" - page_title "New Snippet" %h3.page-title New Snippet -- 2.30.9