fix(ui): ensure field components safely access field.admin property (#7670)
This commit is contained in:
@@ -40,7 +40,7 @@ const RichTextComponent: React.FC<
|
||||
readOnly: readOnlyFromAdmin,
|
||||
style,
|
||||
width,
|
||||
},
|
||||
} = {},
|
||||
label,
|
||||
required,
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ const RichTextEditor = lazy(() =>
|
||||
|
||||
export const RichTextField: React.FC<LexicalRichTextFieldProps> = (props) => {
|
||||
const {
|
||||
admin,
|
||||
admin = {},
|
||||
field: { richTextComponentMap },
|
||||
lexicalEditorConfig,
|
||||
} = props
|
||||
|
||||
@@ -64,7 +64,7 @@ const RichTextField: React.FC<LoadedSlateFieldProps> = (props) => {
|
||||
readOnly: readOnlyFromAdmin,
|
||||
style,
|
||||
width,
|
||||
},
|
||||
} = {},
|
||||
label,
|
||||
required,
|
||||
},
|
||||
|
||||
@@ -43,7 +43,7 @@ export const ArrayFieldComponent: React.FC<ArrayFieldProps> = (props) => {
|
||||
description,
|
||||
isSortable = true,
|
||||
readOnly: readOnlyFromAdmin,
|
||||
},
|
||||
} = {},
|
||||
fields,
|
||||
label,
|
||||
localized,
|
||||
|
||||
@@ -42,7 +42,7 @@ const BlocksFieldComponent: React.FC<BlockFieldProps> = (props) => {
|
||||
field: {
|
||||
name,
|
||||
_path: pathFromProps,
|
||||
admin: { className, description, isSortable = true, readOnly: readOnlyFromAdmin },
|
||||
admin: { className, description, isSortable = true, readOnly: readOnlyFromAdmin } = {},
|
||||
blocks,
|
||||
label,
|
||||
labels: labelsFromProps,
|
||||
|
||||
@@ -37,7 +37,7 @@ const CodeFieldComponent: React.FC<CodeFieldProps> = (props) => {
|
||||
readOnly: readOnlyFromAdmin,
|
||||
style,
|
||||
width,
|
||||
},
|
||||
} = {},
|
||||
label,
|
||||
required,
|
||||
},
|
||||
|
||||
@@ -27,7 +27,7 @@ const CollapsibleFieldComponent: React.FC<CollapsibleFieldProps> = (props) => {
|
||||
field,
|
||||
field: {
|
||||
_path: pathFromProps,
|
||||
admin: { className, description, initCollapsed = false, readOnly: readOnlyFromAdmin },
|
||||
admin: { className, description, initCollapsed = false, readOnly: readOnlyFromAdmin } = {},
|
||||
fields,
|
||||
label,
|
||||
},
|
||||
|
||||
@@ -35,7 +35,7 @@ const DateTimeFieldComponent: React.FC<DateFieldProps> = (props) => {
|
||||
readOnly: readOnlyFromAdmin,
|
||||
style,
|
||||
width,
|
||||
},
|
||||
} = {},
|
||||
label,
|
||||
required,
|
||||
},
|
||||
|
||||
@@ -32,7 +32,7 @@ export const GroupFieldComponent: React.FC<GroupFieldProps> = (props) => {
|
||||
descriptionProps,
|
||||
field,
|
||||
field: {
|
||||
admin: { className, description, hideGutter, readOnly: readOnlyFromAdmin, style, width },
|
||||
admin: { className, description, hideGutter, readOnly: readOnlyFromAdmin, style, width } = {},
|
||||
fields,
|
||||
label,
|
||||
},
|
||||
|
||||
@@ -25,7 +25,14 @@ const JSONFieldComponent: React.FC<JSONFieldProps> = (props) => {
|
||||
field: {
|
||||
name,
|
||||
_path: pathFromProps,
|
||||
admin: { className, description, editorOptions, readOnly: readOnlyFromAdmin, style, width },
|
||||
admin: {
|
||||
className,
|
||||
description,
|
||||
editorOptions,
|
||||
readOnly: readOnlyFromAdmin,
|
||||
style,
|
||||
width,
|
||||
} = {},
|
||||
jsonSchema,
|
||||
label,
|
||||
required,
|
||||
|
||||
@@ -34,7 +34,7 @@ export const PointFieldComponent: React.FC<PointFieldProps> = (props) => {
|
||||
step,
|
||||
style,
|
||||
width,
|
||||
},
|
||||
} = {},
|
||||
label,
|
||||
required,
|
||||
},
|
||||
|
||||
@@ -50,7 +50,7 @@ const RelationshipFieldComponent: React.FC<RelationshipFieldProps> = (props) =>
|
||||
sortOptions,
|
||||
style,
|
||||
width,
|
||||
},
|
||||
} = {},
|
||||
hasMany,
|
||||
label,
|
||||
relationTo,
|
||||
|
||||
@@ -16,10 +16,7 @@ const baseClass = 'row'
|
||||
|
||||
const RowFieldComponent: React.FC<RowFieldProps> = (props) => {
|
||||
const {
|
||||
field: {
|
||||
admin: { className },
|
||||
fields,
|
||||
},
|
||||
field: { admin: { className } = {}, fields },
|
||||
forceRender = false,
|
||||
} = props
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const TabsFieldComponent: React.FC<TabsFieldProps> = (props) => {
|
||||
field,
|
||||
field: {
|
||||
_path: pathFromProps,
|
||||
admin: { className, readOnly: readOnlyFromAdmin },
|
||||
admin: { className, readOnly: readOnlyFromAdmin } = {},
|
||||
tabs = [],
|
||||
},
|
||||
forceRender = false,
|
||||
|
||||
@@ -31,7 +31,7 @@ const TextFieldComponent: React.FC<TextFieldProps> = (props) => {
|
||||
rtl,
|
||||
style,
|
||||
width,
|
||||
},
|
||||
} = {},
|
||||
hasMany,
|
||||
label,
|
||||
localized,
|
||||
|
||||
@@ -32,7 +32,7 @@ const TextareaFieldComponent: React.FC<TextareaFieldProps> = (props) => {
|
||||
rtl,
|
||||
style,
|
||||
width,
|
||||
},
|
||||
} = {},
|
||||
label,
|
||||
localized,
|
||||
maxLength,
|
||||
|
||||
@@ -22,7 +22,7 @@ const UploadComponent: React.FC<UploadFieldProps> = (props) => {
|
||||
field,
|
||||
field: {
|
||||
_path: pathFromProps,
|
||||
admin: { className, readOnly: readOnlyFromAdmin, style, width },
|
||||
admin: { className, readOnly: readOnlyFromAdmin, style, width } = {},
|
||||
label,
|
||||
relationTo,
|
||||
required,
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
],
|
||||
"paths": {
|
||||
"@payload-config": [
|
||||
"./test/fields/config.ts"
|
||||
"./test/_community/config.ts"
|
||||
],
|
||||
"@payloadcms/live-preview": [
|
||||
"./packages/live-preview/src"
|
||||
|
||||
Reference in New Issue
Block a user