Skip to content

Commit b65ae07

Browse files
fix(plugin-multi-tenant): corrects default value for tenantsArrayTenantFieldName (#11189)
Incorrect default value on exported `tenantsArrayField` field. Should have been `tenant` but was using `tenants`. This affected the multi-tenant example which uses a custom tenants array field. You would not notice this issue unless you were using: ```ts tenantsArrayField: { includeDefaultField: false, } ``` Fixes #11125
1 parent 480113a commit b65ae07

File tree

2 files changed

+31
-4
lines changed
  • examples/multi-tenant/src/collections/Users
  • packages/plugin-multi-tenant/src/fields/tenantsArrayField

2 files changed

+31
-4
lines changed

examples/multi-tenant/src/collections/Users/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import { setCookieBasedOnDomain } from './hooks/setCookieBasedOnDomain'
1010
import { tenantsArrayField } from '@payloadcms/plugin-multi-tenant/fields'
1111

1212
const defaultTenantArrayField = tenantsArrayField({
13+
tenantsArrayFieldName: 'tenants',
14+
tenantsArrayTenantFieldName: 'tenant',
15+
tenantsCollectionSlug: 'tenants',
1316
arrayFieldAccess: {},
1417
tenantFieldAccess: {},
1518
rowFields: [

packages/plugin-multi-tenant/src/fields/tenantsArrayField/index.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,43 @@ import type { ArrayField, RelationshipField } from 'payload'
33
import { defaults } from '../../defaults.js'
44

55
type Args = {
6+
/**
7+
* Access configuration for the array field
8+
*/
69
arrayFieldAccess?: ArrayField['access']
10+
/**
11+
* Additional fields to include on the tenant array rows
12+
*/
713
rowFields?: ArrayField['fields']
14+
/**
15+
* Access configuration for the tenant field
16+
*/
817
tenantFieldAccess?: RelationshipField['access']
9-
tenantsArrayFieldName: ArrayField['name']
10-
tenantsArrayTenantFieldName: RelationshipField['name']
11-
tenantsCollectionSlug: string
18+
/**
19+
* The name of the array field that holds the tenants
20+
*
21+
* @default 'tenants'
22+
*/
23+
tenantsArrayFieldName?: ArrayField['name']
24+
/**
25+
* The name of the field that will be used to store the tenant relationship in the array
26+
*
27+
* @default 'tenant'
28+
*/
29+
tenantsArrayTenantFieldName?: RelationshipField['name']
30+
/**
31+
* The slug for the tenant collection
32+
*
33+
* @default 'tenants'
34+
*/
35+
tenantsCollectionSlug?: string
1236
}
1337
export const tenantsArrayField = ({
1438
arrayFieldAccess,
1539
rowFields,
1640
tenantFieldAccess,
1741
tenantsArrayFieldName = defaults.tenantsArrayFieldName,
18-
tenantsArrayTenantFieldName = defaults.tenantsArrayFieldName,
42+
tenantsArrayTenantFieldName = defaults.tenantsArrayTenantFieldName,
1943
tenantsCollectionSlug = defaults.tenantCollectionSlug,
2044
}: Args): ArrayField => ({
2145
name: tenantsArrayFieldName,

0 commit comments

Comments
 (0)