Updated mailgun check to use isEnabled from settings

no issue
This commit is contained in:
Rish 2019-11-13 09:32:08 +05:30 committed by Rishabh Garg
parent 6a972d8b9e
commit db899a90f0
2 changed files with 4 additions and 24 deletions

View File

@ -26,7 +26,7 @@ export default Component.extend({
testEmailAddress: oneWay('session.user.email'),
mailgunError: computed('settings.memberSubscriptionSettings', function () {
return !this._isMailgunConfigured();
return !this.settings.get('bulkEmailSettings.isEnabled');
}),
actions: {
@ -70,7 +70,7 @@ export default Component.extend({
this.set('sendTestEmailError', 'Please enter a valid email');
return false;
}
if (!this._isMailgunConfigured()) {
if (!this.settings.get('bulkEmailSettings.isEnabled')) {
this.set('sendTestEmailError', 'Please configure Mailgun in Labs → Members');
return false;
}
@ -87,15 +87,5 @@ export default Component.extend({
this.notifications.showAPIError(error, {key: 'send.previewEmail'});
}
}
}).drop(),
// TODO: put this on settings model
_isMailgunConfigured() {
let subSettingsValue = this.settings.get('membersSubscriptionSettings');
let subscriptionSettings = subSettingsValue ? JSON.parse(subSettingsValue) : {};
if (Object.keys(subscriptionSettings).includes('mailgunApiKey')) {
return (subscriptionSettings.mailgunApiKey && subscriptionSettings.mailgunDomain);
}
return true;
}
}).drop()
});

View File

@ -21,7 +21,7 @@ export default Component.extend({
canSendEmail: computed('feature.labs.members', 'post.{displayName,email}', function () {
let membersEnabled = this.feature.get('labs.members');
let mailgunIsConfigured = this._isMailgunConfigured();
let mailgunIsConfigured = this.get('settings.bulkEmailSettings.isEnabled');
let isPost = this.post.displayName === 'post';
let hasSentEmail = !!this.post.email;
@ -81,16 +81,6 @@ export default Component.extend({
}
},
// TODO: put this on settings model
_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 false;
},
// API only accepts dates at least 2 mins in the future, default the
// scheduled date 5 mins in the future to avoid immediate validation errors
_getMinDate() {