Good morning,
I’m trying to get experience in writing plugins for Camunda Modeler, and I am trying to extend the properties panel like the bpmn-js example here.
I managed to create this plugin following the example, to create a ‘General’ tab for every element and also a ‘Magic’ tab for the StartEvent, but what I would like to do now is to get the previous ‘propertiesProvider’ and extend its getTabs property appending the Magic tab.
I tried different solutions without success. It returns me the error ‘Cannot resolve circular dependency! (Resolving: propertiesPanel → propertiesProvider → propertiesProvider)’ . What’s wrong?
I finally found a more reliable solution to my first question, avoiding circular dependency. It’s better to explain it using the first example. Instead of instantiating a new CamundaPropertiesProvider, I use again the propertiesProvider injected and extend it. I don’t know why I did not think about it earlier.
function SharedPropertiesProvider(eventBus, propertiesProvider, elementRegistry) {
PropertiesActivator.call(this, eventBus);
let oldProviderGetTabs = propertiesProvider.getTabs;
propertiesProvider.getTabs = (element) => {
// The "magic" tab
var magicTab = {
id: 'magic',
label: 'Magic',
groups: createMagicTabGroups(element, elementRegistry)
};
var arrayTabs = oldProviderGetTabs(element);
arrayTabs.push(magicTab);
return arrayTabs ;
};
}
inherits(SharedPropertiesProvider, PropertiesActivator);
SharedPropertiesProvider.$inject = [
'eventBus', 'propertiesProvider', 'elementRegistry'
];
module.exports = {
__init__: [ 'magicPropertiesProvider' ], // MUST BE A DIFFERENT NAME!!!
magicPropertiesProvider: [ 'type', SharedPropertiesProvider ]
};
In this way, you get the old instance of the propertiesProvider (camundaPropertiesProvider, or even another extended one in this way) and you extend it adding groups to the previous array result.
I feel better now.
Uh, right. Another thing.
The important parts are in the file client/ExtendedPropertiesProvider.js , and be careful to name the module with a different name than propertiesProvider, that is the name of the module we are extending. Also, don’t follow the part in the client/client.js file present in the project, please follow the plugins guide for that part. You should import the official module camunda-modeler-plugin-helpers which now has a function to import also moddles.