Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix updating the Subflow name during a copy #4809

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GogoVega
Copy link
Contributor

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

Fix updating the Subflow name during a copy:

  • If the Subflow is copied, updating the id before calling addSubflow causes createNewIds is false.
  • Name update starts at 2 (instead of 1)

Related PR: #4757.

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run npm run test to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

*
* @param {object} sf The Subflow to add.
* @param {boolean|undefined} createNewIds Whether to update the name.
*/
function addSubflow(sf, createNewIds) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is createNewIds supposed to only update the name or also the id (inside this function)?
Note: this function is exported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably just a lazily named argument because it is createNewIds from the calling function. The ids will have already been regenerated by the time this is called - on the basis that it is a duplicate subflow we're importing a copy. As a copy, we want to update the name to make sure its unique.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks, maybe we can call it something else?

@knolleary
Copy link
Member

If the Subflow is copied, updating the id before calling addSubflow causes createNewIds is false.

What does that result in? When I test with 4.0.1, if I import an existing subflow and request to import a copy, I get the copy with the updated name. It looks like it's working.

Please can you provide the steps needed to reproduce the issue.

We can argue over whether the copy numbering should start with 1 or 2... but that's a separate matter for this PR.

@GogoVega
Copy link
Contributor Author

GogoVega commented Jul 1, 2024

If you import the subflow below for the first time you will have the name of Subflow (tab) Subflow 1:

[{"id":"fce385f33b15f673","type":"subflow","name":"Subflow 1","info":"","in":[],"out":[]},{"id":"1a65476b8e0791f5","type":"subflow:fce385f33b15f673","z":"15cdbf1d258ebb57","name":"","x":380,"y":540,"wires":[]}]

And now if you re-import it, copy the subflow (tab), you will also have the name Subflow 1. This second tab should have had Subflow 1 (1) as name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants