Files
payloadcms/test/admin/shared.ts
Jacob c639c5f278 fix(next): cannot override tab of default views (#11789)
### What?

TypeScript says that it is possible to modify the tab of the default
view however, when you specify the path to the custom component, nothing
happens. I fixed it.

### How?

If a Component for the tab of the default view is defined in the config,
I return that Component instead of DocumentTab

### Example Configuration

config.ts
```ts
export const MenuGlobal: GlobalConfig = {
  slug: menuSlug,
  fields: [
    {
      name: 'globalText',
      type: 'text',
    },
  ],
  admin: {
    components: {
      views: {
        edit: {
          api: {
            tab: {
              Component: './TestComponent.tsx',
            },
          },
        },
      },
    },
  },
}
```
./TestComponent.tsx
```tsx
const TestComponent = () => 'example'

export default TestComponent
```


### Before
![Screenshot 2025-03-20 at 08 42
06](https://github.com/user-attachments/assets/2acc0950-847f-44c5-bedf-660c5c3747a0)

### After
![Screenshot 2025-03-20 at 08 43
06](https://github.com/user-attachments/assets/c3917d02-abfb-4f80-9235-cc1ba784586d)

---------

Co-authored-by: Jacob Fletcher <jacobsfletch@gmail.com>
2025-06-02 14:51:33 -04:00

65 lines
2.0 KiB
TypeScript

import type { Config } from 'payload'
export const slugSingularLabel = 'Post'
export const slugPluralLabel = 'Posts'
export const customViewPath = '/custom-view'
export const customNestedViewPath = `${customViewPath}/nested-view`
export const publicCustomViewPath = '/public-custom-view'
export const protectedCustomNestedViewPath = `${publicCustomViewPath}/protected-nested-view`
export const customParamViewPathBase = '/custom-param'
export const customParamViewPath = `${customParamViewPathBase}/:id`
export const customViewTitle = 'Custom View'
export const customParamViewTitle = 'Custom Param View'
export const customNestedViewTitle = 'Custom Nested View'
export const customEditLabel = 'Custom Edit Label'
export const customTabComponent = 'Custom Tab Component'
export const overriddenDefaultRouteTabLabel = 'Custom Tab Component Default View'
export const customTabLabel = 'Custom Tab Label'
export const customTabViewPath = '/custom-tab-component'
export const customTabViewTitle = 'Custom View With Tab Component'
export const customTabLabelViewTitle = 'Custom Tab Label View'
export const customTabViewComponentTitle = 'Custom View With Tab Component'
export const customNestedTabViewPath = `${customTabViewPath}/nested-view`
export const customCollectionMetaTitle = 'Custom Meta Title'
export const customRootViewMetaTitle = 'Custom Root View Meta Title'
export const customDefaultTabMetaTitle = 'Custom Default Tab Meta Title'
export const customVersionsTabMetaTitle = 'Custom Versions Tab Meta Title'
export const customTabAdminDescription = 'Custom Tab Admin Description'
export const customViewMetaTitle = 'Custom Tab Meta Title'
export const customNestedTabViewTitle = 'Custom Nested Tab View'
export const customCollectionParamViewPathBase = '/custom-param'
export const customCollectionParamViewPath = `${customCollectionParamViewPathBase}/:slug`
export const customAdminRoutes: Config['admin']['routes'] = {
inactivity: '/custom-inactivity',
logout: '/custom-logout',
}