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

Reveal sidemenu structure in the breadcrumb of the notification center

Henriette Darge1d5a34ab8f26
diff --git a/app/components/notifications/index_page_header_component.html.erb b/app/components/notifications/index_page_header_component.html.erb
index 2c56ef78df3..dfe0cf2782c 100644
--- a/app/components/notifications/index_page_header_component.html.erb
+++ b/app/components/notifications/index_page_header_component.html.erb
@@ -1,6 +1,6 @@
<%= render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { page_title }
- header.with_breadcrumbs(breadcrumb_items)
+ header.with_breadcrumbs(breadcrumb_items, selected_item_font_weight: current_breadcrumb_element == page_title ? :bold : :normal)
header.with_action_button(tag: :a,
mobile_icon: :gear,
diff --git a/app/components/notifications/index_page_header_component.rb b/app/components/notifications/index_page_header_component.rb
index 3af873f9b5d..d6bd5852893 100644
--- a/app/components/notifications/index_page_header_component.rb
+++ b/app/components/notifications/index_page_header_component.rb
@@ -38,16 +38,41 @@ module Notifications
end
def page_title
- I18n.t("js.notifications.title")
+ if current_item.present?
+ current_item.title
+ else
+ I18n.t("notifications.menu.inbox")
+ end
end
def breadcrumb_items
- [parent_element,
- page_title]
+ [{ href: home_path, text: helpers.organization_name },
+ { href: notifications_path, text: I18n.t("js.notifications.title") },
+ current_breadcrumb_element]
end
- def parent_element
- { href: home_path, text: helpers.organization_name }
+ 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
+ else
+ page_title
+ end
+ end
+
+ def current_section
+ return @current_section if defined?(@current_section)
+
+ @current_section = Notifications::Menu
+ .new(params:, current_user: User.current)
+ .selected_menu_group
+ end
+
+ def current_item
+ return @current_item if defined?(@current_item)
+
+ @current_item = Notifications::Menu
+ .new(params:, current_user: User.current)
+ .selected_menu_item
end
end
end
diff --git a/app/menus/notifications/menu.rb b/app/menus/notifications/menu.rb
index 5488c610d32..cc6961c823e 100644
--- a/app/menus/notifications/menu.rb
+++ b/app/menus/notifications/menu.rb
@@ -108,7 +108,7 @@ module Notifications
end
def selected?(query_params)
- params[:filter] == query_params[:filter] && params[:name] == query_params[:name].to_s
+ params[:filter] == query_params[:filter] && params[:name] == (query_params[:name] ? query_params[:name].to_s : nil)
end
def query_path(query_params)