mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-31 14:42:10 +00:00
Merge pull request #7715 from haiwen/fix/file_tree_update_after_moving
update tree nodes after move files
This commit is contained in:
@@ -707,9 +707,13 @@ class LibContentView extends React.Component {
|
|||||||
let newAddedDirents = newDirentList.filter(item => {
|
let newAddedDirents = newDirentList.filter(item => {
|
||||||
return !nodeChildrenNames.includes(item.name);
|
return !nodeChildrenNames.includes(item.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let updatedTree = tree.clone();
|
||||||
newAddedDirents.forEach(item => {
|
newAddedDirents.forEach(item => {
|
||||||
this.addNodeToTree(item.name, path, item.type);
|
const node = this.createTreeNode(item.name, item.type);
|
||||||
|
updatedTree = treeHelper.addNodeToParentByPath(updatedTree, node, path);
|
||||||
});
|
});
|
||||||
|
this.setState({ treeData: updatedTree });
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
toaster.danger(errMessage);
|
toaster.danger(errMessage);
|
||||||
@@ -836,15 +840,25 @@ class LibContentView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (repoID === destRepo.repo_id) {
|
if (repoID === destRepo.repo_id) {
|
||||||
if (this.state.isTreePanelShown) {
|
|
||||||
this.deleteTreeNodes(direntPaths);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.moveDirents(dirNames);
|
this.moveDirents(dirNames);
|
||||||
|
|
||||||
// 2. tow columns mode need update left tree
|
|
||||||
if (this.state.isTreePanelShown) {
|
if (this.state.isTreePanelShown) {
|
||||||
this.updateMoveCopyTreeNode(destDirentPath);
|
const updatedTree = treeHelper.moveNodeListByPaths(this.state.treeData, direntPaths, destDirentPath);
|
||||||
|
|
||||||
|
const destNode = updatedTree.getNodeByPath(destDirentPath);
|
||||||
|
if (destNode) {
|
||||||
|
const sortedChildren = Utils.sortDirents(
|
||||||
|
destNode.children.map(n => n.object),
|
||||||
|
'name',
|
||||||
|
'asc'
|
||||||
|
).map(dirent => {
|
||||||
|
return destNode.children.find(n => n.object.name === dirent.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
destNode.children = sortedChildren;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({ treeData: updatedTree });
|
||||||
}
|
}
|
||||||
|
|
||||||
// show tip message if move to current repo
|
// show tip message if move to current repo
|
||||||
|
Reference in New Issue
Block a user