feat: Add badge to leaf nodes#138
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds subtype “badges” to task leaf nodes in the React Flow diagram editor, along with subtype extraction helpers and initial support for TryCatch/Catch nodes to advance the agreed node styling/UX work.
Changes:
- Introduces task subtype extraction utilities for
Call,Run, andListentasks and exports them fromsrc/core. - Adds badge rendering to leaf task nodes (text for known subtypes, info-icon with tooltip for unknown).
- Adds
Catchas a leaf node (incl. config + tests) andTryCatchas a placeholder container node; adjusts default node sizing and demo diagram data.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/serverless-workflow-diagram-editor/tests/react-flow/nodes/taskNodeConfig.test.ts | Updates leaf node config coverage to include Catch. |
| packages/serverless-workflow-diagram-editor/tests/react-flow/nodes/Nodes.test.tsx | Extends node rendering tests for TryCatch/Catch and adds badge rendering tests. |
| packages/serverless-workflow-diagram-editor/tests/core/taskSubType.test.ts | Adds unit tests for subtype extraction utilities. |
| packages/serverless-workflow-diagram-editor/src/react-flow/nodes/taskNodeConfig.ts | Adds Catch leaf node config (color/icon/type label). |
| packages/serverless-workflow-diagram-editor/src/react-flow/nodes/Nodes.tsx | Adds TryCatch/Catch node types and implements TaskNodeBadge rendering. |
| packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.tsx | Updates hardcoded demo nodes to include badges and tweaks positions/edge waypoints. |
| packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.css | Adds badge styling and adjusts leaf node layout to accommodate badge + truncation. |
| packages/serverless-workflow-diagram-editor/src/core/taskSubType.ts | Implements getCallSubType, getRunSubType, getListenSubType, getTaskSubType. |
| packages/serverless-workflow-diagram-editor/src/core/index.ts | Exports the new taskSubType module. |
| packages/serverless-workflow-diagram-editor/src/core/autoLayout.ts | Increases default node width to 200. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3d87847 to
21beae8
Compare
21beae8 to
b2907b4
Compare
b2907b4 to
5d33e62
Compare
5d33e62 to
3f556b0
Compare
8f681b3 to
8b4665f
Compare
Signed-off-by: lornakelly <lornakelly88@gmail.com>
8b4665f to
a47057b
Compare
|
@fantonangeli @handreyrc Ready for review after rebase |
handreyrc
left a comment
There was a problem hiding this comment.
@lornakelly
It LGTM, Just a small remark to consider.
| ); | ||
| } | ||
|
|
||
| function TaskNodeContent({ id, data, selected, type }: NodeContentProps) { |
There was a problem hiding this comment.
Looking at the node components, we have the task base type already solved then it is converted back to a generic task type as prop to the TaskNodeComponent, finally the task type is solved again in the TaskNodeComponent to get a subtype if there is one. Maybe it could be possible to avoid the back and forth of task types.
I understand we are trying to avoid repetition. However, I see that we reached a point that we need to specialize the nodes content. I suggest to handle the specifics of each task type within its respective node component, otherwise we may end up with lengthy TaskNodeComponent with lots of "ifs". Break TaskNodeComponent into smaller reusable components and add then to the nodes as needed would make it easier follow and maintain IMO.
For example, the TaskNodeBadge could be moved to the node component, if we make those changes while nodes content is still simple and small.
WDYT?
Closes #85
Summary
Add badge rendering and subtype extraction for leaf nodes
Changes
Catchleaf node andTryCatchcontainer node with placeholder content