mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 22:34:07 +03:00
Added error for incorrect mailgun config in publish and settings menu
This commit is contained in:
parent
04d1efac5f
commit
2aa781eef1
@ -30,7 +30,7 @@ export default Component.extend(SettingsMenuMixin, {
|
||||
_showThrobbers: false,
|
||||
|
||||
emailTestScratch: '',
|
||||
isValidTestEmail: true,
|
||||
sendTestEmailError: '',
|
||||
canonicalUrlScratch: alias('post.canonicalUrlScratch'),
|
||||
customExcerptScratch: alias('post.customExcerptScratch'),
|
||||
codeinjectionFootScratch: alias('post.codeinjectionFootScratch'),
|
||||
@ -550,15 +550,28 @@ export default Component.extend(SettingsMenuMixin, {
|
||||
this.set('_showThrobbers', true);
|
||||
}).restartable(),
|
||||
|
||||
isMailgunConfigured: function () {
|
||||
let subSettingsValue = this.get('settings.membersSubscriptionSettings');
|
||||
let subscriptionSettings = subSettingsValue ? JSON.parse(subSettingsValue) : {};
|
||||
if (Object.keys(subscriptionSettings).includes('mailgunApiKey')) {
|
||||
return (subscriptionSettings.mailgunApiKey && subscriptionSettings.mailgunDomain);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
sendTestEmail: task(function* () {
|
||||
try {
|
||||
const resourceId = this.post.id;
|
||||
const testEmail = this.emailTestScratch.trim();
|
||||
if (!validator.isEmail(testEmail)) {
|
||||
this.set('isValidTestEmail', false);
|
||||
this.set('sendTestEmailError', 'Please enter a valid email');
|
||||
return false;
|
||||
}
|
||||
this.set('isValidTestEmail', true);
|
||||
if (!this.isMailgunConfigured()) {
|
||||
this.set('sendTestEmailError', 'Please configure mailgun in settings');
|
||||
return false;
|
||||
}
|
||||
this.set('sendTestEmailError', '');
|
||||
const url = this.get('ghostPaths.url').api('/email_preview/posts', resourceId);
|
||||
const data = {emails: [testEmail]};
|
||||
const options = {
|
||||
|
@ -6,7 +6,7 @@ import {inject as service} from '@ember/service';
|
||||
|
||||
export default Component.extend({
|
||||
feature: service(),
|
||||
|
||||
settings: service(),
|
||||
post: null,
|
||||
saveType: null,
|
||||
|
||||
@ -16,7 +16,17 @@ export default Component.extend({
|
||||
|
||||
'data-test-publishmenu-draft': true,
|
||||
|
||||
disableEmailOption: computed.equal('memberCount', 0),
|
||||
disableEmailOption: computed('memberCount', 'settings.membersSubscriptionSettings', function () {
|
||||
if (!this.feature.members) {
|
||||
return true;
|
||||
}
|
||||
let subSettingsValue = this.get('settings.membersSubscriptionSettings');
|
||||
let subscriptionSettings = subSettingsValue ? JSON.parse(subSettingsValue) : {};
|
||||
if (Object.keys(subscriptionSettings).includes('mailgunApiKey')) {
|
||||
return !subscriptionSettings.mailgunApiKey || !subscriptionSettings.mailgunDomain || this.membersCount === 0;
|
||||
}
|
||||
return this.membersCount === 0;
|
||||
}),
|
||||
|
||||
didInsertElement() {
|
||||
this.post.set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
|
||||
|
@ -359,9 +359,9 @@
|
||||
input=(action (mut emailTestScratch) value="target.value")
|
||||
stopEnterKeyDownPropagation=true
|
||||
data-test-field="email-test"}}
|
||||
{{#unless isValidTestEmail}}
|
||||
<div class="error"><p class="response">Please enter a valid email</p></div>
|
||||
{{/unless}}
|
||||
{{#if sendTestEmailError}}
|
||||
<div class="error"><p class="response">{{sendTestEmailError}}</p></div>
|
||||
{{/if}}
|
||||
{{gh-task-button "Send test email"
|
||||
task=sendTestEmail
|
||||
successText="Email sent"
|
||||
|
Loading…
Reference in New Issue
Block a user