Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Display basic info in PSM once an email has been sent
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinansfield committed Nov 8, 2019
1 parent f5f8430 commit a360859
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 57 deletions.
4 changes: 2 additions & 2 deletions app/models/email.js
Expand Up @@ -13,9 +13,9 @@ export default Model.extend({
submittedAtUTC: attr('moment-utc'),
uuid: attr('string'),

createdAtUTC: attr('string'),
createdAtUTC: attr('moment-utc'),
createdBy: attr('string'),
updatedAtUTC: attr('string'),
updatedAtUTC: attr('moment-utc'),
updatedBy: attr('string'),

post: belongsTo('post')
Expand Down
10 changes: 10 additions & 0 deletions app/serializers/email.js
@@ -0,0 +1,10 @@
/* eslint-disable camelcase */
import ApplicationSerializer from 'ghost-admin/serializers/application';

export default ApplicationSerializer.extend({
attrs: {
createdAtUTC: {key: 'created_at'},
updatedAtUTC: {key: 'updated_at'},
submittedAtUTC: {key: 'submitted_at'}
}
});
120 changes: 65 additions & 55 deletions app/templates/components/gh-post-settings-menu/email.hbs
Expand Up @@ -5,65 +5,75 @@
</div>

<div class="settings-menu-content settings-menu-email">
{{#if mailgunError}}
<p class="gh-box gh-box-warning settings-menu-mailgun-warning">
{{svg-jar "info" class="w5 h5 fill-yellow nl1"}}
You need to configure Mailgun in {{#link-to "settings.labs" data-test-nav="labs"}}Labs → Members settings{{/link-to}} to enable email newsletters.
</p>
{{/if}}
<form {{action "discardEnter" on="submit"}}>
{{#gh-form-group errors=post.errors hasValidated=post.hasValidated property="emailSubject"}}
<label for="og-title">Subject</label>
{{gh-text-input
class="post-setting-email-subject"
id="email-subject"
name="post-setting-email-subject"
placeholder=(truncate emailSubject 40)
value=(readonly emailSubjectScratch)
input=(action (mut emailSubjectScratch) value="target.value")
focus-out=(action "setEmailSubject" emailSubjectScratch)
stopEnterKeyDownPropagation=true
disabled=deliveredAction
data-test-field="email-subject"}}
{{gh-error-message errors=post.errors property="emailSubject" data-test-error="email-subject"}}
{{/gh-form-group}}

<div class="form-group">
<div class="flex">
<label class="nowrap flex-auto">Test email</label>
<button type="button" class="gh-btn gh-btn-link settings-menu-email-button" onclick={{action "toggleEmailPreview"}}
data-test-button="toggle-email-preview">
<span class="blue">
Preview in browser
</span>
</button>
</div>
{{#if post.email}}
{{!-- Mail has already been sent --}}
<p>Subject: {{this.post.email.subject}}</p>
<p>Status: {{this.post.email.status}}</p>
<p>Sent on: {{gh-format-post-time this.post.email.createdAtUTC}}</p>
<p>Sent to {{pluralize this.post.email.emailCount "member"}}</p>
{{else}}
{{!-- Mail not sent yet --}}
{{#if mailgunError}}
<p class="gh-box gh-box-warning settings-menu-mailgun-warning">
{{svg-jar "info" class="w5 h5 fill-yellow nl1"}}
You need to configure Mailgun in {{#link-to "settings.labs" data-test-nav="labs"}}Labs → Members settings{{/link-to}} to enable email newsletters.
</p>
{{/if}}

<div class="{{if mailgunError "disabled"}}">
<form {{action "discardEnter" on="submit"}}>
{{#gh-form-group errors=post.errors hasValidated=post.hasValidated property="emailSubject"}}
<label for="og-title">Subject</label>
{{gh-text-input
class="post-setting-email-test"
id="email-test"
name="post-setting-email-test"
placeholder=(truncate 'noreply@example.com' 40)
value=(readonly emailTestScratch)
input=(action (mut emailTestScratch) value="target.value")
class="post-setting-email-subject"
id="email-subject"
name="post-setting-email-subject"
placeholder=(truncate emailSubject 40)
value=(readonly emailSubjectScratch)
input=(action (mut emailSubjectScratch) value="target.value")
focus-out=(action "setEmailSubject" emailSubjectScratch)
stopEnterKeyDownPropagation=true
disabled=mailgunError
data-test-field="email-test"}}
disabled=deliveredAction
data-test-field="email-subject"}}
{{gh-error-message errors=post.errors property="emailSubject" data-test-error="email-subject"}}
{{/gh-form-group}}

{{#if sendTestEmailError}}
<div class="error"><p class="response">{{sendTestEmailError}}</p></div>
{{/if}}
<div class="form-group">
<div class="flex">
<label class="nowrap flex-auto">Test email</label>
<button type="button" class="gh-btn gh-btn-link settings-menu-email-button" onclick={{action "toggleEmailPreview"}}
data-test-button="toggle-email-preview">
<span class="blue">
Preview in browser
</span>
</button>
</div>

{{gh-task-button "Send test email"
task=sendTestEmail
successText="Email sent"
runningText="Sending..."
class="gh-btn w-100 mt2 gh-btn-icon"
disabled=mailgunError
data-test-send-test-mail=true
}}
<div class="{{if mailgunError "disabled"}}">
{{gh-text-input
class="post-setting-email-test"
id="email-test"
name="post-setting-email-test"
placeholder=(truncate 'noreply@example.com' 40)
value=(readonly emailTestScratch)
input=(action (mut emailTestScratch) value="target.value")
stopEnterKeyDownPropagation=true
disabled=mailgunError
data-test-field="email-test"}}

{{#if sendTestEmailError}}
<div class="error"><p class="response">{{sendTestEmailError}}</p></div>
{{/if}}

{{gh-task-button "Send test email"
task=sendTestEmail
successText="Email sent"
runningText="Sending..."
class="gh-btn w-100 mt2 gh-btn-icon"
disabled=mailgunError
data-test-send-test-mail=true
}}
</div>
</div>
</div>
</form>
</form>
{{/if}}
</div>

0 comments on commit a360859

Please sign in to comment.