fix: versions not loading properly (#11256)
### What? The admin panel was not respecting where constraints returned from the readAccess function. ### Why? `getEntityPolicies` was always using `find` when looping over the operations, but `readVersions` should be using `findVersions`. ### How? When the operation is `readVersions` run the `findVersions` operation. Fixes https://github.com/payloadcms/payload/issues/11240
This commit is contained in:
@@ -35,6 +35,7 @@ import {
|
||||
readNotUpdateGlobalSlug,
|
||||
readOnlyGlobalSlug,
|
||||
readOnlySlug,
|
||||
restrictedVersionsAdminPanelSlug,
|
||||
restrictedVersionsSlug,
|
||||
slug,
|
||||
unrestrictedSlug,
|
||||
@@ -63,6 +64,7 @@ describe('Access Control', () => {
|
||||
let richTextUrl: AdminUrlUtil
|
||||
let readOnlyGlobalUrl: AdminUrlUtil
|
||||
let restrictedVersionsUrl: AdminUrlUtil
|
||||
let restrictedVersionsAdminPanelUrl: AdminUrlUtil
|
||||
let userRestrictedCollectionURL: AdminUrlUtil
|
||||
let userRestrictedGlobalURL: AdminUrlUtil
|
||||
let disabledFields: AdminUrlUtil
|
||||
@@ -81,6 +83,7 @@ describe('Access Control', () => {
|
||||
readOnlyCollectionUrl = new AdminUrlUtil(serverURL, readOnlySlug)
|
||||
readOnlyGlobalUrl = new AdminUrlUtil(serverURL, readOnlySlug)
|
||||
restrictedVersionsUrl = new AdminUrlUtil(serverURL, restrictedVersionsSlug)
|
||||
restrictedVersionsAdminPanelUrl = new AdminUrlUtil(serverURL, restrictedVersionsAdminPanelSlug)
|
||||
userRestrictedCollectionURL = new AdminUrlUtil(serverURL, userRestrictedCollectionSlug)
|
||||
userRestrictedGlobalURL = new AdminUrlUtil(serverURL, userRestrictedGlobalSlug)
|
||||
disabledFields = new AdminUrlUtil(serverURL, disabledSlug)
|
||||
@@ -557,16 +560,26 @@ describe('Access Control', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
existingDoc = await payload.create({
|
||||
collection: restrictedVersionsSlug,
|
||||
collection: restrictedVersionsAdminPanelSlug,
|
||||
data: {
|
||||
name: 'name',
|
||||
},
|
||||
})
|
||||
|
||||
await payload.update({
|
||||
collection: restrictedVersionsAdminPanelSlug,
|
||||
id: existingDoc.id,
|
||||
data: {
|
||||
hidden: true,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('versions sidebar should not show', async () => {
|
||||
await page.goto(restrictedVersionsUrl.edit(existingDoc.id))
|
||||
await expect(page.locator('.versions-count')).toBeHidden()
|
||||
test('versions tab should not show', async () => {
|
||||
await page.goto(restrictedVersionsAdminPanelUrl.edit(existingDoc.id))
|
||||
await page.locator('.doc-tabs__tabs').getByLabel('Versions').click()
|
||||
const rows = page.locator('.versions table tbody tr')
|
||||
await expect(rows).toHaveCount(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user