From f738001328f84aa2835625a0bc15f2f18c609935 Mon Sep 17 00:00:00 2001 From: Kabiru Mwenja Date: Thu, 12 Dec 2024 12:29:05 +0300 Subject: [PATCH] [#59815] Add email setting to send an email reminder immediately https://community.openproject.org/work_packages/59815 --- app/models/user_preference.rb | 2 +- config/locales/js-en.yml | 1 + config/schemas/user_preferences.schema.json | 3 +++ .../immediate-reminder-settings.component.html | 12 ++++++++++++ .../immediate-reminder-settings.component.ts | 1 + .../page/reminder-settings-page.component.ts | 2 ++ .../user-preferences/state/user-preferences.model.ts | 1 + .../user-preferences/state/user-preferences.store.ts | 1 + .../settings/immediate_reminder_spec.rb | 11 +++++++++-- 9 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 041f930fe201..0e90fe646d18 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -140,7 +140,7 @@ def workdays end def immediate_reminders - super.presence || { mentioned: true }.with_indifferent_access + super.presence || { mentioned: true, personal_reminder: true }.with_indifferent_access end def pause_reminders diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml index 16d80a5b2dc6..0a862579f48e 100644 --- a/config/locales/js-en.yml +++ b/config/locales/js-en.yml @@ -805,6 +805,7 @@ en: immediate: title: "Send me an email reminder" mentioned: "Immediately when someone @mentions me" + personal_reminder: "Immediately when I receive a personal reminder" alerts: title: "Email alerts for other items (that are not work packages)" explanation: > diff --git a/config/schemas/user_preferences.schema.json b/config/schemas/user_preferences.schema.json index 55f9af30c0b9..0c9cda5fe729 100644 --- a/config/schemas/user_preferences.schema.json +++ b/config/schemas/user_preferences.schema.json @@ -74,6 +74,9 @@ "properties": { "mentioned": { "type": "boolean" + }, + "personalReminder": { + "type": "boolean" } }, "required": [ diff --git a/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.html b/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.html index 3e85891c967f..1a1bc1accf8c 100644 --- a/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.html +++ b/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.html @@ -14,4 +14,16 @@

data-qa-immediate-reminder="mentioned" /> + + + + diff --git a/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.ts b/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.ts index f94fac6e7510..c96b9216807d 100644 --- a/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.ts +++ b/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.ts @@ -22,6 +22,7 @@ export class ImmediateReminderSettingsComponent implements OnInit { title: this.I18n.t('js.reminders.settings.immediate.title'), explanation: this.I18n.t('js.reminders.settings.immediate.explanation'), mentioned: this.I18n.t('js.reminders.settings.immediate.mentioned'), + personalReminder: this.I18n.t('js.reminders.settings.immediate.personal_reminder'), }; constructor( diff --git a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts index 8d271291f78d..b2d1af356d86 100644 --- a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts +++ b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts @@ -39,6 +39,7 @@ export class ReminderSettingsPageComponent extends UntilDestroyedMixin implement public form = this.fb.group({ immediateReminders: this.fb.group({ mentioned: this.fb.control(false), + personalReminder: this.fb.control(false), }), dailyReminders: this.fb.group({ enabled: this.fb.control(false), @@ -112,6 +113,7 @@ export class ReminderSettingsPageComponent extends UntilDestroyedMixin implement private buildForm(settings:IUserPreference, globalSetting:INotificationSetting) { this.form.get('immediateReminders.mentioned')?.setValue(settings.immediateReminders.mentioned); + this.form.get('immediateReminders.personalReminder')?.setValue(settings.immediateReminders.personalReminder); this.form.get('dailyReminders.enabled')?.setValue(settings.dailyReminders.enabled); diff --git a/frontend/src/app/features/user-preferences/state/user-preferences.model.ts b/frontend/src/app/features/user-preferences/state/user-preferences.model.ts index 172a4ff16c87..c2f527626352 100644 --- a/frontend/src/app/features/user-preferences/state/user-preferences.model.ts +++ b/frontend/src/app/features/user-preferences/state/user-preferences.model.ts @@ -11,6 +11,7 @@ export interface PauseRemindersSettings { } export interface ImmediateRemindersSettings { mentioned:boolean; + personalReminder:boolean; } export interface IUserPreference { diff --git a/frontend/src/app/features/user-preferences/state/user-preferences.store.ts b/frontend/src/app/features/user-preferences/state/user-preferences.store.ts index c5f8d658857e..f05236f1a435 100644 --- a/frontend/src/app/features/user-preferences/state/user-preferences.store.ts +++ b/frontend/src/app/features/user-preferences/state/user-preferences.store.ts @@ -46,6 +46,7 @@ function createInitialState():IUserPreference { workdays: [1, 2, 3, 4, 5], immediateReminders: { mentioned: false, + personalReminder: false, }, pauseReminders: { enabled: false, diff --git a/spec/features/notifications/settings/immediate_reminder_spec.rb b/spec/features/notifications/settings/immediate_reminder_spec.rb index 92d25c6165f6..6f63e2f3191a 100644 --- a/spec/features/notifications/settings/immediate_reminder_spec.rb +++ b/spec/features/notifications/settings/immediate_reminder_spec.rb @@ -10,10 +10,15 @@ reminders_settings_page.visit! # By default the immediate reminder is checked - expect(pref.immediate_reminders[:mentioned]).to be true + expect(pref.immediate_reminders[:mentioned]).to be(true) reminders_settings_page.expect_immediate_reminder :mentioned, true + # By default the personal reminder is checked + expect(pref.immediate_reminders[:personal_reminder]).to be(true) + reminders_settings_page.expect_immediate_reminder :personal_reminder, true + reminders_settings_page.set_immediate_reminder :mentioned, false + reminders_settings_page.set_immediate_reminder :personal_reminder, false reminders_settings_page.save @@ -22,8 +27,10 @@ reminders_settings_page.reload! reminders_settings_page.expect_immediate_reminder :mentioned, false + reminders_settings_page.expect_immediate_reminder :personal_reminder, false - expect(pref.reload.immediate_reminders[:mentioned]).to be false + expect(pref.reload.immediate_reminders[:mentioned]).to be(false) + expect(pref.reload.immediate_reminders[:personal_reminder]).to be(false) end end