Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Dec 6, 2023
1 parent dbb002e commit fd7e1ac
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 21 deletions.
46 changes: 46 additions & 0 deletions src/cloud-element-templates/CalledElementBehavior.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
import { is } from 'bpmn-js/lib/util/ModelUtil';

import { findExtension } from './Helper';

/**
* Enforces no variable propagation for templated call activities.
*/
export class CalledElementBehavior extends CommandInterceptor {
constructor(eventBus, modeling) {
super(eventBus, modeling);

this._modeling = modeling;

this.postExecuted(
'propertiesPanel.zeebe.changeTemplate', this._handleTemplateChange, true, this);
}

_handleTemplateChange(context) {
if (!context.newTemplate) {
return;
}

const { element } = context;

if (!is(element, 'bpmn:CallActivity')) {
return;
}

const calledElement = findExtension(element, 'zeebe:CalledElement');

if (!calledElement) {
return;
}

this._modeling.updateModdleProperties(element, calledElement, {
propagateAllChildVariables: false,
propagateAllParentVariables: false
});
}
}

CalledElementBehavior.$inject = [
'eventBus',
'modeling'
];
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
} from '../CreateHelper';
import { getDefaultValue } from '../Helper';

import { ensureNoPropagation } from '../util/calledElement';


export class CalledElementBindingProvider {
static create(element, options) {
Expand All @@ -30,4 +28,9 @@ export class CalledElementBindingProvider {

calledElement.set(propertyName, value);
}
}
}

function ensureNoPropagation(calledElement) {
calledElement.set('propagateAllChildVariables', false);
calledElement.set('propagateAllParentVariables', false);
}
7 changes: 5 additions & 2 deletions src/cloud-element-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ElementTemplatesPropertiesProvider from './ElementTemplatesPropertiesProv
import UpdateTemplatePropertiesOrder from './UpdateTemplatePropertiesOrder';
import { ReferencedElementBehavior } from './ReferencedElementBehavior';
import { GeneratedValueBehavior } from './GeneratedValueBehavior';
import { CalledElementBehavior } from './CalledElementBehavior';


export default {
Expand All @@ -25,7 +26,8 @@ export default {
'elementTemplatesConditionChecker',
'generatedValueBehavior',
'referencedElementBehavior',
'updateTemplatePropertiesOrder'
'updateTemplatePropertiesOrder',
'calledElementBehavior'
],
elementTemplates: [ 'type', ElementTemplates ],
elementTemplatesLoader: [ 'type', ElementTemplatesLoader ],
Expand All @@ -34,5 +36,6 @@ export default {
elementTemplatesConditionChecker: [ 'type', ElementTemplatesConditionChecker ],
generatedValueBehavior: [ 'type', GeneratedValueBehavior ],
referencedElementBehavior: [ 'type', ReferencedElementBehavior ],
updateTemplatePropertiesOrder: [ 'type', UpdateTemplatePropertiesOrder ]
updateTemplatePropertiesOrder: [ 'type', UpdateTemplatePropertiesOrder ],
calledElementBehavior: [ 'type', CalledElementBehavior ]
};
4 changes: 0 additions & 4 deletions src/cloud-element-templates/util/calledElement.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1722,12 +1722,9 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
const calledElement = findExtension(task, 'zeebe:CalledElement');

expect(calledElement).to.exist;
expect(calledElement).to.jsonEqual({
$type: 'zeebe:CalledElement',
processId: 'paymentProcess',
propagateChildVariables: false,
propagateParentVariables: false
});
expect(calledElement).to.have.property('processId', 'paymentProcess');
expect(calledElement).to.have.property('propagateAllChildVariables', false);
expect(calledElement).to.have.property('propagateAllParentVariables', false);
}));


Expand Down Expand Up @@ -1769,12 +1766,9 @@ describe('cloud-element-templates/cmd - ChangeElementTemplateHandler', function(
const calledElement = findExtension(task, 'zeebe:CalledElement');

expect(calledElement).to.exist;
expect(calledElement).to.jsonEqual({
$type: 'zeebe:CalledElement',
processId: 'paymentProcess',
propagateChildVariables: false,
propagateParentVariables: false
});
expect(calledElement).to.have.property('processId', 'paymentProcess');
expect(calledElement).to.have.property('propagateAllChildVariables', false);
expect(calledElement).to.have.property('propagateAllParentVariables', false);
}));
});

Expand Down

0 comments on commit fd7e1ac

Please sign in to comment.