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 date alert + reminder note

Kabiru Mwenja6f8e2ccea499
diff --git a/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.html b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.html
index 1956ae5dfa8..14ad39483e6 100644
--- a/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.html
+++ b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.html
@@ -1,7 +1,13 @@
+<op-in-app-notification-date-alert
+ *ngIf="hasDateAlert"
+ [aggregatedNotifications]="dateAlerts">
+</op-in-app-notification-date-alert>
<op-in-app-notification-relative-time
+ *ngIf="!hasDateAlert"
[notification]="reminderAlert"
- [hasActorByLine]="false"
-/>
+ [hasActorByLine]="false">
+</op-in-app-notification-relative-time>
+
<span
class="op-ian-reminder-alert--note"
[textContent]="reminderNote"
diff --git a/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.ts b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.ts
index 84392aeabde..f898e9b47b9 100644
--- a/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.ts
+++ b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.ts
@@ -23,6 +23,8 @@ export class InAppNotificationReminderAlertComponent implements OnInit {
reminderNote:string;
reminderAlert:INotification;
+ hasDateAlert = false;
+ dateAlerts:INotification[] = [];
constructor(
private I18n:I18nService,
@@ -31,6 +33,8 @@ export class InAppNotificationReminderAlertComponent implements OnInit {
ngOnInit():void {
this.reminderAlert = this.deriveMostRecentReminder(this.aggregatedNotifications);
this.reminderNote = this.extractReminderNoteValue(this.reminderAlert._embedded.details);
+ this.dateAlerts = this.aggregatedNotifications.filter((notification) => notification.reason === 'dateAlert');
+ this.hasDateAlert = this.dateAlerts.length > 0;
}
private deriveMostRecentReminder(aggregatedNotifications:INotification[]):INotification {
diff --git a/spec/features/notifications/notification_center/notification_center_reminder_spec.rb b/spec/features/notifications/notification_center/notification_center_reminder_spec.rb
index af66d590716..ca000c92f74 100644
--- a/spec/features/notifications/notification_center/notification_center_reminder_spec.rb
+++ b/spec/features/notifications/notification_center/notification_center_reminder_spec.rb
@@ -13,13 +13,19 @@ RSpec.describe "Notification center reminder, mention and date alert",
member_with_permissions: { project => %w[view_work_packages] })
end
shared_let(:work_package) { create(:work_package, project:, due_date: 1.day.ago) }
+ shared_let(:work_package2) { create(:work_package, project:) }
- shared_let(:notification_mention) do
- create(:notification,
- reason: :mentioned,
- recipient: user,
- resource: work_package,
- actor:)
+ shared_let(:notification_mentions) do
+ [create(:notification,
+ reason: :mentioned,
+ recipient: user,
+ resource: work_package,
+ actor:),
+ create(:notification,
+ reason: :mentioned,
+ recipient: user,
+ resource: work_package2,
+ actor: actor)]
end
shared_let(:notification_date_alert) do
@@ -30,13 +36,11 @@ RSpec.describe "Notification center reminder, mention and date alert",
end
shared_let(:notification_reminder) do
- reminder = create(:reminder, remindable: work_package, creator: user, note: "This is an important reminder")
- notification = create(:notification,
- reason: :reminder,
- recipient: user,
- resource: work_package)
- create(:reminder_notification, reminder:, notification:)
- notification
+ create_reminder_notification_for(work_package: work_package, user: user)
+ end
+
+ shared_let(:notification_reminder2) do
+ create_reminder_notification_for(work_package: work_package2, user: user)
end
let(:center) { Pages::Notifications::Center.new }
@@ -47,10 +51,31 @@ RSpec.describe "Notification center reminder, mention and date alert",
wait_for_reload
end
- it "shows the reminder alert within aggregation with reminder note" do
- center.within_item(notification_reminder) do
- expect(page).to have_text("Date alert, Mentioned, Reminder")
- expect(page).to have_text("a few seconds ago.\nNote: “This is an important reminder”")
+ context "with a reminder, mention and date alert" do
+ it "shows the reminder alert within aggregation with date alert + reminder note" do
+ center.within_item(notification_reminder) do
+ expect(page).to have_text("##{work_package.id}\n- #{project.name} -\nDate alert, Mentioned, Reminder")
+ expect(page).to have_text("Overdue since 1 day.\nNote: “This is an important reminder”")
+ end
end
end
+
+ context "with a reminder and mention, no date alert" do
+ it "shows the reminder alert within aggregation with mention" do
+ center.within_item(notification_reminder2) do
+ expect(page).to have_text("##{work_package2.id}\n- #{project.name} -\nMentioned, Reminder")
+ expect(page).to have_text("a few seconds ago.\nNote: “This is an important reminder”")
+ end
+ end
+ end
+
+ def create_reminder_notification_for(work_package:, user:)
+ reminder = create(:reminder, remindable: work_package, creator: user, note: "This is an important reminder")
+ notification = create(:notification,
+ reason: :reminder,
+ recipient: user,
+ resource: work_package)
+ create(:reminder_notification, reminder:, notification:)
+ notification
+ end
end