Opt-in to cross tenant relationships on a per-field basis when using the multi-tenant plugin #12872
evelynhathaway
started this conversation in
Feature Requests & Ideas
Replies: 1 comment
-
Adding a condition to the multi tenant
diff --git a/dist/utilities/addFilterOptionsToFields.js b/dist/utilities/addFilterOptionsToFields.js
index 72e0cd45632fc2b2387694d6de3eb2840d3f50cd..fc576c979e9998e410993c770ca6f9698b120a70 100644
--- a/dist/utilities/addFilterOptionsToFields.js
+++ b/dist/utilities/addFilterOptionsToFields.js
@@ -85,6 +85,11 @@ export function addFilterOptionsToFields({ config, fields, tenantEnabledCollecti
});
}
function addFilter({ field, tenantEnabledCollectionSlugs, tenantFieldName, tenantsArrayFieldName = defaults.tenantsArrayFieldName, tenantsArrayTenantFieldName = defaults.tenantsArrayTenantFieldName, tenantsCollectionSlug }) {
+ // TODO: Remove if a option is added in a new version of the plugin
+ // Skip filtering by tenant on a per-relationship field basis
+ // - Defaults to filtering, overridden only by `false`
+ // - See: https://github.com/payloadcms/payload/discussions/12872
+ if (field.custom?.useTenantFilter === false) return;
// User specified filter
const originalFilter = field.filterOptions;
field.filterOptions = async (args)=>{ But relationship drawers will still apply the tenant A core change would be appreciated since a workaround isn't possible. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
It would be beneficial for some multi-tenant applications to selectively allow relationships to cross the tenant boundary, especially for linking.
Background
The multi tenant plugin does a great job of separating documents by tenant, but it doesn't allow for selectively bridging between tenants in relationships since the plugin's
filterOptions
is added unconditionally:payload/packages/plugin-multi-tenant/src/utilities/addFilterOptionsToFields.ts
Line 123 in 6c4dfe4
However, the filters on the tenants, users, and each multi-tenant collection list view can already be toggled off, and serve as a good model for how the relationship filters can be disabled:
payload/packages/plugin-multi-tenant/README.md
Lines 38 to 43 in 6c4dfe4
payload/packages/plugin-multi-tenant/README.md
Lines 153 to 160 in 6c4dfe4
Request
While I am not attached to the syntax, it would be nice to have granular control of relationship filters like the below.
Similar to the underlying request from #10983
Use Case
If implemented, most of the relationships in my instance would take advantage of the current behavior as the default. The safety from the separation being the remaining the default is desired, just like
baseListFilter
. I think that makes sense for most cases, and is of course critical for fields like theparent
relationship from the nested documents plugin.The relationships fields that I would opt out in my instance would be links (rich text, button blocks, navigation items) and redirect destinations. My instance would be able to support the access controls required to accomodate this, and I am not advocating for the plugin to provide access controls for cross-tenant relationships as I believe it would be too much of a implementation-specific niche for the plugin to handle itself.
Advantages for My Use Case
Beta Was this translation helpful? Give feedback.
All reactions