Updated labs to use new mailgun_* settings (#1628)
refs https://github.com/TryGhost/Ghost/issues/10318 This removes references to the old bulk_email_settings
This commit is contained in:
parent
7517373176
commit
3e21c21d12
|
@ -318,7 +318,7 @@
|
|||
</div>
|
||||
</section>
|
||||
{{/if}}
|
||||
{{#unless this.hasBulkEmailConfig}}
|
||||
{{#unless this.mailgunIsConfigured}}
|
||||
<section class="bb b--whitegrey pa5">
|
||||
<div class="flex justify-between">
|
||||
<div>
|
||||
|
@ -341,7 +341,7 @@
|
|||
<PowerSelect
|
||||
@options={{this.mailgunRegions}}
|
||||
@selected={{this.mailgunRegion}}
|
||||
@onChange={{action "setBulkEmailRegion"}}
|
||||
@onChange={{action "setMailgunRegion"}}
|
||||
@searchEnabled={{false}}
|
||||
@triggerComponent="gh-power-select/trigger"
|
||||
as |region|
|
||||
|
@ -353,8 +353,8 @@
|
|||
<GhFormGroup>
|
||||
<label class="fw6 f8">Mailgun domain</label>
|
||||
<GhTextInput
|
||||
@value={{readonly this.bulkEmailSettings.domain}}
|
||||
@input={{action "setBulkEmailSettings" "domain"}}
|
||||
@value={{readonly this.mailgunSettings.domain}}
|
||||
@input={{action "setMailgunDomain"}}
|
||||
@class="mt1"
|
||||
/>
|
||||
</GhFormGroup>
|
||||
|
@ -368,8 +368,8 @@
|
|||
<label class="fw6 f8">Mailgun API key</label>
|
||||
<GhTextInput
|
||||
@type="password"
|
||||
@value={{readonly this.bulkEmailSettings.apiKey}}
|
||||
@input={{action "setBulkEmailSettings" "apiKey"}}
|
||||
@value={{readonly this.mailgunSettings.apiKey}}
|
||||
@input={{action "setMailgunApiKey"}}
|
||||
@class="mt1 password" @autocomplete="new-password"
|
||||
/>
|
||||
<a href="https://app.mailgun.com/app/account/security/api_keys" target="_blank" class="mt1 fw4 f8">
|
||||
|
|
|
@ -2,7 +2,6 @@ import Component from '@ember/component';
|
|||
import {computed} from '@ember/object';
|
||||
import {reads} from '@ember/object/computed';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {set} from '@ember/object';
|
||||
import {task} from 'ember-concurrency';
|
||||
|
||||
const US = {flag: '🇺🇸', name: 'US', baseUrl: 'https://api.mailgun.net/v3'};
|
||||
|
@ -51,6 +50,8 @@ export default Component.extend({
|
|||
|
||||
stripeDirect: reads('config.stripeDirect'),
|
||||
|
||||
mailgunIsConfigured: reads('config.mailgunIsConfigured'),
|
||||
|
||||
allowSelfSignup: reads('settings.membersAllowFreeSignup'),
|
||||
|
||||
/** OLD **/
|
||||
|
@ -79,13 +80,13 @@ export default Component.extend({
|
|||
return (domainExp && domainExp[1]) || '';
|
||||
}),
|
||||
|
||||
mailgunRegion: computed('settings.bulkEmailSettings.baseUrl', function () {
|
||||
if (!this.settings.get('bulkEmailSettings.baseUrl')) {
|
||||
mailgunRegion: computed('settings.mailgunBaseUrl', function () {
|
||||
if (!this.settings.get('mailgunBaseUrl')) {
|
||||
return US;
|
||||
}
|
||||
|
||||
return [US, EU].find((region) => {
|
||||
return region.baseUrl === this.settings.get('bulkEmailSettings.baseUrl');
|
||||
return region.baseUrl === this.settings.get('mailgunBaseUrl');
|
||||
});
|
||||
}),
|
||||
|
||||
|
@ -106,15 +107,12 @@ export default Component.extend({
|
|||
};
|
||||
}),
|
||||
|
||||
bulkEmailSettings: computed('settings.bulkEmailSettings', function () {
|
||||
let bulkEmailSettings = this.get('settings.bulkEmailSettings') || {};
|
||||
const {apiKey = '', baseUrl = US.baseUrl, domain = ''} = bulkEmailSettings;
|
||||
return {apiKey, baseUrl, domain};
|
||||
}),
|
||||
|
||||
hasBulkEmailConfig: computed('settings.bulkEmailSettings', function () {
|
||||
let bulkEmailSettings = this.get('settings.bulkEmailSettings');
|
||||
return !!bulkEmailSettings.isConfig;
|
||||
mailgunSettings: computed('settings.{mailgunBaseUrl,mailgunApiKey,mailgunDomain}', function () {
|
||||
return {
|
||||
apiKey: this.get('settings.mailgunApiKey') || '',
|
||||
domain: this.get('settings.mailgunDomain') || '',
|
||||
baseUrl: this.get('settings.mailgunBaseUrl') || ''
|
||||
};
|
||||
}),
|
||||
|
||||
init() {
|
||||
|
@ -136,19 +134,16 @@ export default Component.extend({
|
|||
this.setDefaultContentVisibility(value);
|
||||
},
|
||||
|
||||
setBulkEmailSettings(key, event) {
|
||||
let bulkEmailSettings = this.get('settings.bulkEmailSettings') || {};
|
||||
bulkEmailSettings[key] = event.target.value;
|
||||
if (!bulkEmailSettings.baseUrl) {
|
||||
set(bulkEmailSettings, 'baseUrl', US.baseUrl);
|
||||
}
|
||||
this.setBulkEmailSettings(bulkEmailSettings);
|
||||
setMailgunDomain(event) {
|
||||
this.set('settings.mailgunDomain', event.target.value);
|
||||
},
|
||||
|
||||
setBulkEmailRegion(region) {
|
||||
let bulkEmailSettings = this.get('settings.bulkEmailSettings') || {};
|
||||
set(bulkEmailSettings, 'baseUrl', region.baseUrl);
|
||||
this.setBulkEmailSettings(bulkEmailSettings);
|
||||
setMailgunApiKey(event) {
|
||||
this.set('settings.mailgunApiKey', event.target.value);
|
||||
},
|
||||
|
||||
setMailgunRegion(region) {
|
||||
this.set('settings.mailgunBaseUrl', region.baseUrl);
|
||||
},
|
||||
|
||||
setFromAddress(fromAddress) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import Component from '@ember/component';
|
|||
import EmailFailedError from 'ghost-admin/errors/email-failed-error';
|
||||
import validator from 'validator';
|
||||
import {action} from '@ember/object';
|
||||
import {alias, oneWay, or} from '@ember/object/computed';
|
||||
import {alias, not, oneWay, or} from '@ember/object/computed';
|
||||
import {computed} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task, timeout} from 'ember-concurrency';
|
||||
|
@ -16,6 +16,7 @@ export default Component.extend({
|
|||
notifications: service(),
|
||||
session: service(),
|
||||
settings: service(),
|
||||
config: service(),
|
||||
|
||||
post: null,
|
||||
sendTestEmailError: '',
|
||||
|
@ -29,8 +30,10 @@ export default Component.extend({
|
|||
|
||||
testEmailAddress: oneWay('session.user.email'),
|
||||
|
||||
mailgunError: computed('settings.memberSubscriptionSettings', function () {
|
||||
return !this.settings.get('bulkEmailSettings.isEnabled');
|
||||
mailgunError: not('mailgunIsEnabled'),
|
||||
|
||||
mailgunIsEnabled: computed('settings.{mailgunApiKey,mailgunDomain,mailgunBaseUrl}', 'config.mailgunIsConfigured', function () {
|
||||
return this.get('settings.mailgunApiKey') && this.get('settings.mailgunDomain') && this.get('settings.mailgunBaseUrl') || this.get('config.mailgunIsConfigured');
|
||||
}),
|
||||
|
||||
actions: {
|
||||
|
@ -74,7 +77,7 @@ export default Component.extend({
|
|||
this.set('sendTestEmailError', 'Please enter a valid email');
|
||||
return false;
|
||||
}
|
||||
if (!this.settings.get('bulkEmailSettings.isEnabled')) {
|
||||
if (!this.get('mailgunIsEnabled')) {
|
||||
this.set('sendTestEmailError', 'Please verify your email settings');
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import {inject as service} from '@ember/service';
|
|||
export default Component.extend({
|
||||
feature: service(),
|
||||
settings: service(),
|
||||
config: service(),
|
||||
session: service(),
|
||||
post: null,
|
||||
saveType: null,
|
||||
|
@ -24,9 +25,9 @@ export default Component.extend({
|
|||
return (this.get('session.user.isOwnerOrAdmin') && this.memberCount === 0);
|
||||
}),
|
||||
|
||||
canSendEmail: computed('feature.labs.members', 'post.{displayName,email}', function () {
|
||||
canSendEmail: computed('feature.labs.members', 'post.{displayName,email}', 'settings.{mailgunApiKey,mailgunDomain,mailgunBaseUrl}', 'config.mailgunIsConfigured', function () {
|
||||
let membersEnabled = this.feature.get('labs.members');
|
||||
let mailgunIsConfigured = this.get('settings.bulkEmailSettings.isEnabled');
|
||||
let mailgunIsConfigured = this.get('settings.mailgunApiKey') && this.get('settings.mailgunDomain') && this.get('settings.mailgunBaseUrl') || this.get('config.mailgunIsConfigured');
|
||||
let isPost = this.post.displayName === 'post';
|
||||
let hasSentEmail = !!this.post.email;
|
||||
|
||||
|
|
|
@ -184,10 +184,6 @@ export default Controller.extend({
|
|||
this.set('settings.stripeConnectIntegrationToken', stripeConnectIntegrationToken);
|
||||
},
|
||||
|
||||
setBulkEmailSettings(bulkEmailSettings) {
|
||||
this.set('settings.bulkEmailSettings', bulkEmailSettings);
|
||||
},
|
||||
|
||||
setFromAddress(fromAddress) {
|
||||
this.set('fromAddress', fromAddress);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ export default Model.extend(ValidationEngine, {
|
|||
ogTitle: attr('string'),
|
||||
ogDescription: attr('string'),
|
||||
ogImage: attr('string'),
|
||||
bulkEmailSettings: attr('json-string'),
|
||||
mailgunApiKey: attr('string'),
|
||||
mailgunDomain: attr('string'),
|
||||
mailgunBaseUrl: attr('string'),
|
||||
portalButton: attr('boolean'),
|
||||
portalName: attr('boolean'),
|
||||
portalPlans: attr('json-string'),
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
@fromAddress={{this.fromAddress}}
|
||||
@setDefaultContentVisibility={{action "setDefaultContentVisibility"}}
|
||||
@setStripeConnectIntegrationTokenSetting={{action "setStripeConnectIntegrationTokenSetting"}}
|
||||
@setBulkEmailSettings={{action "setBulkEmailSettings"}}
|
||||
@setFromAddress={{action "setFromAddress"}}
|
||||
/>
|
||||
<div class="mt5 pl5 pr5 pb5">
|
||||
|
|
Loading…
Reference in New Issue