diff --git a/ghost/admin/app/components/gh-post-settings-menu.js b/ghost/admin/app/components/gh-post-settings-menu.js index a2b153df2a..e52b020d7e 100644 --- a/ghost/admin/app/components/gh-post-settings-menu.js +++ b/ghost/admin/app/components/gh-post-settings-menu.js @@ -15,6 +15,7 @@ export default Component.extend(SettingsMenuMixin, { feature: service(), store: service(), config: service(), + ajax: service(), ghostPaths: service(), notifications: service(), slugGenerator: service(), @@ -27,6 +28,7 @@ export default Component.extend(SettingsMenuMixin, { _showSettingsMenu: false, _showThrobbers: false, + emailTestScratch: '', canonicalUrlScratch: alias('post.canonicalUrlScratch'), customExcerptScratch: alias('post.customExcerptScratch'), codeinjectionFootScratch: alias('post.codeinjectionFootScratch'), @@ -46,7 +48,7 @@ export default Component.extend(SettingsMenuMixin, { twitterDescription: or('twitterDescriptionScratch', 'customExcerptScratch', 'seoDescription'), twitterImage: or('post.twitterImage', 'post.featureImage'), twitterTitle: or('twitterTitleScratch', 'seoTitle'), - emailSubject: alias('emailSubjectScratch', 'post.title'), + emailSubject: or('emailSubjectScratch', 'post.title'), showVisibilityInput: or('session.user.isOwner', 'session.user.isAdmin', 'session.user.isEditor'), @@ -410,6 +412,19 @@ export default Component.extend(SettingsMenuMixin, { return this.savePost.perform(); }); }, + + 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' + }; + console.log('Resource id', resourceId, url, options); + await this.ajax.post(url, options); + }, setEmailSubject(emailSubject) { // Grab the post and current stored email subject diff --git a/ghost/admin/app/components/modal-post-email-preview.js b/ghost/admin/app/components/modal-post-email-preview.js index 7b36a27d9a..83431bffeb 100644 --- a/ghost/admin/app/components/modal-post-email-preview.js +++ b/ghost/admin/app/components/modal-post-email-preview.js @@ -22,7 +22,7 @@ export default ModalComponent.extend({ const url = this.get('ghostPaths.url').api('/email_preview/posts', resourceId); let htmlData = this.get('previewHtml'); if (!htmlData) { - const response = await this.ajax.request(`${url}`); + const response = await this.ajax.request(url); let [emailPreview] = response.email_previews; htmlData = emailPreview.html; } diff --git a/ghost/admin/app/templates/components/gh-post-settings-menu.hbs b/ghost/admin/app/templates/components/gh-post-settings-menu.hbs index d5d8e95789..dd8aa242c0 100644 --- a/ghost/admin/app/templates/components/gh-post-settings-menu.hbs +++ b/ghost/admin/app/templates/components/gh-post-settings-menu.hbs @@ -339,22 +339,21 @@ {{/gh-form-group}}