-
Notifications
You must be signed in to change notification settings - Fork 0
fix(DataMapper): Delete DataMapper metadata entry when the step is de… #94
Conversation
reported KaotoIO/vscode-kaoto#681 |
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.
PR implementing API on VS Code Kaoto side KaotoIO/vscode-kaoto#682
based on this (internal) conversation https://redhat-internal.slack.com/archives/C06NYTRDMSR/p1727940000320609?thread_ts=1727725969.056549&cid=C06NYTRDMSR we should ask end-user if he wants to delete the associated xslt file or not
I have 2 questions about the confirmation dialog
|
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.
While the approach is working, as you mentioned in the description, the place of the implementation might not be ideal.
For example, when deleting the datamapper
step, we iterate over the registered components in the CanvasForm
anchor. This could be expected if the operation were in the canvas form itself, but it's not the case.
There's also the situation when multiple registered components might pass the activationFn
callback when deleting the datamapper
step.
That being said, I see 2 ways to move forward:
-
We consider the current approach, although not ideal, enough for what we need to do at this exact moment and merge it.
-
Update this PR a bit to create a similar provider to the
RenderingProvider
, perhaps namedInteractionProviders
to register interaction handlers with step names.
The idea behind is the same, we register kaoto-datamapper
step with some callbacks, for starters, we could implement the onDelete
, this way, we could extend it in the future to have other lifecycle events, like onAdd
, onReplace
, etc...
packages/ui/src/components/Visualization/Custom/ContextMenu/ItemReplaceStep.tsx
Outdated
Show resolved
Hide resolved
packages/ui/src/components/Visualization/Custom/ContextMenu/ItemDeleteStep.tsx
Outdated
Show resolved
Hide resolved
packages/ui/src/components/RenderingAnchor/rendering.provider.tsx
Outdated
Show resolved
Hide resolved
packages/ui/src/components/registers/interactions/node-interaction.provider.tsx
Outdated
Show resolved
Hide resolved
packages/ui/src/components/Visualization/Custom/ContextMenu/ItemDeleteGroup.tsx
Outdated
Show resolved
Hide resolved
packages/ui/src/components/registers/interactions/node-interaction.model.ts
Outdated
Show resolved
Hide resolved
As you commented in another thread, I think we can expand the existing confirmation modal to include different buttons and return the ID of the clicked one, instead of the current |
61e4a7a
to
ca396ad
Compare
packages/ui/src/components/registers/interactions/node-interaction.model.ts
Outdated
Show resolved
Hide resolved
packages/ui/src/components/Visualization/Custom/ContextMenu/ItemDeleteGroup.tsx
Outdated
Show resolved
Hide resolved
packages/ui/src/components/Visualization/Custom/ContextMenu/ItemDeleteGroup.tsx
Outdated
Show resolved
Hide resolved
b295d48
to
65e738d
Compare
const onDeleteRecursively = useCallback( | ||
(parentVizNode: IVisualizationNode) => { | ||
parentVizNode.getChildren()?.forEach((child) => { | ||
onDeleteRecursively(child); | ||
}); | ||
const addons = getRegisteredInteractionAddons(IInteractionAddonType.ON_DELETE, parentVizNode); | ||
addons.forEach((addon) => { | ||
addon.callback(parentVizNode); | ||
}); | ||
}, | ||
[getRegisteredInteractionAddons], | ||
); |
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.
This function looks very similar to the ItemDeleteStep
and the ItemReplace
components, we should extract them to a single place so we can also benefit from testing the function on isolation.
If you don't mind, let's create an issue for this and move forward 👍
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 think once we extract the function, we could use it like this: (we probably should pick a more appropriate name than onDelete
since the function will live somewhere else now)
onDelete(IVizNode, (vizNode: IVisualizationNode => getRegisteredInteractionAddons(IInteractionAddonType.ON_DELETE, parentVizNode)
Notice how we pass the current visualizationNode
to the function as the first argument, and for the second argument, we pass a function that tells how and what type of interactions we are looking for, this way we bridge the React world (providers) with the outside, using regular Javascript.
Alternatively, since we're just traversing objects and we're not relying on any particular class instance, we might even simplify it as:
onDelete(IVizNode, getRegisteredInteractionAddons);
Then the onDelete
function body will be in charge of passing the right VizNode and the right interaction type.
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.
…leted
Fixes: KaotoIO/kaoto#1757
Here's something that works as expected. Now I have 2 questions:
RenderingAnchor
doesn't fit for this purpose, registeringonDelete
along withDataMapperLauncher
component looks good for maintainability.deleteResourceContent
to VS Code extension side. Does it sound right?TODO
prev
andnext
step also need to be looked at when hookingonDelete
for the children - https://github.com/KaotoIO/kaoto-datamapper-integration/pull/94/files#r1786507148choice
orwhen
usesItemDeleteStep
but notItemDeleteGroup
, so bothItemDeleteStep
andItemReplaceStep
would have to process recursivelyItemDeleteGroup
is used when an entire route is deleted.NodeInteraction
, theNodeInteractionProvider
in this PR might be better to rename to something else - https://github.com/KaotoIO/kaoto/blob/main/packages/ui/src/models/visualization/base-visual-entity.ts#L165NodeInteractionAddonProvider
Split the PR, submitNodeInteractionXXProvider
andItem*.tsx
change to the upstream first, then rebase this PR with just DataMapper specificRegisterComponents
andRenderingAnchor
are also not yet merged to upstream main. SinceNodeInteractionAddonProvider
sharesactivationFn
with it, keep it here until we merge them together.Update - splitted following to a separate issue - KaotoIO/kaoto#1749