From bfee2ffe70b2b7cbdaf7c80f8d4329b2d46ba56d Mon Sep 17 00:00:00 2001 From: Igor Carvalho Date: Wed, 19 Jul 2023 17:39:36 -0300 Subject: [PATCH] refactor[undoRedoContext]: Move undoRedoContext types to types directorie --- src/frontend/src/contexts/undoRedoContext.tsx | 27 ++----------------- src/frontend/src/types/typesContext/index.ts | 26 +++++++++++++++++- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/frontend/src/contexts/undoRedoContext.tsx b/src/frontend/src/contexts/undoRedoContext.tsx index 3df201082..e3084cc5a 100644 --- a/src/frontend/src/contexts/undoRedoContext.tsx +++ b/src/frontend/src/contexts/undoRedoContext.tsx @@ -6,32 +6,9 @@ import { useEffect, useState, } from "react"; -import { Edge, Node, useReactFlow } from "reactflow"; +import { useReactFlow } from "reactflow"; import { TabsContext } from "./tabsContext"; - -type undoRedoContextType = { - undo: () => void; - redo: () => void; - takeSnapshot: () => void; -}; - -type UseUndoRedoOptions = { - maxHistorySize: number; - enableShortcuts: boolean; -}; - -type UseUndoRedo = (options?: UseUndoRedoOptions) => { - undo: () => void; - redo: () => void; - takeSnapshot: () => void; - canUndo: boolean; - canRedo: boolean; -}; - -type HistoryItem = { - nodes: Node[]; - edges: Edge[]; -}; +import { undoRedoContextType, UseUndoRedoOptions , UseUndoRedo, HistoryItem } from "../types/typesContext"; const initialValue = { undo: () => {}, diff --git a/src/frontend/src/types/typesContext/index.ts b/src/frontend/src/types/typesContext/index.ts index 76a1fc17c..ab655f6e7 100644 --- a/src/frontend/src/types/typesContext/index.ts +++ b/src/frontend/src/types/typesContext/index.ts @@ -1,4 +1,4 @@ -import { ReactFlowInstance } from "reactflow"; +import { ReactFlowInstance, Edge, Node } from "reactflow"; import { APIClassType } from "../api"; import { AlertItemType } from "../alerts"; @@ -72,3 +72,27 @@ export type locationContextType = { extraComponent: any; setExtraComponent: (newState: any) => void; }; + +export type undoRedoContextType = { + undo: () => void; + redo: () => void; + takeSnapshot: () => void; +}; + +export type UseUndoRedoOptions = { + maxHistorySize: number; + enableShortcuts: boolean; +}; + +export type UseUndoRedo = (options?: UseUndoRedoOptions) => { + undo: () => void; + redo: () => void; + takeSnapshot: () => void; + canUndo: boolean; + canRedo: boolean; +}; + +export type HistoryItem = { + nodes: Node[]; + edges: Edge[]; +};