-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zeebe): add
zeebe:versionTag
behavior
Related to bpmn-io/bpmn-js-properties-panel#1063
- Loading branch information
1 parent
3e4f6f7
commit 6c5040a
Showing
4 changed files
with
206 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { isDefined } from 'min-dash'; | ||
|
||
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor'; | ||
|
||
import { isAny } from 'bpmn-js/lib/util/ModelUtil'; | ||
|
||
/** | ||
* Zeebe BPMN specific version tag behavior. | ||
*/ | ||
export default class VersionTagBehavior extends CommandInterceptor { | ||
constructor(eventBus) { | ||
super(eventBus); | ||
|
||
/** | ||
* Ensure that `zeebe:BindingTypeSupported` (`zeebe:CalledDecision`, | ||
* `zeebe:CalledElement` and `zeebe:FormDefinition`) only has | ||
* `zeebe:versionTag` if `zeebe:bindingType` is `versionTag`. | ||
*/ | ||
this.preExecute('element.updateModdleProperties', function(context) { | ||
const { | ||
moddleElement, | ||
properties | ||
} = context; | ||
|
||
if (!isAny(moddleElement, [ | ||
'zeebe:CalledDecision', | ||
'zeebe:CalledElement', | ||
'zeebe:FormDefinition' | ||
])) { | ||
return; | ||
} | ||
|
||
// unset `zeebe:versionTag` if `zeebe:bindingType` is not set to `versionTag` | ||
if ('bindingType' in properties | ||
&& properties.bindingType !== 'versionTag' | ||
&& isDefined(moddleElement.get('versionTag'))) { | ||
properties.versionTag = undefined; | ||
} | ||
|
||
// set `zeebe:bindingType` to `versionTag` if `zeebe:versionTag` is set | ||
if ('versionTag' in properties && moddleElement.get('bindingType') !== 'versionTag') { | ||
properties.bindingType = 'versionTag'; | ||
} | ||
}, true); | ||
} | ||
} | ||
|
||
VersionTagBehavior.$inject = [ | ||
'eventBus' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { | ||
bootstrapCamundaCloudModeler, | ||
inject | ||
} from 'test/TestHelper'; | ||
|
||
import { | ||
getBusinessObject, | ||
isAny | ||
} from 'bpmn-js/lib/util/ModelUtil'; | ||
|
||
import diagramXML from './version-tag.bpmn'; | ||
|
||
|
||
describe('camunda-cloud/features/modeling - VersionTagBehavior', function() { | ||
|
||
beforeEach(bootstrapCamundaCloudModeler(diagramXML)); | ||
|
||
|
||
[ | ||
'CallActivity', | ||
'BusinessRuleTask', | ||
'UserTask' | ||
].forEach(function(type) { | ||
|
||
describe('unset version tag', function() { | ||
|
||
it('should unset version tag', inject(function(elementRegistry, modeling) { | ||
|
||
// given | ||
const element = elementRegistry.get(`${ type }_1`); | ||
|
||
const extensionElement = getExtensionElement(element); | ||
|
||
expect(extensionElement.get('bindingType')).to.equal('versionTag'); | ||
expect(extensionElement.get('versionTag')).to.equal('v1.0.0'); | ||
|
||
// when | ||
modeling.updateModdleProperties(element, extensionElement, { | ||
bindingType: 'deployment' | ||
}); | ||
|
||
// then | ||
expect(extensionElement.get('bindingType')).to.equal('deployment'); | ||
expect(extensionElement.get('versionTag')).not.to.exist; | ||
})); | ||
|
||
}); | ||
|
||
describe('set binding type', function() { | ||
|
||
it('should set binding type', inject(function(elementRegistry, modeling) { | ||
|
||
// given | ||
const element = elementRegistry.get(`${ type }_2`); | ||
|
||
const extensionElement = getExtensionElement(element); | ||
|
||
expect(extensionElement.get('bindingType')).to.equal('deployment'); | ||
|
||
// when | ||
modeling.updateModdleProperties(element, extensionElement, { | ||
versionTag: 'v1.0.0' | ||
}); | ||
|
||
// then | ||
expect(extensionElement.get('bindingType')).to.equal('versionTag'); | ||
expect(extensionElement.get('versionTag')).to.equal('v1.0.0'); | ||
})); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
// helpers ////////// | ||
|
||
function getExtensionElement(element) { | ||
const businessObject = getBusinessObject(element); | ||
|
||
const extensionElements = businessObject.get('extensionElements'); | ||
|
||
if (!extensionElements) { | ||
return null; | ||
} | ||
|
||
return extensionElements.get('values').find(extensionElement => { | ||
return isAny(extensionElement, [ | ||
'zeebe:CalledDecision', | ||
'zeebe:CalledElement', | ||
'zeebe:FormDefinition' | ||
]); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?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:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0949dru" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.26.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0"> | ||
<bpmn:process id="Process_0xt54td" isExecutable="true"> | ||
<bpmn:callActivity id="CallActivity_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledElement propagateAllChildVariables="false" bindingType="versionTag" versionTag="v1.0.0" /> | ||
</bpmn:extensionElements> | ||
</bpmn:callActivity> | ||
<bpmn:businessRuleTask id="BusinessRuleTask_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledDecision bindingType="versionTag" versionTag="v1.0.0" /> | ||
</bpmn:extensionElements> | ||
</bpmn:businessRuleTask> | ||
<bpmn:userTask id="UserTask_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:formDefinition formId="" bindingType="versionTag" versionTag="v1.0.0" /> | ||
</bpmn:extensionElements> | ||
</bpmn:userTask> | ||
<bpmn:callActivity id="CallActivity_2"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledElement propagateAllChildVariables="false" bindingType="deployment" /> | ||
</bpmn:extensionElements> | ||
</bpmn:callActivity> | ||
<bpmn:businessRuleTask id="BusinessRuleTask_2"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledDecision bindingType="deployment" /> | ||
</bpmn:extensionElements> | ||
</bpmn:businessRuleTask> | ||
<bpmn:userTask id="UserTask_2"> | ||
<bpmn:extensionElements> | ||
<zeebe:formDefinition formId="" bindingType="deployment" /> | ||
</bpmn:extensionElements> | ||
</bpmn:userTask> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0xt54td"> | ||
<bpmndi:BPMNShape id="Activity_04qoo0e_di" bpmnElement="CallActivity_1"> | ||
<dc:Bounds x="160" y="80" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_0rpa9kq_di" bpmnElement="BusinessRuleTask_1"> | ||
<dc:Bounds x="290" y="80" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_1t7eh0a_di" bpmnElement="UserTask_1"> | ||
<dc:Bounds x="420" y="80" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_1ad2nfv_di" bpmnElement="CallActivity_2"> | ||
<dc:Bounds x="160" y="190" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_1ylf3wd_di" bpmnElement="BusinessRuleTask_2"> | ||
<dc:Bounds x="290" y="190" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_09ac9pr_di" bpmnElement="UserTask_2"> | ||
<dc:Bounds x="420" y="190" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |