From 857415ff465296a73ff6339d342011c3360665e2 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Wed, 29 May 2024 00:25:12 +0200 Subject: [PATCH] fix(drilldown): handle missing process (parent) DI elements --- .../drilldown/DrilldownBreadcrumbs.js | 27 ++++++++++++------- test/spec/features/drilldown/DrilldownSpec.js | 12 +++++++++ .../process-missing-bpmndiagram.bpmn | 15 +++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 test/spec/features/drilldown/process-missing-bpmndiagram.bpmn diff --git a/lib/features/drilldown/DrilldownBreadcrumbs.js b/lib/features/drilldown/DrilldownBreadcrumbs.js index 40b2dc030f..ba01dfa6ec 100644 --- a/lib/features/drilldown/DrilldownBreadcrumbs.js +++ b/lib/features/drilldown/DrilldownBreadcrumbs.js @@ -61,24 +61,31 @@ export default function DrilldownBreadcrumbs(eventBus, elementRegistry, canvas) businessObjectParents = getBusinessObjectParentChain(element); } - var path = businessObjectParents.map(function(parent) { - var title = escapeHTML(parent.name || parent.id); - var link = domify('
  • ' + title + '
  • '); - - 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 + var path = businessObjectParents.flatMap(function(parent) { + 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 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 []; + } + + var title = escapeHTML(parent.name || parent.id); + var link = domify('
  • ' + title + '
  • '); + link.addEventListener('click', function() { canvas.setRootElement(parentPlane); }); diff --git a/test/spec/features/drilldown/DrilldownSpec.js b/test/spec/features/drilldown/DrilldownSpec.js index d17620e1f3..2d8d96fbeb 100644 --- a/test/spec/features/drilldown/DrilldownSpec.js +++ b/test/spec/features/drilldown/DrilldownSpec.js @@ -625,6 +625,18 @@ describe('features/drilldown - integration', function() { expect(warnings).to.be.empty; }); + + it('no for process', async function() { + + const { + error, + warnings + } = await importXML(processMissingBpmnDiagram_XML); + + // then + expect(error).not.to.exist; + expect(warnings).to.be.empty; + }); }); }); diff --git a/test/spec/features/drilldown/process-missing-bpmndiagram.bpmn b/test/spec/features/drilldown/process-missing-bpmndiagram.bpmn new file mode 100644 index 0000000000..9959debd85 --- /dev/null +++ b/test/spec/features/drilldown/process-missing-bpmndiagram.bpmn @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + +