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)
}
if (type && typeof type == 'function' && objectData) {
type = type(objectData, parentData)
}
if (!value) {
value = getPropertyValue(objectData, name)
}

View File

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

View File

@ -90,10 +90,25 @@ export const AuditLog = {
name: 'changes',
label: 'Changes',
columnWidth: 500,
type: 'propertyChanges',
type: (objectData) => {
return objectData.operation === 'subscribe' ||
objectData.operation === 'unsubscribe'
? 'text'
: 'propertyChanges'
},
objectType: (objectData) => {
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
}
]