fix: corrects permission access reading for disabling fields (#6815)
Fixes issues where access control was not properly affecting the read-only setting on fields.
This commit is contained in:
42
test/access-control/collections/Disabled/index.ts
Normal file
42
test/access-control/collections/Disabled/index.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { CollectionConfig, Field } from 'payload/types'
|
||||
|
||||
import { disabledSlug } from '../../shared.js'
|
||||
|
||||
const disabledFromUpdateAccessControl = (fieldName = 'text'): Field => ({
|
||||
type: 'text',
|
||||
name: fieldName,
|
||||
access: {
|
||||
update: () => {
|
||||
return false
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export const Disabled: CollectionConfig = {
|
||||
slug: disabledSlug,
|
||||
fields: [
|
||||
{
|
||||
type: 'group',
|
||||
name: 'group',
|
||||
fields: [disabledFromUpdateAccessControl()],
|
||||
},
|
||||
{
|
||||
type: 'tabs',
|
||||
tabs: [
|
||||
{
|
||||
name: 'namedTab',
|
||||
fields: [disabledFromUpdateAccessControl()],
|
||||
},
|
||||
{
|
||||
label: 'unnamedTab',
|
||||
fields: [disabledFromUpdateAccessControl('unnamedTab')],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
name: 'array',
|
||||
fields: [disabledFromUpdateAccessControl()],
|
||||
},
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user