mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: apply feedback
This commit is contained in:
parent
71462facb8
commit
aabbfed851
@ -28,7 +28,6 @@ import {
|
|||||||
DiagramEngine,
|
DiagramEngine,
|
||||||
DiagramModel,
|
DiagramModel,
|
||||||
DiagramModelGenerics,
|
DiagramModelGenerics,
|
||||||
NodeModel,
|
|
||||||
} from "@projectstorm/react-diagrams";
|
} from "@projectstorm/react-diagrams";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { SyntheticEvent, useCallback, useEffect, useState } from "react";
|
import { SyntheticEvent, useCallback, useEffect, useState } from "react";
|
||||||
@ -84,12 +83,6 @@ const Diagrams = () => {
|
|||||||
$eq: [{ category: selectedCategoryId }],
|
$eq: [{ category: selectedCategoryId }],
|
||||||
});
|
});
|
||||||
const selectedEntities = engine?.getModel()?.getSelectedEntities();
|
const selectedEntities = engine?.getModel()?.getSelectedEntities();
|
||||||
const selectedLinks = (selectedEntities || []).filter(
|
|
||||||
(entity) => entity instanceof AdvancedLinkModel,
|
|
||||||
);
|
|
||||||
const selectedBlocks = (selectedEntities || []).filter(
|
|
||||||
(entity) => entity instanceof NodeModel,
|
|
||||||
);
|
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { mutate: duplicateBlock, isLoading: isDuplicatingBlock } = useCreate(
|
const { mutate: duplicateBlock, isLoading: isDuplicatingBlock } = useCreate(
|
||||||
EntityType.BLOCK,
|
EntityType.BLOCK,
|
||||||
@ -100,9 +93,8 @@ const Diagrams = () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
const shouldDisableDuplicateButton =
|
const shouldDisableDuplicateButton =
|
||||||
selectedLinks.length >= 1 ||
|
selectedEntities?.length !== 1 ||
|
||||||
selectedBlocks.length > 1 ||
|
selectedEntities[0]?.getID()?.length !== 24 ||
|
||||||
selectedBlocks.length === 0 ||
|
|
||||||
isDuplicatingBlock;
|
isDuplicatingBlock;
|
||||||
const { data: categories } = useFind(
|
const { data: categories } = useFind(
|
||||||
{ entity: EntityType.CATEGORY },
|
{ entity: EntityType.CATEGORY },
|
||||||
@ -197,8 +189,10 @@ const Diagrams = () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
const handleDuplicateBlock = () => {
|
const handleDuplicateBlock = () => {
|
||||||
const selectedBlock = selectedBlocks[0] as any;
|
if (!selectedEntities || selectedEntities.length !== 1) {
|
||||||
const block = getBlockFromCache(selectedBlock?.options?.id);
|
return;
|
||||||
|
}
|
||||||
|
const block = getBlockFromCache(selectedEntities[0].getID());
|
||||||
|
|
||||||
if (!block) {
|
if (!block) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user