Better error messages if the "Send Test Email" button fails.

This commit is contained in:
Robin Ward 2014-03-18 15:25:16 -04:00
parent fa4bc90fbb
commit d0edfe2179
3 changed files with 16 additions and 3 deletions

View File

@ -31,14 +31,21 @@ Discourse.AdminEmailIndexController = Discourse.Controller.extend({
@method sendTestEmail @method sendTestEmail
**/ **/
sendTestEmail: function() { sendTestEmail: function() {
this.set('sentTestEmail', false); this.setProperties({
sendingEmail: true,
sentTestEmail: false
});
var adminEmailLogsController = this; var self = this;
Discourse.ajax("/admin/email/test", { Discourse.ajax("/admin/email/test", {
type: 'POST', type: 'POST',
data: { email_address: this.get('testEmailAddress') } data: { email_address: this.get('testEmailAddress') }
}).then(function () { }).then(function () {
adminEmailLogsController.set('sentTestEmail', true); self.set('sentTestEmail', true);
}).catch(function () {
bootbox.alert(I18n.t('admin.email.test_error'));
}).finally(function() {
self.set('sendingEmail', false);
}); });
} }

View File

@ -13,6 +13,9 @@
</table> </table>
<div class='admin-controls'> <div class='admin-controls'>
{{#if sendingEmail}}
<div class='span15 controls'>{{i18n admin.email.sending_test}}</div>
{{else}}
<div class='span5 controls'> <div class='span5 controls'>
{{textField value=testEmailAddress placeholderKey="admin.email.test_email_address"}} {{textField value=testEmailAddress placeholderKey="admin.email.test_email_address"}}
</div> </div>
@ -20,4 +23,5 @@
<button class='btn' {{action sendTestEmail}} {{bind-attr disabled="sendTestEmailDisabled"}}>{{i18n admin.email.send_test}}</button> <button class='btn' {{action sendTestEmail}} {{bind-attr disabled="sendTestEmailDisabled"}}>{{i18n admin.email.send_test}}</button>
{{#if sentTestEmail}}<span class='result-message'>{{i18n admin.email.sent_test}}</span>{{/if}} {{#if sentTestEmail}}<span class='result-message'>{{i18n admin.email.sent_test}}</span>{{/if}}
</div> </div>
{{/if}}
</div> </div>

View File

@ -1414,6 +1414,8 @@ en:
title: "Email" title: "Email"
settings: "Settings" settings: "Settings"
all: "All" all: "All"
sending_test: "Sending test Email..."
test_error: "There was an issue sending email. Please check your settings and try again."
sent: "Sent" sent: "Sent"
skipped: "Skipped" skipped: "Skipped"
sent_at: "Sent At" sent_at: "Sent At"