fix(ui): fix version list status for unpublished documents#11983
Merged
DanRibbens merged 4 commits intoMay 2, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
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({
DanRibbens
reviewed
May 1, 2025
| await expect(page.locator('.app-header .global-versions-button')).toHaveCount(1) | ||
| }) | ||
|
|
||
| // TODO: Check versions/:version-id view for collections / globals |
Contributor
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
Deleted. Thanks 🙌
DanRibbens
previously approved these changes
May 1, 2025
DanRibbens
left a comment
Contributor
There was a problem hiding this comment.
Looks good! What do you want to do about that TODO?
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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