mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
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
This commit is contained in:
parent
a1d26a575c
commit
a5fe1fa48c
4 changed files with 74 additions and 2 deletions
|
@ -17,6 +17,7 @@
|
|||
{{else if this.isComplete}}
|
||||
<EditorLabs::Modals::PublishFlow::Complete
|
||||
@publishOptions={{@data.publishOptions}}
|
||||
@postCount={{this.postCount}}
|
||||
@close={{@close}}
|
||||
/>
|
||||
{{else}}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,37 @@
|
|||
{{#let @publishOptions.post as |post|}}
|
||||
<div class="gh-publish-title">
|
||||
<span class="green">Boom. It’s out there.</span> That’s 391 posts published, keep going!
|
||||
{{#if post.isScheduled}}
|
||||
<span class="green">All set!</span>
|
||||
|
||||
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}}
|
||||
<span class="green">Boom. It’s out there.</span>
|
||||
|
||||
{{#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}}
|
||||
</div>
|
||||
|
||||
<div class="gh-publish-cta">
|
||||
|
|
14
ghost/admin/app/helpers/is-moment-today.js
Normal file
14
ghost/admin/app/helpers/is-moment-today.js
Normal file
|
@ -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');
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue