fix: bulk publish from collection list (#6065)

This commit is contained in:
Dan Ribbens
2024-04-26 15:46:02 -04:00
committed by GitHub
parent 739dfc1434
commit 81fb0515fb
3 changed files with 35 additions and 11 deletions

View File

@@ -56,7 +56,7 @@ export const PublishMany: React.FC<PublishManyProps> = (props) => {
setSubmitted(true)
await requests
.patch(
`${serverURL}${api}/${slug}${getQueryParams({ _status: { not_equals: 'published' } })}`,
`${serverURL}${api}/${slug}${getQueryParams({ _status: { not_equals: 'published' } })}&draft=true`,
{
body: JSON.stringify({
_status: 'published',

View File

@@ -10,7 +10,7 @@ const AutosavePosts: CollectionConfig = {
},
admin: {
useAsTitle: 'title',
defaultColumns: ['title', 'description', 'createdAt'],
defaultColumns: ['title', 'description', 'createdAt', '_status'],
preview: () => 'https://payloadcms.com',
},
versions: {

View File

@@ -118,6 +118,7 @@ describe('versions', () => {
autosaveURL = new AdminUrlUtil(serverURL, autosaveCollectionSlug)
disablePublishURL = new AdminUrlUtil(serverURL, disablePublishSlug)
customIDURL = new AdminUrlUtil(serverURL, customIDSlug)
postURL = new AdminUrlUtil(serverURL, postCollectionSlug)
})
// This test has to run before bulk updates that will rename the title
@@ -155,6 +156,38 @@ describe('versions', () => {
await expect(findTableCell(page, '_status', 'Draft Title')).toContainText('Published')
})
test('bulk publish with autosave documents', async () => {
const title = 'autosave title'
const description = 'autosave description'
await page.goto(autosaveURL.create)
// fill the fields
await page.locator('#field-title').fill(title)
await page.locator('#field-description').fill(description)
// wait for autosave
await waitForAutoSaveToRunAndComplete(page)
// go to list
await page.goto(autosaveURL.list)
// expect the status to be draft
await expect(findTableCell(page, '_status', title)).toContainText('Draft')
// select the row
// await page.locator('.row-1 .select-row__checkbox').click()
await selectTableRow(page, title)
// click the publish many
await page.locator('.publish-many__toggle').click()
// confirm the dialog
await page.locator('#confirm-publish').click()
// expect the status to be published
await expect(findTableCell(page, '_status', title)).toContainText('Published')
})
test('bulk update - should unpublish many', async () => {
await page.goto(url.list)
@@ -539,15 +572,6 @@ describe('versions', () => {
await expect(page.locator('#action-save')).not.toBeAttached()
})
})
describe('posts collection', () => {
beforeAll(() => {
url = new AdminUrlUtil(serverURL, draftCollectionSlug)
autosaveURL = new AdminUrlUtil(serverURL, autosaveCollectionSlug)
disablePublishURL = new AdminUrlUtil(serverURL, disablePublishSlug)
customIDURL = new AdminUrlUtil(serverURL, customIDSlug)
postURL = new AdminUrlUtil(serverURL, postCollectionSlug)
})
test('should show documents title in relationship even if draft document', async () => {
await payload.create({