fix(ui): proper permissions within version diff view (#9346)
Fixes #9337. The version view was not able to render its diff because of an invalid permissions lookup. This was a result of a change to how access results are returned from the API, which are now sanitized: https://github.com/payloadcms/payload/pull/7335
This commit is contained in:
@@ -25,6 +25,7 @@ const RenderFieldsToDiff: React.FC<Props> = ({
|
|||||||
// typing it as `as typeof _diffComponents` here ensures the TField generics of DiffComponentProps are respected.
|
// typing it as `as typeof _diffComponents` here ensures the TField generics of DiffComponentProps are respected.
|
||||||
// Without it, you could pass a UI field to the Tabs component, without it erroring
|
// Without it, you could pass a UI field to the Tabs component, without it erroring
|
||||||
const diffComponents: typeof _diffComponents = __diffComponents as typeof _diffComponents
|
const diffComponents: typeof _diffComponents = __diffComponents as typeof _diffComponents
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={baseClass}>
|
<div className={baseClass}>
|
||||||
{fields?.map((field, i) => {
|
{fields?.map((field, i) => {
|
||||||
@@ -51,7 +52,9 @@ const RenderFieldsToDiff: React.FC<Props> = ({
|
|||||||
: comparison?.[fieldName]
|
: comparison?.[fieldName]
|
||||||
|
|
||||||
const hasPermission =
|
const hasPermission =
|
||||||
fieldPermissions?.[fieldName] === true || fieldPermissions?.[fieldName]?.read
|
fieldPermissions === true ||
|
||||||
|
fieldPermissions?.[fieldName] === true ||
|
||||||
|
fieldPermissions?.[fieldName]?.read
|
||||||
|
|
||||||
const subFieldPermissions =
|
const subFieldPermissions =
|
||||||
fieldPermissions?.[fieldName] === true || fieldPermissions?.[fieldName]?.fields
|
fieldPermissions?.[fieldName] === true || fieldPermissions?.[fieldName]?.fields
|
||||||
|
|||||||
@@ -317,6 +317,7 @@ describe('versions', () => {
|
|||||||
const versionID = await row2.locator('.cell-id').textContent()
|
const versionID = await row2.locator('.cell-id').textContent()
|
||||||
await page.goto(`${savedDocURL}/versions/${versionID}`)
|
await page.goto(`${savedDocURL}/versions/${versionID}`)
|
||||||
await page.waitForURL(`${savedDocURL}/versions/${versionID}`)
|
await page.waitForURL(`${savedDocURL}/versions/${versionID}`)
|
||||||
|
await expect(page.locator('.render-field-diffs')).toBeVisible()
|
||||||
await page.locator('.restore-version__button').click()
|
await page.locator('.restore-version__button').click()
|
||||||
await page.locator('button:has-text("Confirm")').click()
|
await page.locator('button:has-text("Confirm")').click()
|
||||||
await page.waitForURL(savedDocURL)
|
await page.waitForURL(savedDocURL)
|
||||||
|
|||||||
Reference in New Issue
Block a user