Open
Conversation
|
Preview deployment: https://duplicate-to-enhance.preview.avy-fx.org |
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.
Description
Improves the page duplication logic introduced in #974 by replacing the incomplete block-type filtering approach with a utility that properly clears relationship and upload fields from any block — keeping the block structure intact and letting editors repopulate the tenant-specific references.
Also extends the same fix to the Duplicate to Tenant admin action, ensures duplicated/provisioned pages and navigation are saved as drafts (bypassing required-field validation), and adds tests for both flows.
The
clearLayoutRelationshipsutility currently handles all field types in Payload's schema (group,array,tabs,row,collapsible,richTextwith Lexical blocks). If new field container types are added to Payload in the future, the utility would need updating.Related Issues
Part of #533 (follow-up to #974)
Closes #625
Key Changes
clearLayoutRelationshipsutility — recursively clearsrelationshipanduploadfields from any block in a page layout (including nested groups, arrays, tabs, and Lexical rich-text blocks), keeping structure intact so editors repopulate tenant-specific references after duplication.provisionTenantandduplicatePageToTenantupdated — both now useclearLayoutRelationshipsand create pages/navigation as drafts, bypassing required-field validation.duplicatePageToTenantwas spreading the cleaned layout array intodatainstead of assigning it asdata.layout.clearLayoutRelationships(relationships, uploads, groups, arrays, tabs, Lexical blocks, id stripping) and integration tests forduplicatePageToTenant, backed by a sharedfixtures/mockBlocks.ts.How to test
Added tests
pnpm seedto get a fresh database with the DVAC template tenantScreenshots / Demo video
Duplicate page to... demo
Provisioning tenant demo
Migration Explanation
No schema changes — no migration needed.