From a5fe1fa48c79bc6c90d121d090d9e3a0cf03a974 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 10 May 2022 12:51:05 +0100 Subject: [PATCH] Updated publish complete step copy refs https://github.com/TryGhost/Team/issues/1598 - pre-fetch post count when reaching the confirm step so it's available once save is complete - updated copy on complete step to reflect the action that occurred, including the number of published posts when a post was published - added `{{is-moment-today someDate}}` helper so we can switch between "today" and another date format --- .../editor-labs/modals/publish-flow.hbs | 1 + .../editor-labs/modals/publish-flow.js | 28 +++++++++++++++- .../modals/publish-flow/complete.hbs | 33 ++++++++++++++++++- ghost/admin/app/helpers/is-moment-today.js | 14 ++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 ghost/admin/app/helpers/is-moment-today.js diff --git a/ghost/admin/app/components/editor-labs/modals/publish-flow.hbs b/ghost/admin/app/components/editor-labs/modals/publish-flow.hbs index 1fe434e470..59e65c134b 100644 --- a/ghost/admin/app/components/editor-labs/modals/publish-flow.hbs +++ b/ghost/admin/app/components/editor-labs/modals/publish-flow.hbs @@ -17,6 +17,7 @@ {{else if this.isComplete}} {{else}} diff --git a/ghost/admin/app/components/editor-labs/modals/publish-flow.js b/ghost/admin/app/components/editor-labs/modals/publish-flow.js index cf47b1acc6..f55d9deb15 100644 --- a/ghost/admin/app/components/editor-labs/modals/publish-flow.js +++ b/ghost/admin/app/components/editor-labs/modals/publish-flow.js @@ -1,5 +1,6 @@ import Component from '@glimmer/component'; import {action} from '@ember/object'; +import {inject as service} from '@ember/service'; import {task} from 'ember-concurrency'; import {tracked} from '@glimmer/tracking'; @@ -10,8 +11,11 @@ export default class PublishModalComponent extends Component { ignoreBackdropClick: true }; + @service store; + @tracked isConfirming = false; @tracked isComplete = false; + @tracked postCount = null; get recipientType() { const filter = this.args.data.publishOptions.recipientFilter; @@ -37,8 +41,11 @@ export default class PublishModalComponent extends Component { @action toggleConfirm() { - // TODO: validate? this.isConfirming = !this.isConfirming; + + if (this.isConfirming) { + this.fetchPostCountTask.perform(); + } } @task @@ -48,4 +55,23 @@ export default class PublishModalComponent extends Component { this.isConfirming = false; this.isComplete = true; } + + // we fetch the new post count in advance when reaching the confirm step + // to avoid a copy flash when reaching the complete step + @task + *fetchPostCountTask() { + const publishOptions = this.args.data.publishOptions; + + // no count is shown for pages, scheduled posts, or email-only posts + if (publishOptions.post.isPage || publishOptions.isScheduled || !publishOptions.willPublish) { + return; + } + + const result = yield this.store.query('post', {limit: 1}); + let count = result.meta.pagination.total; + + count += 1; // account for the new post + + this.postCount = count; + } } diff --git a/ghost/admin/app/components/editor-labs/modals/publish-flow/complete.hbs b/ghost/admin/app/components/editor-labs/modals/publish-flow/complete.hbs index 1233bbcde1..9ec1e8eac5 100644 --- a/ghost/admin/app/components/editor-labs/modals/publish-flow/complete.hbs +++ b/ghost/admin/app/components/editor-labs/modals/publish-flow/complete.hbs @@ -1,6 +1,37 @@ {{#let @publishOptions.post as |post|}}
- Boom. It’s out there. That’s 391 posts published, keep going! + {{#if post.isScheduled}} + All set! + + Your {{if post.emailOnly "email" post.displayName}} will be + + {{#if post.emailOnly}} + sent + {{else if post.willEmail}} + published and sent + {{else}} + published + {{/if}} + + {{#let (moment-site-tz post.publishedAtUTC) as |scheduledAt|}} + {{#if (is-moment-today scheduledAt)}} + today + {{else}} + on {{moment-format scheduledAt "MMMM Do"}} + {{/if}} + at {{moment-format scheduledAt "HH:mm"}} + {{/let}} + {{else}} + Boom. It’s out there. + + {{#if post.emailOnly}} + Your email has been sent. + {{else if (and post.isPost @postCount)}} + That’s {{@postCount}} posts published, keep going! + {{else}} + Your {{post.displayName}} has been published. + {{/if}} + {{/if}}
diff --git a/ghost/admin/app/helpers/is-moment-today.js b/ghost/admin/app/helpers/is-moment-today.js new file mode 100644 index 0000000000..3719e41b73 --- /dev/null +++ b/ghost/admin/app/helpers/is-moment-today.js @@ -0,0 +1,14 @@ +import Helper from '@ember/component/helper'; +import moment from 'moment'; +import {inject as service} from '@ember/service'; + +export default class MomentSiteTz extends Helper { + @service settings; + + compute([date]) { + const today = moment().tz(this.settings.get('timezone')); + const dateMoment = moment.tz(date, this.settings.get('timezone')); + + return dateMoment.isSame(today, 'day'); + } +}