1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

Added send test email button loading states

This commit is contained in:
Rish 2019-11-07 09:58:02 +07:00
parent 2cde1ea276
commit c36c7a1950
2 changed files with 25 additions and 18 deletions

View file

@ -413,18 +413,6 @@ export default Component.extend(SettingsMenuMixin, {
});
},
async sendTestEmail() {
const resourceId = this.post.id;
const testEmail = this.emailTestScratch;
const url = this.get('ghostPaths.url').api('/email_preview/posts', resourceId);
const data = {emails: [testEmail]};
const options = {
data,
dataType: 'json'
};
await this.ajax.post(url, options);
},
setEmailSubject(emailSubject) {
// Grab the post and current stored email subject
let post = this.post;
@ -560,6 +548,24 @@ export default Component.extend(SettingsMenuMixin, {
this.set('_showThrobbers', true);
}).restartable(),
sendTestEmail: task(function* () {
try {
const resourceId = this.post.id;
const testEmail = this.emailTestScratch;
const url = this.get('ghostPaths.url').api('/email_preview/posts', resourceId);
const data = {emails: [testEmail]};
const options = {
data,
dataType: 'json'
};
return yield this.ajax.post(url, options);
} catch (error) {
if (error) {
this.notifications.showAPIError(error, {key: 'send.previewEmail'});
}
}
}).drop(),
showError(error) {
// TODO: remove null check once ValidationEngine has been removed
if (error) {

View file

@ -359,12 +359,13 @@
stopEnterKeyDownPropagation=true
data-test-field="email-test"}}
<button type="button" class="gh-btn w-100 mt2"
onclick={{action "sendTestEmail"}} data-test-button="send-test-email">
<span>
Send Test Email
</span>
</button>
{{gh-task-button "Send Test Email"
task=sendTestEmail
successText="Sent"
runningText="Sending..."
class="gh-btn w-100 mt2 gh-btn-icon"
data-test-send-test-mail=true
}}
</div>
</form>
</div>