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

Allow switching facet

Oliver Günther60d2aa79c250
diff --git a/app/components/notifications/index_page_header_component.html.erb b/app/components/notifications/index_page_header_component.html.erb
index 0faf95fde8a..a62c00710c1 100644
--- a/app/components/notifications/index_page_header_component.html.erb
+++ b/app/components/notifications/index_page_header_component.html.erb
@@ -2,6 +2,19 @@
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"),
@@ -15,8 +28,9 @@
header.with_action_button(tag: :a,
mobile_icon: :gear,
mobile_label: I18n.t("js.notifications.settings.title"),
- href: notifications_path,
+ 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")
diff --git a/app/components/notifications/index_page_header_component.rb b/app/components/notifications/index_page_header_component.rb
index b3471c04900..334def67af7 100644
--- a/app/components/notifications/index_page_header_component.rb
+++ b/app/components/notifications/index_page_header_component.rb
@@ -32,9 +32,12 @@ module Notifications
class IndexPageHeaderComponent < ApplicationComponent
include ApplicationHelper
- def initialize(project: nil)
+ attr_reader :facet
+
+ def initialize(project: nil, facet: nil)
super
@project = project
+ @facet = facet
end
def page_title
diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb
index f077ed0ef34..de32f527398 100644
--- a/app/views/notifications/index.html.erb
+++ b/app/views/notifications/index.html.erb
@@ -1,4 +1,4 @@
<% html_title t("js.notifications.title") %>
-<%= render(Notifications::IndexPageHeaderComponent.new) %>
+<%= render(Notifications::IndexPageHeaderComponent.new(facet: params[:facet])) %>
<%= angular_component_tag "opce-notification-center" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 98f3e930a80..4e1acf21628 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1910,6 +1910,11 @@ en:
responsible: "Accountable"
shared: "Shared"
watched: "Watcher"
+ facets:
+ unread: "Unread"
+ unread_title: "Show unread"
+ all: "All"
+ all_title: "Show all"
menu:
by_project: "Unread by project"
by_reason: "Reason"
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index b421cc47a3c..f661fc015bf 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -698,11 +698,6 @@ en:
upsale:
title: "Date alerts"
description: "With date alerts, you will be notified of upcoming start or finish dates so that you never miss or forget an important deadline."
- facets:
- unread: "Unread"
- unread_title: "Show unread"
- all: "All"
- all_title: "Show all"
center:
label_actor_and: "and"
and_more_users:
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
index f38b1b55350..40cc9cd5ca8 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
@@ -145,7 +145,8 @@ export class InAppNotificationCenterComponent implements OnInit {
}
ngOnInit():void {
- this.storeService.setFacet('unread');
+ const facet = this.urlParams.get('facet') || 'unread';
+ this.storeService.setFacet(facet as 'unread'|'all');
this.storeService.setFilters({
filter: this.urlParams.get('filter'),
name: this.urlParams.get('name'),