-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do Not Copy Message Flows Without Participant #1904
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ BpmnRules.prototype.init = function() { | |
|
||
return every(elements, function(element) { | ||
if (isConnection(element)) { | ||
return canConnect(element.source, element.target, element); | ||
return (canConnect(element.source, element.target, element) || {}).type === element.type; | ||
} | ||
|
||
if (element.host) { | ||
|
@@ -1068,11 +1068,11 @@ function canConnectMessageFlow(source, target) { | |
return false; | ||
} | ||
|
||
return ( | ||
isMessageFlowSource(source) && | ||
isMessageFlowTarget(target) && | ||
!isSameOrganization(source, target) | ||
); | ||
return isMessageFlowSource(source) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm hesitant to merge this, as this is completely unclear what these additions ensure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have to check whether this check is strictly necessary. The point is to make sure source and target are in different participants. |
||
&& (is(source, 'bpmn:Participant') || !!getParent(source, 'bpmn:Participant')) | ||
&& isMessageFlowTarget(target) | ||
&& (is(target, 'bpmn:Participant') || !!getParent(target, 'bpmn:Participant')) | ||
&& !isSameOrganization(source, target); | ||
} | ||
|
||
/** | ||
|
@@ -1143,16 +1143,6 @@ function canInsert(shape, connection, position) { | |
canDrop(shape, connection.parent, position)); | ||
} | ||
|
||
/** | ||
* @param {Element[]} elements | ||
* @param {Element} element | ||
* | ||
* @return {boolean} | ||
*/ | ||
function includes(elements, element) { | ||
return (elements && element) && elements.indexOf(element) !== -1; | ||
} | ||
|
||
/** | ||
* @param {Element[]} elements | ||
* @param {Element} element | ||
|
@@ -1164,10 +1154,18 @@ function canCopy(elements, element) { | |
return true; | ||
} | ||
|
||
if (is(element, 'bpmn:Lane') && !includes(elements, element.parent)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're getting rid of null-safety here. Is this intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me have a look. |
||
if (is(element, 'bpmn:Lane') && !elements.includes(element.parent)) { | ||
return false; | ||
} | ||
|
||
if (is(element, 'bpmn:MessageFlow')) { | ||
const source = element.source, | ||
target = element.target; | ||
|
||
return elements.includes(is(source, 'bpmn:Participant') ? source : getParent(source, 'bpmn:Participant')) | ||
&& elements.includes(is(target, 'bpmn:Participant') ? target : getParent(target, 'bpmn:Participant')); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
|
@@ -1178,4 +1176,4 @@ function canCopy(elements, element) { | |
*/ | ||
function getRootElement(element) { | ||
return getParent(element, 'bpmn:Process') || getParent(element, 'bpmn:Collaboration'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,8 @@ describe('features/modeling/rules - BpmnRules', function() { | |
sequenceFlow = elementFactory.createConnection({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we're fixing something I'd expect a test case that verifies the new behavior. |
||
type: 'bpmn:SequenceFlow', | ||
source: task1, | ||
target: task2 | ||
target: task2, | ||
waypoints: [] | ||
}); | ||
|
||
// then | ||
|
@@ -74,7 +75,8 @@ describe('features/modeling/rules - BpmnRules', function() { | |
sequenceFlow = elementFactory.createConnection({ | ||
type: 'bpmn:MessageFlow', | ||
source: task1, | ||
target: task2 | ||
target: task2, | ||
waypoints: [] | ||
}); | ||
|
||
// then | ||
|
@@ -218,6 +220,32 @@ describe('features/modeling/rules - BpmnRules', function() { | |
expectCanCopy(boundaryEvent, [ boundaryEvent ], true); | ||
})); | ||
|
||
|
||
it('copy message flow with parent participants of source and target', inject(function(elementFactory) { | ||
|
||
// given | ||
var sourceParticipant = elementFactory.createShape({ type: 'bpmn:Participant' }), | ||
targetParticipant = elementFactory.createShape({ type: 'bpmn:Participant' }), | ||
source = elementFactory.createShape({ type: 'bpmn:Task', parent: sourceParticipant }), | ||
target = elementFactory.createShape({ type: 'bpmn:Task', parent: targetParticipant }), | ||
messageFlow = elementFactory.createConnection({ type: 'bpmn:MessageFlow', source: source, target: target, waypoints: [] }); | ||
|
||
// then | ||
expectCanCopy(messageFlow, [ sourceParticipant, targetParticipant, source, target, messageFlow ], true); | ||
})); | ||
|
||
|
||
it('copy message flow without parent participants of source and target', inject(function(elementFactory) { | ||
|
||
// given | ||
var source = elementFactory.createShape({ type: 'bpmn:Task' }), | ||
target = elementFactory.createShape({ type: 'bpmn:Task' }), | ||
messageFlow = elementFactory.createConnection({ type: 'bpmn:MessageFlow', source: source, target: target, waypoints: [] }); | ||
|
||
// then | ||
expectCanCopy(messageFlow, [ source, target, messageFlow ], false); | ||
})); | ||
|
||
}); | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's elaborate what this does.
My guess is it ensures that connections can only be created if they would not change their type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the check was useless before because we want to create a number of shapes and connections that are predefined and must not change their type during creation.