-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/where-builder-closing-on-remove
- Loading branch information
Showing
37 changed files
with
456 additions
and
274 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const defaults = { | ||
tenantCollectionSlug: 'tenants', | ||
tenantFieldName: 'tenant', | ||
tenantsArrayFieldName: 'tenants', | ||
tenantsArrayTenantFieldName: 'tenant', | ||
} |
This file contains 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
26 changes: 18 additions & 8 deletions
26
packages/plugin-multi-tenant/src/fields/tenantsArrayField/index.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
import type { ArrayField, RelationshipField } from 'payload' | ||
|
||
export const tenantsArrayField = (args: { | ||
import { defaults } from '../../defaults.js' | ||
|
||
type Args = { | ||
arrayFieldAccess?: ArrayField['access'] | ||
rowFields?: ArrayField['fields'] | ||
tenantFieldAccess?: RelationshipField['access'] | ||
tenantsArrayFieldName: ArrayField['name'] | ||
tenantsArrayTenantFieldName: RelationshipField['name'] | ||
tenantsCollectionSlug: string | ||
}): ArrayField => ({ | ||
name: args.tenantsArrayFieldName, | ||
} | ||
export const tenantsArrayField = ({ | ||
arrayFieldAccess, | ||
rowFields, | ||
tenantFieldAccess, | ||
tenantsArrayFieldName = defaults.tenantsArrayFieldName, | ||
tenantsArrayTenantFieldName = defaults.tenantsArrayFieldName, | ||
tenantsCollectionSlug = defaults.tenantCollectionSlug, | ||
}: Args): ArrayField => ({ | ||
name: tenantsArrayFieldName, | ||
type: 'array', | ||
access: args?.arrayFieldAccess, | ||
access: arrayFieldAccess, | ||
fields: [ | ||
{ | ||
name: args.tenantsArrayTenantFieldName, | ||
name: tenantsArrayTenantFieldName, | ||
type: 'relationship', | ||
access: args.tenantFieldAccess, | ||
access: tenantFieldAccess, | ||
index: true, | ||
relationTo: args.tenantsCollectionSlug, | ||
relationTo: tenantsCollectionSlug, | ||
required: true, | ||
saveToJWT: true, | ||
}, | ||
...(args?.rowFields || []), | ||
...(rowFields || []), | ||
], | ||
saveToJWT: true, | ||
}) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.