mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-26 15:26:19 +00:00
Optimize/tree op validation (#8157)
* optimize tree operations validation * optimize * optimize --------- Co-authored-by: zhouwenxuan <aries@Mac.local> Co-authored-by: Michael An <1822852997@qq.com>
This commit is contained in:
@@ -2032,7 +2032,18 @@ class LibContentView extends React.Component {
|
||||
}
|
||||
};
|
||||
|
||||
isTreeReady = (path = null) => {
|
||||
const { treeData, isTreeDataLoading } = this.state;
|
||||
if (isTreeDataLoading || !treeData || !treeData.root) return false;
|
||||
if (path) {
|
||||
const node = treeData.getNodeByPath(path);
|
||||
return node !== null;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
addNodeToTree = (name, parentPath, type) => {
|
||||
if (!this.isTreeReady(parentPath)) return;
|
||||
let node = this.createTreeNode(name, type);
|
||||
let tree = treeHelper.addNodeToParentByPath(this.state.treeData, node, parentPath);
|
||||
this.setState({ treeData: tree });
|
||||
|
Reference in New Issue
Block a user