Adding Items to User Settings

Is there anyone who can point me in a direction on how to add items to the "User Settings" editor menu within Node-red? (or a custom menu like "User Settings").

I am specifically trying to add some items that I can use either in flows and/or can have under-the-hood (shell scripts) use to configure system settings (ex. IP addresses, socket timeout settings, etc.)

My goal is to have a node installed, that will add these option to the editor menus.

Hi @vlagnar

we haven't published the api for doing this, although it does exist in the editor. But there is no documentation I can point you at other that show you how it is used,

You can see it in action here, where the palette manager adds itself to the settings dialog: https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/editor-client/src/js/ui/palette-editor.js#L440

RED.userSettings.add({
   id:'my-settings',  // A *unique* identifier for the pane
   title: "My Settings", // The label for the pane
   get: function() {},    // Called when the settings dialog is being opened
   close: function() {},  // Called when the settings dialog is being closed
   focus: function() {}   // Called when this pane is getting focus
})

The get function should return the DOM element for the settings pane. For example:

get: function() {
   var settingsPane = $("<div>",{style: "height: 100%"});
   // Build up the settings pane
   return settingsPane;
}

For another reference, here's where the 'view' settings pane is added: https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/editor-client/src/js/ui/userSettings.js#L224

This is all written largely off the top of my head - hopefully I've not missed anything vital...

2 Likes

Thanks will give it a try.

Nice, I was looking for something like that too.
Thank you, Nick!

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