0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Added user notification toggle for Milestone emails

refs https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4?pvs=4

- Added a toggle to disable and enable receiving Milestone emails behind a feature flag
This commit is contained in:
Aileen Nowak 2023-03-14 17:32:33 +02:00 committed by Aileen Booker
parent 8d290c4560
commit b374bd4b94
4 changed files with 31 additions and 0 deletions

View file

@ -216,6 +216,11 @@ export default class UserController extends Controller {
this.user.mentionNotifications = event.target.checked; this.user.mentionNotifications = event.target.checked;
} }
@action
toggleMilestoneNotifications(event) {
this.user.milestoneNotifications = event.target.checked;
}
@action @action
toggleMemberEmailAlerts(type, event) { toggleMemberEmailAlerts(type, event) {
if (type === 'free-signup') { if (type === 'free-signup') {

View file

@ -41,6 +41,7 @@ export default BaseModel.extend(ValidationEngine, {
paidSubscriptionStartedNotification: attr(), paidSubscriptionStartedNotification: attr(),
paidSubscriptionCanceledNotification: attr(), paidSubscriptionCanceledNotification: attr(),
mentionNotifications: attr(), mentionNotifications: attr(),
milestoneNotifications: attr(),
ghostPaths: service(), ghostPaths: service(),
ajax: service(), ajax: service(),
session: service(), session: service(),

View file

@ -346,6 +346,27 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
{{#if (feature 'milestoneEmails') }}
<div class="user-setting-toggle">
<div>
<label for="user-email">Milestones</label>
<p>Occasional summaries of your audience & revenue growth</p>
</div>
<div class="for-switch small">
<label class="switch" for="milestone-notifications" data-test-label="milestone-notifications">
<input
id="milestone-notifications"
type="checkbox"
checked={{this.user.milestoneNotifications}}
class="gh-input"
{{on "change" this.toggleMilestoneNotifications}}
data-test-checkbox="milestone-notifications"
>
<span class="input-toggle-component"></span>
</label>
</div>
</div>
{{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}
</GhFormGroup> </GhFormGroup>

View file

@ -82,6 +82,7 @@ describe('Acceptance: Staff', function () {
enableStripe(this.server); enableStripe(this.server);
enableLabsFlag(this.server, 'webmentions'); enableLabsFlag(this.server, 'webmentions');
enableLabsFlag(this.server, 'webmentionEmails'); enableLabsFlag(this.server, 'webmentionEmails');
enableLabsFlag(this.server, 'milestoneEmails');
admin = this.server.create('user', {email: 'admin@example.com', roles: [adminRole]}); admin = this.server.create('user', {email: 'admin@example.com', roles: [adminRole]});
@ -873,11 +874,13 @@ describe('Acceptance: Staff', function () {
expect(find('[data-test-checkbox="paid-started-notifications"]')).to.not.be.checked; expect(find('[data-test-checkbox="paid-started-notifications"]')).to.not.be.checked;
expect(find('[data-test-checkbox="paid-canceled-notifications"]')).to.not.be.checked; expect(find('[data-test-checkbox="paid-canceled-notifications"]')).to.not.be.checked;
expect(find('[data-test-checkbox="mention-notifications"]')).to.not.be.checked; expect(find('[data-test-checkbox="mention-notifications"]')).to.not.be.checked;
expect(find('[data-test-checkbox="milestone-notifications"]')).to.not.be.checked;
await click('[data-test-label="free-signup-notifications"]'); await click('[data-test-label="free-signup-notifications"]');
await click('[data-test-label="paid-started-notifications"]'); await click('[data-test-label="paid-started-notifications"]');
await click('[data-test-label="paid-canceled-notifications"]'); await click('[data-test-label="paid-canceled-notifications"]');
await click('[data-test-label="mention-notifications"]'); await click('[data-test-label="mention-notifications"]');
await click('[data-test-label="milestone-notifications"]');
await click('[data-test-save-button]'); await click('[data-test-save-button]');
await visit(`/settings/staff/${admin.slug}`); await visit(`/settings/staff/${admin.slug}`);
@ -886,6 +889,7 @@ describe('Acceptance: Staff', function () {
expect(find('[data-test-checkbox="paid-started-notifications"]')).to.be.checked; expect(find('[data-test-checkbox="paid-started-notifications"]')).to.be.checked;
expect(find('[data-test-checkbox="paid-canceled-notifications"]')).to.be.checked; expect(find('[data-test-checkbox="paid-canceled-notifications"]')).to.be.checked;
expect(find('[data-test-checkbox="mention-notifications"]')).to.be.checked; expect(find('[data-test-checkbox="mention-notifications"]')).to.be.checked;
expect(find('[data-test-checkbox="milestone-notifications"]')).to.be.checked;
}); });
}); });