You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: hide fields with read: false in list view columns, filters, and groupBy (#14118)
### What?
Fixes fields with `read: false` access control appearing in list view
column selector, filter dropdown, and groupBy dropdown. Previously,
these fields would show with `<No Restricted Field>` placeholders in
columns, and were still selectable in the filter and groupBy dropdowns
despite the user not having read access.
### Why?
Users should not be able to interact with fields they don't have read
access to.
### How?
- Created `filterFieldsWithPermissions` utility that recursively filters
fields based on `read` permissions
- Handles nested structures (tabs, groups, rows, collapsibles) by
recursively accessing nested permissions via
`fieldPermissions[fieldName]?.fields` or `fieldPermissions[fieldName]`
- Checks `fieldPermissions[field.name] === true` or
`fieldPermissions[field.name]?.read` for leaf fields with data
- Combines filtering logic from existing `filterFields` with permission
checks
- Updated `buildColumnState` to use `filterFieldsWithPermissions`
instead of `filterFields`, filtering both client and server fields
before flattening
- Updated `renderTable` to use `filterFieldsWithPermissions` when
building field lists for relationship tables
---------
Co-authored-by: Jarrod Flesch <[email protected]>
Copy file name to clipboardExpand all lines: packages/ui/src/providers/TableColumns/buildColumnState/index.tsx
+24-12Lines changed: 24 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ import type {
12
12
Payload,
13
13
PayloadRequest,
14
14
SanitizedCollectionConfig,
15
+
SanitizedFieldsPermissions,
15
16
ServerComponentProps,
16
17
StaticLabel,
17
18
ViewTypes,
@@ -32,7 +33,7 @@ import {
32
33
SortColumn,
33
34
// eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587
0 commit comments