diff --git a/ontrack-web-core/components/core/model/EventEntity.js b/ontrack-web-core/components/core/model/EventEntity.js index fe5ccf1f3c..353c3d18c2 100644 --- a/ontrack-web-core/components/core/model/EventEntity.js +++ b/ontrack-web-core/components/core/model/EventEntity.js @@ -1,41 +1,48 @@ import {extractProjectEntityInfo} from "@components/entities/ProjectEntityPageInfo"; import {Space} from "antd"; +import {useEffect, useState} from "react"; export default function EventEntity({event}) { - let entityType = null - let entity = null - - if (event.entities.VALIDATION_RUN) { - entityType = 'VALIDATION_RUN' - entity = event.entities.VALIDATION_RUN - } else if (event.entities.PROMOTION_RUN) { - entityType = 'PROMOTION_RUN' - entity = event.entities.PROMOTION_RUN - } else if (event.entities.PROMOTION_LEVEL) { - entityType = 'PROMOTION_LEVEL' - entity = event.entities.PROMOTION_LEVEL - } else if (event.entities.VALIDATION_STAMP) { - entityType = 'VALIDATION_STAMP' - entity = event.entities.VALIDATION_STAMP - } else if (event.entities.BUILD) { - entityType = 'BUILD' - entity = event.entities.BUILD - } else if (event.entities.BRANCH) { - entityType = 'BRANCH' - entity = event.entities.BRANCH - } else if (event.entities.PROJECT) { - entityType = 'PROJECT' - entity = event.entities.PROJECT - } - - const info = extractProjectEntityInfo(entityType, entity) + const [info, setInfo] = useState(null) + + useEffect(() => { + + let entityType = null + let entity = null + + if (event.entities.VALIDATION_RUN) { + entityType = 'VALIDATION_RUN' + entity = event.entities.VALIDATION_RUN + } else if (event.entities.PROMOTION_RUN) { + entityType = 'PROMOTION_RUN' + entity = event.entities.PROMOTION_RUN + } else if (event.entities.PROMOTION_LEVEL) { + entityType = 'PROMOTION_LEVEL' + entity = event.entities.PROMOTION_LEVEL + } else if (event.entities.VALIDATION_STAMP) { + entityType = 'VALIDATION_STAMP' + entity = event.entities.VALIDATION_STAMP + } else if (event.entities.BUILD) { + entityType = 'BUILD' + entity = event.entities.BUILD + } else if (event.entities.BRANCH) { + entityType = 'BRANCH' + entity = event.entities.BRANCH + } else if (event.entities.PROJECT) { + entityType = 'PROJECT' + entity = event.entities.PROJECT + } + + setInfo(extractProjectEntityInfo(entityType, entity)) + }, [event]) + return ( <> - {info.type} - {info.component} + {info?.type} + {info?.component} )