Skip to content

feat(plugin-multi-tenant): add tenantSelectorComponent option to cust… #12372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Lezzio
Copy link

@Lezzio Lezzio commented May 10, 2025

What?

  • Add tenantSelectorComponent option
    Introduces a new tenantSelectorComponent?: CustomComponent | null field on the multi-tenant plugin config, with three modes:
    1. Custom: supply your own component → rendered in the admin UI
    2. Disabled: supply null → no selector is rendered
    3. Default: leave it undefined → the existing default selector is used

Why?

  • Enable multi-tenant selector UI and UX flexibility
    Developers can now completely disable the selector or swap in a custom implementation.

Examples:

This property is an intuitive addition in the current design and it unlocks customization and workarounds for UI and UX

How?

  1. Schema change

    /**
     * Override or disable the TenantSelector shown above the nav.
     *
     * - supply a `CustomComponent` → your component is rendered
     * - supply `null`              → no selector is rendered
     * - leave it `undefined`       → the default selector is rendered
     *
     * @default undefined
     */
    tenantSelectorComponent?: CustomComponent | null
  2. Component setup

    /**
     * Add tenant selector to admin UI
     */
    const defaultTenantSelector: CustomComponent = {
      clientProps: { label: tenantSelectorLabel },
      path: '@payloadcms/plugin-multi-tenant/client#TenantSelector',
    }
    
    if (pluginConfig.tenantSelectorComponent !== null) {
      incomingConfig.admin.components.beforeNavLinks.push(
        pluginConfig.tenantSelectorComponent ?? defaultTenantSelector,
      )
    }
  3. Link to issue
    Provides a configuration-level workaround for the behavior detailed in [#12369](Switching tenant while editing a document unintentionally changes document tenant #12369) without baking in a specific redirect or mutation strategy.

@Lezzio Lezzio marked this pull request as ready for review May 10, 2025 22:58
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