### Improved tenant assignment flow This PR improves the tenant assignment flow. I know a lot of users liked the previous flow where the field was not injected into the document. But the original flow, confused many of users because the tenant filter (top left) was being used to set the tenant on the document _and_ filter the list view. This change shown below is aiming to solve both of those groups with a slightly different approach. As always, feedback is welcome while we try to really make this plugin work for everyone. https://github.com/user-attachments/assets/ceee8b3a-c5f5-40e9-8648-f583e2412199 Added 2 new localization strings: ``` // shown in the 3 dot menu 'assign-tenant-button-label': 'Assign Tenant', // shown when needing to assign a tenant to a NEW document 'assign-tenant-modal-title': 'Assign "{{title}}"', ``` Removed 2 localization strings: ``` 'confirm-modal-tenant-switch--body', 'confirm-modal-tenant-switch--heading' ```
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { multiTenantPlugin } from '@payloadcms/plugin-multi-tenant'
|
|
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
import type { Config as ConfigType } from './payload-types.js'
|
|
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
import { AutosaveGlobal } from './collections/AutosaveGlobal.js'
|
|
import { Menu } from './collections/Menu.js'
|
|
import { MenuItems } from './collections/MenuItems.js'
|
|
import { Tenants } from './collections/Tenants.js'
|
|
import { Users } from './collections/Users/index.js'
|
|
import { seed } from './seed/index.js'
|
|
import { autosaveGlobalSlug, menuItemsSlug, menuSlug } from './shared.js'
|
|
|
|
export default buildConfigWithDefaults({
|
|
collections: [Tenants, Users, MenuItems, Menu, AutosaveGlobal],
|
|
admin: {
|
|
autoLogin: false,
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
components: {
|
|
graphics: {
|
|
Logo: '/components/Logo/index.js#Logo',
|
|
Icon: '/components/Icon/index.js#Icon',
|
|
},
|
|
},
|
|
},
|
|
onInit: seed,
|
|
plugins: [
|
|
multiTenantPlugin<ConfigType>({
|
|
// debug: true,
|
|
userHasAccessToAllTenants: (user) => Boolean(user.roles?.includes('admin')),
|
|
useTenantsCollectionAccess: false,
|
|
tenantField: {
|
|
access: {},
|
|
},
|
|
collections: {
|
|
[menuItemsSlug]: {
|
|
useTenantAccess: false,
|
|
},
|
|
[menuSlug]: {
|
|
isGlobal: true,
|
|
},
|
|
[autosaveGlobalSlug]: {
|
|
isGlobal: true,
|
|
},
|
|
},
|
|
i18n: {
|
|
translations: {
|
|
en: {
|
|
'field-assignedTenant-label': 'Site',
|
|
'nav-tenantSelector-label': 'Filter by Site',
|
|
'assign-tenant-button-label': 'Assign Site',
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
],
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|