0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Added "published_latest" key to revisionList

refs https://github.com/TryGhost/Team/issues/3123

This commit modifies the revisionList method to add a new key-value pair published_latest: true to the object if the current index matches with the index of the latest published revision with the reason 'published'. The change only affects the latest published revision and doesn't modify any existing data. This update improves the display of post revisions by highlighting the latest published revision in the list.
This commit is contained in:
Ronald 2023-05-01 10:30:02 +02:00
parent 60d26c62e8
commit d6794e6c43
2 changed files with 12 additions and 5 deletions

View file

@ -61,9 +61,10 @@
<span class="gh-post-history-version">{{gh-format-post-time revision.createdAt format="D MMM YYYY, HH:mm"}}{{this.timezone}}</span>
{{#if revision.latest}}
<span class="gh-post-history-version-tag current">Latest</span>
{{#if (eq revision.postStatus "published")}}
<span class="gh-post-history-version-tag published">{{{revision.postStatus}}}</span>
{{/if}}
{{#if (eq revision.published_latest true)}}
<span class="gh-post-history-version-tag published">Published</span>
{{/if}}
</div>

View file

@ -52,7 +52,12 @@ export default class ModalPostHistory extends Component {
}
get revisionList() {
return this.post.get('postRevisions').toArray().reverse().map((revision, index) => {
const revisions = this.post.get('postRevisions').toArray().reverse();
const latestPublishedIndex = revisions.findIndex(
revision => revision.get('postStatus') === 'published' && revision.get('reason') === 'published'
);
return revisions.map((revision, index) => {
return {
lexical: revision.get('lexical'),
selected: index === this.selectedRevisionIndex,
@ -66,7 +71,8 @@ export default class ModalPostHistory extends Component {
name: revision.get('author.name') || 'Deleted staff user'
},
postStatus: revision.get('postStatus'),
reason: revision.get('reason')
reason: revision.get('reason'),
published_latest: latestPublishedIndex !== -1 && latestPublishedIndex === index
};
});
}