From d25b94fb77183480352276a53493b82de4e7363b Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Thu, 28 Apr 2022 12:01:25 +0200 Subject: [PATCH] Fixed sender name and email in email preview link refs https://github.com/TryGhost/Team/issues/1568 Sender name and email of newsletter was not used in the preview. --- .../admin/app/components/modals/email-preview.hbs | 4 ++-- .../admin/app/components/modals/email-preview.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ghost/admin/app/components/modals/email-preview.hbs b/ghost/admin/app/components/modals/email-preview.hbs index 5898584543..503f50312a 100644 --- a/ghost/admin/app/components/modals/email-preview.hbs +++ b/ghost/admin/app/components/modals/email-preview.hbs @@ -20,7 +20,7 @@

- {{this.config.blogTitle}} <{{this.settings.membersFromAddress}}> + {{or this.newsletter.senderName this.settings.title}} <{{full-email-address (or this.newsletter.senderEmail "noreply")}}>

To: Jamie Larson <jamie@example.com>

@@ -35,7 +35,7 @@

- {{this.config.blogTitle}} <{{this.settings.membersFromAddress}}> + {{or this.newsletter.senderName this.settings.title}} <{{full-email-address (or this.newsletter.senderEmail "noreply")}}>

To: Jamie Larson <jamie@example.com>

diff --git a/ghost/admin/app/components/modals/email-preview.js b/ghost/admin/app/components/modals/email-preview.js index e70f44090c..0608302bde 100644 --- a/ghost/admin/app/components/modals/email-preview.js +++ b/ghost/admin/app/components/modals/email-preview.js @@ -20,6 +20,7 @@ export default class EmailPreviewModal extends Component { @service config; @service ghostPaths; @service settings; + @service store; static modalOptions = { className: 'fullscreen-modal-full-overlay fullscreen-modal-email-preview' @@ -27,6 +28,7 @@ export default class EmailPreviewModal extends Component { @tracked tab = 'desktop'; @tracked subject = null; + @tracked newsletter = null; // cached to avoid re-fetching when changing tabs html = null; @@ -52,6 +54,19 @@ export default class EmailPreviewModal extends Component { async _fetchEmailData() { let {html, subject} = this; + // Fetch newsletter + if (!this.newsletter && this.args.data.newsletterId) { + const newsletters = (await this.store.query('newsletter', {filter: 'status:active+id:' + this.args.data.newsletterId, limit: 1})).toArray(); + const defaultNewsletter = newsletters[0]; + this.newsletter = defaultNewsletter; + } + + if (!this.newsletter) { + const newsletters = (await this.store.query('newsletter', {filter: 'status:active', limit: 1})).toArray(); + const defaultNewsletter = newsletters[0]; + this.newsletter = defaultNewsletter; + } + if (html && subject) { return; }