Skip to content
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

feat!: component paths #7246

Merged
merged 114 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
cf3f226
feat: component path types
AlessioGr Jul 19, 2024
c4d96f4
feat: properly typed Server and Client components
AlessioGr Jul 19, 2024
7ffd3a3
feat: ability to mark components as server-only and client-only in a …
AlessioGr Jul 19, 2024
0d304d5
chore: correct usage of PayloadComponent
AlessioGr Jul 19, 2024
ad093cb
chore: type fixes
AlessioGr Jul 19, 2024
67bd26b
fix: cursed TypeScript error which appears when certain generics (e.g…
AlessioGr Jul 19, 2024
605dc22
fix remaining types
AlessioGr Jul 19, 2024
d37c158
make joi component schema weak
AlessioGr Jul 22, 2024
d513fac
Merge remote-tracking branch 'origin/beta' into feat/lexical-inlineFI…
AlessioGr Jul 22, 2024
6d9ea96
WIP migrate richtext-lexical
AlessioGr Jul 22, 2024
f56ef4d
Merge remote-tracking branch 'origin/beta' into feat/component-paths
AlessioGr Jul 22, 2024
606a152
finish migrate richtext-lexical
AlessioGr Jul 22, 2024
f15400b
migrate richtext field and cell components
AlessioGr Jul 22, 2024
8ccdb9a
feat!: working path components, migrate buildComponentMap, pattern fo…
AlessioGr Jul 24, 2024
bba012d
featlexical component map
AlessioGr Jul 24, 2024
318952d
lexical clear server & client separation
AlessioGr Jul 26, 2024
f0b551f
refactor component handling
AlessioGr Jul 26, 2024
096ec6e
richtext handling fixes
AlessioGr Jul 26, 2024
4e3a54d
fix avatar handling
AlessioGr Jul 26, 2024
ca0606c
fix list view
AlessioGr Jul 29, 2024
d16f4fb
It's alive!
AlessioGr Jul 29, 2024
da55395
revamp lexical blocks & componentMap handling
AlessioGr Jul 30, 2024
42dd46c
simplify what the block feature passes down to the client
AlessioGr Jul 30, 2024
242001f
lexical builds
AlessioGr Jul 30, 2024
b8b93a4
get bundled version to work
AlessioGr Jul 30, 2024
8094934
cleanup
AlessioGr Jul 30, 2024
ad5d108
Merge remote-tracking branch 'origin/beta' into feat/component-paths
AlessioGr Jul 30, 2024
a82595c
merge conflicts
AlessioGr Jul 30, 2024
8b60e41
fix errors after merge
AlessioGr Jul 30, 2024
d892db7
update plugin-seo
AlessioGr Jul 30, 2024
7841b0e
Merge remote-tracking branch 'origin/beta' into feat/component-paths
AlessioGr Jul 30, 2024
f066a56
update plugin-search
AlessioGr Jul 30, 2024
a1c1fb6
RenderMappedComponent => RenderComponent, and let RenderComponent han…
AlessioGr Jul 30, 2024
05d534f
add dev:generate-importMap script
AlessioGr Jul 30, 2024
8a40f68
add force option
AlessioGr Jul 30, 2024
77f3408
commit empty importMap
AlessioGr Jul 30, 2024
af83d74
add to gitignore
AlessioGr Jul 30, 2024
3f8ada0
empty importMap
AlessioGr Jul 30, 2024
63d61e7
gitignore
AlessioGr Jul 30, 2024
7911ccb
Update .gitignore
AlessioGr Jul 30, 2024
764ca3b
chore: updates import paths for versions test suite
PatrikKozak Jul 30, 2024
bba021b
Merge branch 'feat/component-paths' of https://github.com/payloadcms/…
PatrikKozak Jul 30, 2024
541166d
fix: more aggressively find imports for blocks and tabs fields admin …
AlessioGr Jul 30, 2024
f77000e
Merge remote-tracking branch 'origin/feat/component-paths' into feat/…
AlessioGr Jul 30, 2024
b799040
gitignore
AlessioGr Jul 30, 2024
0336084
undo
AlessioGr Jul 30, 2024
4aa6bd8
Stop tracking changes to initial_file.txt
AlessioGr Jul 30, 2024
70d4390
chore: updates component import paths for uploads
PatrikKozak Jul 30, 2024
3337440
Merge branch 'feat/component-paths' of https://github.com/payloadcms/…
PatrikKozak Jul 30, 2024
4dee907
gitignore
AlessioGr Jul 30, 2024
de8389f
importMap
AlessioGr Jul 30, 2024
034688b
delete importMap
AlessioGr Jul 30, 2024
51562cb
gitignore
AlessioGr Jul 30, 2024
e8eec17
initImportMap script
AlessioGr Jul 30, 2024
4a98ffe
Merge remote-tracking branch 'origin/feat/component-paths' into feat/…
AlessioGr Jul 30, 2024
6470071
fix: prevent duplications in importMap
AlessioGr Jul 30, 2024
aa55561
add some missing props to import map
AlessioGr Jul 30, 2024
ec87859
init importMap in dev.ts
AlessioGr Jul 30, 2024
289e70b
fix custom Tab handling
AlessioGr Jul 30, 2024
840a241
WIP admin test suite
AlessioGr Jul 30, 2024
a528be4
chore: updates versions and uploads component imports
PatrikKozak Jul 30, 2024
9b09768
Merge branch 'feat/component-paths' of https://github.com/payloadcms/…
PatrikKozak Jul 30, 2024
2a6554a
migrate richtext-slate
AlessioGr Jul 30, 2024
f24b12b
Merge remote-tracking branch 'origin/feat/component-paths' into feat/…
AlessioGr Jul 30, 2024
8c3fa00
fully migrate admin test suite
AlessioGr Jul 30, 2024
024fc22
chore: updates component imports in plugin-sentry
PatrikKozak Jul 30, 2024
0f5998a
intellij run configs
AlessioGr Jul 31, 2024
6b71e13
more intellij run configs
AlessioGr Jul 31, 2024
04a58d8
reliable init importMap generation, improve monorepo compile times by…
AlessioGr Jul 31, 2024
9e48a80
fix: cell component for ID field not showing
AlessioGr Jul 31, 2024
b9007fb
fix slate build, properly type richText generateComponentMap.tsx
AlessioGr Jul 31, 2024
f64a396
convert plugin-stripe
AlessioGr Jul 31, 2024
b507142
chore: updates component imports for live-preview test suite
PatrikKozak Jul 31, 2024
e2eda38
proper error handling
AlessioGr Jul 31, 2024
9119f07
fields
AlessioGr Jul 31, 2024
e94b498
add admin.importMap.baseDir to every test suite config
AlessioGr Jul 31, 2024
baead05
get int test spawnInitProcess scripts to work
AlessioGr Jul 31, 2024
968ee31
gitignore live-preview importMap
AlessioGr Jul 31, 2024
f481411
gitignore live-preview importMap
AlessioGr Jul 31, 2024
d5ea883
fix: live-preview importMaps
AlessioGr Jul 31, 2024
73dfab3
attempt to fix auth/custom-strategy int tests
AlessioGr Jul 31, 2024
8104e99
safely access inlineblock componentmap from shared plugin, in case no…
AlessioGr Jul 31, 2024
e344955
chore: updates component imports for i18n test suite
PatrikKozak Jul 31, 2024
8d6ac8f
fix auth test suites
AlessioGr Jul 31, 2024
2d2d4a7
fix access-cpmtrpö test suites
AlessioGr Jul 31, 2024
b64a6d7
update tests (#7450)
paulpopus Jul 31, 2024
c7b9e47
more verbose logging when writing to databaseAdapter.ts
AlessioGr Jul 31, 2024
4ba65b5
reduce log spam from generateImportMap
AlessioGr Jul 31, 2024
3f6801f
update form builder plugin
paulpopus Jul 31, 2024
3beb0a7
fix: do not attempt rendering undefined components
AlessioGr Jul 31, 2024
8aebc9b
Merge remote-tracking branch 'origin/feat/component-paths' into feat/…
AlessioGr Jul 31, 2024
9fdc8a2
fix nested docs test
paulpopus Jul 31, 2024
9f05e3f
fix: explicit path to tsx in spawnInitProcess, fixing IDE test runners
AlessioGr Jul 31, 2024
b2f01cc
make LexicalPluginToLexicalFeature in test suites quiet
AlessioGr Jul 31, 2024
f83e8a6
add missing quiet
AlessioGr Jul 31, 2024
41c5a2f
fix: Filter component not being rendered correctly
AlessioGr Jul 31, 2024
0db1d5f
fix: plugin-for-builder monorepo tsconfig paths
AlessioGr Jul 31, 2024
08b4292
remove duplicate import map
paulpopus Jul 31, 2024
ca5d1c3
fix: db adapter generated too late for jest
AlessioGr Jul 31, 2024
21f5879
fix: rename env vars, optional ROOT_DIR env var
AlessioGr Jul 31, 2024
215c9be
fix: add default for admin.importMap.baseDir
AlessioGr Jul 31, 2024
66497e1
chore: rename admin.adminDependencies to admin.dependencies
AlessioGr Jul 31, 2024
d8e2ee3
Merge remote-tracking branch 'origin/beta' into feat/component-paths
AlessioGr Jul 31, 2024
ee22c21
fix: import map generation
AlessioGr Jul 31, 2024
c9ab1e8
relative importMap paths & fix webpack left hand assignment error
AlessioGr Jul 31, 2024
ab4c41d
fix create first user fields
paulpopus Jul 31, 2024
afc067f
fix empty component handling
AlessioGr Jul 31, 2024
1fb4ea7
fix admin-root e2e
AlessioGr Jul 31, 2024
307d7cc
actually fix admin-root e2e
AlessioGr Jul 31, 2024
6a4cb39
actually fix admin-root e2e 2
AlessioGr Jul 31, 2024
def188d
actually fix admin-root e2e 3
AlessioGr Jul 31, 2024
441a6f1
actually fix admin-root e2e 4
AlessioGr Jul 31, 2024
aeeb470
Merge remote-tracking branch 'origin/beta' into feat/component-paths
AlessioGr Jul 31, 2024
0244109
merge fixes
AlessioGr Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
!/.idea/runConfigurations
!/.idea/payload.iml


test-results
.devcontainer
.localstack
Expand Down Expand Up @@ -300,3 +301,8 @@ $RECYCLE.BIN/

/build
.swc
app/(payload)/admin/importMap.js
test/live-preview/app/(payload)/admin/importMap.js
/test/live-preview/app/(payload)/admin/importMap.js
test/admin-root/app/(payload)/admin/importMap.js
/test/admin-root/app/(payload)/admin/importMap.js
1 change: 1 addition & 0 deletions .idea/payload.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions .idea/runConfigurations/Run_Dev_Fields.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions .idea/runConfigurations/Run_Dev__community.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/runConfigurations/Run_Dev_admin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions app/(app)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'

export const metadata = {
description: 'Generated by Next.js',
title: 'Next.js',
}

export default function RootLayout({ children }: { children: React.ReactNode }) {

Check warning on line 8 in app/(app)/layout.tsx

View workflow job for this annotation

GitHub Actions / lint

Exporting 'default' is restricted

Check warning on line 8 in app/(app)/layout.tsx

View workflow job for this annotation

GitHub Actions / lint

Component props should be read-only
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
11 changes: 11 additions & 0 deletions app/(app)/test/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import configPromise from '@payload-config'
import { getPayloadHMR } from '@payloadcms/next/utilities'

export const Page = async ({ params, searchParams }) => {

Check warning on line 4 in app/(app)/test/page.tsx

View workflow job for this annotation

GitHub Actions / lint

Component props should be read-only

Check warning on line 4 in app/(app)/test/page.tsx

View workflow job for this annotation

GitHub Actions / lint

'params' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 4 in app/(app)/test/page.tsx

View workflow job for this annotation

GitHub Actions / lint

'searchParams' is defined but never used. Allowed unused args must match /^_/u
const payload = await getPayloadHMR({
config: configPromise,
})
return <div>test ${payload?.config?.collections?.length}</div>
}

export default Page

Check warning on line 11 in app/(app)/test/page.tsx

View workflow job for this annotation

GitHub Actions / lint

Exporting 'default' is restricted
5 changes: 4 additions & 1 deletion app/(payload)/admin/[[...segments]]/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
import { NotFoundPage, generatePageMetadata } from '@payloadcms/next/views'

import { importMap } from '../importMap.js'

type Args = {
params: {
segments: string[]
Expand All @@ -17,6 +19,7 @@
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
generatePageMetadata({ config, params, searchParams })

const NotFound = ({ params, searchParams }: Args) => NotFoundPage({ config, params, searchParams })
const NotFound = ({ params, searchParams }: Args) =>
NotFoundPage({ config, importMap, params, searchParams })

export default NotFound

Check warning on line 25 in app/(payload)/admin/[[...segments]]/not-found.tsx

View workflow job for this annotation

GitHub Actions / lint

Exporting 'default' is restricted
5 changes: 4 additions & 1 deletion app/(payload)/admin/[[...segments]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
import { RootPage, generatePageMetadata } from '@payloadcms/next/views'

import { importMap } from '../importMap.js'

type Args = {
params: {
segments: string[]
Expand All @@ -17,6 +19,7 @@
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
generatePageMetadata({ config, params, searchParams })

const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
const Page = ({ params, searchParams }: Args) =>
RootPage({ config, importMap, params, searchParams })

export default Page

Check warning on line 25 in app/(payload)/admin/[[...segments]]/page.tsx

View workflow job for this annotation

GitHub Actions / lint

Exporting 'default' is restricted
9 changes: 8 additions & 1 deletion app/(payload)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import configPromise from '@payload-config'
import { RootLayout } from '@payloadcms/next/layouts'

import { importMap } from './admin/importMap.js'

// import '@payloadcms/ui/styles.css' // Uncomment this line if `@payloadcms/ui` in `tsconfig.json` points to `/ui/dist` instead of `/ui/src`
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
import React from 'react'
Expand All @@ -11,6 +14,10 @@
children: React.ReactNode
}

const Layout = ({ children }: Args) => <RootLayout config={configPromise}>{children}</RootLayout>
const Layout = ({ children }: Args) => (

Check warning on line 17 in app/(payload)/layout.tsx

View workflow job for this annotation

GitHub Actions / lint

Component props should be read-only
<RootLayout config={configPromise} importMap={importMap}>
{children}
</RootLayout>
)

export default Layout

Check warning on line 23 in app/(payload)/layout.tsx

View workflow job for this annotation

GitHub Actions / lint

Exporting 'default' is restricted
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const rootParserOptions = {
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
EXPERIMENTAL_useProjectService: {
allowDefaultProjectForFiles: ['./src/*.ts', './src/*.tsx'],
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 100,
},
sourceType: 'module',
ecmaVersion: 'latest',
Expand Down
9 changes: 9 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import bundleAnalyzer from '@next/bundle-analyzer'

import withPayload from './packages/next/src/withPayload.js'
import path from 'path'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(__filename)

const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
Expand All @@ -15,6 +20,10 @@ export default withBundleAnalyzer(
typescript: {
ignoreBuildErrors: true,
},
env: {
PAYLOAD_CORE_DEV: 'true',
ROOT_DIR: path.resolve(dirname),
},
async redirects() {
return [
{
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"build:email-nodemailer": "turbo build --filter email-nodemailer",
"build:email-resend": "turbo build --filter email-resend",
"build:eslint-config": "turbo build --filter eslint-config",
"build:essentials:force": "pnpm clean:build && turbo build --filter=\"payload...\" --filter=\"@payloadcms/ui\" --filter=\"@payloadcms/next\" --filter=\"@payloadcms/db-mongodb\" --filter=\"@payloadcms/db-postgres\" --filter=\"@payloadcms/richtext-lexical\" --filter=\"@payloadcms/translations\" --filter=\"@payloadcms/plugin-cloud\" --filter=\"@payloadcms/graphql\" --no-cache --force",
"build:force": "pnpm run build:core:force",
"build:graphql": "turbo build --filter graphql",
"build:live-preview": "turbo build --filter live-preview",
Expand Down Expand Up @@ -52,10 +53,11 @@
"clean:all": "node ./scripts/delete-recursively.js '@node_modules' 'media/*' '**/dist/' '**/.cache/*' '**/.next/*' '**/.turbo/*' '**/tsconfig.tsbuildinfo' '**/payload*.tgz' '**/meta_*.json'",
"clean:build": "node ./scripts/delete-recursively.js 'media/' '**/dist/' '**/.cache/' '**/.next/' '**/.turbo/' '**/tsconfig.tsbuildinfo' '**/payload*.tgz' '**/meta_*.json'",
"clean:cache": "node ./scripts/delete-recursively.js node_modules/.cache! packages/payload/node_modules/.cache! .next/*",
"dev": "cross-env NODE_OPTIONS=--no-deprecation node ./test/dev.js",
"dev": "cross-env NODE_OPTIONS=--no-deprecation tsx ./test/dev.ts",
"dev:generate-graphql-schema": "cross-env NODE_OPTIONS=--no-deprecation tsx ./test/generateGraphQLSchema.ts",
"dev:generate-importMap": "cross-env NODE_OPTIONS=--no-deprecation tsx ./test/generateImportMap.ts",
"dev:generate-types": "cross-env NODE_OPTIONS=--no-deprecation tsx ./test/generateTypes.ts",
"dev:postgres": "cross-env NODE_OPTIONS=--no-deprecation PAYLOAD_DATABASE=postgres node ./test/dev.js",
"dev:postgres": "cross-env NODE_OPTIONS=--no-deprecation PAYLOAD_DATABASE=postgres tsx ./test/dev.ts",
"devsafe": "node ./scripts/delete-recursively.js '**/.next' && pnpm dev",
"docker:restart": "pnpm docker:stop --remove-orphans && pnpm docker:start",
"docker:start": "docker compose -f packages/plugin-cloud-storage/docker-compose.yml up -d",
Expand Down
25 changes: 0 additions & 25 deletions packages/db-mongodb/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,6 @@ export type FieldGenerator<TSchema, TField> = {
schema: TSchema
}

/**
* Field config types that need representation in the database
*/
type FieldType =
| 'array'
| 'blocks'
| 'checkbox'
| 'code'
| 'collapsible'
| 'date'
| 'email'
| 'group'
| 'json'
| 'number'
| 'point'
| 'radio'
| 'relationship'
| 'richText'
| 'row'
| 'select'
| 'tabs'
| 'text'
| 'textarea'
| 'upload'

export type FieldGeneratorFunction<TSchema, TField extends Field> = (
args: FieldGenerator<TSchema, TField>,
) => void
Expand Down
25 changes: 20 additions & 5 deletions packages/next/src/elements/DocumentHeader/Tabs/Tab/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
import type { DocumentTabConfig, DocumentTabProps } from 'payload'

import { RenderComponent, getCreateMappedComponent } from '@payloadcms/ui/shared'
import React, { Fragment } from 'react'

import { DocumentTabLink } from './TabLink.js'
import './index.scss'

export const baseClass = 'doc-tab'

export const DocumentTab: React.FC<DocumentTabConfig & DocumentTabProps> = (props) => {
export const DocumentTab: React.FC<
{ Pill_Component?: React.FC } & DocumentTabConfig & DocumentTabProps
> = (props) => {
const {
Pill,
Pill_Component,
apiURL,
collectionConfig,
condition,
config,
globalConfig,
href: tabHref,
i18n,
isActive: tabIsActive,
label,
newTab,
payload,
permissions,
} = props

const { config } = payload
const { routes } = config

let href = typeof tabHref === 'string' ? tabHref : ''
Expand Down Expand Up @@ -55,6 +59,17 @@ export const DocumentTab: React.FC<DocumentTabConfig & DocumentTabProps> = (prop
})
: label

const createMappedComponent = getCreateMappedComponent({
importMap: payload.importMap,
serverProps: {
i18n,
payload,
permissions,
},
})

const mappedPin = createMappedComponent(Pill, undefined, Pill_Component)

return (
<DocumentTabLink
adminRoute={routes.admin}
Expand All @@ -67,10 +82,10 @@ export const DocumentTab: React.FC<DocumentTabConfig & DocumentTabProps> = (prop
>
<span className={`${baseClass}__label`}>
{labelToRender}
{Pill && (
{mappedPin && (
<Fragment>
&nbsp;
<Pill />
<RenderComponent mappedComponent={mappedPin} />
</Fragment>
)}
</span>
Expand Down
32 changes: 28 additions & 4 deletions packages/next/src/elements/DocumentHeader/Tabs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { I18n } from '@payloadcms/translations'
import type {
Payload,
Permissions,
SanitizedCollectionConfig,
SanitizedConfig,
SanitizedGlobalConfig,
} from 'payload'

import { RenderComponent, getCreateMappedComponent } from '@payloadcms/ui/shared'
import { isPlainObject } from 'payload'
import React from 'react'

Expand All @@ -20,12 +21,13 @@ const baseClass = 'doc-tabs'

export const DocumentTabs: React.FC<{
collectionConfig: SanitizedCollectionConfig
config: SanitizedConfig
globalConfig: SanitizedGlobalConfig
i18n: I18n
payload: Payload
permissions: Permissions
}> = (props) => {
const { collectionConfig, config, globalConfig, permissions } = props
const { collectionConfig, globalConfig, i18n, payload, permissions } = props
const { config } = payload

const customViews = getCustomViews({ collectionConfig, globalConfig })

Expand Down Expand Up @@ -82,7 +84,29 @@ export const DocumentTabs: React.FC<{
}

if (typeof Tab === 'function') {
return <Tab path={path} {...props} key={`tab-custom-${index}`} />
const createMappedComponent = getCreateMappedComponent({
importMap: payload.importMap,
serverProps: {
i18n,
payload,
permissions,
...props,
key: `tab-custom-${index}`,
path,
},
})

const mappedTab = createMappedComponent(Tab)
return (
<RenderComponent
clientProps={{
key: `tab-custom-${index}`,
path,
}}
key={`tab-custom-${index}`}
mappedComponent={mappedTab}
/>
)
}

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DocumentTabConfig } from 'payload'
import type React from 'react'

import { VersionsPill } from './VersionsPill/index.js'

Expand All @@ -17,6 +18,7 @@ export type DocumentViewKey = (typeof documentViewKeys)[number]
export const tabs: Record<
DocumentViewKey,
{
Pill_Component?: React.FC
order?: number // TODO: expose this to the globalConfig config
} & DocumentTabConfig
> = {
Expand Down Expand Up @@ -67,7 +69,7 @@ export const tabs: Record<
condition: () => false,
},
Versions: {
Pill: VersionsPill,
Pill_Component: VersionsPill,
condition: ({ collectionConfig, globalConfig, permissions }) =>
Boolean(
(collectionConfig?.versions &&
Expand Down
Loading
Loading