Added unpublished
reason to post revisions (#16726)
closes https://github.com/TryGhost/Team/issues/3137 We have now included the ability to display an "Unpublished" tag for revisions that have been unpublished. The tag is only displayed when the revision's reason property is set to "unpublished". A new revision is triggered when a post is unpublished, regardless whether there's a change in the content.
This commit is contained in:
parent
cef062452b
commit
6189040fc4
@ -66,7 +66,7 @@
|
||||
{{#if revision.new_publish}}
|
||||
<span class="gh-post-history-version-tag published">Published</span>
|
||||
{{/if}}
|
||||
{{#if revision.new_unpublish}}
|
||||
{{#if (eq revision.reason "unpublished")}}
|
||||
<span class="gh-post-history-version-tag unpublished">Unpublished</span>
|
||||
{{/if}}
|
||||
|
||||
|
@ -71,8 +71,7 @@ export default class ModalPostHistory extends Component {
|
||||
},
|
||||
postStatus: revision.get('postStatus'),
|
||||
reason: revision.get('reason'),
|
||||
new_publish: revision.get('postStatus') === 'published' && revisions[index + 1]?.get('postStatus') === 'draft',
|
||||
new_unpublish: revision.get('postStatus') === 'draft' && revisions[index + 1]?.get('postStatus') === 'published'
|
||||
new_publish: revision.get('postStatus') === 'published' && revisions[index + 1]?.get('postStatus') === 'draft'
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -935,7 +935,9 @@ Post = ghostBookshelf.Model.extend({
|
||||
// This can be refactored once we have the status stored in each revision
|
||||
const revisionOptions = {
|
||||
forceRevision: options.save_revision,
|
||||
isPublished: newStatus === 'published'
|
||||
isPublished: newStatus === 'published',
|
||||
newStatus,
|
||||
olderStatus
|
||||
};
|
||||
const newRevisions = await postRevisions.getRevisions(current, revisions, revisionOptions);
|
||||
model.set('post_revisions', newRevisions);
|
||||
|
@ -52,6 +52,12 @@ class PostRevisions {
|
||||
if (revisions.length === 0) {
|
||||
return {value: true, reason: 'initial_revision'};
|
||||
}
|
||||
// check if the post has been unpublished
|
||||
const isUnpublished = options && options.newStatus === 'draft' && options.olderStatus === 'published';
|
||||
if (isUnpublished) {
|
||||
return {value: true, reason: 'unpublished'};
|
||||
}
|
||||
// check if the post has been published
|
||||
const isPublished = options && options.isPublished;
|
||||
if (isPublished) {
|
||||
return {value: true, reason: 'published'};
|
||||
|
@ -89,6 +89,27 @@ describe('PostRevisions', function () {
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should return true if post is unpublished and forceRevision is true', function () {
|
||||
const postRevisions = new PostRevisions({config});
|
||||
|
||||
const expected = {value: true, reason: 'unpublished'};
|
||||
|
||||
const actual = postRevisions.shouldGenerateRevision({
|
||||
lexical: 'blah',
|
||||
html: 'blah',
|
||||
title: 'blah2'
|
||||
}, [{
|
||||
lexical: 'blah'
|
||||
}], {
|
||||
isPublished: false,
|
||||
forceRevision: true,
|
||||
newStatus: 'draft',
|
||||
olderStatus: 'published'
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should always return true if isPublished is true', function () {
|
||||
const postRevisions = new PostRevisions({config});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user