Snapshot took when updating node name and inputs

This commit is contained in:
Lucas Oliveira 2023-10-13 01:06:22 -03:00
commit 3c4d3ab5e2
2 changed files with 8 additions and 0 deletions

View file

@ -25,6 +25,7 @@ import { Button } from "../../../../components/ui/button";
import { TOOLTIP_EMPTY } from "../../../../constants/constants";
import { TabsContext } from "../../../../contexts/tabsContext";
import { typesContext } from "../../../../contexts/typesContext";
import { undoRedoContext } from "../../../../contexts/undoRedoContext";
import { ParameterComponentType } from "../../../../types/components";
import { TabsState } from "../../../../types/tabs";
import {
@ -88,9 +89,12 @@ export default function ParameterComponent({
const { data: myData } = useContext(typesContext);
const { takeSnapshot } = useContext(undoRedoContext);
const handleOnNewValue = (
newValue: string | string[] | boolean | Object[]
): void => {
takeSnapshot();
let newData = cloneDeep(data);
newData.node!.template[name].value = newValue;
setData(newData);

View file

@ -9,6 +9,7 @@ import { Textarea } from "../../components/ui/textarea";
import { useSSE } from "../../contexts/SSEContext";
import { TabsContext } from "../../contexts/tabsContext";
import { typesContext } from "../../contexts/typesContext";
import { undoRedoContext } from "../../contexts/undoRedoContext";
import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent";
import { validationStatusType } from "../../types/components";
import { NodeDataType } from "../../types/flow";
@ -50,6 +51,8 @@ export default function GenericNode({
const [handles, setHandles] = useState<boolean[] | []>([]);
let numberOfInputs: boolean[] = [];
const { takeSnapshot } = useContext(undoRedoContext);
function countHandles(): void {
numberOfInputs = Object.keys(data.node!.template)
.filter((templateField) => templateField.charAt(0) !== "_")
@ -189,6 +192,7 @@ export default function GenericNode({
} else {
setNodeName(data.node!.display_name);
}
takeSnapshot();
}}
value={nodeName}
onChange={setNodeName}