Skip to content

Enhance duplicate page action#985

Open
rchlfryn wants to merge 7 commits intoendpoint-new-tenantfrom
duplicate-to-enhance
Open

Enhance duplicate page action#985
rchlfryn wants to merge 7 commits intoendpoint-new-tenantfrom
duplicate-to-enhance

Conversation

@rchlfryn
Copy link
Collaborator

@rchlfryn rchlfryn commented Mar 12, 2026

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 clearLayoutRelationships utility currently handles all field types in Payload's schema (group, array, tabs, row, collapsible, richText with 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

  • clearLayoutRelationships utility — recursively clears relationship and upload fields 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.
  • provisionTenant and duplicatePageToTenant updated — both now use clearLayoutRelationships and create pages/navigation as drafts, bypassing required-field validation.
  • Bug fixduplicatePageToTenant was spreading the cleaned layout array into data instead of assigning it as data.layout.
  • Tests — unit tests for clearLayoutRelationships (relationships, uploads, groups, arrays, tabs, Lexical blocks, id stripping) and integration tests for duplicatePageToTenant, backed by a shared fixtures/mockBlocks.ts.

How to test

Added tests

  1. pnpm seed to get a fresh database with the DVAC template tenant
  2. Provisioning: Create a new avalanche center in the admin panel. Verify the onboarding checklist shows automated steps as complete. Pages and navigation will be drafts — publish them after repopulating the tenant-specific relationship fields (e.g. blog post references, sponsor logos).
  3. Duplicate to Tenant: Open any published page on DVAC → ⋮ menu → "Duplicate to Tenant" → pick another tenant. Verify the new page is created as a draft, relationship fields are cleared (empty), and non-relationship fields (text, colors, layout structure) are preserved.

Screenshots / Demo video

Screenshot 2026-03-11 at 17 48 34

Duplicate page to... demo
Provisioning tenant demo

Migration Explanation

No schema changes — no migration needed.

@github-actions
Copy link

Preview deployment: https://duplicate-to-enhance.preview.avy-fx.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant