Merge branch 'master' into develop

This commit is contained in:
Maciej Barelkowski 2021-06-02 08:53:22 +02:00
commit 2a60745991
7 changed files with 108 additions and 11 deletions

View File

@ -2,7 +2,10 @@ import inherits from 'inherits';
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
import { is } from '../../../util/ModelUtil';
import {
getBusinessObject,
is
} from '../../../util/ModelUtil';
import { isAny } from '../util/ModelingUtil';
@ -20,9 +23,9 @@ export default function DataStoreBehavior(
commandStack.registerHandler('dataStore.updateContainment', UpdateSemanticParentHandler);
function getFirstParticipant() {
function getFirstParticipantWithProcessRef() {
return elementRegistry.filter(function(element) {
return is(element, 'bpmn:Participant');
return is(element, 'bpmn:Participant') && getBusinessObject(element).processRef;
})[0];
}
@ -35,7 +38,7 @@ export default function DataStoreBehavior(
function updateDataStoreParent(dataStore, newDataStoreParent) {
var dataStoreBo = dataStore.businessObject || dataStore;
newDataStoreParent = newDataStoreParent || getFirstParticipant();
newDataStoreParent = newDataStoreParent || getFirstParticipantWithProcessRef();
if (newDataStoreParent) {
var newDataStoreParentBo = newDataStoreParent.businessObject || newDataStoreParent;

View File

@ -494,6 +494,13 @@ function canDrop(element, target, position) {
return isAny(target, [ 'bpmn:Participant', 'bpmn:Lane' ]);
}
// disallow dropping data store reference if there is no process to append to
if (is(element, 'bpmn:DataStoreReference') && is(target, 'bpmn:Collaboration')) {
return some(getBusinessObject(target).get('participants'), function(participant) {
return !!participant.get('processRef');
});
}
// account for the fact that data associations are always
// rendered and moved to top (Process or Collaboration level)
//

View File

@ -9,7 +9,8 @@ if [[ $GITHUB_REF =~ ^refs/heads/master$ ]] || [[ $GITHUB_REF =~ ^refs/tags/ ]];
exit 0;
fi
FEATURE_BRANCH=$(echo "$GITHUB_REF" | cut -d"/" -f3)
# GITHUB_HEAD_REF is set for pull request
FEATURE_BRANCH=$([ $GITHUB_HEAD_REF != "" ] && echo $GITHUB_HEAD_REF || echo "$GITHUB_REF" | cut -d"/" -f3)
echo "Attempting to install diagram-js@$FEATURE_BRANCH";

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.15.0-dev" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn:collaboration id="Collaboration">
<bpmn:participant id="Participant" />
<bpmn:participant id="Participant_2" processRef="Process_2" />
</bpmn:collaboration>
<bpmn:process id="Process_2" isExecutable="false" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
<bpmndi:BPMNShape id="Participant_di" bpmnElement="Participant" isHorizontal="false">
<dc:Bounds x="42" y="46" width="600" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_066vvzt_di" bpmnElement="Participant_2">
<dc:Bounds x="42" y="514" width="600" height="250" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -45,7 +45,7 @@ describe('features/modeling/behavior - data store', function() {
}));
it('should create DataStoreReference on sub process', inject(function(elementRegistry, modeling, bpmnjs) {
it('should create DataStoreReference on sub process', inject(function(elementRegistry, modeling) {
// give
var subProcessElement = elementRegistry.get('SubProcess'),
@ -70,7 +70,7 @@ describe('features/modeling/behavior - data store', function() {
}));
it('should create DataStoreReference on collaboration', inject(function(elementRegistry, modeling, bpmnjs) {
it('should create DataStoreReference on collaboration', inject(function(elementRegistry, modeling) {
// give
var collaborationElement = elementRegistry.get('Collaboration'),
@ -95,6 +95,41 @@ describe('features/modeling/behavior - data store', function() {
expect(dataStoreReference.dataStoreRef).not.to.exist;
}));
describe('empty pool', function() {
var processDiagramXML = require('./DataStoreBehavior.empty-pool.bpmn');
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
it('should create DataStoreReference on collaboration if first participant is an empty pool',
inject(function(elementRegistry, modeling) {
// give
var collaboration = elementRegistry.get('Collaboration'),
participantWithProcess = elementRegistry.get('Participant_2').businessObject;
// when
var dataStoreShape = modeling.createShape(
{ type: 'bpmn:DataStoreReference' },
{ x: 420, y: 370 },
collaboration
);
var dataStoreReference = dataStoreShape.businessObject;
// then
// reference correctly wired
expect(dataStoreReference.$parent).to.exist;
expect(dataStoreReference.$parent).to.eql(participantWithProcess.processRef);
expect(participantWithProcess.processRef.flowElements).to.contain(dataStoreReference);
// no actual data store created
expect(dataStoreReference.dataStoreRef).not.to.exist;
})
);
});
});
@ -105,7 +140,7 @@ describe('features/modeling/behavior - data store', function() {
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
it('should move DataStoreReference to Participant', inject(function(elementRegistry, modeling, bpmnjs) {
it('should move DataStoreReference to Participant', inject(function(elementRegistry, modeling) {
// give
var participantElement = elementRegistry.get('Participant'),
@ -123,7 +158,7 @@ describe('features/modeling/behavior - data store', function() {
it('should move DataStoreReference from partipant to Collaboration keeping parent particpant', inject(
function(elementRegistry, modeling, bpmnjs) {
function(elementRegistry, modeling) {
// give
var collaborationElement = elementRegistry.get('Collaboration'),
@ -143,7 +178,7 @@ describe('features/modeling/behavior - data store', function() {
it('should move DataStoreReference from subprocess to Collaboration keeping parent particpant', inject(
function(elementRegistry, modeling, bpmnjs) {
function(elementRegistry, modeling) {
// give
var collaborationElement = elementRegistry.get('Collaboration'),
@ -163,7 +198,7 @@ describe('features/modeling/behavior - data store', function() {
it('should move without changing parent', inject(
function(elementRegistry, modeling, bpmnjs) {
function(elementRegistry, modeling) {
// give
var collaborationElement = elementRegistry.get('Collaboration'),

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:bpmn2="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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_biH3sOTeEeS2YerRfpjPrw" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.14.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="Collaboration">
<bpmn2:participant id="Participant" name="Pool"/>
</bpmn2:collaboration>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant" isHorizontal="true">
<dc:Bounds x="72" y="48" width="706" height="266" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>

View File

@ -123,6 +123,26 @@ describe('features/modeling/rules - BpmnRules', function() {
expectCanCreate([task1, task2], 'SequenceFlow', false);
}));
describe('empty pool', function() {
var testXML = require('./BpmnRules.collaboration-empty.bpmn');
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
it('should not allow to drop DataStoreReference when there is no process to append to',
inject(function(elementFactory) {
// given
var dataStoreReference = elementFactory.createShape({ type: 'bpmn:DataStoreReference' });
// then
expectCanCreate(dataStoreReference, 'Collaboration', false);
})
);
});
});