fix(content-manager): warn before publishing with draft relations#26736
Conversation
Re-enable draft-relation counting on publish so editors see a confirmation dialog with cancel or publish-without-relations. Bulk publish uses the same count API again, and the collection-type edit view e2e covers the warning. Fixes #25361
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Size Change: +7.37 kB (+0.22%) Total Size: 3.31 MB 📦 View Changed
ℹ️ View Unchanged
|
Add an E2E spec for cancel vs publish-without-relations and fix the collection-type edit view test to use a seeded draft author.
|
I tested this a bit, I think there are a few flaws here and there, so when we have many to many, i guess 1 to 1 and self relations as well, the pop up will appear but there is not way to resolve it because it will appear from both contenttypes both being unable to published, and the pop up seems to keep appearing regardless of if I published the related contentType or not. |
|
actually in many to many we may not need the pop up warning at all, it seems the related entity self heals if it gets published |
…feedback Open the confirmation dialog from the publish keyboard shortcut, refetch the server draft-relation count when the document or window focus changes, and exclude self-referential relations from the warning (they are preserved on publish).
… helper Fixes build:types failure where countLocalDraftRelations passed component schemas typed as Component into a ContentType-only parameter.
Bidirectional M2M draft links are counted separately from xToOne-style relations so publish dialogs use accurate copy and severity.
Align unit, API, and E2E tests with M2M draft-relation warnings and add a shared publish helper for entries that trigger the confirmation dialog.
|
The modal seems to be popping up whenever a draft relation is added, am guessing adding the modal is affecting the flow of the e2e tests as well |
Passing dialogRequestId as 0 when draft relations were detected auto-opened the publish warning via useLayoutEffect. Only forward the id after the keyboard shortcut increments it, ignore 0 in the open effect, and align API/E2E tests with the corrected behavior.
Replace dialogRequestId/useLayoutEffect with scoped confirm openers so the warning modal never auto-opens when draft relations are detected. Sum local and server counts for modified documents so incremental relation adds show the correct total. Update E2E tests for keyboard confirm and modal publish.
Keep Publish disabled until server draft-relation counts are applied, avoid networkidle in publish helpers, and harden edit-view, preview, and relations on-the-fly tests for suite timing under Firefox and WebKit.
…type Restore unidirectional warnings that relations are stripped on publish, and keep bidirectional M2M copy about links appearing once related entries publish.
…layout Add optional bodyIcon to DocumentActionConfirmDialog so publish warnings use the same centered icon and typography as bulk publish confirmations.
AI-generated QA checklistScope / ImpactRe-enables the "count draft relations" warning when publishing content with draft relations, both from the single edit view and from the list-view bulk publish. The flow distinguishes two cases:
Affected areas:
Reviewer feedback on the open PR (@Bassel17) flagged: dialog appearing on both sides of bidirectional M2M with no way to resolve, dialog re-appearing after the related entry is published (stale fetch), and the keyboard shortcut not triggering publish. The diff appears to address all three but those flows deserve focused manual re-verification. Manual QA
Edge Cases
Test Setup
Possible QA Automation
Assumptions / Gaps
QA ResolutionAdd |
Register the publish POST listener before clicking Publish and race it against the confirmation dialog so slow CI cannot miss the response when publish proceeds without a warning.
Ted Lasso seed data includes draft article M2M links that open the draft-relations dialog before publish reaches review-workflow validation.
Extract draft-relation counting into a shared util with unit tests and assert bodyIcon dialog layout in DocumentActions.
Move count resolution and dialog variant selection into tested helpers to improve coverage on the draft-relations publish warning logic.
…6736) * fix(content-manager): warn before publishing with draft relations Re-enable draft-relation counting on publish so editors see a confirmation dialog with cancel or publish-without-relations. Bulk publish uses the same count API again, and the collection-type edit view e2e covers the warning. Fixes #25361 * test(e2e): cover draft-relations publish warning flow Add an E2E spec for cancel vs publish-without-relations and fix the collection-type edit view test to use a seeded draft author. * fix(content-manager): address draft-relations publish warning review feedback Open the confirmation dialog from the publish keyboard shortcut, refetch the server draft-relation count when the document or window focus changes, and exclude self-referential relations from the warning (they are preserved on publish). * fix(content-manager): accept Component schema in draft-relation count helper Fixes build:types failure where countLocalDraftRelations passed component schemas typed as Component into a ContentType-only parameter. * fix(content-manager): split draft-relation warnings by relation type Bidirectional M2M draft links are counted separately from xToOne-style relations so publish dialogs use accurate copy and severity. * test(content-manager): fix draft-relations CI failures on PR 26736 Align unit, API, and E2E tests with M2M draft-relation warnings and add a shared publish helper for entries that trigger the confirmation dialog. * fix(content-manager): only open draft-relations dialog on publish intent Passing dialogRequestId as 0 when draft relations were detected auto-opened the publish warning via useLayoutEffect. Only forward the id after the keyboard shortcut increments it, ignore 0 in the open effect, and align API/E2E tests with the corrected behavior. * fix(content-manager): open draft-relations dialog only on publish intent Replace dialogRequestId/useLayoutEffect with scoped confirm openers so the warning modal never auto-opens when draft relations are detected. Sum local and server counts for modified documents so incremental relation adds show the correct total. Update E2E tests for keyboard confirm and modal publish. * test(e2e): stabilize draft-relations publish flow and fix preview flake Keep Publish disabled until server draft-relation counts are applied, avoid networkidle in publish helpers, and harden edit-view, preview, and relations on-the-fly tests for suite timing under Firefox and WebKit. * fix(content-manager): correct draft-relations publish dialog copy by type Restore unidirectional warnings that relations are stripped on publish, and keep bidirectional M2M copy about links appearing once related entries publish. * fix(content-manager): align draft-relations dialog with bulk confirm layout Add optional bodyIcon to DocumentActionConfirmDialog so publish warnings use the same centered icon and typography as bulk publish confirmations. * test(e2e): fix publish helper race when no draft-relations dialog Register the publish POST listener before clicking Publish and race it against the confirmation dialog so slow CI cannot miss the response when publish proceeds without a warning. * test(e2e): clear draft relations before review-workflow publish check Ted Lasso seed data includes draft article M2M links that open the draft-relations dialog before publish reaches review-workflow validation. * test(content-manager): cover draft relation count helpers Extract draft-relation counting into a shared util with unit tests and assert bodyIcon dialog layout in DocumentActions. * fix(content-manager): restore DraftRelationCounts imports in DocumentActions * test(content-manager): fix draftRelationCounts test type assertions * test(content-manager): extract draft-relations publish state helpers Move count resolution and dialog variant selection into tested helpers to improve coverage on the draft-relations publish warning logic.
Summary
m2m (bidirectional):

unidirectional:

Fixes #25361
Publishing related entries first is intentionally out of scope here (permissions and ordering make it a follow-up).
Test plan
Experimental version:
0.0.0-experimental.cb80fd5e9b78bde9ac2c175e5a5e1977b2bcfb33yarn test:front DocumentActions.test ConfirmBulkActionDialog.testyarn nx run @strapi/content-manager:lintyarn test:e2e --domains content-manager --grep "warns on publish"(new E2E spec)