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

Show total amount of notifications next to "inbox" and fix date alert filter

Henriette Dargec9caa58e7aa6
diff --git a/app/menus/notifications/menu.rb b/app/menus/notifications/menu.rb
index 14b4d65bfa9..cb96bedbf61 100644
--- a/app/menus/notifications/menu.rb
+++ b/app/menus/notifications/menu.rb
@@ -33,11 +33,12 @@ module Notifications
include Rails.application.routes.url_helpers
attr_reader :params, :current_user,
- :query, :unread_by_reason, :unread_by_project
+ :query, :unread, :unread_by_reason, :unread_by_project
def initialize(params:, current_user:)
@params = params
@current_user = current_user
+ @unread = filter_unread
@unread_by_reason = filter_unread_by_reason
@unread_by_project = filter_unread_by_project
@@ -57,16 +58,17 @@ module Notifications
private
def inbox_menu
- menu_item(title: I18n.t("notifications.menu.inbox"), icon_key: :inbox)
+ count = unread
+ menu_item(title: I18n.t("notifications.menu.inbox"), icon_key: :inbox, count: count == 0 ? nil : count)
end
def reason_filters
- %w[mentioned assigned responsible watched date_alert shared].map do |reason|
+ %w[mentioned assigned responsible watched dateAlert shared].map do |reason|
count = unread_by_reason[reason]
menu_item(title: I18n.t("notifications.reasons.#{reason}"),
icon_key: reason,
count: count == 0 ? nil : count,
- query_params: query_params("reason", reason.camelize(:lower)))
+ query_params: query_params("reason", reason))
end
end
@@ -76,16 +78,24 @@ module Notifications
end
end
+ def base_query
+ Queries::Notifications::NotificationQuery.new(user: current_user)
+ .where(:read_ian, "=", "f")
+ end
+
+ def filter_unread
+ query = base_query
+ query.results.count
+ end
+
def filter_unread_by_reason
- query = Queries::Notifications::NotificationQuery.new(user: current_user)
- query.where(:read_ian, "=", "f")
+ query = base_query
query.group(:reason)
query.group_values
end
def filter_unread_by_project
- query = Queries::Notifications::NotificationQuery.new(user: current_user)
- query.where(:read_ian, "=", "f")
+ query = base_query
query.group(:project)
query.group_values
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f8c7b48e3d8..9233452d804 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1905,7 +1905,7 @@ en:
notifications:
reasons:
assigned: "Assignee"
- date_alert: "Date alert"
+ dateAlert: "Date alert"
mentioned: "Mentioned"
responsible: "Accountable"
shared: "Shared"
diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
index ab8854ddc9f..18250942224 100644
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
@@ -355,6 +355,10 @@ export class IanCenterService extends UntilDestroyedMixin {
private reloadOnNotificationRead(action:ReturnType<typeof notificationsMarkedRead>) {
if (action.all) {
this.store.update({ activeCollection: { ids: [] }, activeFacet: 'unread' });
+
+ // Reload the sidemenu frame
+ void this.menuFrame.reload();
+
return;
}