Enhance ObjectProperty and OperationDisplay components to support dynamic type resolution and add subscription/unsubscription operations with corresponding icons. Update AuditLog model to handle new operation types and provide descriptive values for user actions.
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good

This commit is contained in:
Tom Butcher 2026-07-13 02:48:08 +01:00
parent cd11f0437b
commit 00243b0e5e
3 changed files with 31 additions and 1 deletions

View File

@ -148,6 +148,10 @@ const ObjectProperty = ({
readOnly = readOnly(objectData, parentData) readOnly = readOnly(objectData, parentData)
} }
if (type && typeof type == 'function' && objectData) {
type = type(objectData, parentData)
}
if (!value) { if (!value) {
value = getPropertyValue(objectData, name) value = getPropertyValue(objectData, name)
} }

View File

@ -4,6 +4,7 @@ import QuestionCircleIcon from '../../Icons/QuestionCircleIcon'
import PlusIcon from '../../Icons/PlusIcon' import PlusIcon from '../../Icons/PlusIcon'
import BinIcon from '../../Icons/BinIcon' import BinIcon from '../../Icons/BinIcon'
import EditIcon from '../../Icons/EditIcon' import EditIcon from '../../Icons/EditIcon'
import BellIcon from '../../Icons/BellIcon'
const OperationDisplay = ({ const OperationDisplay = ({
operation, operation,
@ -30,6 +31,16 @@ const OperationDisplay = ({
tagIcon = <EditIcon /> tagIcon = <EditIcon />
tagColor = 'blue' tagColor = 'blue'
break break
case 'subscribe':
tagText = 'Subscribe'
tagIcon = <BellIcon />
tagColor = 'orange'
break
case 'unsubscribe':
tagText = 'Unsubscribe'
tagIcon = <BellIcon />
tagColor = 'orange'
break
default: default:
break break
} }

View File

@ -90,10 +90,25 @@ export const AuditLog = {
name: 'changes', name: 'changes',
label: 'Changes', label: 'Changes',
columnWidth: 500, columnWidth: 500,
type: 'propertyChanges', type: (objectData) => {
return objectData.operation === 'subscribe' ||
objectData.operation === 'unsubscribe'
? 'text'
: 'propertyChanges'
},
objectType: (objectData) => { objectType: (objectData) => {
return objectData.parentType return objectData.parentType
}, },
value: (objectData) => {
if (objectData.operation === 'subscribe') {
return 'User subscribed to object.'
}
if (objectData.operation === 'unsubscribe') {
return 'User unsubscribed from object.'
}
return objectData.changes
},
showCopy: true showCopy: true
} }
] ]