Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use common helper for nested breadcrumb element (#17783)

Oliver Günther7705f75970f4
diff --git a/app/components/attribute_help_texts/index_page_header_component.rb b/app/components/attribute_help_texts/index_page_header_component.rb
index 0e0637a472e..5c1615f05e6 100644
--- a/app/components/attribute_help_texts/index_page_header_component.rb
+++ b/app/components/attribute_help_texts/index_page_header_component.rb
@@ -39,9 +39,11 @@ class AttributeHelpTexts::IndexPageHeaderComponent < ApplicationComponent
end
def breadcrumb_items
- [{ href: admin_index_path, text: t("label_administration") },
- I18n.t("menus.breadcrumb.nested_element", section_header: t(:"attribute_help_texts.label_plural"),
- title: I18n.t(currently_selected_tab[:label].to_s)).html_safe]
+ [
+ { href: admin_index_path, text: t("label_administration") },
+ helpers.nested_breadcrumb_element(t(:"attribute_help_texts.label_plural"),
+ I18n.t(currently_selected_tab[:label].to_s))
+ ]
end
def currently_selected_tab
diff --git a/app/components/custom_fields/index_page_header_component.rb b/app/components/custom_fields/index_page_header_component.rb
index bfefb5b22ec..db2f7ebeb05 100644
--- a/app/components/custom_fields/index_page_header_component.rb
+++ b/app/components/custom_fields/index_page_header_component.rb
@@ -39,9 +39,11 @@ class CustomFields::IndexPageHeaderComponent < ApplicationComponent
end
def breadcrumb_items
- [{ href: admin_index_path, text: t("label_administration") },
- I18n.t("menus.breadcrumb.nested_element", section_header: t(:label_custom_field_plural),
- title: I18n.t(currently_selected_tab[:label].to_s)).html_safe]
+ [
+ { href: admin_index_path, text: t("label_administration") },
+ helpers.nested_breadcrumb_element(t(:label_custom_field_plural),
+ I18n.t(currently_selected_tab[:label].to_s))
+ ]
end
def currently_selected_tab
diff --git a/app/components/members/index_page_header_component.rb b/app/components/members/index_page_header_component.rb
index c0df1b1bbd9..18bd0019258 100644
--- a/app/components/members/index_page_header_component.rb
+++ b/app/components/members/index_page_header_component.rb
@@ -63,7 +63,7 @@ class Members::IndexPageHeaderComponent < ApplicationComponent
if @query && query_name
if menu_header.present?
- I18n.t("menus.breadcrumb.nested_element", section_header: menu_header, title: query_name).html_safe
+ helpers.nested_breadcrumb_element(menu_header, query_name)
else
query_name
end
diff --git a/app/components/notifications/index_page_header_component.rb b/app/components/notifications/index_page_header_component.rb
index d6bd5852893..dcb1f9fd0d8 100644
--- a/app/components/notifications/index_page_header_component.rb
+++ b/app/components/notifications/index_page_header_component.rb
@@ -53,7 +53,7 @@ module Notifications
def current_breadcrumb_element
if current_section && current_section.header.present?
- I18n.t("menus.breadcrumb.nested_element", section_header: current_section.header, title: page_title).html_safe
+ helpers.nested_breadcrumb_element(current_section.header, page_title)
else
page_title
end
diff --git a/app/components/projects/index_page_header_component.rb b/app/components/projects/index_page_header_component.rb
index 0e5902d8185..2e6fff5186a 100644
--- a/app/components/projects/index_page_header_component.rb
+++ b/app/components/projects/index_page_header_component.rb
@@ -122,7 +122,7 @@ class Projects::IndexPageHeaderComponent < ApplicationComponent
return page_title if query.name.blank?
if current_section && current_section.header.present?
- I18n.t("menus.breadcrumb.nested_element", section_header: current_section.header, title: query.name).html_safe
+ helpers.nested_breadcrumb_element(current_section.header, query.name)
else
page_title
end
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
index 39b3cf28b13..48d65d53682 100644
--- a/app/helpers/breadcrumb_helper.rb
+++ b/app/helpers/breadcrumb_helper.rb
@@ -41,6 +41,14 @@ module BreadcrumbHelper
end
end
+ def nested_breadcrumb_element(section_header, title)
+ output = "".html_safe
+ output << "#{section_header}: "
+ output << content_tag(:strong, title)
+
+ output
+ end
+
def breadcrumb_paths(*args)
if args.empty?
@breadcrumb_paths ||= [default_breadcrumb]
diff --git a/app/views/enumerations/edit.html.erb b/app/views/enumerations/edit.html.erb
index 92f9ba9635d..341e498fa31 100644
--- a/app/views/enumerations/edit.html.erb
+++ b/app/views/enumerations/edit.html.erb
@@ -32,10 +32,14 @@ See COPYRIGHT and LICENSE files for more details.
<%=
render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { h @enumeration.name }
- header.with_breadcrumbs([{ href: admin_index_path, text: t(:label_administration) },
- { href: enumerations_path, text: t(:label_enumerations) },
- I18n.t("menus.breadcrumb.nested_element", section_header: t(@enumeration.option_name), title: h(@enumeration.name)).html_safe],
- selected_item_font_weight: :normal)
+ header.with_breadcrumbs(
+ [
+ { href: admin_index_path, text: t(:label_administration) },
+ { href: enumerations_path, text: t(:label_enumerations) },
+ nested_breadcrumb_element(t(@enumeration.option_name), @enumeration.name)
+ ],
+ selected_item_font_weight: :normal
+ )
end
%>
diff --git a/app/views/enumerations/new.html.erb b/app/views/enumerations/new.html.erb
index c8d70fd03a9..599df6f2c6e 100644
--- a/app/views/enumerations/new.html.erb
+++ b/app/views/enumerations/new.html.erb
@@ -32,10 +32,13 @@ See COPYRIGHT and LICENSE files for more details.
<%=
render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { t(:label_enumeration_new) }
- header.with_breadcrumbs([{ href: admin_index_path, text: t(:label_administration) },
- { href: enumerations_path, text: t(:label_enumerations) },
- I18n.t("menus.breadcrumb.nested_element", section_header: t(@enumeration.option_name), title: t(:label_enumeration_new)).html_safe],
- selected_item_font_weight: :normal)
+ header.with_breadcrumbs(
+ [{ href: admin_index_path, text: t(:label_administration) },
+ { href: enumerations_path, text: t(:label_enumerations) },
+ nested_breadcrumb_element(t(@enumeration.option_name), t(:label_enumeration_new))
+ ],
+ selected_item_font_weight: :normal
+ )
end
%>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 51dda272418..ce5e3be08b3 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2202,8 +2202,6 @@ en:
api_and_webhooks: "API and webhooks"
quick_add:
label: "Open quick add menu"
- breadcrumb:
- nested_element: "%{section_header}: <b>%{title}</b>"
my_account:
access_tokens:
diff --git a/modules/bim/app/views/bim/bcf/issues/perform_import.html.erb b/modules/bim/app/views/bim/bcf/issues/perform_import.html.erb
index f04c750c717..da834cc6221 100644
--- a/modules/bim/app/views/bim/bcf/issues/perform_import.html.erb
+++ b/modules/bim/app/views/bim/bcf/issues/perform_import.html.erb
@@ -1,12 +1,14 @@
-<link rel="stylesheet" href="/highlighting/styles.css" />
+<link rel="stylesheet" href="/highlighting/styles.css"/>
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { t(:label_summary) }
- header.with_breadcrumbs([{ href: project_overview_path(@project.id), text: @project.name },
- { href: defaults_bcf_project_ifc_models_path(@project.identifier), text: I18n.t(:"bcf.label_bcf") },
- I18n.t("menus.breadcrumb.nested_element", section_header: t("bcf.bcf_xml.import_title"), title: t(:label_summary)).html_safe],
- selected_item_font_weight: :normal)
+ header.with_breadcrumbs(
+ [{ href: project_overview_path(@project.id), text: @project.name },
+ { href: defaults_bcf_project_ifc_models_path(@project.identifier), text: I18n.t(:"bcf.label_bcf") },
+ nested_breadcrumb_element(t("bcf.bcf_xml.import_title"), t(:label_summary))
+ ],
+ selected_item_font_weight: :normal)
end
%>
diff --git a/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/show_page_header_component.rb b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/show_page_header_component.rb
index 28b79769467..6c197e11652 100644
--- a/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/show_page_header_component.rb
+++ b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/show_page_header_component.rb
@@ -38,12 +38,13 @@ class LdapGroups::SynchronizedFilters::ShowPageHeaderComponent < ApplicationComp
end
def breadcrumb_items
- [{ href: admin_index_path, text: t(:label_administration) },
- { href: admin_settings_authentication_path, text: t(:label_authentication) },
- { href: ldap_groups_synchronized_groups_path, text: I18n.t("ldap_groups.label_menu_item") },
- I18n.t("menus.breadcrumb.nested_element",
- section_header: t("ldap_groups.synchronized_filters.singular"),
- title: h(@filter.name)).html_safe]
+ [
+ { href: admin_index_path, text: t(:label_administration) },
+ { href: admin_settings_authentication_path, text: t(:label_authentication) },
+ { href: ldap_groups_synchronized_groups_path, text: I18n.t("ldap_groups.label_menu_item") },
+ helpers.nested_breadcrumb_element(t("ldap_groups.synchronized_filters.singular"),
+ h(@filter.name))
+ ]
end
def blocked?
diff --git a/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/edit.html.erb b/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/edit.html.erb
index b3c8129aaf9..0d27bc4e3da 100644
--- a/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/edit.html.erb
+++ b/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/edit.html.erb
@@ -3,11 +3,14 @@
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { @filter.name }
- header.with_breadcrumbs([{ href: admin_index_path, text: t(:label_administration) },
- { href: admin_settings_authentication_path, text: t(:label_authentication) },
- { href: ldap_groups_synchronized_groups_path, text: I18n.t("ldap_groups.label_menu_item") },
- I18n.t("menus.breadcrumb.nested_element", section_header: t("ldap_groups.synchronized_filters.singular"), title: @filter.name).html_safe],
- selected_item_font_weight: :normal)
+ header.with_breadcrumbs(
+ [
+ { href: admin_index_path, text: t(:label_administration) },
+ { href: admin_settings_authentication_path, text: t(:label_authentication) },
+ { href: ldap_groups_synchronized_groups_path, text: I18n.t("ldap_groups.label_menu_item") },
+ nested_breadcrumb_element(t("ldap_groups.synchronized_filters.singular"), @filter.name),
+ ],
+ selected_item_font_weight: :normal)
end
%>
diff --git a/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb b/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb
index 44c2a15f1c6..789d2f504bc 100644
--- a/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb
+++ b/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb
@@ -3,11 +3,14 @@
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { h(@group.dn) }
- header.with_breadcrumbs([{ href: admin_index_path, text: t(:label_administration) },
- { href: admin_settings_authentication_path, text: t(:label_authentication) },
- { href: ldap_groups_synchronized_groups_path, text: I18n.t("ldap_groups.label_menu_item") },
- I18n.t("menus.breadcrumb.nested_element", section_header: t("ldap_groups.synchronized_groups.singular"), title: h(@group.dn)).html_safe],
- selected_item_font_weight: :normal)
+ header.with_breadcrumbs(
+ [{ href: admin_index_path, text: t(:label_administration) },
+ { href: admin_settings_authentication_path, text: t(:label_authentication) },
+ { href: ldap_groups_synchronized_groups_path, text: I18n.t("ldap_groups.label_menu_item") },
+ nested_breadcrumb_element(t("ldap_groups.synchronized_groups.singular"), @group.dn)
+ ],
+ selected_item_font_weight: :normal
+ )
end
%>
diff --git a/modules/meeting/app/components/meetings/index_page_header_component.rb b/modules/meeting/app/components/meetings/index_page_header_component.rb
index aca17d620c4..a2aff11ecf4 100644
--- a/modules/meeting/app/components/meetings/index_page_header_component.rb
+++ b/modules/meeting/app/components/meetings/index_page_header_component.rb
@@ -62,7 +62,7 @@ module Meetings
def current_breadcrumb_element
if section_present?
- I18n.t("menus.breadcrumb.nested_element", section_header: current_section.header, title: page_title).html_safe
+ helpers.nested_breadcrumb_element(current_section.header, page_title)
else
page_title
end
diff --git a/modules/reporting/app/components/cost_reports/index_page_header_component.rb b/modules/reporting/app/components/cost_reports/index_page_header_component.rb
index 3b7cfe36e76..e9b137d3ff8 100644
--- a/modules/reporting/app/components/cost_reports/index_page_header_component.rb
+++ b/modules/reporting/app/components/cost_reports/index_page_header_component.rb
@@ -62,7 +62,7 @@ module CostReports
return I18n.t(:label_new_report) unless @query.persisted?
if current_section && current_section.header.present?
- I18n.t("menus.breadcrumb.nested_element", section_header: current_section.header, title: @query.name).html_safe
+ helpers.nested_breadcrumb_element(current_section.header, @query.name)
else
I18n.t(:label_new_report)
end
diff --git a/modules/storages/app/views/storages/project_settings/project_storage_members/index.html.erb b/modules/storages/app/views/storages/project_settings/project_storage_members/index.html.erb
index a10087e7a57..b2bcf9dcbc1 100644
--- a/modules/storages/app/views/storages/project_settings/project_storage_members/index.html.erb
+++ b/modules/storages/app/views/storages/project_settings/project_storage_members/index.html.erb
@@ -29,19 +29,21 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_administration), t("project_module_storages"), @storage.name %>
<%=
- render Primer::OpenProject::PageHeader.new do |header|
- header.with_title { t("storages.page_titles.project_storage_members.title") }
- header.with_breadcrumbs([{ href: project_overview_path(@project.id), text: @project.name },
- { href: project_settings_general_path(@project.id), text: I18n.t("label_project_settings") },
- { href: external_file_storages_project_settings_project_storages_path(@project), text: t("project_module_storages") },
- I18n.t("menus.breadcrumb.nested_element", section_header: @storage.name, title: t("storages.page_titles.project_storage_members.title")).html_safe],
- selected_item_font_weight: :normal)
- end
+ render Primer::OpenProject::PageHeader.new do |header|
+ header.with_title { t("storages.page_titles.project_storage_members.title") }
+ header.with_breadcrumbs(
+ [{ href: project_overview_path(@project.id), text: @project.name },
+ { href: project_settings_general_path(@project.id), text: I18n.t("label_project_settings") },
+ { href: external_file_storages_project_settings_project_storages_path(@project), text: t("project_module_storages") },
+ nested_breadcrumb_element(@storage.name, t("storages.page_titles.project_storage_members.title"))
+ ],
+ selected_item_font_weight: :normal)
+ end
%>
<%= content_tag(:p,
- t("storages.page_titles.project_storage_members.subtitle",
- storage_name_link: link_to(@storage.name, edit_admin_settings_storage_path(@storage))).html_safe
-) %>
+ t("storages.page_titles.project_storage_members.subtitle",
+ storage_name_link: link_to(@storage.name, edit_admin_settings_storage_path(@storage))).html_safe
+ ) %>
<%= render(::Storages::ProjectStorages::Members::TableComponent.new(rows: @project_users, storage: @storage)) %>
diff --git a/modules/two_factor_authentication/app/views/two_factor_authentication/two_factor_devices/new.html.erb b/modules/two_factor_authentication/app/views/two_factor_authentication/two_factor_devices/new.html.erb
index 3432a3c10db..c9c297cd589 100644
--- a/modules/two_factor_authentication/app/views/two_factor_authentication/two_factor_devices/new.html.erb
+++ b/modules/two_factor_authentication/app/views/two_factor_authentication/two_factor_devices/new.html.erb
@@ -3,9 +3,13 @@
<%=
render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title(test_selector: "two_factor_authentication_new_device_header_title") { t('two_factor_authentication.devices.add_new') }
- header.with_breadcrumbs([{ href: my_account_path, text: t(:label_my_account) },
- { href: my_2fa_devices_path , text: t('two_factor_authentication.label_two_factor_authentication') },
- I18n.t("menus.breadcrumb.nested_element", section_header: t("two_factor_authentication.devices.#{@device_type}.title"), title: t("two_factor_authentication.devices.add_new")).html_safe], selected_item_font_weight: :normal)
+ header.with_breadcrumbs(
+ [
+ { href: my_account_path, text: t(:label_my_account) },
+ { href: my_2fa_devices_path, text: t('two_factor_authentication.label_two_factor_authentication') },
+ nested_breadcrumb_element(t("two_factor_authentication.devices.#{@device_type}.title"), t("two_factor_authentication.devices.add_new")),
+ ],
+ selected_item_font_weight: :normal)
end
%>
<%= labelled_tabular_form_for @device,