diff --git a/src/render/PanelHeaderProvider.js b/src/render/PanelHeaderProvider.js index c62209192..6cef8a3de 100644 --- a/src/render/PanelHeaderProvider.js +++ b/src/render/PanelHeaderProvider.js @@ -13,6 +13,10 @@ import { isInterrupting } from 'bpmn-js/lib/util/DiUtil'; +import { + useService +} from '../hooks'; + import iconsByType from '../icons'; export function getConcreteType(element) { @@ -64,6 +68,18 @@ export function getConcreteType(element) { export const PanelHeaderProvider = { + getDocumentationRef: (element) => { + + // eslint-disable-next-line react-hooks/rules-of-hooks + const elementTemplates = useService('elementTemplates', false); + + if (!elementTemplates) { + return; + } + + return getTemplateDocumentation(element, elementTemplates); + }, + getElementLabel: (element) => { if (is(element, 'bpmn:Process')) { return getBusinessObject(element).name; @@ -137,12 +153,21 @@ function isConditionalFlow(element) { return businessObject.conditionExpression && is(sourceBusinessObject, 'bpmn:Activity'); } - -// helpers ////////// function isPlane(element) { // Backwards compatibility for bpmn-js<8 const di = element && (element.di || getBusinessObject(element).di); return is(di, 'bpmndi:BPMNPlane'); +} + +function getTemplate(element, elementTemplates) { + const templateId = elementTemplates._getTemplateId(element); + return templateId && elementTemplates.get(templateId); +} + +function getTemplateDocumentation(element, elementTemplates) { + const template = getTemplate(element, elementTemplates); + + return template && template.documentationRef; } \ No newline at end of file diff --git a/test/spec/provider/cloud-element-templates/fixtures/complex.bpmn b/test/spec/provider/cloud-element-templates/fixtures/complex.bpmn index 205c4419f..cedc336ba 100644 --- a/test/spec/provider/cloud-element-templates/fixtures/complex.bpmn +++ b/test/spec/provider/cloud-element-templates/fixtures/complex.bpmn @@ -54,6 +54,7 @@ + @@ -92,6 +93,9 @@ + + + diff --git a/test/spec/provider/cloud-element-templates/fixtures/complex.json b/test/spec/provider/cloud-element-templates/fixtures/complex.json index bb06d7b4d..d08856284 100644 --- a/test/spec/provider/cloud-element-templates/fixtures/complex.json +++ b/test/spec/provider/cloud-element-templates/fixtures/complex.json @@ -525,5 +525,24 @@ "feel": "required" } ] + }, + { + "$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json", + "name": "REST Connector (with Docs)", + "id": "io.camunda.connectors.RestConnector-documentationRef", + "description": "A generic REST service.", + "appliesTo": [ + "bpmn:ServiceTask" + ], + "documentationRef": "https://docs.camunda.io", + "properties": [ + { + "type": "Hidden", + "value": "http", + "binding": { + "type": "zeebe:taskDefinition:type" + } + } + ] } ] \ No newline at end of file