fix(API): update return type of getFlowPool function to match the actual response structure
fix(EditNodeModal): remove unused setPending function call fix(PageComponent): remove unused setFlowPool and setLoading state variables fix(flowStore): remove unused import and updateFlowInDatabase function call, add logic to fetch flowPool data when resetting flow
This commit is contained in:
parent
3a7e46b776
commit
9726defa33
4 changed files with 9 additions and 26 deletions
|
|
@ -877,7 +877,7 @@ export async function getFlowPool({
|
||||||
}: {
|
}: {
|
||||||
flowId: string;
|
flowId: string;
|
||||||
nodeId?: string;
|
nodeId?: string;
|
||||||
}): Promise<AxiosResponse<FlowPoolType>> {
|
}): Promise<AxiosResponse<{ vertex_builds: FlowPoolType }>> {
|
||||||
const config = {};
|
const config = {};
|
||||||
config["params"] = { flow_id: flowId };
|
config["params"] = { flow_id: flowId };
|
||||||
if (nodeId) {
|
if (nodeId) {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@ const EditNodeModal = forwardRef(
|
||||||
) => {
|
) => {
|
||||||
const [myData, setMyData] = useState(data);
|
const [myData, setMyData] = useState(data);
|
||||||
|
|
||||||
const setPending = useFlowStore((state) => state.setPending);
|
|
||||||
const edges = useFlowStore((state) => state.edges);
|
const edges = useFlowStore((state) => state.edges);
|
||||||
const setNode = useFlowStore((state) => state.setNode);
|
const setNode = useFlowStore((state) => state.setNode);
|
||||||
|
|
||||||
|
|
@ -546,7 +545,6 @@ const EditNodeModal = forwardRef(
|
||||||
node: myData.node,
|
node: myData.node,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
setPending(true);
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ export default function Page({
|
||||||
const takeSnapshot = useFlowsManagerStore((state) => state.takeSnapshot);
|
const takeSnapshot = useFlowsManagerStore((state) => state.takeSnapshot);
|
||||||
const paste = useFlowStore((state) => state.paste);
|
const paste = useFlowStore((state) => state.paste);
|
||||||
const resetFlow = useFlowStore((state) => state.resetFlow);
|
const resetFlow = useFlowStore((state) => state.resetFlow);
|
||||||
const setFlowPool = useFlowStore((state) => state.setFlowPool);
|
|
||||||
const lastCopiedSelection = useFlowStore(
|
const lastCopiedSelection = useFlowStore(
|
||||||
(state) => state.lastCopiedSelection
|
(state) => state.lastCopiedSelection
|
||||||
);
|
);
|
||||||
|
|
@ -80,7 +79,6 @@ export default function Page({
|
||||||
const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId);
|
const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId);
|
||||||
const setErrorData = useAlertStore((state) => state.setErrorData);
|
const setErrorData = useAlertStore((state) => state.setErrorData);
|
||||||
const [selectionMenuVisible, setSelectionMenuVisible] = useState(false);
|
const [selectionMenuVisible, setSelectionMenuVisible] = useState(false);
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
const edgeUpdateSuccessful = useRef(true);
|
const edgeUpdateSuccessful = useRef(true);
|
||||||
|
|
||||||
const position = useRef({ x: 0, y: 0 });
|
const position = useRef({ x: 0, y: 0 });
|
||||||
|
|
@ -164,12 +162,8 @@ export default function Page({
|
||||||
edges: flow?.data?.edges ?? [],
|
edges: flow?.data?.edges ?? [],
|
||||||
viewport: flow?.data?.viewport ?? { zoom: 1, x: 0, y: 0 },
|
viewport: flow?.data?.viewport ?? { zoom: 1, x: 0, y: 0 },
|
||||||
});
|
});
|
||||||
// getFlowPool({flowId: currentFlowId}).then((flowPool) => {
|
|
||||||
// setFlowPool(flowPool.data)
|
|
||||||
// setLoading(false)
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
}, [currentFlowId, reactFlowInstance, setLoading, setFlowPool]);
|
}, [currentFlowId, reactFlowInstance]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
applyNodeChanges,
|
applyNodeChanges,
|
||||||
} from "reactflow";
|
} from "reactflow";
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { updateFlowInDatabase } from "../controllers/API";
|
import { getFlowPool, updateFlowInDatabase } from "../controllers/API";
|
||||||
import {
|
import {
|
||||||
NodeDataType,
|
NodeDataType,
|
||||||
NodeType,
|
NodeType,
|
||||||
|
|
@ -35,7 +35,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
nodes: [],
|
nodes: [],
|
||||||
edges: [],
|
edges: [],
|
||||||
isBuilding: false,
|
isBuilding: false,
|
||||||
isPending: false,
|
isPending: true,
|
||||||
hasIO: false,
|
hasIO: false,
|
||||||
reactFlowInstance: null,
|
reactFlowInstance: null,
|
||||||
lastCopiedSelection: null,
|
lastCopiedSelection: null,
|
||||||
|
|
@ -46,19 +46,12 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
set({ flowPool });
|
set({ flowPool });
|
||||||
},
|
},
|
||||||
addDataToFlowPool: (data: any, nodeId: string) => {
|
addDataToFlowPool: (data: any, nodeId: string) => {
|
||||||
const currentFlow = useFlowsManagerStore.getState().currentFlow;
|
|
||||||
let newFlowPool = cloneDeep({ ...get().flowPool });
|
let newFlowPool = cloneDeep({ ...get().flowPool });
|
||||||
if (!newFlowPool[nodeId]) newFlowPool[nodeId] = [data];
|
if (!newFlowPool[nodeId]) newFlowPool[nodeId] = [data];
|
||||||
else {
|
else {
|
||||||
newFlowPool[nodeId].push(data);
|
newFlowPool[nodeId].push(data);
|
||||||
}
|
}
|
||||||
get().setFlowPool(newFlowPool);
|
get().setFlowPool(newFlowPool);
|
||||||
if (currentFlow) {
|
|
||||||
window.sessionStorage.setItem(
|
|
||||||
`${currentFlow!.id}`,
|
|
||||||
JSON.stringify(newFlowPool)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
CleanFlowPool: () => {
|
CleanFlowPool: () => {
|
||||||
get().setFlowPool({});
|
get().setFlowPool({});
|
||||||
|
|
@ -68,12 +61,6 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
},
|
},
|
||||||
resetFlow: ({ nodes, edges, viewport }) => {
|
resetFlow: ({ nodes, edges, viewport }) => {
|
||||||
const currentFlow = useFlowsManagerStore.getState().currentFlow;
|
const currentFlow = useFlowsManagerStore.getState().currentFlow;
|
||||||
let flowPool = {};
|
|
||||||
if (currentFlow) {
|
|
||||||
flowPool = JSON.parse(
|
|
||||||
window.sessionStorage.getItem(`${currentFlow!.id}`) ?? "{}"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let newEdges = cleanEdges(nodes, edges);
|
let newEdges = cleanEdges(nodes, edges);
|
||||||
const { inputs, outputs } = getInputsAndOutputs(nodes);
|
const { inputs, outputs } = getInputsAndOutputs(nodes);
|
||||||
set({
|
set({
|
||||||
|
|
@ -83,9 +70,13 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
inputs,
|
inputs,
|
||||||
outputs,
|
outputs,
|
||||||
hasIO: inputs.length > 0 || outputs.length > 0,
|
hasIO: inputs.length > 0 || outputs.length > 0,
|
||||||
flowPool,
|
|
||||||
});
|
});
|
||||||
get().reactFlowInstance!.setViewport(viewport);
|
get().reactFlowInstance!.setViewport(viewport);
|
||||||
|
if (currentFlow) {
|
||||||
|
getFlowPool({ flowId: currentFlow.id }).then((flowPool) => {
|
||||||
|
set({ flowPool: flowPool.data.vertex_builds });
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setIsBuilding: (isBuilding) => {
|
setIsBuilding: (isBuilding) => {
|
||||||
set({ isBuilding });
|
set({ isBuilding });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue