From 682c5e4190b78a742f8e52969398476cf469d144 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Fri, 8 Nov 2019 17:07:47 +0700 Subject: [PATCH] Display basic info in PSM once an email has been sent --- ghost/admin/app/models/email.js | 4 +- ghost/admin/app/serializers/email.js | 10 ++ .../gh-post-settings-menu/email.hbs | 120 ++++++++++-------- 3 files changed, 77 insertions(+), 57 deletions(-) create mode 100644 ghost/admin/app/serializers/email.js diff --git a/ghost/admin/app/models/email.js b/ghost/admin/app/models/email.js index 1bce380c71..060b1dce7a 100644 --- a/ghost/admin/app/models/email.js +++ b/ghost/admin/app/models/email.js @@ -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') diff --git a/ghost/admin/app/serializers/email.js b/ghost/admin/app/serializers/email.js new file mode 100644 index 0000000000..6d9b96712b --- /dev/null +++ b/ghost/admin/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'} + } +}); diff --git a/ghost/admin/app/templates/components/gh-post-settings-menu/email.hbs b/ghost/admin/app/templates/components/gh-post-settings-menu/email.hbs index 3007370ce1..3d0aea8710 100644 --- a/ghost/admin/app/templates/components/gh-post-settings-menu/email.hbs +++ b/ghost/admin/app/templates/components/gh-post-settings-menu/email.hbs @@ -5,65 +5,75 @@
- {{#if mailgunError}} -

- {{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. -

- {{/if}} -
- {{#gh-form-group errors=post.errors hasValidated=post.hasValidated property="emailSubject"}} - - {{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}} + {{#if post.email}} + {{!-- Mail has already been sent --}} +

Subject: {{this.post.email.subject}}

+

Status: {{this.post.email.status}}

+

Sent on: {{gh-format-post-time this.post.email.createdAtUTC}}

+

Sent to {{pluralize this.post.email.emailCount "member"}}

+ {{else}} + {{!-- Mail not sent yet --}} + {{#if mailgunError}} +

+ {{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. +

+ {{/if}} -
-
- - -
- -
+ + {{#gh-form-group errors=post.errors hasValidated=post.hasValidated property="emailSubject"}} + {{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}} -

{{sendTestEmailError}}

- {{/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 - }} +
+ {{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}} +

{{sendTestEmailError}}

+ {{/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 + }} +
-
- + + {{/if}}
\ No newline at end of file