Ghost/ghost/admin/app/components/editor-labs/modals/preview.hbs
Kevin Ansfield 5415fb6e01 Updated post email preview to render with the selected newsletter (#2382)
refs https://github.com/TryGhost/Team/issues/1621
reqs https://github.com/TryGhost/Ghost/pull/14820

We want to allow previewing emails based on the newsletter selected in the publish flow.

- passed the selected newsletter from `<PublishManagement>` through to the preview modal then through to the email preview component
- removed tracked `newsletter` property and fetching of the default newsletter in the email preview component that was in place to allow `senderName` and `senderEmail` to be used in the component
- added `newsletter` getter that uses the `post.newsletter` or the passed in selected newsletter
- updated the email preview fetching to pass `?newsletter=slug` so the email is rendered with the correct newlsetter
2022-05-16 12:16:12 +01:00

58 lines
2.8 KiB
Handlebars

<div class="flex flex-column h-100">
<header class="modal-header gh-post-preview-header" data-test-modal="preview-email">
<div class="left">
<button class="gh-editor-back-button" title="Close" type="button" {{on "click" @close}}>
<span>{{svg-jar "arrow-left"}} Editor</span>
</button>
</div>
<div class="gh-post-preview-btn-group">
<div class="gh-contentfilter gh-btn-group">
<button type="button" class="gh-btn {{if (eq this.tab "browser") "gh-btn-group-selected"}} gh-post-preview-mode" {{on "click" (fn this.changeTab "browser")}}><span>{{svg-jar "desktop"}}</span></button>
<button type="button" class="gh-btn {{if (eq this.tab "mobile") "gh-btn-group-selected"}} gh-post-preview-mode" {{on "click" (fn this.changeTab "mobile")}}><span>{{svg-jar "mobile-phone"}}</span></button>
{{#if (and (not-eq this.settings.membersSignupAccess "none") (not-eq this.settings.editorDefaultEmailRecipients "disabled"))}}
{{#if @data.post.isPost}}
<button type="button" class="gh-btn {{if (eq this.tab "email") "gh-btn-group-selected"}} gh-post-preview-mode" {{on "click" (fn this.changeTab "email")}}><span>{{svg-jar "email-unread"}}</span></button>
{{/if}}
{{/if}}
<button type="button" class="gh-btn {{if (eq this.tab "social") "gh-btn-group-selected"}} gh-post-preview-mode" {{on "click" (fn this.changeTab "social")}}><span>{{svg-jar "twitter"}}</span></button>
</div>
</div>
<div class="right">
<button
type="button"
class="gh-btn gh-editor-preview-trigger active"
{{on "click" @close}}
>
<span>Preview</span>
</button>
<button
type="button"
class="gh-btn gh-btn-editor darkgrey gh-publish-trigger"
{{on "click" @data.togglePreviewPublish}}
>
<span>Publish</span>
</button>
<div class="settings-menu-toggle-spacer"></div>
</div>
</header>
{{#if this.saveFirstTask.isRunning}}
<GhLoadingSpinner />
{{else}}
{{#if (eq this.tab "browser")}}
<EditorLabs::Modals::Preview::Browser @post={{@data.post}} />
{{/if}}
{{#if (and (eq this.tab "mobile"))}}
<EditorLabs::Modals::Preview::Mobile @post={{@data.post}} />
{{/if}}
{{#if (and (eq this.tab "email") @data.post.isPost)}}
<EditorLabs::Modals::Preview::Email @post={{@data.post}} @newsletter={{@data.newsletter}} />
{{/if}}
{{#if (eq this.tab "social")}}
<EditorLabs::Modals::Preview::Social @post={{@data.post}} />
{{/if}}
{{/if}}
</div>