fix(canvas): support pasting single-entity resources - #3515
fix(canvas): support pasting single-entity resources#3515bissamiftikhar wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe paste flow now chooses the appropriate entity template shape and uses new Kamelet and Pipe resource methods to rebuild their visual entities and return their ids. ChangesPaste entity reconstruction
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ui/src/models/camel/kamelet-resource.ts`:
- Around line 53-59: Update KameletResource.addNewEntity to rebuild beans from
the replacement Kamelet template, or clear beans when the template has none;
update PipeResource.addNewEntity to rebuild errorHandler from the replacement
Pipe specification, or clear it when absent. Apply the corresponding
synchronization at packages/ui/src/models/camel/kamelet-resource.ts:53-59 and
packages/ui/src/models/camel/pipe-resource.ts:58-65 so child entities no longer
reference stale resources.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8a4ec3a6-92d6-45dd-9e10-e4cbe5118860
📒 Files selected for processing (3)
packages/ui/src/hooks/usePasteEntity.tspackages/ui/src/models/camel/kamelet-resource.tspackages/ui/src/models/camel/pipe-resource.ts
| addNewEntity(_entityType?: EntityType, entityTemplate?: unknown): string { | ||
| if (entityTemplate) { | ||
| this.resource = entityTemplate as IKameletDefinition; | ||
| this.flow = new KameletVisualEntity(this.resource as IKameletDefinition); | ||
| } | ||
| return this.flow?.id ?? ''; | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Synchronize dependent entities when replacing pasted resources.
Both implementations replace the underlying resource but retain child entities bound to the previous resource, which can overwrite pasted data or apply later edits to stale state.
packages/ui/src/models/camel/kamelet-resource.ts#L53-L59: rebuildbeansfrom the new Kamelet template, or clear it when absent.packages/ui/src/models/camel/pipe-resource.ts#L58-L65: rebuilderrorHandlerfrom the new Pipe specification, or clear it when absent.
📍 Affects 2 files
packages/ui/src/models/camel/kamelet-resource.ts#L53-L59(this comment)packages/ui/src/models/camel/pipe-resource.ts#L58-L65
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/ui/src/models/camel/kamelet-resource.ts` around lines 53 - 59,
Update KameletResource.addNewEntity to rebuild beans from the replacement
Kamelet template, or clear beans when the template has none; update
PipeResource.addNewEntity to rebuild errorHandler from the replacement Pipe
specification, or clear it when absent. Apply the corresponding synchronization
at packages/ui/src/models/camel/kamelet-resource.ts:53-59 and
packages/ui/src/models/camel/pipe-resource.ts:58-65 so child entities no longer
reference stale resources.
|
Thank you for your interest in contributing to Kaoto! |



Fixes #3445 and #3446 by passing the raw entity template instead of wrapping it in an object literal, and implementing
addNewEntityto actually apply the template for Pipe and Kamelet resources.Summary by CodeRabbit