Skip to content

Commit

Permalink
feat: support overrides provider
Browse files Browse the repository at this point in the history
Related to #737
  • Loading branch information
Niklas Kiefer committed Sep 2, 2022
1 parent 941ece4 commit eefa7d7
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 37 deletions.
5 changes: 4 additions & 1 deletion src/render/BpmnPropertiesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { PanelPlaceholderProvider } from './PanelPlaceholderProvider';
* @param {Injector} props.injector
* @param { (djs.model.Base) => Array<PropertiesProvider> } props.getProviders
* @param {Object} props.layoutConfig
* @param {Object} props.overridesConfig
* @param {Object} props.descriptionConfig
*/
export default function BpmnPropertiesPanel(props) {
Expand All @@ -33,7 +34,8 @@ export default function BpmnPropertiesPanel(props) {
injector,
getProviders,
layoutConfig,
descriptionConfig
descriptionConfig,
overridesConfig
} = props;

const canvas = injector.get('canvas');
Expand Down Expand Up @@ -210,6 +212,7 @@ export default function BpmnPropertiesPanel(props) {
layoutChanged={ onLayoutChanged }
descriptionConfig={ descriptionConfig }
descriptionLoaded={ onDescriptionLoaded }
overridesConfig={ overridesConfig }
eventBus={ eventBus } />
</BpmnPropertiesPanelContext.Provider>;
}
Expand Down
5 changes: 4 additions & 1 deletion src/render/BpmnPropertiesPanelRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ export default class BpmnPropertiesPanelRenderer {
const {
parent,
layout: layoutConfig,
description: descriptionConfig
description: descriptionConfig,
overrides: overridesConfig
} = config || {};

this._eventBus = eventBus;
this._injector = injector;
this._layoutConfig = layoutConfig;
this._descriptionConfig = descriptionConfig;
this._overridesConfig = overridesConfig;

this._container = domify(
'<div style="height: 100%" class="bio-properties-panel-container"></div>'
Expand Down Expand Up @@ -162,6 +164,7 @@ export default class BpmnPropertiesPanelRenderer {
getProviders={ this._getProviders.bind(this) }
layoutConfig={ this._layoutConfig }
descriptionConfig={ this._descriptionConfig }
overridesConfig={ this._overridesConfig }
/>,
this._container
);
Expand Down
22 changes: 12 additions & 10 deletions test/fixtures/service-task.bpmn
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_169thxk" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.7.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="1.0.0">
<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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_169thxk" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.2.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="1.0.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="StartEvent_1" name="Start Event">
<bpmn:outgoing>Flow_10peumi</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:serviceTask id="ServiceTask_1" name="Service Task">
<bpmn:extensionElements>
<zeebe:ioMapping>
Expand All @@ -20,7 +17,12 @@
<bpmn:incoming>Flow_0pxbkit</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0pxbkit" sourceRef="ServiceTask_1" targetRef="Event_1" />
<bpmn:startEvent id="StartEvent_1" name="Start Event">
<bpmn:outgoing>Flow_10peumi</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_0uq647x" messageRef="Message_3hlpglg" />
</bpmn:startEvent>
</bpmn:process>
<bpmn:message id="Message_3hlpglg" name="Message_3hlpglg" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNEdge id="Flow_0pxbkit_di" bpmnElement="Flow_0pxbkit">
Expand All @@ -31,12 +33,6 @@
<di:waypoint x="198" y="160" />
<di:waypoint x="280" y="160" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="162" y="142" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="153" y="185" width="55" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0nqz47m_di" bpmnElement="ServiceTask_1">
<dc:Bounds x="280" y="120" width="100" height="80" />
</bpmndi:BPMNShape>
Expand All @@ -46,6 +42,12 @@
<dc:Bounds x="455" y="185" width="51" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1u5bslf_di" bpmnElement="StartEvent_1">
<dc:Bounds x="162" y="142" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="153" y="185" width="55" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
107 changes: 82 additions & 25 deletions test/spec/BpmnPropertiesPanelRenderer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
zeebe: ZeebeModdle
},
description = {},
layout = {}
layout = {},
overrides = {},
} = options;

clearBpmnJS();
Expand All @@ -102,7 +103,8 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
propertiesPanel: {
parent: propertiesContainer,
description,
layout
layout,
overrides
},
...options
});
Expand Down Expand Up @@ -398,29 +400,6 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
});


it('should allow providing custom entries', async function() {

// given
const diagramXml = require('test/fixtures/service-task.bpmn').default;

const modules = [
ZeebeModdleExtension,
BpmnPropertiesPanel,
BpmnPropertiesProvider,
ZeebePropertiesProvider,
ExamplePropertiesProvider
];

// when
await createModeler(diagramXml, {
additionalModules: modules
});

// then
expect(getGroup(propertiesContainer, 'foo-group')).to.exist;
});


it('should ignore implicit root', async function() {

// given
Expand Down Expand Up @@ -909,6 +888,84 @@ describe('<BpmnPropertiesPanelRenderer>', function() {

});


describe('extensions', function() {

it('should allow providing custom entries', async function() {

// given
const diagramXml = require('test/fixtures/service-task.bpmn').default;

const modules = [
ZeebeModdleExtension,
BpmnPropertiesPanel,
BpmnPropertiesProvider,
ZeebePropertiesProvider,
ExamplePropertiesProvider
];

// when
await createModeler(diagramXml, {
additionalModules: modules
});

// then
expect(getGroup(propertiesContainer, 'foo-group')).to.exist;
});


it('should configure via overrides provider', async function() {

// given
const diagramXml = require('test/fixtures/service-task.bpmn').default;

const overrides = {
'id': {
validate: () => 'Are you sure?'
},
'versionTag': {
getValue: () => {
return 'foo';
}
},
'name': {
validate: (value) => {
if (value === 'bar') {
return 'No <bar> please!';
}
}
},
'formType': {
getValue: () => 'formRef',
getOptions: () => {
return [
{ value: '', label: '<none>' },
{ value: 'formRef', label: 'Camunda Forms rocks! 🎸' }
];
}
}
};

const modules = [
CamundaModdleExtension,
BpmnPropertiesPanel,
BpmnPropertiesProvider,
CamundaPropertiesProvider
];

// when
await createModeler(diagramXml, {
additionalModules: modules,
moddleExtensions: { camunda: CamundaModdle },
overrides
});

// then
expect(domQuery('input[name="versionTag"]', propertiesContainer).value).to.eql('foo');
});

});

});


Expand Down

0 comments on commit eefa7d7

Please sign in to comment.