Accessing configuration in a menu plugin

Hi All,

I’ve created a menu plugin (following the example on camunda-modeler-plugins/menu-plugin-example at main · camunda/camunda-modeler-plugins · GitHub) with a configuration overlay (based on this auto-save plugin GitHub - pinussilvestrus/camunda-modeler-autosave-plugin: Automatically save your diagrams modeled in Camunda Modeler).

Both work fine on their own, but I want to combine the two.

How can I get access to the configuration from the menu plugin? In the example code, electronApp and menuState are injected, but neither do carry the config afaik.

Thanks for any advice.

1 Like

To answer my own question by means of a workaround:

const path = require('path');
const fs = require('fs');
const CLIENT_CONFIG_FILE = 'config.json';
const CONFIG_FILE_ENCODING = 'utf8';
const userDataPath = electronApp.getPath('userData');

export function getPluginConfig(userDataPath) {
  const config = JSON.parse(
    fs.readFileSync(
      path.join(userData, CLIENT_CONFIG_FILE),
      CONFIG_FILE_ENCODING
    )
  );
  let pluginConfig = config.plugins?.pluginName?.clientConfig;
  if (!pluginConfig) {
    pluginConfig = {
      enabled: false,
      url: '',
      user: {},
    };
  }

  return pluginConfig;
}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.