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

Extract "Mark all as read" and facet switch into SubHeader

Henriette Darge6bb61936246d
diff --git a/app/components/notifications/index_page_header_component.html.erb b/app/components/notifications/index_page_header_component.html.erb
index 55a36394b15..2c56ef78df3 100644
--- a/app/components/notifications/index_page_header_component.html.erb
+++ b/app/components/notifications/index_page_header_component.html.erb
@@ -2,38 +2,14 @@
header.with_title { page_title }
header.with_breadcrumbs(breadcrumb_items)
- header.with_action_segmented_control("aria-label": t(:label_filter_plural)) do |control|
- control.with_item(tag: :a,
- href: notifications_path(facet: nil),
- label: t("notifications.facets.unread"),
- title: t("notifications.facets.unread_title"),
- selected: @facet != "all")
- control.with_item(tag: :a,
- href: notifications_path(facet: "all"),
- label: t("notifications.facets.all"),
- title: t("notifications.facets.all_title"),
- selected: @facet == "all")
- end
-
- header.with_action_button(tag: :a,
- mobile_icon: :'op-read-all',
- mobile_label: I18n.t("js.notifications.center.mark_all_read"),
- href: mark_all_read_notifications_path({ filter: @filter_type, name: @filter_name }.compact),
- data: { method: :post },
- size: :medium,
- aria: { label: I18n.t("js.notifications.center.mark_all_read") }) do |button|
- button.with_leading_visual_icon(icon: :'op-read-all')
- I18n.t("js.notifications.center.mark_all_read")
- end
-
header.with_action_button(tag: :a,
mobile_icon: :gear,
- mobile_label: I18n.t("js.notifications.settings.title"),
+ mobile_label: I18n.t(:label_setting_plural),
href: my_notifications_path,
size: :medium,
target: "_blank",
aria: { label: I18n.t("js.notifications.settings.title") }) do |button|
button.with_leading_visual_icon(icon: :gear)
- I18n.t("js.notifications.settings.title")
+ I18n.t(:label_setting_plural)
end
end %>
diff --git a/app/components/notifications/index_page_header_component.rb b/app/components/notifications/index_page_header_component.rb
index 21c9a892497..2589da0ccec 100644
--- a/app/components/notifications/index_page_header_component.rb
+++ b/app/components/notifications/index_page_header_component.rb
@@ -32,14 +32,9 @@ module Notifications
class IndexPageHeaderComponent < ApplicationComponent
include ApplicationHelper
- attr_reader :facet, :filter_type, :filter_name
-
- def initialize(project: nil, facet: nil, filter_type: nil, filter_name: nil)
+ def initialize(project: nil)
super
@project = project
- @facet = facet
- @filter_type = filter_type
- @filter_name = filter_name
end
def page_title
diff --git a/app/components/notifications/index_sub_header_component.html.erb b/app/components/notifications/index_sub_header_component.html.erb
new file mode 100644
index 00000000000..aa16a09e10d
--- /dev/null
+++ b/app/components/notifications/index_sub_header_component.html.erb
@@ -0,0 +1,25 @@
+<%= render(Primer::OpenProject::SubHeader.new) do |subheader|
+ subheader.with_filter_component do
+ render(Primer::Alpha::SegmentedControl.new("aria-label": I18n.t(:label_filter_plural))) do |control|
+ control.with_item(tag: :a,
+ href: notifications_path(facet: nil),
+ label: t("notifications.facets.unread"),
+ title: t("notifications.facets.unread_title"),
+ selected: @facet != "all")
+ control.with_item(tag: :a,
+ href: notifications_path(facet: "all"),
+ label: t("notifications.facets.all"),
+ title: t("notifications.facets.all_title"),
+ selected: @facet == "all")
+ end
+ end
+
+ subheader.with_action_button(tag: :a,
+ href: mark_all_read_notifications_path({ filter: @filter_type, name: @filter_name }.compact),
+ data: { method: :post },
+ size: :medium,
+ aria: { label: I18n.t("js.notifications.center.mark_all_read") }) do |button|
+ button.with_leading_visual_icon(icon: :'op-read-all')
+ I18n.t("js.notifications.center.mark_all_read")
+ end
+end %>
diff --git a/app/components/notifications/index_sub_header_component.rb b/app/components/notifications/index_sub_header_component.rb
new file mode 100644
index 00000000000..7743de89e18
--- /dev/null
+++ b/app/components/notifications/index_sub_header_component.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2010-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+# ++
+
+module Notifications
+ class IndexSubHeaderComponent < ApplicationComponent
+ include ApplicationHelper
+
+ attr_reader :facet, :filter_type, :filter_name
+
+ def initialize(project: nil, facet: nil, filter_type: nil, filter_name: nil)
+ super
+ @project = project
+ @facet = facet
+ @filter_type = filter_type
+ @filter_name = filter_name
+ end
+ end
+end
diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb
index d2b79d21eba..3e975299c18 100644
--- a/app/views/notifications/index.html.erb
+++ b/app/views/notifications/index.html.erb
@@ -1,7 +1,8 @@
<% html_title t("js.notifications.title") %>
<% content_for :content_header do %>
- <%= render(Notifications::IndexPageHeaderComponent.new(
+ <%= render(Notifications::IndexPageHeaderComponent.new) %>
+ <%= render(Notifications::IndexSubHeaderComponent.new(
facet: params[:facet],
filter_name: params[:name],
filter_type: params[:filter]
diff --git a/frontend/src/global_styles/primer/_overrides.sass b/frontend/src/global_styles/primer/_overrides.sass
index 03abb7b1a92..aad9e52b401 100644
--- a/frontend/src/global_styles/primer/_overrides.sass
+++ b/frontend/src/global_styles/primer/_overrides.sass
@@ -45,9 +45,6 @@ action-menu
ul
margin-left: 0
-ul.tabnav-tabs
- margin-left: 0
-
.UnderlineNav
@include styled-scroll-bar
margin-bottom: 12px
@@ -57,9 +54,13 @@ ul.tabnav-tabs
/* Remove margin-left: 2rem from Breadcrumbs */
#breadcrumb,
-page-header
- ol
+page-header,
+sub-header,
+.op-work-package-details-tab-component
+ ol, ul
margin-left: 0
+
+#breadcrumb
.breadcrumb-item.breadcrumb-item-selected
a
pointer-events: none