mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Added error for incorrect mailgun config in publish and settings menu
This commit is contained in:
parent
04d1efac5f
commit
2aa781eef1
3 changed files with 31 additions and 8 deletions
|
@ -30,7 +30,7 @@ export default Component.extend(SettingsMenuMixin, {
|
||||||
_showThrobbers: false,
|
_showThrobbers: false,
|
||||||
|
|
||||||
emailTestScratch: '',
|
emailTestScratch: '',
|
||||||
isValidTestEmail: true,
|
sendTestEmailError: '',
|
||||||
canonicalUrlScratch: alias('post.canonicalUrlScratch'),
|
canonicalUrlScratch: alias('post.canonicalUrlScratch'),
|
||||||
customExcerptScratch: alias('post.customExcerptScratch'),
|
customExcerptScratch: alias('post.customExcerptScratch'),
|
||||||
codeinjectionFootScratch: alias('post.codeinjectionFootScratch'),
|
codeinjectionFootScratch: alias('post.codeinjectionFootScratch'),
|
||||||
|
@ -550,15 +550,28 @@ export default Component.extend(SettingsMenuMixin, {
|
||||||
this.set('_showThrobbers', true);
|
this.set('_showThrobbers', true);
|
||||||
}).restartable(),
|
}).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* () {
|
sendTestEmail: task(function* () {
|
||||||
try {
|
try {
|
||||||
const resourceId = this.post.id;
|
const resourceId = this.post.id;
|
||||||
const testEmail = this.emailTestScratch.trim();
|
const testEmail = this.emailTestScratch.trim();
|
||||||
if (!validator.isEmail(testEmail)) {
|
if (!validator.isEmail(testEmail)) {
|
||||||
this.set('isValidTestEmail', false);
|
this.set('sendTestEmailError', 'Please enter a valid email');
|
||||||
return false;
|
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 url = this.get('ghostPaths.url').api('/email_preview/posts', resourceId);
|
||||||
const data = {emails: [testEmail]};
|
const data = {emails: [testEmail]};
|
||||||
const options = {
|
const options = {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {inject as service} from '@ember/service';
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
feature: service(),
|
feature: service(),
|
||||||
|
settings: service(),
|
||||||
post: null,
|
post: null,
|
||||||
saveType: null,
|
saveType: null,
|
||||||
|
|
||||||
|
@ -16,7 +16,17 @@ export default Component.extend({
|
||||||
|
|
||||||
'data-test-publishmenu-draft': true,
|
'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() {
|
didInsertElement() {
|
||||||
this.post.set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
|
this.post.set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
|
||||||
|
|
|
@ -359,9 +359,9 @@
|
||||||
input=(action (mut emailTestScratch) value="target.value")
|
input=(action (mut emailTestScratch) value="target.value")
|
||||||
stopEnterKeyDownPropagation=true
|
stopEnterKeyDownPropagation=true
|
||||||
data-test-field="email-test"}}
|
data-test-field="email-test"}}
|
||||||
{{#unless isValidTestEmail}}
|
{{#if sendTestEmailError}}
|
||||||
<div class="error"><p class="response">Please enter a valid email</p></div>
|
<div class="error"><p class="response">{{sendTestEmailError}}</p></div>
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
{{gh-task-button "Send test email"
|
{{gh-task-button "Send test email"
|
||||||
task=sendTestEmail
|
task=sendTestEmail
|
||||||
successText="Email sent"
|
successText="Email sent"
|
||||||
|
|
Loading…
Add table
Reference in a new issue