Skip to content

Commit

Permalink
[#59815] Add email setting to send an email reminder immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
akabiru committed Dec 13, 2024
1 parent 6dfdced commit f738001
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/user_preference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/locales/js-en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/user_preferences.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
"properties": {
"mentioned": {
"type": "boolean"
},
"personalReminder": {
"type": "boolean"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,16 @@ <h3 [textContent]="text.title" class="op-form--section-header-title"></h3>
data-qa-immediate-reminder="mentioned"
/>
</spot-selector-field>

<spot-selector-field
[label]="text.personalReminder"
[control]="form.get('personalReminder')"
>
<input
slot="input"
type="checkbox"
formControlName="personalReminder"
data-qa-immediate-reminder="personalReminder"
/>
</spot-selector-field>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface PauseRemindersSettings {
}
export interface ImmediateRemindersSettings {
mentioned:boolean;
personalReminder:boolean;
}

export interface IUserPreference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function createInitialState():IUserPreference {
workdays: [1, 2, 3, 4, 5],
immediateReminders: {
mentioned: false,
personalReminder: false,
},
pauseReminders: {
enabled: false,
Expand Down
11 changes: 9 additions & 2 deletions spec/features/notifications/settings/immediate_reminder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit f738001

Please sign in to comment.