mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
Renamed members-email-labs to newsletters and removed unused files
no issue We still had some old components and templates from the `members-email` settings that were only were used when the (now GA) `multipleNewsletters` flag was disabled. I’ve removed them and renamed all routes and components from `members-email` and `members-email-labs` to just `newsletters` because it was sometimes hard to understand if a given components was still used or not when fixing issues.
This commit is contained in:
parent
67505f838c
commit
19249bdae5
@ -89,7 +89,7 @@
|
||||
{{#if this.mailgunError}}
|
||||
<p class="gh-box gh-box-alert settings-menu-mailgun-alert">
|
||||
{{svg-jar "info" class="w5 h5 fill-yellow nl1"}}
|
||||
You need to configure Mailgun in <LinkTo @route="settings.members-email" data-test-nav="labs">Settings → Email newsletter</LinkTo> to enable email newsletters.
|
||||
You need to configure Mailgun in <LinkTo @route="settings.newsletters" data-test-nav="labs">Settings → Email newsletter</LinkTo> to enable email newsletters.
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
@ -147,4 +147,4 @@
|
||||
</div>
|
||||
</form>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@
|
||||
{{else if this.newsletter}}
|
||||
<p>
|
||||
Success! From address for newsletter
|
||||
"<LinkTo @route="settings.members-email-labs.edit-newsletter" @model={{this.newsletter.id}}>{{this.newsletter.name}}</LinkTo>"
|
||||
"<LinkTo @route="settings.newsletters.edit-newsletter" @model={{this.newsletter.id}}>{{this.newsletter.name}}</LinkTo>"
|
||||
changed to <strong>{{this.newsletter.senderEmail}}</strong>
|
||||
</p>
|
||||
{{else if this.error}}
|
||||
@ -31,4 +31,4 @@
|
||||
<span>Ok</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,246 +0,0 @@
|
||||
<section class="gh-main-section gh-setting-email-section">
|
||||
<div class="gh-expandable">
|
||||
<div class="gh-expandable-block">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
<h4 class="gh-expandable-title">Enable newsletter sending</h4>
|
||||
<p class="gh-expandable-description">Newsletter features are active, posts can be sent by email</p>
|
||||
</div>
|
||||
<div class="for-switch">
|
||||
<label class="switch" for="email-newsletter-enabled" {{on "click" (action "toggleEmailNewsletterEnabled")}}>
|
||||
<input type="checkbox" checked={{this.emailNewsletterEnabled}} class="gh-input" {{on "click" (action "toggleEmailNewsletterEnabled")}} name="email-newsletter-enabled" data-test-checkbox="email-newsletter-enabled">
|
||||
<span class="input-toggle-component mt1"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{#if this.emailNewsletterEnabled}}
|
||||
|
||||
<section class="gh-main-section gh-setting-email-section">
|
||||
<div class="gh-expandable">
|
||||
<div class="gh-expandable-block">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
<h4 class="gh-expandable-title">Email design</h4>
|
||||
<p class="gh-expandable-description">Customize the look and feel of your newsletters</p>
|
||||
</div>
|
||||
<button type="button" class="gh-btn gh-btn-green" {{on "click" @toggleEmailDesignSettings}} data-test-toggle-membersFrom><span> Customize design →</span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<hr>
|
||||
|
||||
<section class="gh-main-section gh-setting-email-section content-preview">
|
||||
<div>
|
||||
<div class="gh-expandable">
|
||||
<div class="gh-setting-richdd-container gh-setting-rich-dropdown">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
<h4 class="gh-expandable-title">Default newsletter recipients</h4>
|
||||
<p class="gh-expandable-description">When you publish new content, who do you usually want to send it to?</p>
|
||||
</div>
|
||||
</div>
|
||||
<Settings::MembersEmail::DefaultRecipientsSelect
|
||||
@recipients={{this.recipientsSelectValue}}
|
||||
@segment={{this.settings.editorDefaultEmailRecipientsFilter}}
|
||||
@onRecipientsChange={{action "setDefaultEmailRecipients"}}
|
||||
@onSegmentChange={{action "setDefaultEmailRecipientsFilter"}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gh-expandable">
|
||||
<div class="gh-expandable-block">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
<h4 class="gh-expandable-title">Email addresses</h4>
|
||||
<p class="gh-expandable-description">Contact information used for newsletters and member login emails</p>
|
||||
</div>
|
||||
<button type="button" class="gh-btn" {{action (toggle "membersFromOpen" this)}} data-test-toggle-membersFrom><span>{{if this.membersFromOpen "Close" "Expand"}}</span></button>
|
||||
</div>
|
||||
<div class="gh-expandable-content">
|
||||
{{#liquid-if this.membersFromOpen}}
|
||||
<div>
|
||||
<GhFormGroup>
|
||||
<label class="fw6 f8">Newsletter email address</label>
|
||||
<div class="flex items-center justify-center mt1">
|
||||
<GhTextInput
|
||||
@value={{readonly this.fromAddress}}
|
||||
@input={{action "setFromAddress" value="target.value"}}
|
||||
@class="gh-labs-members-emailinput"
|
||||
/>
|
||||
<GhTaskButton
|
||||
@buttonText="Update newsletter address"
|
||||
@runningText="Sending..."
|
||||
@successText="Confirmation email sent"
|
||||
@disabled={{this.disableUpdateFromAddressButton}}
|
||||
@task={{this.updateFromAddress}}
|
||||
@class="gh-btn gh-btn-icon gh-btn-green gh-btn-textfield-group gh-labs-members-emaildropdown"
|
||||
data-test-button="update-from-address"
|
||||
/>
|
||||
</div>
|
||||
<p>The address your newsletter posts are sent from</p>
|
||||
</GhFormGroup>
|
||||
{{#if this.showFromAddressConfirmation}}
|
||||
<div class="flex items-center green-d1 nt3 lh-1">
|
||||
{{svg-jar "check-circle" class="w4 h4 mr1 stroke-green-d1"}} <span class="nudge-left--2">Check your inbox and confirm before saving your settings</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
<GhFormGroup @class="for-select gh-members-defaultemaildd">
|
||||
<label class="fw6 f8" for="reply-address">Newsletter replies go to</label>
|
||||
<span class="gh-select mt1">
|
||||
{{one-way-select this.selectedReplyAddress
|
||||
id="reply-address"
|
||||
name="reply-address"
|
||||
options=(readonly this.replyAddresses)
|
||||
optionValuePath="value"
|
||||
optionLabelPath="label"
|
||||
update=(action "setReplyAddress")
|
||||
}}
|
||||
{{svg-jar "arrow-down-small"}}
|
||||
</span>
|
||||
<div class="flex justify-between">
|
||||
<p>Where you receive responses to newsletters</p>
|
||||
{{#if (eq this.settings.membersReplyAddress "support")}}
|
||||
<LinkTo @route="settings.membership" class="gh-update-support-address" type="button" @query={{hash showPortalSettings=true}}>Change support email address</LinkTo>
|
||||
{{/if}}
|
||||
</div>
|
||||
</GhFormGroup>
|
||||
{{/liquid-if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gh-expandable">
|
||||
<div class="gh-expandable-block">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
<h4 class="gh-expandable-title">Enable newsletter open-rate</h4>
|
||||
<p class="gh-expandable-description">Track how many members are reading your emails</p>
|
||||
</div>
|
||||
<div class="for-switch">
|
||||
<label class="switch" for="email-track-opens" {{on "click" (action "toggleEmailTrackOpens")}}>
|
||||
<input type="checkbox" checked={{this.settings.emailTrackOpens}} class="gh-input" {{on "click" (action "toggleEmailTrackOpens")}} name="email-track-opens" data-test-checkbox="email-track-opens">
|
||||
<span class="input-toggle-component mt1"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gh-email-publishmenu-preview">
|
||||
<h4 class="gh-main-section-header small bn">Preview</h4>
|
||||
<div class="gh-publishmenu-dropdown-container">
|
||||
<div class="gh-publishmenu-dropdown">
|
||||
<header class="gh-publishmenu-heading">Ready to <span class="gh-publishmenu-heading-dropdown">{{#if this.emailPreviewVisible}} publish & send {{else}} publish {{/if}}{{svg-jar "arrow-down"}}</span> this post?</header>
|
||||
<section class="gh-publishmenu-content">
|
||||
<div class="gh-publishmenu-section {{if this.emailPreviewVisible "" "mb7"}}">
|
||||
<div class="gh-publishmenu-radio active">
|
||||
<div class="gh-publishmenu-radio-button"></div>
|
||||
<div class="gh-publishmenu-radio-content">
|
||||
<div class="gh-publishmenu-radio-label">Set it live now</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gh-publishmenu-radio">
|
||||
<div class="gh-publishmenu-radio-button"></div>
|
||||
<div class="gh-publishmenu-radio-content">
|
||||
<div class="gh-publishmenu-radio-label">Schedule it for later</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{#if this.emailPreviewVisible}}
|
||||
<div class="gh-publishmenu-section">
|
||||
<div class="gh-publishmenu-email">
|
||||
<div class="gh-publishmenu-email-label">
|
||||
<label class="gh-publishmenu-radio-label mb3">Send by email to</label>
|
||||
<div class="form-group">
|
||||
<GhMembersRecipientSelect
|
||||
@filter={{this.settings.editorDefaultEmailRecipientsFilter}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{#unless this.config.mailgunIsConfigured}}
|
||||
<hr>
|
||||
<section class="gh-main-section">
|
||||
<h4 class="gh-main-section-header small bn">Advanced</h4>
|
||||
<div class="gh-expandable">
|
||||
<div class="gh-expandable-block">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
<h4 class="gh-expandable-title">Mailgun configuration</h4>
|
||||
<p class="gh-expandable-description">The Mailgun API is used for bulk email newsletter delivery. <a href="https://ghost.org/docs/faq/mailgun-newsletters/" target="_blank" rel="noopener noreferrer">Why is this required?</a></p>
|
||||
</div>
|
||||
<button type="button" class="gh-btn" {{action (toggle "membersEmailOpen" this)}} data-test-toggle-membersemail>
|
||||
<span>{{if this.membersEmailOpen "Close" "Expand"}}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="gh-expandable-content">
|
||||
{{#liquid-if this.membersEmailOpen}}
|
||||
<div class="flex flex-column flex">
|
||||
<GhFormGroup>
|
||||
<div class="flex items-center">
|
||||
<GhFormGroup @class="gh-mailgun-region no-margin">
|
||||
<label class="fw6 f8">Mailgun region</label>
|
||||
<div class="mt1">
|
||||
<PowerSelect
|
||||
@options={{this.mailgunRegions}}
|
||||
@selected={{this.mailgunRegion}}
|
||||
@onChange={{action "setMailgunRegion"}}
|
||||
@class="gh-select"
|
||||
@searchEnabled={{false}}
|
||||
@triggerComponent="gh-power-select/trigger"
|
||||
as |region|
|
||||
>
|
||||
{{region.flag}} {{region.name}}
|
||||
</PowerSelect>
|
||||
</div>
|
||||
</GhFormGroup>
|
||||
<GhFormGroup @class="no-margin">
|
||||
<label class="fw6 f8">Mailgun domain</label>
|
||||
<GhTextInput
|
||||
@value={{readonly this.mailgunSettings.domain}}
|
||||
@input={{action "setMailgunDomain"}}
|
||||
@class="mt1"
|
||||
data-test-mailgun-domain-input={{true}}
|
||||
/>
|
||||
</GhFormGroup>
|
||||
</div>
|
||||
<p>Find your Mailgun region and domain
|
||||
<a href="https://app.mailgun.com/app/sending/domains" target="_blank" class="fw5" rel="noopener noreferrer">here</a>
|
||||
</p>
|
||||
</GhFormGroup>
|
||||
<GhFormGroup>
|
||||
<label class="fw6 f8">Mailgun Private API key</label>
|
||||
<GhTextInput
|
||||
@type="password"
|
||||
@value={{readonly this.mailgunSettings.apiKey}}
|
||||
@input={{action "setMailgunApiKey"}}
|
||||
@class="mt1 password" @autocomplete="new-password"
|
||||
data-test-mailgun-api-key-input={{true}}
|
||||
/>
|
||||
<p>Find your Mailgun API keys
|
||||
<a href="https://app.mailgun.com/app/account/security/api_keys" target="_blank" class="fw5" rel="noopener noreferrer">here</a>
|
||||
</p>
|
||||
</GhFormGroup>
|
||||
</div>
|
||||
{{/liquid-if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{{/unless}}
|
||||
|
||||
{{/if}}
|
@ -1,225 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import classic from 'ember-classic-decorator';
|
||||
import {action, computed} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
|
||||
const US = {flag: '🇺🇸', name: 'US', baseUrl: 'https://api.mailgun.net/v3'};
|
||||
const EU = {flag: '🇪🇺', name: 'EU', baseUrl: 'https://api.eu.mailgun.net/v3'};
|
||||
|
||||
@classic
|
||||
export default class MembersEmail extends Component {
|
||||
@service config;
|
||||
@service ghostPaths;
|
||||
@service ajax;
|
||||
@service settings;
|
||||
|
||||
replyAddresses = null;
|
||||
recipientsSelectValue = null;
|
||||
showFromAddressConfirmation = false;
|
||||
showEmailDesignSettings = false;
|
||||
|
||||
@computed('settings.editorDefaultEmailRecipients')
|
||||
get emailNewsletterEnabled() {
|
||||
return this.get('settings.editorDefaultEmailRecipients') !== 'disabled';
|
||||
}
|
||||
|
||||
@computed('recipientsSelectValue')
|
||||
get emailPreviewVisible() {
|
||||
return this.recipientsSelectValue !== 'none';
|
||||
}
|
||||
|
||||
@computed('settings.membersReplyAddress')
|
||||
get selectedReplyAddress() {
|
||||
return this.replyAddresses.findBy('value', this.get('settings.membersReplyAddress'));
|
||||
}
|
||||
|
||||
@computed('fromAddress')
|
||||
get disableUpdateFromAddressButton() {
|
||||
const savedFromAddress = this.get('settings.membersFromAddress') || '';
|
||||
if (!savedFromAddress.includes('@') && this.config.emailDomain) {
|
||||
return !this.fromAddress || (this.fromAddress === `${savedFromAddress}@${this.config.emailDomain}`);
|
||||
}
|
||||
return !this.fromAddress || (this.fromAddress === savedFromAddress);
|
||||
}
|
||||
|
||||
@computed('settings.mailgunBaseUrl')
|
||||
get mailgunRegion() {
|
||||
if (!this.settings.get('mailgunBaseUrl')) {
|
||||
return US;
|
||||
}
|
||||
|
||||
return [US, EU].find((region) => {
|
||||
return region.baseUrl === this.settings.get('mailgunBaseUrl');
|
||||
});
|
||||
}
|
||||
|
||||
@computed('settings.{mailgunBaseUrl,mailgunApiKey,mailgunDomain}')
|
||||
get mailgunSettings() {
|
||||
return {
|
||||
apiKey: this.get('settings.mailgunApiKey') || '',
|
||||
domain: this.get('settings.mailgunDomain') || '',
|
||||
baseUrl: this.get('settings.mailgunBaseUrl') || ''
|
||||
};
|
||||
}
|
||||
|
||||
init() {
|
||||
super.init(...arguments);
|
||||
this.set('mailgunRegions', [US, EU]);
|
||||
this.set('replyAddresses', [
|
||||
{
|
||||
label: 'Newsletter email address (' + this.fromAddress + ')',
|
||||
value: 'newsletter'
|
||||
},
|
||||
{
|
||||
label: 'Support email address (' + this.supportAddress + ')',
|
||||
value: 'support'
|
||||
}
|
||||
]);
|
||||
|
||||
// set recipientsSelectValue as a static property because within this
|
||||
// component's lifecycle it's not always derived from the settings values.
|
||||
// e.g. can be set to "segment" when the filter is empty which is not derivable
|
||||
// from settings as it would equate to "none"
|
||||
this.set('recipientsSelectValue', this._getDerivedRecipientsSelectValue());
|
||||
}
|
||||
|
||||
@action
|
||||
toggleFromAddressConfirmation() {
|
||||
this.toggleProperty('showFromAddressConfirmation');
|
||||
}
|
||||
|
||||
@action
|
||||
closeEmailDesignSettings() {
|
||||
this.set('showEmailDesignSettings', false);
|
||||
}
|
||||
|
||||
@action
|
||||
setMailgunDomain(event) {
|
||||
this.set('settings.mailgunDomain', event.target.value);
|
||||
if (!this.get('settings.mailgunBaseUrl')) {
|
||||
this.set('settings.mailgunBaseUrl', this.mailgunRegion.baseUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
setMailgunApiKey(event) {
|
||||
this.set('settings.mailgunApiKey', event.target.value);
|
||||
if (!this.get('settings.mailgunBaseUrl')) {
|
||||
this.set('settings.mailgunBaseUrl', this.mailgunRegion.baseUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
setMailgunRegion(region) {
|
||||
this.set('settings.mailgunBaseUrl', region.baseUrl);
|
||||
}
|
||||
|
||||
@action
|
||||
setFromAddress(fromAddress) {
|
||||
this.setEmailAddress('fromAddress', fromAddress);
|
||||
}
|
||||
|
||||
@action
|
||||
toggleEmailTrackOpens(event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
this.set('settings.emailTrackOpens', !this.settings.get('emailTrackOpens'));
|
||||
}
|
||||
|
||||
@action
|
||||
toggleEmailNewsletterEnabled(event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
const newsletterEnabled = !this.emailNewsletterEnabled;
|
||||
|
||||
if (newsletterEnabled) {
|
||||
this.set('settings.editorDefaultEmailRecipients', 'visibility');
|
||||
} else {
|
||||
this.set('settings.editorDefaultEmailRecipients', 'disabled');
|
||||
this.set('settings.editorDefaultEmailRecipientsFilter', null);
|
||||
}
|
||||
|
||||
this.set('recipientsSelectValue', this._getDerivedRecipientsSelectValue());
|
||||
}
|
||||
|
||||
@action
|
||||
setReplyAddress(event) {
|
||||
const newReplyAddress = event.value;
|
||||
|
||||
this.set('settings.membersReplyAddress', newReplyAddress);
|
||||
}
|
||||
|
||||
@action
|
||||
setDefaultEmailRecipients(value) {
|
||||
// Update the underlying setting properties to match the selected recipients option
|
||||
|
||||
if (['visibility', 'disabled'].includes(value)) {
|
||||
this.settings.set('editorDefaultEmailRecipients', value);
|
||||
this.settings.set('editorDefaultEmailRecipientsFilter', null);
|
||||
} else {
|
||||
this.settings.set('editorDefaultEmailRecipients', 'filter');
|
||||
}
|
||||
|
||||
if (value === 'all-members') {
|
||||
this.settings.set('editorDefaultEmailRecipientsFilter', 'status:free,status:-free');
|
||||
}
|
||||
|
||||
if (value === 'paid-only') {
|
||||
this.settings.set('editorDefaultEmailRecipientsFilter', 'status:-free');
|
||||
}
|
||||
|
||||
if (value === 'none') {
|
||||
this.settings.set('editorDefaultEmailRecipientsFilter', null);
|
||||
}
|
||||
|
||||
// Update the value used to display the selected recipients option explicitly
|
||||
// because it's local non-derived state
|
||||
this.set('recipientsSelectValue', value);
|
||||
}
|
||||
|
||||
@action
|
||||
setDefaultEmailRecipientsFilter(filter) {
|
||||
this.settings.set('editorDefaultEmailRecipientsFilter', filter);
|
||||
}
|
||||
|
||||
@(task(function* () {
|
||||
let url = this.get('ghostPaths.url').api('/settings/members/email');
|
||||
try {
|
||||
const response = yield this.ajax.post(url, {
|
||||
data: {
|
||||
email: this.fromAddress,
|
||||
type: 'fromAddressUpdate'
|
||||
}
|
||||
});
|
||||
this.toggleProperty('showFromAddressConfirmation');
|
||||
return response;
|
||||
} catch (e) {
|
||||
// Failed to send email, retry
|
||||
return false;
|
||||
}
|
||||
}).drop())
|
||||
updateFromAddress;
|
||||
|
||||
_getDerivedRecipientsSelectValue() {
|
||||
const defaultEmailRecipients = this.settings.get('editorDefaultEmailRecipients');
|
||||
const defaultEmailRecipientsFilter = this.settings.get('editorDefaultEmailRecipientsFilter');
|
||||
|
||||
if (defaultEmailRecipients === 'filter') {
|
||||
if (defaultEmailRecipientsFilter === 'status:free,status:-free') {
|
||||
return 'all-members';
|
||||
} else if (defaultEmailRecipientsFilter === 'status:-free') {
|
||||
return 'paid-only';
|
||||
} else if (defaultEmailRecipientsFilter === null) {
|
||||
return 'none';
|
||||
} else {
|
||||
return 'segment';
|
||||
}
|
||||
}
|
||||
|
||||
return defaultEmailRecipients;
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
</section>
|
||||
|
||||
{{#if this.emailNewsletterEnabled}}
|
||||
<Settings::MembersEmailLabs::NewsletterManagement />
|
||||
<Settings::Newsletters::NewsletterManagement />
|
||||
|
||||
<section class="gh-main-section">
|
||||
<h4 class="gh-main-section-header small bn">General settings</h4>
|
||||
@ -164,4 +164,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{{/if}}
|
||||
{{/if}}
|
@ -6,7 +6,7 @@ import {tracked} from '@glimmer/tracking';
|
||||
const US = {flag: '🇺🇸', name: 'US', baseUrl: 'https://api.mailgun.net/v3'};
|
||||
const EU = {flag: '🇪🇺', name: 'EU', baseUrl: 'https://api.eu.mailgun.net/v3'};
|
||||
|
||||
export default class MembersEmailLabs extends Component {
|
||||
export default class Newsletters extends Component {
|
||||
@service config;
|
||||
@service settings;
|
||||
|
@ -64,7 +64,7 @@
|
||||
</p>
|
||||
</div>
|
||||
{{else}}
|
||||
<LinkTo @route="settings.members-email-labs.edit-newsletter" @model={{newsletter.id}} class="gh-newsletter-card-block title-block">
|
||||
<LinkTo @route="settings.newsletters.edit-newsletter" @model={{newsletter.id}} class="gh-newsletter-card-block title-block">
|
||||
<h3 class="gh-newsletter-card-name">
|
||||
{{newsletter.name}}
|
||||
</h3>
|
||||
@ -87,7 +87,7 @@
|
||||
{{/if}}
|
||||
<div class="gh-newsletter-card-block cta-block">
|
||||
{{#if this.displayingDefault}}
|
||||
<LinkTo @route="settings.members-email-labs.edit-newsletter" @model={{newsletter.id}} class="gh-btn gh-btn-green" data-test-button="customize-newsletter"><span>Customize →</span></LinkTo>
|
||||
<LinkTo @route="settings.newsletters.edit-newsletter" @model={{newsletter.id}} class="gh-btn gh-btn-green" data-test-button="customize-newsletter"><span>Customize →</span></LinkTo>
|
||||
{{else}}
|
||||
<GhBasicDropdown @verticalPosition="below" @horizontalPosition="right" @renderInPlace={{true}} as |dd|>
|
||||
<dd.Trigger class="gh-btn gh-btn-action-icon gh-btn-icon gh-btn-outline gh-product-card-actions-button icon-only">
|
||||
@ -99,7 +99,7 @@
|
||||
<dd.Content class="relative-dropdown-menu gh-newsletter-actions-menu">
|
||||
<ul class="dropdown-menu dropdown-triangle-top-right" role="listbox" {{css-transition "anim-fade-in-scale"}}>
|
||||
<li>
|
||||
<LinkTo @route="settings.members-email-labs.edit-newsletter" @model={{newsletter.id}} class="mr2" data-test-button="customize-newsletter"><span>Edit</span></LinkTo>
|
||||
<LinkTo @route="settings.newsletters.edit-newsletter" @model={{newsletter.id}} class="mr2" data-test-button="customize-newsletter"><span>Edit</span></LinkTo>
|
||||
</li>
|
||||
{{#if (eq newsletter.status "active")}}
|
||||
<li>
|
||||
@ -129,6 +129,6 @@
|
||||
</div>
|
||||
</section>
|
||||
{{#if (feature "multipleNewslettersUI")}}
|
||||
<LinkTo @route="settings.members-email-labs.new-newsletter" class="gh-add-newsletter" data-test-button="add-newsletter">{{svg-jar "add-stroke"}}Add newsletter</LinkTo>
|
||||
<LinkTo @route="settings.newsletters.new-newsletter" class="gh-add-newsletter" data-test-button="add-newsletter">{{svg-jar "add-stroke"}}Add newsletter</LinkTo>
|
||||
{{/if}}
|
||||
</div>
|
@ -65,7 +65,7 @@ export default class NewsletterManagementComponent extends Component {
|
||||
// an explicit tracked filteredNewsletters property rather than using a reactive
|
||||
// getter that automatically displays newly added newsletters
|
||||
|
||||
if (transition.from.name === 'settings.members-email-labs.new-newsletter') {
|
||||
if (transition.from.name === 'settings.newsletters.new-newsletter') {
|
||||
this.updateFilteredNewsletters();
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
import Controller from '@ember/controller';
|
||||
import {action} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
export default class MembersEmailController extends Controller {
|
||||
@service config;
|
||||
@service session;
|
||||
@service settings;
|
||||
|
||||
queryParams = ['showEmailDesignSettings'];
|
||||
|
||||
// from/supportAddress are set here so that they can be reset to saved values on save
|
||||
// to avoid it looking like they've been saved when they have a separate update process
|
||||
@tracked fromAddress = '';
|
||||
@tracked supportAddress = '';
|
||||
|
||||
@tracked showEmailDesignSettings = false;
|
||||
@tracked showLeaveSettingsModal = false;
|
||||
|
||||
@action
|
||||
setEmailAddress(property, email) {
|
||||
this[property] = email;
|
||||
}
|
||||
|
||||
@action
|
||||
toggleEmailDesignSettings() {
|
||||
this.showEmailDesignSettings = !this.showEmailDesignSettings;
|
||||
}
|
||||
|
||||
leaveRoute(transition) {
|
||||
if (this.settings.get('hasDirtyAttributes')) {
|
||||
transition.abort();
|
||||
this.leaveSettingsTransition = transition;
|
||||
this.showLeaveSettingsModal = true;
|
||||
}
|
||||
this.showEmailDesignSettings = false;
|
||||
}
|
||||
|
||||
@action
|
||||
async confirmLeave() {
|
||||
this.settings.rollbackAttributes();
|
||||
this.showLeaveSettingsModal = false;
|
||||
this.leaveSettingsTransition.retry();
|
||||
}
|
||||
|
||||
@action
|
||||
cancelLeave() {
|
||||
this.showLeaveSettingsModal = false;
|
||||
this.leaveSettingsTransition = null;
|
||||
}
|
||||
|
||||
parseEmailAddress(address) {
|
||||
const emailAddress = address || 'noreply';
|
||||
// Adds default domain as site domain
|
||||
if (emailAddress.indexOf('@') < 0 && this.config.emailDomain) {
|
||||
return `${emailAddress}@${this.config.emailDomain}`;
|
||||
}
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
resetEmailAddresses() {
|
||||
this.fromAddress = this.parseEmailAddress(this.settings.get('membersFromAddress'));
|
||||
this.supportAddress = this.parseEmailAddress(this.settings.get('membersSupportAddress'));
|
||||
}
|
||||
|
||||
@task({drop: true})
|
||||
*saveSettings() {
|
||||
const response = yield this.settings.save();
|
||||
this.resetEmailAddresses();
|
||||
return response;
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
export default class MembersEmailLabsController extends Controller {
|
||||
export default class NewslettersController extends Controller {
|
||||
@service settings;
|
||||
|
||||
queryParams = ['verifyEmail'];
|
@ -42,10 +42,11 @@ Router.map(function () {
|
||||
this.route('settings');
|
||||
this.route('settings.general', {path: '/settings/general'});
|
||||
this.route('settings.membership', {path: '/settings/members'});
|
||||
this.route('settings.members-email', {path: '/settings/members-email'});
|
||||
this.route('settings.code-injection', {path: '/settings/code-injection'});
|
||||
|
||||
this.route('settings.members-email-labs', {path: '/settings/newsletters'}, function () {
|
||||
|
||||
// redirect from old /settings/members-email to /settings/newsletters
|
||||
this.route('settings.members-email', {path: '/settings/members-email'});
|
||||
this.route('settings.newsletters', {path: '/settings/newsletters'}, function () {
|
||||
this.route('new-newsletter', {path: 'new'});
|
||||
this.route('edit-newsletter', {path: ':newsletter_id'});
|
||||
});
|
||||
|
@ -1,43 +1,8 @@
|
||||
import AdminRoute from 'ghost-admin/routes/admin';
|
||||
import {action} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
|
||||
export default class MembersEmailRoute extends AdminRoute {
|
||||
@service feature;
|
||||
@service notifications;
|
||||
@service settings;
|
||||
|
||||
beforeModel(transition) {
|
||||
super.beforeModel(...arguments);
|
||||
|
||||
if (this.feature.multipleNewsletters) {
|
||||
return this.transitionTo('settings.members-email-labs');
|
||||
}
|
||||
|
||||
if (transition.to.queryParams?.fromAddressUpdate === 'success') {
|
||||
this.notifications.showAlert(
|
||||
`Newsletter email address has been updated`,
|
||||
{type: 'success', key: 'members.settings.from-address.updated'}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
model() {
|
||||
return this.settings.reload();
|
||||
}
|
||||
|
||||
setupController(controller) {
|
||||
controller.resetEmailAddresses();
|
||||
}
|
||||
|
||||
@action
|
||||
willTransition(transition) {
|
||||
return this.controller.leaveRoute(transition);
|
||||
}
|
||||
|
||||
buildRouteInfoMetadata() {
|
||||
return {
|
||||
titleToken: 'Settings - Email newsletter'
|
||||
};
|
||||
beforeModel() {
|
||||
// Moved to newsletters
|
||||
return this.replaceWith('settings.newsletters');
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,6 @@ export default class MembersEmailLabsRoute extends AdminRoute {
|
||||
confirmModal = null;
|
||||
hasConfirmed = false;
|
||||
|
||||
beforeModel() {
|
||||
super.beforeModel(...arguments);
|
||||
|
||||
if (!this.feature.multipleNewsletters) {
|
||||
return this.transitionTo('settings.members-email');
|
||||
}
|
||||
}
|
||||
|
||||
model() {
|
||||
return this.settings.reload();
|
||||
}
|
||||
@ -39,7 +31,7 @@ export default class MembersEmailLabsRoute extends AdminRoute {
|
||||
|
||||
// clear query param so it doesn't linger and cause problems re-entering route
|
||||
transition.abort();
|
||||
return this.transitionTo('settings.members-email-labs', {queryParams: {verifyEmail: null}});
|
||||
return this.transitionTo('settings.newsletters', {queryParams: {verifyEmail: null}});
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ export default class EditNewsletterRoute extends AdminRoute {
|
||||
|
||||
@action
|
||||
afterSave() {
|
||||
this.router.transitionTo('settings.members-email-labs');
|
||||
this.router.transitionTo('settings.newsletters');
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
@ -88,7 +88,7 @@ export default class EditNewsletterRoute extends AdminRoute {
|
||||
const shouldLeave = await this.confirmUnsavedChanges();
|
||||
|
||||
if (shouldLeave && !this.isLeaving) {
|
||||
this.router.transitionTo('settings.members-email-labs');
|
||||
this.router.transitionTo('settings.newsletters');
|
||||
return true;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ export default class NewNewsletterRoute extends AdminRoute {
|
||||
|
||||
@action
|
||||
afterSave() {
|
||||
this.router.transitionTo('settings.members-email-labs');
|
||||
this.router.transitionTo('settings.newsletters');
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
@ -40,7 +40,7 @@ export default class NewNewsletterRoute extends AdminRoute {
|
||||
@action
|
||||
async beforeModalClose() {
|
||||
if (!this.isLeaving) {
|
||||
this.router.transitionTo('settings.members-email-labs');
|
||||
this.router.transitionTo('settings.newsletters');
|
||||
}
|
||||
}
|
||||
}
|
@ -73,7 +73,7 @@
|
||||
</div>
|
||||
<div class="footer">
|
||||
<LinkTo class="gh-btn gh-btn-outline mt2 mr2" @route="settings.design"><span>Design</span></LinkTo>
|
||||
<LinkTo class="gh-btn gh-btn-outline mt2" @route="settings.members-email"><span>Email</span></LinkTo>
|
||||
<LinkTo class="gh-btn gh-btn-outline mt2" @route="settings.newsletters"><span>Email</span></LinkTo>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gh-dashboard-box">
|
||||
|
@ -48,7 +48,7 @@
|
||||
<p>Access, subscription, and pricing options</p>
|
||||
</div>
|
||||
</LinkTo>
|
||||
<LinkTo class="gh-setting-group" @route="settings.members-email" data-test-nav="members-email">
|
||||
<LinkTo class="gh-setting-group" @route="settings.newsletters" data-test-nav="members-email">
|
||||
<span class="yellow">{{svg-jar "email-stroke"}}</span>
|
||||
<div>
|
||||
<h4>Email newsletter</h4>
|
||||
@ -91,4 +91,4 @@
|
||||
@confirm={{action "leavePortalSettings"}}
|
||||
@close={{action "closeLeaveSettingsModal"}}
|
||||
@modifier="action wide" />
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
@ -1,48 +0,0 @@
|
||||
<section class="gh-canvas gh-setting-email">
|
||||
<GhCanvasHeader class="gh-canvas-header">
|
||||
<h2 class="gh-canvas-title" data-test-screen-title>
|
||||
<LinkTo @route="settings">Settings</LinkTo>
|
||||
<span>{{svg-jar "arrow-right"}}</span>
|
||||
Email newsletter
|
||||
</h2>
|
||||
<section class="view-actions">
|
||||
<GhTaskButton
|
||||
@buttonText="Save"
|
||||
@task={{this.saveSettings}}
|
||||
@successText="Saved"
|
||||
@runningText="Saving"
|
||||
@class="gh-btn gh-btn-primary gh-btn-icon"
|
||||
{{on-key "cmd+s"}}
|
||||
data-test-button="save-members-settings"
|
||||
/>
|
||||
</section>
|
||||
</GhCanvasHeader>
|
||||
|
||||
<section class="view-container settings-debug">
|
||||
<div class="gh-setting-liquid-section">
|
||||
<Settings::MembersEmail
|
||||
@fromAddress={{this.fromAddress}}
|
||||
@supportAddress={{this.supportAddress}}
|
||||
@setEmailAddress={{this.setEmailAddress}}
|
||||
@toggleEmailDesignSettings={{this.toggleEmailDesignSettings}}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{#if this.showLeaveSettingsModal}}
|
||||
<GhFullscreenModal
|
||||
@modal="leave-settings"
|
||||
@confirm={{this.confirmLeave}}
|
||||
@close={{this.cancelLeave}}
|
||||
@modifier="action wide"
|
||||
/>
|
||||
{{/if}}
|
||||
</section>
|
||||
|
||||
{{#if this.showEmailDesignSettings}}
|
||||
<GhFullscreenModal @modifier="full-overlay portal-settings">
|
||||
<ModalEmailDesignSettings
|
||||
@closeModal={{this.toggleEmailDesignSettings}}
|
||||
/>
|
||||
</GhFullscreenModal>
|
||||
{{/if}}
|
@ -20,7 +20,7 @@
|
||||
|
||||
<section class="view-container settings-debug">
|
||||
<div class="gh-setting-liquid-section">
|
||||
<Settings::MembersEmailLabs />
|
||||
<Settings::Newsletters />
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
@ -1,39 +0,0 @@
|
||||
import {authenticateSession} from 'ember-simple-auth/test-support';
|
||||
import {click, currentURL, find} from '@ember/test-helpers';
|
||||
import {expect} from 'chai';
|
||||
import {setupApplicationTest} from 'ember-mocha';
|
||||
import {setupMirage} from 'ember-cli-mirage/test-support';
|
||||
import {visit} from '../../helpers/visit';
|
||||
|
||||
describe('Acceptance: Settings - Members email', function () {
|
||||
const hooks = setupApplicationTest();
|
||||
setupMirage(hooks);
|
||||
|
||||
beforeEach(async function () {
|
||||
this.server.loadFixtures('configs');
|
||||
|
||||
const role = this.server.create('role', {name: 'Owner'});
|
||||
this.server.create('user', {roles: [role]});
|
||||
|
||||
return await authenticateSession();
|
||||
});
|
||||
|
||||
it('loads non-labs route', async function () {
|
||||
await visit('/settings/members-email');
|
||||
expect(currentURL()).to.equal('/settings/members-email');
|
||||
});
|
||||
|
||||
it('can manage open rate tracking', async function () {
|
||||
this.server.db.settings.update({key: 'email_track_opens'}, {value: 'true'});
|
||||
|
||||
await visit('/settings/members-email');
|
||||
expect(find('[data-test-checkbox="email-track-opens"]')).to.be.checked;
|
||||
|
||||
await click('label[for="email-track-opens"]');
|
||||
expect(find('[data-test-checkbox="email-track-opens"]')).to.not.be.checked;
|
||||
|
||||
await click('[data-test-button="save-members-settings"]');
|
||||
|
||||
expect(this.server.db.settings.findBy({key: 'email_track_opens'}).value).to.equal(false);
|
||||
});
|
||||
});
|
@ -1,12 +1,12 @@
|
||||
import {authenticateSession} from 'ember-simple-auth/test-support';
|
||||
import {click, currentURL, fillIn, find, findAll} from '@ember/test-helpers';
|
||||
import {disableLabsFlag, enableLabsFlag} from '../../helpers/labs-flag';
|
||||
import {enableLabsFlag} from '../../helpers/labs-flag';
|
||||
import {expect} from 'chai';
|
||||
import {setupApplicationTest} from 'ember-mocha';
|
||||
import {setupMirage} from 'ember-cli-mirage/test-support';
|
||||
import {visit} from '../../helpers/visit';
|
||||
|
||||
describe('Acceptance: Settings - Members email (multipleNewsletters)', function () {
|
||||
describe('Acceptance: Settings - Newsletters (multipleNewsletters)', function () {
|
||||
const hooks = setupApplicationTest();
|
||||
setupMirage(hooks);
|
||||
|
||||
@ -21,12 +21,6 @@ describe('Acceptance: Settings - Members email (multipleNewsletters)', function
|
||||
return await authenticateSession();
|
||||
});
|
||||
|
||||
it('without flag - redirects labs to original', async function () {
|
||||
disableLabsFlag(this.server, 'multipleNewsletters');
|
||||
await visit('/settings/newsletters');
|
||||
expect(currentURL()).to.equal('/settings/members-email');
|
||||
});
|
||||
|
||||
it('with flag - redirects original to labs', async function () {
|
||||
await visit('/settings/members-email');
|
||||
expect(currentURL()).to.equal('/settings/newsletters');
|
||||
@ -47,7 +41,7 @@ describe('Acceptance: Settings - Members email (multipleNewsletters)', function
|
||||
});
|
||||
});
|
||||
|
||||
describe('Acceptance: Settings - Members email (multipleNewslettersUI)', function () {
|
||||
describe('Acceptance: Settings - Newsletters (multipleNewslettersUI)', function () {
|
||||
const hooks = setupApplicationTest();
|
||||
setupMirage(hooks);
|
||||
|
Loading…
Reference in New Issue
Block a user