-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor Dynamic Node Callbacks #927
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
base: master
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9596f63 to
35a7502
Compare
35a7502 to
0b3349b
Compare
0b3349b to
87e51db
Compare
87e51db to
b50521d
Compare
b50521d to
770419a
Compare
770419a to
cbcb1f5
Compare
55af5f0 to
62e8606
Compare
62e8606 to
97a70b0
Compare
97a70b0 to
7051a11
Compare
7051a11 to
3bdcabb
Compare
c426542 to
7bcc36b
Compare
7bcc36b to
d9b0b7a
Compare
| readOnly?: boolean; | ||
| connectable?: boolean; |
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.
For future: do we have any instance of Graph to be readonly, BUT connectable? I feel that this is single property "readOnly".
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.
It's more the opposite scenario that's the concern: the graph is not readonly and node connection is disabled - specifically this lock button
I've been growing increasingly discontent with "readOnly" and how it's used specifically for the run route. I think in future we will want to take a look and properly make readOnly an actual read-only state regardless of the route.
|
|
||
| export type TaskType = "task" | "input" | "output"; | ||
|
|
||
| export interface NodeData extends Record<string, unknown> { |
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.
For future: Do we need to have more arbitrary properties on this object? extending it from Record makes it harder to type causing weird code to appear down the road, e.g.
TaskNode:
const typedData = useMemo(() => data as TaskNodeData, [data]);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.
I vaguely recall trying to not extend and ReactFlow threw up a huge amount of type errors. There may be some larger changes need to our type structure to make this happen, but I do agree with the idea.
| readOnly?: boolean; | ||
| isGhost?: boolean; | ||
| connectable?: boolean; | ||
| highlighted?: boolean; |
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.
For future: highlighted might not belong to the Node properties/data, but I'm not sure yet.
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.
Most likely the node overlay or highlighter you made would solve this but we haven't gotten around to looking into it.
maxy-shpfy
left a comment
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.
Tested, no immediate issues found
5d5a668 to
0c9c20e
Compare
0c9c20e to
8a86e79
Compare
8a86e79 to
9e0dc05
Compare


Description
generateDynamicNodeCallbackshas now been replaced withconvertNodeCallbacksToTaskCallbacks, which is much simpler in logic and has clearer typing.This relates to the automatic generation of Task Callbacks during node creation, and, to make the distinction clearer, the input
NodeDatatype has been separated from the internalTaskNodeDatatype.Background explanation
A Task Node's callbacks are defined at the Flow-Canvas level in
useNodeCallbacksand require thetaskIdandnodeIdto be passed in so ReactFlow & ComponentSpec can be updated accordingly. However, within a task node, where these callbacks are executed,taskIdandnodeIdare already known and are static. Thus, we currently have a transform that occurs when Task Nodes are created to inject the known ids into the callback function. This saves us from having to manually pass in the ids when executing the callbacks within a node (e.g. in TaskNodeProvider).This PR simplifies that conversion function significantly and institutes a clear division between the internal TaskNode data and the external node data needed to create the task node.
This PR is intended to start laying the groundwork for a node compatibility layer to be introduced, which will ultimately involve id generation at the task node creation level. Having simplified task creation code will make this process easier.
No change to app functionality.
Note/Follow-up:
generateDynamicNodeCallbacksdid the conversion dynamically. this new system requires the methods to be manually coded. Consider if there is a way to go back to a dynamic model so that any new methods don't need to be manually addedRelated Issue and Pull requests
Closes https://github.com/Shopify/oasis-frontend/issues/334
Type of Change
Checklist
Screenshots (if applicable)
Test Instructions
Expected Results
All functionality should behave identically to before the refactor. No visual or functional changes should be observed.
Additional Comments