Skip to content

Commit

Permalink
wip wip add documentationRef
Browse files Browse the repository at this point in the history
Closes #616
  • Loading branch information
Niklas Kiefer committed Mar 28, 2022
1 parent 0ed6e68 commit 80a263d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/render/PanelHeaderProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import {
isInterrupting
} from 'bpmn-js/lib/util/DiUtil';

import {
useService
} from '../hooks';

import iconsByType from '../icons';

export function getConcreteType(element) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
</bpmn:extensionElements>
</bpmn:serviceTask>
<bpmn:serviceTask id="Activity_1k5y89v" name="feel" zeebe:modelerTemplate="io.camunda.connectors.RestConnector-feel" />
<bpmn:serviceTask id="Activity_1ftabot" name="documentationRef" zeebe:modelerTemplate="io.camunda.connectors.RestConnector-documentationRef" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0vvlc66">
Expand Down Expand Up @@ -92,6 +93,9 @@
<bpmndi:BPMNShape id="BPMNShape_0dk5at4" bpmnElement="Activity_1k5y89v">
<dc:Bounds x="270" y="470" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1ftabot_di" bpmnElement="Activity_1ftabot">
<dc:Bounds x="270" y="580" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
19 changes: 19 additions & 0 deletions test/spec/provider/cloud-element-templates/fixtures/complex.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
}
]

0 comments on commit 80a263d

Please sign in to comment.