# There's is surely a better way than copy-paste the same panel?

**URL:** <https://discourse.nodered.org/t/theres-is-surely-a-better-way-than-copy-paste-the-same-panel/87199>\
**Category:** Dashboard\
**Created:** [12 April 2024 15:05 UTC](https://discourse.nodered.org/t/theres-is-surely-a-better-way-than-copy-paste-the-same-panel/87199 "2024-04-12T15:05:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![el\_pablo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/el_pablo/32/45496_2.png) [@el\_pablo](https://discourse.nodered.org/u/el_pablo)\
**Post date:** [12 April 2024 15:05 UTC](https://discourse.nodered.org/t/theres-is-surely-a-better-way-than-copy-paste-the-same-panel/87199/1 "2024-04-12T15:05:59Z")

</div>

Hey guys,

I have a class of the students that must send data through MQTT with an Arduino. Each student has its panel.

 ![firefox_iOGadWfW7E](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57c27f6171812ff71e0d8188a2eee76ea1efef32.png)

When adding a new student, I must duplicate a series of components. I'm pretty sure there's a better way.

My current workflow when adding a new student is :

1. Create a new group Etd\_X in the dashboard
2. Create a new subflow Etd\_X
3. Copy paste from a previous subflow the nodes into subflow Etd\_X
4. Modify each nodes to match the Etd\_X group
5. In the main flow, modify the Switch to send data to subflow Etd\_X

Here's a screen recording of the whole process...

[![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/2/9299c78355e63d0f2b594c827a0b230d49f6db7f.jpeg "NodeRed process to add a new student panel") ](https://www.youtube.com/watch?v=4Hhs2aGuVhw)

I really feel like a first year student that didn't learn arrays yet and copy paste some variables with \_1, \_2, suffixes...

Is there a better way?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2024 15:32 UTC](https://discourse.nodered.org/t/theres-is-surely-a-better-way-than-copy-paste-the-same-panel/87199/2 "2024-04-12T15:32:03Z")

</div>

> [@el\_pablo](#):
>
> Is there a better way?

Yes and no.

firstly, you are creating subflows for individual use - that not only defeats the purpose, it makes things harder to manage. In what you are doing, you may as well make your life easier and not bother copying the dashboard elements to a subflow, but instead, copy them to a new tab in the editor.

Next, I feel your pain having to change the group for each element - luckily, we introduced the ability to set a "Config Type" as an env variable for subflows.

this means, you setup your commonised view once, set the UI "group" as the Env Var, add as many subflows instances as you need - each time, setting the ui-group on the subflow env var properties ONCE (not for every UI node).

This however, is not supported by dashboard 1 (though it will may work). However, for the new Dashboard 2.0, this is supported out of the box.

See here: [Subflows | Node-RED Dashboard 2.0](https://dashboard.flowfuse.com/user/subflows.html#surfacing-node-properties)

You will need to upgrade your node-red to the latest beta using the tag `node-red@next`

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 April 2024 15:54 UTC](https://discourse.nodered.org/t/theres-is-surely-a-better-way-than-copy-paste-the-same-panel/87199/3 "2024-04-12T15:54:17Z")

</div>

> [@Steve-Mcl](#):
>
> However, for the new Dashboard 2.0, this is supported out of the box.

Though it is not yet fully working. It is not possible to specify the position of the subflow in the group if the subflow is not the only widget in the group: [Unable to position a subflow containing a ui-node on the dashboard · Issue #710 · FlowFuse/node-red-dashboard · GitHub](https://github.com/FlowFuse/node-red-dashboard/issues/710)

Also, if one has multiple widgets in a subflow, how does one order the widgets within the subflow?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2024 16:01 UTC](https://discourse.nodered.org/t/theres-is-surely-a-better-way-than-copy-paste-the-same-panel/87199/4 "2024-04-12T16:01:52Z")

</div>

> [@Colin](#):
>
> Also, if one has multiple widgets in a subflow, how does one order the widgets within the subflow?

Not currently possible by drag+drop on sidebar\*

Something i was toying with was showing a separate tree entries for sublfows templates that contains UI nodes - permitting user to drag-drop sort them. it was out of scope due to not knowing if the feature would be used or desired. Fortunately, this is all in the dashboard side. so once NR4 is "current", and the feature is fully released, an update to dashboard is possible at a later time.

BUT it is quite a large piece of work so not likely to drop any time soon

What _MIGHT_ come before that ^ is exposing the sort number as a number entry field when a UI element is inside a subflow template (like we did for the sizer) - that would be much simpler to deliver and would start being useful sooner rather than later.

\* If you **really** need to sort them, at the moment, you would have to cut them from the subflow, paste onto regular flow, sort in the sidebar, cut and re-paste/re-connect in the subflow. (or export, manually edit, import)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 April 2024 16:09 UTC](https://discourse.nodered.org/t/theres-is-surely-a-better-way-than-copy-paste-the-same-panel/87199/5 "2024-04-12T16:09:39Z")

</div>

> [@Steve-Mcl](#):
>
> If you **really** need to sort them, at the moment,

For me this isn't much of an issue as usually I only have one node in the subflow (a ui-template). The fact that I can't position the subflow in the group is the main issue for me.

For the requirement in this thread, however, I think the sorting within the subflow would be the issue.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 May 2024 16:10 UTC](https://discourse.nodered.org/t/theres-is-surely-a-better-way-than-copy-paste-the-same-panel/87199/6 "2024-05-12T16:10:17Z")

</div>

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