Skip to content

Commit

Permalink
fix(ui): proper permissions within version diff view (#9346)
Browse files Browse the repository at this point in the history
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:
#7335
  • Loading branch information
jacobsfletch authored Nov 19, 2024
1 parent d9c6288 commit 188baec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/next/src/views/Version/RenderFieldsToDiff/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const RenderFieldsToDiff: React.FC<Props> = ({
// 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
const diffComponents: typeof _diffComponents = __diffComponents as typeof _diffComponents

return (
<div className={baseClass}>
{fields?.map((field, i) => {
Expand All @@ -51,7 +52,9 @@ const RenderFieldsToDiff: React.FC<Props> = ({
: comparison?.[fieldName]

const hasPermission =
fieldPermissions?.[fieldName] === true || fieldPermissions?.[fieldName]?.read
fieldPermissions === true ||
fieldPermissions?.[fieldName] === true ||
fieldPermissions?.[fieldName]?.read

const subFieldPermissions =
fieldPermissions?.[fieldName] === true || fieldPermissions?.[fieldName]?.fields
Expand Down
1 change: 1 addition & 0 deletions test/versions/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ describe('versions', () => {
const versionID = await row2.locator('.cell-id').textContent()
await page.goto(`${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('button:has-text("Confirm")').click()
await page.waitForURL(savedDocURL)
Expand Down

0 comments on commit 188baec

Please sign in to comment.