Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/ui/src/views/List/ListHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const CollectionListHeader: React.FC<ListHeaderProps> = ({
const { config, getEntityConfig } = useConfig()
const { drawerSlug, isInDrawer, selectedOption } = useListDrawerContext()
const isTrashRoute = viewType === 'trash'
const { isGroupingBy } = useListQuery()
const { isGroupingBy, query } = useListQuery()

if (isInDrawer) {
return (
Expand Down Expand Up @@ -104,6 +104,7 @@ export const CollectionListHeader: React.FC<ListHeaderProps> = ({
label={getTranslation(collectionConfig?.labels?.plural, i18n)}
showSelectAllAcrossPages={!isGroupingBy}
viewType={viewType}
where={query?.where}
/>
),
<DefaultListViewTabs
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/views/List/index.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ export function DefaultListView(props: ListViewClientProps) {
disableBulkEdit={disableBulkEdit}
label={collectionLabel}
showSelectAllAcrossPages={!isGroupingBy}
where={query?.where}
/>
<div className={`${baseClass}__list-selection-actions`}>
{enableRowSelections && typeof onBulkSelect === 'function'
Expand Down
60 changes: 60 additions & 0 deletions test/bulk-edit/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,66 @@ test.describe('Bulk Edit', () => {
)
})

test('should respect the list filter when unpublishing all across pages', async () => {
await deleteAllPosts()

const matchingDescription = 'unpublish-me'
const otherDescription = 'leave-me-alone'

for (let i = 1; i <= 3; i++) {
await createPost({ title: `Matching post ${i}`, description: matchingDescription })
await wait(50)
}

for (let i = 1; i <= 3; i++) {
await createPost({ title: `Other post ${i}`, description: otherDescription })
await wait(50)
}

await page.goto(postsUrl.list)
// Wait until page has limit in the url, to ensure it is fully loaded
await expect.poll(() => page.url(), { timeout: POLL_TOPASS_TIMEOUT }).toContain('limit=')

await addListFilter({
page,
fieldLabel: 'Description',
operatorLabel: 'equals',
value: matchingDescription,
})

await page.locator('input#select-all').check()
await page.locator('button#select-all-across-pages').click()

await page.locator('.list-selection__button[aria-label="Unpublish"]').click()
await page.locator('#unpublish-posts [data-dialog-action="confirm"]').click()

await expect
.poll(
async () => {
const { docs } = await payload.find({
collection: postsSlug,
where: { description: { equals: matchingDescription } },
})

return docs.every((doc) => doc._status === 'draft')
},
{ timeout: POLL_TOPASS_TIMEOUT },
)
.toBe(true)

// Documents outside the filter must be untouched
const { docs: otherDocs } = await payload.find({
collection: postsSlug,
where: { description: { equals: otherDescription } },
})

expect(otherDocs).toHaveLength(3)

for (const doc of otherDocs) {
expect(doc._status).toBe('published')
}
})

test('should update many', async () => {
await deleteAllPosts()

Expand Down