Skip to content

fix(canvas): Apply pasted Pipe and Kamelet templates - #3838

Open
ThomasHartDev wants to merge 1 commit into
KaotoIO:mainfrom
ThomasHartDev:fix/issue-3446-paste-pipe-kamelet
Open

fix(canvas): Apply pasted Pipe and Kamelet templates#3838
ThomasHartDev wants to merge 1 commit into
KaotoIO:mainfrom
ThomasHartDev:fix/issue-3446-paste-pipe-kamelet

Conversation

@ThomasHartDev

@ThomasHartDev ThomasHartDev commented Sep 1, 2026

Copy link
Copy Markdown

When you copy a full Pipe or Kamelet and confirm replace, Kaoto currently resets to a blank template. Those resources inherit a no-op addNewEntity, so the pasted steps never land.

This implements addNewEntity for Pipe and Kamelet so the copied definition is applied, including beans, error handler, and metadata. Paste now hands those resources the raw clipboard definition. KameletBinding inherits the Pipe path.

Fixes #3446

I ran yarn workspace @kaoto/kaoto test, lint:fix, lint:style:fix, and build.

Summary by CodeRabbit

  • Bug Fixes
    • Improved paste and replacement behavior for routes, pipes, and kamelets.
    • Pasted single-entity definitions are now applied in the expected format.
    • Replaced resources now correctly refresh metadata, intermediate steps, beans, and error handlers.
    • Removed stale configuration when replacement data does not include beans or error-handler settings.
  • Tests
    • Added coverage for pasted entity replacement and associated configuration updates.

Pipe and Kamelet resources inherit a no-op addNewEntity, so replacing
on paste left a blank template. Apply the copied definition and rebuild
child entities (beans, error handler, metadata).
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: e16ae45f-9a61-4bf7-a498-39b6107580ff

📥 Commits

Reviewing files that changed from the base of the PR and between fee7abe and c4af2e9.

📒 Files selected for processing (8)
  • packages/ui/src/hooks/usePasteEntity.test.tsx
  • packages/ui/src/hooks/usePasteEntity.ts
  • packages/ui/src/models/camel/camel-k-resource.ts
  • packages/ui/src/models/camel/kamelet-binding-resource.ts
  • packages/ui/src/models/camel/kamelet-resource.test.ts
  • packages/ui/src/models/camel/kamelet-resource.ts
  • packages/ui/src/models/camel/pipe-resource.test.ts
  • packages/ui/src/models/camel/pipe-resource.ts
💤 Files with no reviewable changes (1)
  • packages/ui/src/models/camel/kamelet-binding-resource.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Paste handling now passes complete definitions for single-entity resources. Kamelet and pipe resources replace their current data and rebuild visual and supporting entities. Tests cover intermediate steps, beans, error handlers, and payload shapes.

Changes

Complete paste replacement

Layer / File(s) Summary
Kamelet replacement and metadata synchronization
packages/ui/src/models/camel/camel-k-resource.ts, packages/ui/src/models/camel/kamelet-resource.ts, packages/ui/src/models/camel/kamelet-resource.test.ts, packages/ui/src/models/camel/kamelet-binding-resource.ts
Kamelet replacement now applies the pasted template, rebuilds flow and beans entities, synchronizes metadata, and clears absent beans. The unused binding stub was removed.
Pipe replacement and error-handler rebuilding
packages/ui/src/models/camel/pipe-resource.ts, packages/ui/src/models/camel/pipe-resource.test.ts
Pipe replacement now applies the pasted template, preserves intermediate steps, rebuilds error handlers, clears absent handlers, and synchronizes metadata.
Paste template selection and validation
packages/ui/src/hooks/usePasteEntity.ts, packages/ui/src/hooks/usePasteEntity.test.tsx
Single-entity resources receive raw definitions. Multi-entity resources continue to receive name-keyed definitions. Tests verify both payload shapes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🔵 Low · up to c4af2

Pasting full Pipe and Kamelet definitions now applies their steps and supporting metadata instead of resetting to a blank template. The change is mergeable with owner awareness that malformed pasted content could still leave the editor in a partially replaced state if reconstruction fails.

Suggested reviewers: lordrip, tplevko, shivamg640

Poem

A rabbit pasted routes in a row
Complete little flows began to grow
Pipes kept each step
Kamelets found beans
Old handlers cleared cleanly below

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: applying pasted Pipe and Kamelet templates in the canvas.
Linked Issues check ✅ Passed The changes address issue [#3446]. Pipe and Kamelet paste operations now apply the copied templates, including intermediate steps, beans, error handlers, and metadata. Added tests cover replacement be…
Out of Scope Changes check ✅ Passed All changes support the linked issue [#3446]. The metadata synchronization helper, KameletBinding path adjustment, implementation changes, and tests are directly related to preserving pasted Pipe and …
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 7…
Full details: Linked Issues check

Explanation

The changes address issue [#3446]. Pipe and Kamelet paste operations now apply the copied templates, including intermediate steps, beans, error handlers, and metadata. Added tests cover replacement behavior and clearing stale data.

Full details: Out of Scope Changes check

Explanation

All changes support the linked issue [#3446]. The metadata synchronization helper, KameletBinding path adjustment, implementation changes, and tests are directly related to preserving pasted Pipe and Kamelet templates.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 7 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Canvas] Pipes and kamelets are not pasting full routes but generating a new one

1 participant