-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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(editor): Enable pinning main output with error and always allow unpinning #11452
Merged
CharlieKolb
merged 10 commits into
master
from
ADO-2343/community-issue-cant-unpin-output-in-http-module
Nov 7, 2024
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
306d13d
enable pinning with error output and always unpin
CharlieKolb dd354ff
Add tests
CharlieKolb abee2f7
Merge remote-tracking branch 'origin/master' into ADO-2343/community-…
CharlieKolb aae7ccc
Update packages/editor-ui/src/composables/usePinnedData.ts
CharlieKolb 1cb39c7
PR Feedback
CharlieKolb 4f95885
throw error instead
CharlieKolb a63af7f
self review
CharlieKolb ec5b581
Merge remote-tracking branch 'origin/master' into ADO-2343/community-…
CharlieKolb f03b325
more tests
CharlieKolb 4db633a
PR Feedback
CharlieKolb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,24 +75,36 @@ export function usePinnedData( | |
); | ||
}); | ||
|
||
function canPinNode(checkDataEmpty = false) { | ||
function canPinNode(checkDataEmpty = false, outputIndex?: number) { | ||
const targetNode = unref(node); | ||
if (targetNode === null) return false; | ||
if (targetNode === null || PIN_DATA_NODE_TYPES_DENYLIST.includes(targetNode.type)) return false; | ||
|
||
const nodeType = useNodeTypesStore().getNodeType(targetNode.type, targetNode.typeVersion); | ||
const dataToPin = getInputDataWithPinned(targetNode); | ||
|
||
if (!nodeType || (checkDataEmpty && dataToPin.length === 0)) return false; | ||
|
||
const workflow = workflowsStore.getCurrentWorkflow(); | ||
const outputs = NodeHelpers.getNodeOutputs(workflow, targetNode, nodeType); | ||
const mainOutputs = outputs.filter((output) => | ||
typeof output === 'string' | ||
? output === NodeConnectionType.Main | ||
: output.type === NodeConnectionType.Main, | ||
const outputs = NodeHelpers.getNodeOutputs(workflow, targetNode, nodeType).map((output) => | ||
typeof output === 'string' ? { type: output } : output, | ||
); | ||
|
||
return mainOutputs.length === 1 && !PIN_DATA_NODE_TYPES_DENYLIST.includes(targetNode.type); | ||
const mainOutputs = outputs.filter( | ||
(output) => output.type === NodeConnectionType.Main && output.category !== 'error', | ||
); | ||
|
||
let indexAcceptable = true; | ||
|
||
if (outputIndex !== undefined) { | ||
const output = outputs[outputIndex]; | ||
|
||
if (outputs[outputIndex] === undefined) | ||
throw new Error(`Out of bounds index ${outputIndex} provided to canPinNode`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh nice catch, I had assumed we always have an output. |
||
|
||
indexAcceptable = output.type === NodeConnectionType.Main && output.category !== 'error'; | ||
} | ||
|
||
return mainOutputs.length === 1 && indexAcceptable; | ||
} | ||
|
||
function isValidJSON(data: string): boolean { | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding Unit tests. Would it also be useful to add some e2e tests as well for this bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially if we now drop the condition in the vue file or move it to the composable this unit test should now have us fully covered.
I'm a bit unclear still on when to add e2e tests, I understand we're looking to move away from them "by default" and that there is a real cost associated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's no rule. My general rule is if the bug depends on the interaction of multiple modules, then better to have an e2e test for it.