Subflow: Add labels to OUTPUT nodes

I'm operating with subflows that have a number of output's. I usually give those outputs a name - simply for documentation purposes (in the main flows). Within the subflow I have to use an (additional) comment node to show this given name next to the output:

image

Wouldn't it be better to show the name of the output as the label of the output node - similar to all other nodes?
Any opinions to this proposal?

I'd try to create a PR if this is of interest for the community...

BR, Ralph

2 Likes

Doubleclick the link node, click the appearance tab, enable the label checkbox

@bakman2 this is a question about the subflow port nodes, not link nodes.

@ralphwetzel that's a good idea. I do wonder if it should still have the port number as well. Definitely worth mocking up a concept for. If you are interested in working on a PR, I can help give you some pointers to the right bits of view.js to look at.

To start with, node-red/view.js at 7cd3e49f04f30b8c23a89fe08d6c984b68ce7be8 · node-red/node-red · GitHub is where the label is set.

But if it can now have a variable length label and have to get resized, some more code will be needed to handle resizing as needed.

I'm happy to look at this for the 2.2 release - if you do want to try it, then make sure you work on the dev branch.

Hello Nick,
thank you for your feedback.
After some time with the code I see two ways to implement this:

  1. Treat subflowOutputs (as well as subflowInputs and subflowStatus) as a special type of node(s) and handle them - as currently implemented - in a dedicated section of the code. This will continue the current path of copy/pasting a valid share of code from the standard implementation to handle these special types...

  2. Treat subflowOutputs & the others (for the matter of drawing those nodes) as a standard node (perhaps with a special procedure regarding the icon). This could reduce code bloating ... and should make the maintenance easier later. It yet would need adaptations in more corners than just the drawing code.

I would vote for 2.
Do you have a preference?

R.

Personally, I'd probably stick with 1 until it became overwhelming obvious that a larger refactoring was needed.

Off the top of my head, I can see the subflow nodes don't have icons or annotations (the changed/error markers) - so there would have to be lots of special cases added throughout the node drawing node.

I think the code that calculates the label width is fairly self contained and easily reused for the subflow nodes.

Ok. Then let's go with 1.

Preview:

Any comments - so far?

3 Likes

Nice. I think that fits well.

So... PR is placed (#3352) & feedback welcome.