feat: The Big One UI #47

Merged
j.gerla merged 115 commits from temp_screenshot_manual into dev 2026-01-28 08:27:30 +00:00
3 changed files with 18 additions and 15 deletions
Showing only changes of commit e5b438c17e - Show all commits

View File

@@ -196,17 +196,20 @@ const useFlowStore = create<FlowState>(UndoRedo((set, get) => ({
// If there's no function, OR, our function tells us we can delete it, let's do so... // If there's no function, OR, our function tells us we can delete it, let's do so...
if (ourFunction == undefined || ourFunction()) { if (ourFunction == undefined || ourFunction()) {
deleteElements({ if (deleteElements){
nodes: get().nodes.filter((n) => n.id === nodeId), deleteElements({
edges: get().edges.filter((e) => e.source !== nodeId && e.target === nodeId)} nodes: get().nodes.filter((n) => n.id === nodeId),
).then(() => { edges: get().edges.filter((e) => e.source !== nodeId && e.target === nodeId)}
get().unregisterNodeRules(nodeId); ).then(() => {
get().unregisterWarningsForId(nodeId); get().unregisterNodeRules(nodeId);
}); get().unregisterWarningsForId(nodeId);
// set({ });
// nodes: get().nodes.filter((n) => n.id !== nodeId), } else {
// edges: get().edges.filter((e) => e.source !== nodeId && e.target !== nodeId), set({
// }) nodes: get().nodes.filter((n) => n.id !== nodeId),
edges: get().edges.filter((e) => e.source !== nodeId && e.target !== nodeId),
})
}
} }
}, },

View File

@@ -69,7 +69,7 @@ export type FlowState = {
* Deletes a node and any connected edges. * Deletes a node and any connected edges.
* @param nodeId - the ID of the node to delete * @param nodeId - the ID of the node to delete
*/ */
deleteNode: (nodeId: string, deleteElements: (params: DeleteElementsOptions) => Promise<{ deleteNode: (nodeId: string, deleteElements?: (params: DeleteElementsOptions) => Promise<{
deletedNodes: Node[] deletedNodes: Node[]
deletedEdges: Edge[] deletedEdges: Edge[]
}>) => void; }>) => void;

View File

@@ -3,7 +3,6 @@ import {
type Connection, type Connection,
type Edge, type Edge,
type Node, type Node,
useReactFlow
} from "@xyflow/react"; } from "@xyflow/react";
import type {HandleRule, RuleResult} from "../../../../src/pages/VisProgPage/visualProgrammingUI/HandleRuleLogic.ts"; import type {HandleRule, RuleResult} from "../../../../src/pages/VisProgPage/visualProgrammingUI/HandleRuleLogic.ts";
import { NodeDisconnections } from "../../../../src/pages/VisProgPage/visualProgrammingUI/NodeRegistry.ts"; import { NodeDisconnections } from "../../../../src/pages/VisProgPage/visualProgrammingUI/NodeRegistry.ts";
@@ -402,9 +401,10 @@ describe('FlowStore Functionality', () => {
target: 'B' target: 'B'
}] }]
}); });
const {deleteElements} = useReactFlow();
act(()=> { act(()=> {
deleteNode(nodeId, deleteElements); deleteNode(nodeId);
}); });
const updatedState = useFlowStore.getState(); const updatedState = useFlowStore.getState();