fix(plugin-import-export): disabled flag to cascade to nested fields from parent containers (#13199)

### What?

Fixes the `custom.plugin-import-export.disabled` flag to correctly
disable fields in all nested structures including:
- Groups
- Arrays
- Tabs
- Blocks

Previously, only top-level fields or direct children were respected.
This update ensures nested paths (e.g. `group.array.field1`,
`blocks.hero.title`, etc.) are matched and filtered from exports.

### Why?

- Updated regex logic in both `createExport` and Preview components to
recursively support:
  - Indexed array fields (e.g. `array_0_field1`)
  - Block fields with slugs (e.g. `blocks_0_hero_title`)
  - Nested field accessors with correct part-by-part expansion

### How?

To allow users to disable entire field groups or deeply nested fields in
structured layouts.
This commit is contained in:
Patrik
2025-07-17 14:12:58 -04:00
committed by GitHub
parent 12539c61d4
commit 95e373e60b
11 changed files with 156 additions and 41 deletions

View File

@@ -364,8 +364,8 @@ describe('@payloadcms/plugin-import-export', () => {
const expectedPath = path.join(dirname, './uploads', doc.filename as string)
const data = await readCSV(expectedPath)
expect(data[0].blocks_0_blockType).toStrictEqual('hero')
expect(data[0].blocks_1_blockType).toStrictEqual('content')
expect(data[0].blocks_0_hero_blockType).toStrictEqual('hero')
expect(data[0].blocks_1_content_blockType).toStrictEqual('content')
})
it('should create a csv of all fields when fields is empty', async () => {
@@ -629,8 +629,8 @@ describe('@payloadcms/plugin-import-export', () => {
const expectedPath = path.join(dirname, './uploads', doc.filename as string)
const data = await readCSV(expectedPath)
expect(data[0].blocks_0_blockType).toStrictEqual('hero')
expect(data[0].blocks_1_blockType).toStrictEqual('content')
expect(data[0].blocks_0_hero_blockType).toStrictEqual('hero')
expect(data[0].blocks_1_content_blockType).toStrictEqual('content')
})
})
})