Files
payload/test/admin/components/BeforeList/index.tsx
Jessica Chowdhury c05f10abbc chore: passes allowCreate into list drawer and adds test (#11284)
### What?
We had an `allowCreate` prop for the list drawer that doesn't do
anything. This PR passes the prop through so it can be used.

### How?
Passes `allowCreate` down to the list view and ties it with
`hasCreatePermission`

#### Testing
- Use `admin` test suite and `withListDrawer` collection.
- Test added to the `admin/e2e/list-view`.

Fixes #11246
2025-02-20 12:31:36 +00:00

24 lines
631 B
TypeScript

// src/components/SelectPostsButton.tsx
'use client'
import { Button, type UseListDrawer, useListDrawer } from '@payloadcms/ui'
import { useMemo } from 'react'
type UseListDrawerArgs = Parameters<UseListDrawer>[0]
export const SelectPostsButton = () => {
const listDrawerArgs = useMemo<UseListDrawerArgs>(
() => ({
collectionSlugs: ['with-list-drawer'],
}),
[],
)
const [ListDrawer, _, { toggleDrawer }] = useListDrawer(listDrawerArgs)
return (
<>
<Button onClick={() => toggleDrawer()}>Select posts</Button>
<ListDrawer allowCreate={false} enableRowSelections={false} />
</>
)
}