kaoto icon indicating copy to clipboard operation
kaoto copied to clipboard

Renaming the bean in source code not reflected in the form and bean reference in route source

Open tplevko opened this issue 1 year ago • 4 comments

Describe the Bug

The beans can be renamed - it would be useful, if the changed name would get reflected in the specified node bean reference - both in the form and also in the source code.

Edit - the same is valid for bean deletion - in case it's deleted, the reference in the node remains, pointing to non-existing bean.

Steps to Reproduce the Bug or Issue

  1. create a route with bean reference
  2. rename specified bean
  3. see the bean reference wasn't updated in the canvas form and source code (it gets updated in the beans editor)

Screenshots or Videos

https://github.com/KaotoIO/kaoto-next/assets/4180208/f16abeca-0b6b-47ac-987c-05dc5be4b3aa

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 0.30.0]

tplevko avatar Dec 14 '23 15:12 tplevko

Thanks, good catch :+1: This is not a trivial one. 2 options in mind:

  1. Put some form of link map (mapping bean name and path string of the reference?) inside BeansEntity so that the reference could be traced when bean rename event is triggered
  2. Make full scan on the whole source code and look for the reference

No.1 is better if possible, need to look into deeper. One question is that what is the best way to update the visual entity configurations triggered by an update in the non visual entity?

igarashitm avatar Dec 14 '23 16:12 igarashitm

w/r/t deleting, I'm not 100% confident that we should remove automatically for that case, thinking about when user is splitting the beans into a separate file. We allow bean reference that is not in the beans section of the same YAML in general.

igarashitm avatar Dec 14 '23 16:12 igarashitm

Bean name is changed through Kaoto Beans Editor

It requires two things

  1. When a bean reference is persisted into the source code, as well as the source code is parsed and existing beans are detected, a full path and parameter name needs to be stored along with BeansEntity. We might be able to pass the selectedNode: CanvasNode into uniforms as an additional property. Then BeanReferenceField puts that reference infointo BeansEntity on onChange event.
  2. When a bean name is changed through Beans Editor, trace the references stored with BeansEntity and propagate the name change to the canvas node parameter values.

Bean name is changed through source code editor

IMO the changes made in source code editor is on user's responsibility, so Kaoto itself doesn't have to take care of that if the only bean name in the beans section is changed. This is an inconsistency user intentionanly made in the code editor. However, the Camel Route YAML editor plugin might be able to implement such feature, like when the bean name in beans section is changed, update all references as well. IOW this should happen in the source code editor.

igarashitm avatar Dec 19 '23 13:12 igarashitm

@igarashitm , I'm moving this issue to the backlog, since I think after your last comment, it's no longer blocked 👍 (also I agree with it 😃)

lordrip avatar Mar 21 '24 11:03 lordrip