Skip to content

fix(ui): fix version list status for unpublished documents#11983

Merged
DanRibbens merged 4 commits into
payloadcms:mainfrom
tak-amboss:fix-version-list-status-for-unpublished-documents
May 2, 2025
Merged

fix(ui): fix version list status for unpublished documents#11983
DanRibbens merged 4 commits into
payloadcms:mainfrom
tak-amboss:fix-version-list-status-for-unpublished-documents

Conversation

@tak-amboss

Copy link
Copy Markdown
Contributor

What?

Fixes the label for documents which were the current published document but got unpublished in the version view.

Why?

If the most recent published document was unpublished, it remained displayed as "Currently published version" in the version list.

How?

Checks whether the document has a currently published version instead of only looking at the latest published version when determining the label in the versions view.

Fixes #10838

@AlessioGr AlessioGr self-assigned this Apr 7, 2025
@DanRibbens DanRibbens requested a review from Copilot May 1, 2025 19:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the UI issue where documents that were published and later unpublished were still displayed as “Currently published version” in the version list.

  • Updates the logic to check for the existence of a published document before fetching the latest published version.
  • Adds end-to-end tests to verify the correct labels for both published and unpublished versions.
  • Updates the global versions view and the version comparison component to support the revised logic.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
test/versions/e2e.spec.ts Introduces new tests to assert the correct status labels in the versions view.
packages/next/src/views/Versions/index.tsx Modifies the logic to conditionally retrieve the latest published version based on the actual published document count.
packages/next/src/views/Version/SelectComparison/index.tsx Adjusts the comparison component to only pass the latest published version when a published document exists.
Comments suppressed due to low confidence (1)

packages/next/src/views/Versions/index.tsx:107

  • Using the logical AND operator for assignment may yield a boolean (false) when no published document exists. Consider refactoring using a ternary operator (e.g. publishedDoc.totalDocs > 0 ? await getLatestVersion({...}) : undefined) for clearer intent and to avoid unintended falsy values.
latestPublishedVersion = publishedDoc.totalDocs > 0 && (await getLatestVersion({

Comment thread test/versions/e2e.spec.ts Outdated
await expect(page.locator('.app-header .global-versions-button')).toHaveCount(1)
})

// TODO: Check versions/:version-id view for collections / globals

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this meant to be left in? If we are going to add this assertion then we should do it, otherwise just delete the comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted. Thanks 🙌

DanRibbens
DanRibbens previously approved these changes May 1, 2025

@DanRibbens DanRibbens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! What do you want to do about that TODO?

@DanRibbens DanRibbens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@DanRibbens DanRibbens merged commit b6b02ac into payloadcms:main May 2, 2025
76 checks passed
@github-actions

github-actions Bot commented May 5, 2025

Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.37.0

kendelljoseph pushed a commit that referenced this pull request May 15, 2025
### What?
Fixes the label for documents which were the current published document
but got unpublished in the version view.

### Why?
If the most recent published document was unpublished, it remained
displayed as "Currently published version" in the version list.

### How?
Checks whether the document has a currently published version instead of
only looking at the latest published version when determining the label
in the versions view.

Fixes #10838

---------

Co-authored-by: Alessio Gravili <alessio@gravili.de>
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
kendelljoseph pushed a commit that referenced this pull request May 19, 2025
### What?
Fixes the label for documents which were the current published document
but got unpublished in the version view.

### Why?
If the most recent published document was unpublished, it remained
displayed as "Currently published version" in the version list.

### How?
Checks whether the document has a currently published version instead of
only looking at the latest published version when determining the label
in the versions view.

Fixes #10838

---------

Co-authored-by: Alessio Gravili <alessio@gravili.de>
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unpublishing a version keeps the current version published

4 participants