diff --git a/frontend/src/components/tree-view/tree-view.js b/frontend/src/components/tree-view/tree-view.js index 7e62006d7a..fe21bf9dc3 100644 --- a/frontend/src/components/tree-view/tree-view.js +++ b/frontend/src/components/tree-view/tree-view.js @@ -45,10 +45,6 @@ class TreeView extends React.Component { } } - onItemMove = (repo, dirent, selectedPath, currentPath) => { - this.props.onItemMove(repo, dirent, selectedPath, currentPath); - }; - onNodeDragStart = (e, node) => { if (Utils.isIEBrowser()) { return false; @@ -133,7 +129,7 @@ class TreeView extends React.Component { this.setState({ isTreeViewDropTipShow: false }); return; } - this.onItemMove(this.props.currentRepoInfo, nodeDirent, '/', nodeParentPath); + this.props.onItemMove(this.props.currentRepoInfo, nodeDirent, '/', nodeParentPath); this.setState({ isTreeViewDropTipShow: false }); return; } @@ -163,7 +159,7 @@ class TreeView extends React.Component { } } - this.onItemMove(this.props.currentRepoInfo, nodeDirent, dropNodeData.path, nodeParentPath); + this.props.onItemMove(this.props.currentRepoInfo, nodeDirent, dropNodeData.path, nodeParentPath); }; onMoveItems = (dragStartNodeData, dropNodeData, destRepo, destDirentPath) => { diff --git a/frontend/src/pages/lib-content-view/lib-content-view.js b/frontend/src/pages/lib-content-view/lib-content-view.js index 44fe54c2e7..c9ebfad2b6 100644 --- a/frontend/src/pages/lib-content-view/lib-content-view.js +++ b/frontend/src/pages/lib-content-view/lib-content-view.js @@ -1323,17 +1323,24 @@ class LibContentView extends React.Component { }); } - if (this.state.isTreePanelShown) { - this.deleteTreeNode(direntPath); - } - // 1. move to current repo // 2. tow columns mode need update left tree - if (repoID === targetRepo.repo_id && this.state.isTreePanelShown) { - this.updateMoveCopyTreeNode(moveToDirentPath); - } + const updateAfterMove = () => { + if (repoID === targetRepo.repo_id && this.state.isTreePanelShown) { + this.updateMoveCopyTreeNode(moveToDirentPath); + } + this.moveDirent(direntPath, moveToDirentPath); + this.setState({ path: moveToDirentPath }); + if (this.state.path !== moveToDirentPath) { + this.loadDirentList(moveToDirentPath); + } + }; - this.moveDirent(direntPath, moveToDirentPath); + if (this.state.isTreePanelShown) { + this.deleteTreeNode(direntPath, updateAfterMove); + } else { + updateAfterMove(); + } // show tip message if move to current repo if (repoID === targetRepo.repo_id) { @@ -1345,6 +1352,10 @@ class LibContentView extends React.Component { if (byDialog) { this.updateRecentlyUsedList(targetRepo, moveToDirentPath); } + // update location + let repoInfo = this.state.currentRepoInfo; + let url = siteRoot + 'library/' + repoID + '/' + encodeURIComponent(repoInfo.repo_name) + Utils.encodePath(moveToDirentPath); + window.history.pushState({ url, path: moveToDirentPath }, moveToDirentPath, url); }; onMoveItem = (destRepo, dirent, moveToDirentPath, nodeParentPath, byDialog = false) => { @@ -2040,9 +2051,11 @@ class LibContentView extends React.Component { this.setState({ treeData: tree, currentNode }); }; - deleteTreeNode = (path) => { + deleteTreeNode = (path, callback) => { let tree = treeHelper.deleteNodeByPath(this.state.treeData, path); - this.setState({ treeData: tree }); + this.setState({ treeData: tree }, () => { + callback && callback(); + }); }; deleteTreeNodes = (paths) => {