mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Updated post status in editor
This commit is contained in:
parent
7351a962b7
commit
f5dd75e2e5
@ -1,8 +1,12 @@
|
||||
import Component from '@ember/component';
|
||||
import config from 'ghost-admin/config/environment';
|
||||
import moment from 'moment';
|
||||
import {computed} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task, timeout} from 'ember-concurrency';
|
||||
|
||||
export default Component.extend({
|
||||
clock: service(),
|
||||
post: null,
|
||||
isSaving: false,
|
||||
|
||||
@ -10,6 +14,23 @@ export default Component.extend({
|
||||
|
||||
_isSaving: false,
|
||||
|
||||
countdown: computed('post.{publishedAtUTC,isScheduled}', 'clock.second', function () {
|
||||
let isScheduled = this.get('post.isScheduled');
|
||||
let publishTime = this.get('post.publishedAtUTC') || moment.utc();
|
||||
|
||||
let timeUntilPublished = publishTime.diff(moment.utc(), 'minutes', true);
|
||||
let isPublishedSoon = timeUntilPublished > 0 && timeUntilPublished < 15;
|
||||
|
||||
// force a recompute
|
||||
this.get('clock.second');
|
||||
|
||||
if (isScheduled && isPublishedSoon) {
|
||||
return moment(publishTime).fromNow();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
|
||||
// isSaving will only be true briefly whilst the post is saving,
|
||||
// we want to ensure that the "Saving..." message is shown for at least
|
||||
// a few seconds so that it's noticeable
|
||||
|
@ -6,7 +6,13 @@
|
||||
and sent to {{pluralize this.post.email.emailCount "member"}}
|
||||
{{/if}}
|
||||
{{else if this.post.isScheduled}}
|
||||
Scheduled
|
||||
{{#if countdown}}
|
||||
<time datetime="{{post.publishedAtUTC}}" class="ml1 green f8" data-test-schedule-countdown>
|
||||
Scheduled to be published {{if post.sendEmailWhenPublished "and sent"}} {{countdown}}.
|
||||
</time>
|
||||
{{else}}
|
||||
Scheduled
|
||||
{{/if}}
|
||||
{{else if this.post.isNew}}
|
||||
New
|
||||
{{else}}
|
||||
|
@ -15,19 +15,12 @@
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class="flex items-center pl4 pr4 f8 nudge-left--1 h9 br2 br--right {{unless infoMessage "bg-white"}}">
|
||||
{{#unless post.isScheduled}}
|
||||
<span class="fw4 midgrey-l2">
|
||||
{{gh-editor-post-status
|
||||
post=post
|
||||
isSaving=(or autosave.isRunning saveTasks.isRunning)
|
||||
}}
|
||||
</span>
|
||||
{{/unless}}
|
||||
{{#gh-scheduled-post-countdown post=post as |post countdown|}}
|
||||
<time datetime="{{post.publishedAtUTC}}" class="green f8" data-test-schedule-countdown>
|
||||
Scheduled to be published and sent {{countdown}}.
|
||||
</time>
|
||||
{{/gh-scheduled-post-countdown}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user