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