mirror of
https://github.com/hexastack/hexabot
synced 2024-11-24 04:53:41 +00:00
fix: revert moving link
This commit is contained in:
parent
55fe415fd8
commit
066124acc5
@ -344,6 +344,61 @@ const Diagrams = () => {
|
||||
const id = deleteDialogCtl?.data;
|
||||
|
||||
if (id) {
|
||||
// Handle link deletion
|
||||
if (id.length === 36) {
|
||||
const link = model?.getLink(id) as any;
|
||||
const sourceId = link?.sourcePort.parent.options.id;
|
||||
const targetId = link?.targetPort.parent.options.id;
|
||||
|
||||
if (link?.sourcePort.options.label === BlockPorts.nextBlocksOutPort) {
|
||||
const previousData = getBlockFromCache(sourceId);
|
||||
const nextBlocks = [...(previousData?.nextBlocks || [])];
|
||||
|
||||
await updateBlock(
|
||||
{
|
||||
id: sourceId,
|
||||
params: {
|
||||
nextBlocks: nextBlocks.filter((block) => block !== targetId),
|
||||
},
|
||||
},
|
||||
{
|
||||
onSuccess() {
|
||||
updateCachedBlock({
|
||||
id: targetId,
|
||||
preprocess: ({ previousBlocks = [], ...rest }) => ({
|
||||
...rest,
|
||||
previousBlocks: previousBlocks.filter(
|
||||
(previousBlock) => previousBlock !== sourceId,
|
||||
),
|
||||
}),
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
} else if (
|
||||
link?.sourcePort.options.label === BlockPorts.attachmentOutPort
|
||||
) {
|
||||
await updateBlock(
|
||||
{
|
||||
id: sourceId,
|
||||
params: {
|
||||
attachedBlock: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
onSuccess() {
|
||||
updateCachedBlock({
|
||||
id: targetId,
|
||||
preprocess: (oldData) => ({
|
||||
...oldData,
|
||||
attachedToBlock: null,
|
||||
}),
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const ids = id.split(",");
|
||||
|
||||
if (ids.length > 1) {
|
||||
@ -439,6 +494,7 @@ const Diagrams = () => {
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
deleteCallbackRef.current?.();
|
||||
deleteCallbackRef.current = () => {};
|
||||
|
Loading…
Reference in New Issue
Block a user