fix(admin): only show Pending changes when a live revision exists - #3010
fix(admin): only show Pending changes when a live revision exists#3010eisenbruch wants to merge 1 commit into
Conversation
The content list compared the draft and live revision pointers directly, so an entry that had never been published - draft revision set, live revision null - counted as a difference and rendered the badge. getDraftStatus() already encodes the correct rule and is what the editor's publishing state derives from, so the list now uses it and the two screens agree.
🦋 Changeset detectedLatest commit: 6c5b805 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
This is the right fix for the right problem, implemented in the way the codebase already uses elsewhere.
The bug is real: ContentListItem was computing hasPendingChanges by comparing the two revision pointers directly, so any entry with a draft revision and liveRevisionId === null (draft or scheduled, never published) got the “Pending changes” badge. The editor was already deriving the same boolean from getDraftStatus(item) === "published_with_changes", so the two screens disagreed.
The change:
- swaps the list’s inline pointer comparison for the shared
getDraftStatus()helper fromlib/api, which returns"unpublished"when there is no live revision. This matches the editor’s derivation exactly. - adds a focused regression test for the never-published/scheduled case that would have failed before the fix.
- includes a clear, user-facing changeset for
@emdash-cms/admin.
What I checked:
- Read the diff and the full changed files.
- Verified
getDraftStatusinpackages/admin/src/lib/api/content.tsand its export fromindex.ts. - Traced the editor’s use of the same helper in
ContentEditor.tsx(it already computeshasPendingChangesandisLivefromgetDraftStatus), confirming consistency. - Reviewed the changeset against
.changeset/README.md— it leads with the observable behavior, names the affected surface, and explains the fix. - Confirmed no
messages.pochanges are included, no new logged-out queries, no SQL, no authorization, and no RTL/styling edits.
The test is a real behavior test (the badge text is absent/present), the helper is the same one the editor relies on, and the changeset is properly user-facing. No findings.
|
I have read the CLA Document and I hereby sign the CLA |
What does this PR do?
The content list shows a Pending changes badge on entries that have never been published, so the same entry reads as both
ScheduledandPending changesat once. The editor disagrees with the list for that entry, and the list is the one that is wrong.ContentListItemcompares the revision pointers directly:A draft or scheduled entry has a draft revision and
liveRevisionId === null, so the two "differ" and the badge renders — but there is no published version for the changes to be pending against. The editor goes throughgetContentPublishingState(), which checksisLivefirst and correctly reportsscheduledordraft.The fix uses
getDraftStatus(), which already encodes the rule and already lives inlib/api:Two lines: the badge condition and the import. The two screens now agree.
Found on a site running 0.37: a scheduled entry with several revisions and
live_revision_idnull was listed with pending changes while its editor showed only "Scheduled". Every unpublished entry that had been edited at least once was affected.Closes #
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.Notes on the checklist, so the ticks are honest:
messages.pochanges are included.tests/components/ContentList.test.tsxis 70/70, andpnpm --filter @emdash-cms/admin typecheckpasses.pnpm lint:jsonreports nothing for the touched file; the repository has pre-existing diagnostics elsewhere that this branch does not add to.SeoPanel,SocialSettings,LoginPage,routerand others) and never includesContentList, so they look like local flakes rather than anything from this change.AI-generated code disclosure
Screenshots / test output
No screenshot, deliberately. The only site I can reproduce this on is a private pre-launch client site, and a shot of the affected list is a shot of unpublished client content and headlines. Describing it instead:
The status cell of an unpublished-but-edited entry renders two badges side by side — the lifecycle badge (
Scheduled, blue, calendar icon) immediately followed by the companion badge (Pending changes, amber, arrows icon). After the fix the companion badge is gone and the lifecycle badge is unchanged. A published entry with unpublished edits still shows both, which the pre-existing test covers.If a maintainer wants a rendered before/after, the fastest reproduction is a demo entry: create any entry in a collection with drafts enabled, save it without publishing, and it will show
Pending changesonmain.Test added for the case that was not covered: