### 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
24 lines
631 B
TypeScript
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} />
|
|
</>
|
|
)
|
|
}
|