Default config node

Hi folks,

When you create a config node for the node-red-node-dropbox node, then that config node is automatically selected (in the config dropdown) when a new dropbox node is added to the flow.

I would like to achieve the same behaviour for one of my own nodes, but I can't find how this is implemented in the dropbox.html file. Thought perhaps that the required:true would have that as a side-effect, but it doesn't work for my node so it must be something else doing the magic.

Moreover, I don't want the config to become required ...

Hopefully anybody can enlighten me.
Thanks!
Bart

set it to required:false

here is an example: node-red-contrib-ngrok/ngrok.html at cd02a2431f97832f6f8552480ce941c87a845f57 · sammachin/node-red-contrib-ngrok · GitHub

Hey Steve,
Thanks!
Yes indeed I had already ´required:false´ in my node, but I was looking how the dropbox node automatically assigns a config node. The only difference with my node was that the dropbox node has ´required:true´, so I thought that it perhaps was done that way.
But even setting it to true (which I don't want...) doesn't automatically select the config node in my case. So not sure how to achieve it ...

Still not sure how to continue with this...

Suppose I have N config nodes created for my custom node. As soon as I drop a new instance of my custom node on my flow, then I want to link the first available config node to my new custom node. From this old discussion, I assume that I cannot get a list of the available config nodes (of a particular type)?

Or can I do it another way perhaps? I still don't understand how e.g. the dropbox node selects automatically a config node. Would be nice if somebody could enlighten this piece of magic!!!

Hey,

Take also a look into the js file!
Line 40 and 54 looks promising.
Sorry that i can't help you more but i am currently with my phone on.

Greetings

Hi @H3llsing,
Thanks a lot for your assistance!
But I'm afraid that code won't help me. It is server side code which gets the config that has been selected previously on the frontend.
However it is the frontend part that I'm not understanding: how is the config node automatically selected in the dropdown, as soon as a new dropbox node is being added to the flow ...

Hi @BartButenaers

there isn't anything particularly special about the Dropbox node.

As with all nodes that have a config node dependency, when you first add the node to the workspace it'll be marked with an error because its missing the config node. When you open the edit dialog, if no instances of the config node exist, the select box will be empty with the 'add new XYZ...' option selected. But if there is a suitable config node, it will be selected by default.

That's the only behaviour I can think of that you may be referring to - we automatically select the first available config node if it isn't already set.

1 Like

Hi @knolleary,
That "automatically" is what I don't understand how it works ...

When I use the dropbox node, it indeed behaves exactly like you describe:

  1. When a drop my first node in the flow, it gets a red triangle due to a missing (required) config node:
    image

  2. When I open that node, I get the option to create a new config node:
    image

  3. I create a new config node and that becomes selected:
    image

  4. When I add a second node to my flow, this gets in turn a red triangle due to a missing config node:
    image

  5. When I open that second node, indeed my (first) config node is automatically selected:
    image

Summarized my question is: what do I need to do to get the same magic as in step 5?

Last week I have added a config node to the blockly node, and @cymplecy would like the config node to be selected automatically for new blockly nodes. But that doesn't happen for some reason, although I have a series of config nodes already available:

blockly_config_select
P.S. I have used required:false, but it also doesn't work for required:true.

It must be something stupid, but I don't see what I'm doing wrong...

Hey @BartButenaers
Have you tried to delete the default value?
Try to replace this line

            creds: { value: "", type: "ngrokauth", required: false },

With this

            creds: { type: "ngrokauth", required: true },

Because i think the automatic selection which nick was mention can not apply when you give it an empty default value. Im think the required is only for validation and should not affect the automatism.

2 Likes

Hi @H3llsing,

I knew it must have been something stupid...
After deleting the default value it is indeed solved.
The first config node is automatically selected:

image

Thanks for having a look at my issue !!!!!!!!!!!!!!!!!!!!!!!!

Bart

Im happy to help :slight_smile:

1 Like

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