Skip to content

Commit

Permalink
fix(drilldown): handle missing process (parent) DI elements
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed May 28, 2024
1 parent 91c3db9 commit e544af1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/features/drilldown/DrilldownBreadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,36 @@ export default function DrilldownBreadcrumbs(eventBus, elementRegistry, canvas)
}

var path = businessObjectParents.map(function(parent) {
var title = escapeHTML(parent.name || parent.id);
var link = domify('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');

var parentPlane = canvas.findRoot(getPlaneIdFromShape(parent)) || canvas.findRoot(parent.id);
var parentPlane =
canvas.findRoot(getPlaneIdFromShape(parent)) ||
canvas.findRoot(parent.id);

// when the root is a collaboration, the process does not have a corresponding
// element in the elementRegisty. Instead, we search for the corresponding participant
// when the root is a collaboration, the process does not have a
// corresponding element in the elementRegisty. Instead, we search
// for the corresponding participant
if (!parentPlane && is(parent, 'bpmn:Process')) {
var participant = elementRegistry.find(function(element) {
var businessObject = getBusinessObject(element);

return businessObject && businessObject.get('processRef') && businessObject.get('processRef') === parent;
return businessObject && businessObject.get('processRef') === parent;
});

parentPlane = canvas.findRoot(participant.id);
parentPlane = participant && canvas.findRoot(participant.id);
}

if (!parentPlane) {
return null;
}

var title = escapeHTML(parent.name || parent.id);
var link = domify('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');

link.addEventListener('click', function() {
canvas.setRootElement(parentPlane);
});

return link;
});
}).filter(link => link);

breadcrumbs.innerHTML = '';

Expand Down
12 changes: 12 additions & 0 deletions test/spec/features/drilldown/DrilldownSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,18 @@ describe('features/drilldown - integration', function() {
expect(warnings).to.be.empty;
});


it('no <bpmndi:BPMNDiagram /> for process', async function() {

const {
error,
warnings
} = await importXML(processMissingBpmnDiagram_XML);

// then
expect(error).not.to.exist;
expect(warnings).to.be.empty;
});
});

});
Expand Down
15 changes: 15 additions & 0 deletions test/spec/features/drilldown/process-missing-bpmndiagram.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="DEFINITIONS" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.12.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
<bpmn:process id="PROCESS" isExecutable="true">
<bpmn:subProcess id="SUB_PROCESS_PLANE">
<bpmn:task id="TASK_IN_SUBPROCESS" name="TASK_IN_SUBPROCESS" />
</bpmn:subProcess>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_2" bpmnElement="SUB_PROCESS_PLANE">
<bpmndi:BPMNShape id="TASK_IN_SUBPROCESS_di" bpmnElement="TASK_IN_SUBPROCESS" isExpanded="false">
<dc:Bounds x="160" y="90" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

0 comments on commit e544af1

Please sign in to comment.