Compare commits
1 Commits
claude/iss
...
110f5dc92e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
110f5dc92e |
@@ -264,7 +264,12 @@ const Graph = forwardRef<GraphHandle, { setGraphPath: React.Dispatch<React.SetSt
|
|||||||
title: selectedNodeName,
|
title: selectedNodeName,
|
||||||
key: pathSegmentId,
|
key: pathSegmentId,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
setGraphsPath(prev => prev.slice(0, prev.findIndex(p => p.key === pathSegmentId) + 1));
|
const index = graphsPath.findIndex(p => p.key === pathSegmentId);
|
||||||
|
setGraphsPath(prev => {
|
||||||
|
prev.splice(index + 1);
|
||||||
|
|
||||||
|
return [...prev];
|
||||||
|
});
|
||||||
selectGraphId(pathSegmentId);
|
selectGraphId(pathSegmentId);
|
||||||
}
|
}
|
||||||
} as BreadcrumbItemType;
|
} as BreadcrumbItemType;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Input, Modal } from "antd";
|
import { Input, Modal } from "antd";
|
||||||
import { graphContext, type NodeContext } from "./Graph";
|
import { graphContext, type NodeContext } from "./Graph";
|
||||||
import { useContext, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import { useGraphLayersTreeStore } from "../stores/TreeStore";
|
|
||||||
|
|
||||||
export default function NodeRenameModal({
|
export default function NodeRenameModal({
|
||||||
nodeContext,
|
nodeContext,
|
||||||
@@ -16,8 +15,7 @@ export default function NodeRenameModal({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [nodeName, setSelectedNodeName] = useState(nodeContext.nodeName);
|
const [nodeName, setSelectedNodeName] = useState(nodeContext.nodeName);
|
||||||
const graphContextValue = useContext(graphContext)!;
|
const graphContextValue = useContext(graphContext)!;
|
||||||
const renameTreeNode = useGraphLayersTreeStore(state => state.rename);
|
|
||||||
|
|
||||||
function renameNode() {
|
function renameNode() {
|
||||||
const node = graphContextValue.graph.nodes.find(n => n.id === nodeContext.nodeId);
|
const node = graphContextValue.graph.nodes.find(n => n.id === nodeContext.nodeId);
|
||||||
@@ -26,7 +24,6 @@ export default function NodeRenameModal({
|
|||||||
}
|
}
|
||||||
node.label = nodeName;
|
node.label = nodeName;
|
||||||
graphContextValue.setGraph(prev => ({ ...prev, nodes: graphContextValue.graph.nodes }));
|
graphContextValue.setGraph(prev => ({ ...prev, nodes: graphContextValue.graph.nodes }));
|
||||||
renameTreeNode(nodeContext.nodeId, nodeName);
|
|
||||||
openRenameModal(false);
|
openRenameModal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ export interface TreeStore {
|
|||||||
tree: TreeDataNode[];
|
tree: TreeDataNode[];
|
||||||
add: (childNode: NodeContext, parentNodeId: string | undefined) => void;
|
add: (childNode: NodeContext, parentNodeId: string | undefined) => void;
|
||||||
remove: (nodeId: string) => void;
|
remove: (nodeId: string) => void;
|
||||||
rename: (nodeId: string, newName: string) => void;
|
|
||||||
reset: () => void;
|
reset: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,20 +90,6 @@ export const useGraphLayersTreeStore = create<TreeStore>()((set) => ({
|
|||||||
tree: createTree([...state.rootNodes], nodesFlatById)
|
tree: createTree([...state.rootNodes], nodesFlatById)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
rename: (nodeId, newName) => set((state) => {
|
|
||||||
const node = state.nodesFlatById.get(nodeId);
|
|
||||||
if (!node) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
const nodesFlatById = new Map(state.nodesFlatById);
|
|
||||||
nodesFlatById.set(nodeId, { ...node, title: newName });
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
nodesFlatById,
|
|
||||||
rootNodes: [...state.rootNodes],
|
|
||||||
tree: createTree([...state.rootNodes], nodesFlatById),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
reset: () => set({
|
reset: () => set({
|
||||||
nodesFlatById: new Map<React.Key, TreeDataNode>(),
|
nodesFlatById: new Map<React.Key, TreeDataNode>(),
|
||||||
parentIdByChildId: new Map<React.Key, string>(),
|
parentIdByChildId: new Map<React.Key, string>(),
|
||||||
|
|||||||
Reference in New Issue
Block a user