From a38d9c91f6b5abc8c063960fbe310505c1f9c198 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Mon, 20 Jul 2026 02:06:22 +0100 Subject: [PATCH] Enhance ObjectInfo component by adding support for property definitions and controlled property changes. Introduce new props for parent data and property change handling, improving flexibility and data management in the component. --- .../Dashboard/common/ObjectInfo.jsx | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/Dashboard/common/ObjectInfo.jsx b/src/components/Dashboard/common/ObjectInfo.jsx index 4ec1d97..2699bb8 100644 --- a/src/components/Dashboard/common/ObjectInfo.jsx +++ b/src/components/Dashboard/common/ObjectInfo.jsx @@ -13,7 +13,10 @@ const ObjectInfo = ({ showHyperlink, showLabels = true, objectData = null, + parentData = null, properties = [], + propertyDefinitions = null, + onPropertyChange = null, required = undefined, visibleProperties = {}, objectPropertyProps = {}, @@ -39,7 +42,9 @@ const ObjectInfo = ({ // If properties array is empty, show all properties // Otherwise, filter and order by the properties array let items - if (properties.length === 0) { + if (Array.isArray(propertyDefinitions) && propertyDefinitions.length > 0) { + items = propertyDefinitions + } else if (properties.length === 0) { items = allItems } else { items = properties @@ -80,6 +85,8 @@ const ObjectInfo = ({ } }) + const isControlled = typeof onPropertyChange === 'function' + // Map items to Descriptions 'items' prop format const descriptionItems = items.map((item, idx) => { const key = item.name || item.label || idx @@ -98,7 +105,17 @@ const ObjectInfo = ({ {...objectPropertyProps} isEditing={isEditing} objectData={combinedObjectData} + parentData={parentData} showSince={true} + useFormItem={isControlled ? false : objectPropertyProps.useFormItem} + value={ + isControlled ? combinedObjectData?.[item.name] : undefined + } + onChange={ + isControlled + ? (newVal) => onPropertyChange(item.name, newVal) + : objectPropertyProps.onChange + } /> ), @@ -130,8 +147,11 @@ ObjectInfo.propTypes = { bordered: PropTypes.bool, items: PropTypes.arrayOf(PropTypes.object), isEditing: PropTypes.bool, - type: PropTypes.string.isRequired, + type: PropTypes.string, objectData: PropTypes.object, + parentData: PropTypes.object, + propertyDefinitions: PropTypes.array, + onPropertyChange: PropTypes.func, required: PropTypes.bool, visibleProperties: PropTypes.object, objectPropertyProps: PropTypes.object,