Skip to content
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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/features/rules/BpmnRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

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?

Copy link
Contributor Author

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.

}

if (element.host) {
Expand Down Expand Up @@ -1068,11 +1068,11 @@ function canConnectMessageFlow(source, target) {
return false;
}

return (
isMessageFlowSource(source) &&
isMessageFlowTarget(target) &&
!isSameOrganization(source, target)
);
return isMessageFlowSource(source)
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions test/spec/features/rules/BpmnRulesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ describe('features/modeling/rules - BpmnRules', function() {
sequenceFlow = elementFactory.createConnection({
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand All @@ -74,7 +75,8 @@ describe('features/modeling/rules - BpmnRules', function() {
sequenceFlow = elementFactory.createConnection({
type: 'bpmn:MessageFlow',
source: task1,
target: task2
target: task2,
waypoints: []
});

// then
Expand Down