Add unselectAll function to CodeTabsComponent and FlowStore
This commit is contained in:
parent
3b60133639
commit
276329edf0
3 changed files with 14 additions and 7 deletions
|
|
@ -35,7 +35,6 @@ import {
|
||||||
convertObjToArray,
|
convertObjToArray,
|
||||||
convertValuesToNumbers,
|
convertValuesToNumbers,
|
||||||
hasDuplicateKeys,
|
hasDuplicateKeys,
|
||||||
unselectAllNodes,
|
|
||||||
} from "../../utils/reactflowUtils";
|
} from "../../utils/reactflowUtils";
|
||||||
import { classNames } from "../../utils/utils";
|
import { classNames } from "../../utils/utils";
|
||||||
import DictComponent from "../dictComponent";
|
import DictComponent from "../dictComponent";
|
||||||
|
|
@ -54,6 +53,7 @@ export default function CodeTabsComponent({
|
||||||
const [data, setData] = useState(flow ? flow["data"]!["nodes"] : null);
|
const [data, setData] = useState(flow ? flow["data"]!["nodes"] : null);
|
||||||
const [openAccordion, setOpenAccordion] = useState<string[]>([]);
|
const [openAccordion, setOpenAccordion] = useState<string[]>([]);
|
||||||
const dark = useDarkStore((state) => state.dark);
|
const dark = useDarkStore((state) => state.dark);
|
||||||
|
const unselectAll = useFlowStore((state) => state.unselectAll);
|
||||||
|
|
||||||
const setNodes = useFlowStore((state) => state.setNodes);
|
const setNodes = useFlowStore((state) => state.setNodes);
|
||||||
|
|
||||||
|
|
@ -67,12 +67,7 @@ export default function CodeTabsComponent({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (tweaks && data) {
|
if (tweaks && data) {
|
||||||
unselectAllNodes({
|
unselectAll();
|
||||||
data,
|
|
||||||
updateNodes: (nodes) => {
|
|
||||||
setNodes(nodes);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,17 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
get().reactFlowInstance?.getViewport() ?? { x: 0, y: 0, zoom: 1 }
|
get().reactFlowInstance?.getViewport() ?? { x: 0, y: 0, zoom: 1 }
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
unselectAll: () => {
|
||||||
|
let newNodes = cloneDeep(get().nodes);
|
||||||
|
newNodes.forEach((node) => {
|
||||||
|
node.selected = false;
|
||||||
|
let newEdges = cleanEdges(newNodes, get().edges);
|
||||||
|
set({
|
||||||
|
nodes: newNodes,
|
||||||
|
edges: newEdges,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default useFlowStore;
|
export default useFlowStore;
|
||||||
|
|
|
||||||
|
|
@ -54,4 +54,5 @@ export type FlowStoreType = {
|
||||||
setFilterEdge: (newState) => void;
|
setFilterEdge: (newState) => void;
|
||||||
getFilterEdge: any[];
|
getFilterEdge: any[];
|
||||||
onConnect: (connection: Connection) => void;
|
onConnect: (connection: Connection) => void;
|
||||||
|
unselectAll: () => void;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue