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:
Jarrod Flesch
2024-06-17 18:33:45 -04:00
committed by GitHub
parent 45871489d0
commit cedd916816
9 changed files with 99 additions and 27 deletions

View 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()],
},
],
}