Fix sequence action copy-paste #27652
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
When using Ctrl-C + Ctrl-V to copy/paste a sequence building block inside a script, the paste action does not paste the sequence, but instead cracks it and pastes the individual items, but not the building block.
This is because
is ambiguous, it could be a script with one action, or it could be a building block element inside a script with one action.
To fix this to behave as expected, when we copy a sequence building block in the visual editor, we can use metadata to differentiate that it is a building block and not a complete script. So we will put on the clipboard:
Then in handlePaste, if we detect a sequence with metadata, we know for sure that it is a building block and can do the paste correctly.
This was almost fully clean solution, except that if you Ctrl-C this and paste it in yaml, it is unsaveable, because core will reject a sequence with a metadata object. So I make a core change as well to allow metadata on a sequence building block, same as how we allow it for actions. We will generally clean this up and remove it when normalizing, but we don't currently normalize a script before saving it, so it isn't caught if you just paste this and save.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: