mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added unpublished logic to revisionList.
refs https://github.com/TryGhost/Team/issues/3123 Refactor revisionList function to use a more concise logic for finding new published and unpublished revisions.
This commit is contained in:
parent
9dea2ef911
commit
df1329f5e9
2 changed files with 7 additions and 12 deletions
|
@ -63,9 +63,12 @@
|
|||
<span class="gh-post-history-version-tag current">Latest</span>
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq revision.initial_publish true)}}
|
||||
{{#if (eq revision.new_publish true)}}
|
||||
<span class="gh-post-history-version-tag published">Published</span>
|
||||
{{/if}}
|
||||
{{!-- {{#if (eq revision.new_unpublish true)}}
|
||||
<span class="gh-post-history-version-tag current">Unpublished</span>
|
||||
{{/if}} --}}
|
||||
|
||||
</div>
|
||||
<span class="gh-post-history-version-meta {{if (eq revision.author.name "Deleted staff user") "deleted-user"}}">{{revision.author.name}}</span>
|
||||
|
|
|
@ -52,16 +52,7 @@ export default class ModalPostHistory extends Component {
|
|||
}
|
||||
|
||||
get revisionList() {
|
||||
// sort revisions by createdAt date
|
||||
const revisions = this.post.get('postRevisions').toArray().sort((a, b) => b.get('createdAt') - a.get('createdAt'));
|
||||
// finds the initial published version
|
||||
const publishedIndex = revisions.findIndex(
|
||||
(revision, index, arr) => (
|
||||
revision.get('postStatus') === 'published' &&
|
||||
arr[index + 1]?.get('postStatus') === 'draft'
|
||||
)
|
||||
);
|
||||
|
||||
const revisions = this.post.get('postRevisions').toArray().sort((a, b) => b.get('createdAt') - a.get('createdAt'));
|
||||
return revisions.map((revision, index) => {
|
||||
return {
|
||||
lexical: revision.get('lexical'),
|
||||
|
@ -77,7 +68,8 @@ export default class ModalPostHistory extends Component {
|
|||
},
|
||||
postStatus: revision.get('postStatus'),
|
||||
reason: revision.get('reason'),
|
||||
initial_publish: publishedIndex !== -1 && index === publishedIndex
|
||||
new_publish: revision.get('postStatus') === 'published' && revisions[index + 1]?.get('postStatus') === 'draft',
|
||||
new_unpublish: revision.get('postStatus') === 'draft' && revisions[index + 1]?.get('postStatus') === 'published'
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue