Added takeSnapshot on ungroup and show and hide node
This commit is contained in:
parent
733e6945c6
commit
857fa403a1
3 changed files with 9 additions and 8 deletions
|
|
@ -46,7 +46,6 @@ export default function GenericNode({
|
||||||
);
|
);
|
||||||
const [validationStatus, setValidationStatus] =
|
const [validationStatus, setValidationStatus] =
|
||||||
useState<validationStatusType | null>(null);
|
useState<validationStatusType | null>(null);
|
||||||
const [showNode, setShowNode] = useState<boolean>(true);
|
|
||||||
const [handles, setHandles] = useState<boolean[] | []>([]);
|
const [handles, setHandles] = useState<boolean[] | []>([]);
|
||||||
let numberOfInputs: boolean[] = [];
|
let numberOfInputs: boolean[] = [];
|
||||||
|
|
||||||
|
|
@ -108,12 +107,6 @@ export default function GenericNode({
|
||||||
countHandles();
|
countHandles();
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
updateNodeInternals(data.id);
|
|
||||||
}, 300);
|
|
||||||
}, [showNode]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setNodeDescription(data.node!.description);
|
setNodeDescription(data.node!.description);
|
||||||
}, [data.node!.description]);
|
}, [data.node!.description]);
|
||||||
|
|
@ -132,6 +125,9 @@ export default function GenericNode({
|
||||||
setValidationStatus(null);
|
setValidationStatus(null);
|
||||||
}
|
}
|
||||||
}, [sseData, data.id]);
|
}, [sseData, data.id]);
|
||||||
|
|
||||||
|
const showNode = data.showNode ?? false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NodeToolbar>
|
<NodeToolbar>
|
||||||
|
|
@ -139,7 +135,7 @@ export default function GenericNode({
|
||||||
position={{ x: xPos, y: yPos }}
|
position={{ x: xPos, y: yPos }}
|
||||||
data={data}
|
data={data}
|
||||||
deleteNode={deleteNode}
|
deleteNode={deleteNode}
|
||||||
setShowNode={setShowNode}
|
setShowNode={(showNode: boolean) => {data.showNode = showNode}}
|
||||||
numberOfHandles={handles}
|
numberOfHandles={handles}
|
||||||
showNode={showNode}
|
showNode={showNode}
|
||||||
></NodeToolbarComponent>
|
></NodeToolbarComponent>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import {
|
||||||
updateFlowPosition,
|
updateFlowPosition,
|
||||||
} from "../../../../utils/reactflowUtils";
|
} from "../../../../utils/reactflowUtils";
|
||||||
import { classNames } from "../../../../utils/utils";
|
import { classNames } from "../../../../utils/utils";
|
||||||
|
import { undoRedoContext } from "../../../../contexts/undoRedoContext";
|
||||||
|
|
||||||
export default function NodeToolbarComponent({
|
export default function NodeToolbarComponent({
|
||||||
data,
|
data,
|
||||||
|
|
@ -65,6 +66,7 @@ export default function NodeToolbarComponent({
|
||||||
const isGroup = data.node?.flow ? true : false;
|
const isGroup = data.node?.flow ? true : false;
|
||||||
|
|
||||||
const { paste, saveComponent, version, flows } = useContext(FlowsContext);
|
const { paste, saveComponent, version, flows } = useContext(FlowsContext);
|
||||||
|
const { takeSnapshot } = useContext(undoRedoContext);
|
||||||
const reactFlowInstance = useReactFlow();
|
const reactFlowInstance = useReactFlow();
|
||||||
const [showModalAdvanced, setShowModalAdvanced] = useState(false);
|
const [showModalAdvanced, setShowModalAdvanced] = useState(false);
|
||||||
const [showconfirmShare, setShowconfirmShare] = useState(false);
|
const [showconfirmShare, setShowconfirmShare] = useState(false);
|
||||||
|
|
@ -83,6 +85,7 @@ export default function NodeToolbarComponent({
|
||||||
setShowModalAdvanced(true);
|
setShowModalAdvanced(true);
|
||||||
break;
|
break;
|
||||||
case "show":
|
case "show":
|
||||||
|
takeSnapshot();
|
||||||
setShowNode((prev) => !prev);
|
setShowNode((prev) => !prev);
|
||||||
updateNodeInternals(data.id);
|
updateNodeInternals(data.id);
|
||||||
break;
|
break;
|
||||||
|
|
@ -98,6 +101,7 @@ export default function NodeToolbarComponent({
|
||||||
case "disabled":
|
case "disabled":
|
||||||
break;
|
break;
|
||||||
case "ungroup":
|
case "ungroup":
|
||||||
|
takeSnapshot();
|
||||||
updateFlowPosition(position, data.node?.flow!);
|
updateFlowPosition(position, data.node?.flow!);
|
||||||
expandGroupNode(data, reactFlowInstance, getNodeId);
|
expandGroupNode(data, reactFlowInstance, getNodeId);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export type NodeType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NodeDataType = {
|
export type NodeDataType = {
|
||||||
|
showNode?: boolean;
|
||||||
type: string;
|
type: string;
|
||||||
node?: APIClassType;
|
node?: APIClassType;
|
||||||
id: string;
|
id: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue