1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-12 13:24:52 +00:00

[file chooser] directly open current folder for 'mv/cp dialog'

This commit is contained in:
llj
2021-12-15 14:55:16 +08:00
parent eab3ba2f6d
commit 15e2acc21f
7 changed files with 29 additions and 10 deletions

View File

@@ -158,6 +158,7 @@ class CopyDirent extends React.Component {
<ModalBody> <ModalBody>
<FileChooser <FileChooser
repoID={this.props.repoID} repoID={this.props.repoID}
currentPath={this.props.path}
onDirentItemClick={this.onDirentItemClick} onDirentItemClick={this.onDirentItemClick}
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}
mode={mode} mode={mode}

View File

@@ -255,7 +255,8 @@ class LibSubFolderSerGroupPermissionDialog extends React.Component {
if (this.state.showFileChooser) { if (this.state.showFileChooser) {
return ( return (
<div> <div>
<FileChooser repoID={this.props.repoID} <FileChooser
repoID={this.props.repoID}
mode={'only_current_library'} mode={'only_current_library'}
onDirentItemClick={this.toggleSubFolder} onDirentItemClick={this.toggleSubFolder}
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}

View File

@@ -230,7 +230,8 @@ class LibSubFolderSetUserPermissionDialog extends React.Component {
if (this.state.showFileChooser) { if (this.state.showFileChooser) {
return ( return (
<div> <div>
<FileChooser repoID={this.props.repoID} <FileChooser
repoID={this.props.repoID}
mode={'only_current_library'} mode={'only_current_library'}
onDirentItemClick={this.toggleSubFolder} onDirentItemClick={this.toggleSubFolder}
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}

View File

@@ -172,6 +172,7 @@ class MoveDirent extends React.Component {
<ModalBody> <ModalBody>
<FileChooser <FileChooser
repoID={this.props.repoID} repoID={this.props.repoID}
currentPath={this.props.path}
onDirentItemClick={this.onDirentItemClick} onDirentItemClick={this.onDirentItemClick}
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}
mode={mode} mode={mode}

View File

@@ -32,7 +32,7 @@ class FileChooser extends React.Component {
repoList: [], repoList: [],
currentRepoInfo: null, currentRepoInfo: null,
selectedRepo: null, selectedRepo: null,
selectedPath: '', selectedPath: this.props.currentPath || '/',
isSearching: false, isSearching: false,
isResultGot: false, isResultGot: false,
searchInfo: '', searchInfo: '',
@@ -132,7 +132,7 @@ class FileChooser extends React.Component {
} }
this.setState({ this.setState({
selectedRepo: repo, selectedRepo: repo,
selectedPath: '', selectedPath: '/',
}); });
} }
@@ -386,6 +386,7 @@ class FileChooser extends React.Component {
<RepoListView <RepoListView
initToShowChildren={true} initToShowChildren={true}
currentRepoInfo={this.state.currentRepoInfo} currentRepoInfo={this.state.currentRepoInfo}
currentPath={this.props.currentPath}
selectedRepo={this.state.selectedRepo} selectedRepo={this.state.selectedRepo}
selectedPath={this.state.selectedPath} selectedPath={this.state.selectedPath}
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}
@@ -429,6 +430,7 @@ class FileChooser extends React.Component {
<RepoListView <RepoListView
initToShowChildren={true} initToShowChildren={true}
currentRepoInfo={this.state.currentRepoInfo} currentRepoInfo={this.state.currentRepoInfo}
currentPath={this.props.currentPath}
selectedRepo={this.state.selectedRepo} selectedRepo={this.state.selectedRepo}
selectedPath={this.state.selectedPath} selectedPath={this.state.selectedPath}
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}

View File

@@ -32,7 +32,7 @@ class RepoListItem extends React.Component {
} }
componentDidMount () { componentDidMount () {
let repoID = this.props.repo.repo_id; const repoID = this.props.repo.repo_id;
seafileAPI.listDir(repoID, '/').then(res => { seafileAPI.listDir(repoID, '/').then(res => {
let tree = this.state.treeData.clone(); let tree = this.state.treeData.clone();
let direntList = []; let direntList = [];
@@ -43,7 +43,13 @@ class RepoListItem extends React.Component {
} }
this.addResponseListToNode(direntList, tree.root); this.addResponseListToNode(direntList, tree.root);
this.setState({treeData: tree}); this.setState({treeData: tree}, () => {
const { isCurrentRepo, currentPath } = this.props;
if (isCurrentRepo && currentPath && currentPath != '/') {
const expandNode = true;
this.loadNodeAndParentsByPath(repoID, currentPath, expandNode);
}
});
}).catch(error => { }).catch(error => {
let errMessage = Utils.getErrorMsg(error); let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage); toaster.danger(errMessage);
@@ -98,7 +104,7 @@ class RepoListItem extends React.Component {
this.setState({treeData: tree}); this.setState({treeData: tree});
} }
loadNodeAndParentsByPath = (repoID, path) => { loadNodeAndParentsByPath = (repoID, path, expandNode) => {
let tree = this.state.treeData.clone(); let tree = this.state.treeData.clone();
@@ -121,8 +127,13 @@ class RepoListItem extends React.Component {
this.addResponseListToNode(results[key], node); this.addResponseListToNode(results[key], node);
} }
} }
this.setState({ this.setState({
treeData: tree treeData: tree
}, () => {
if (expandNode) {
this.onNodeExpanded(tree.getNodeByPath(path));
}
}); });
}).catch(error => { }).catch(error => {
let errMessage = Utils.getErrorMsg(error); let errMessage = Utils.getErrorMsg(error);
@@ -156,7 +167,7 @@ class RepoListItem extends React.Component {
render() { render() {
let repoActive = false; let repoActive = false;
let isCurrentRepo = this.isCurrentRepo(); let isCurrentRepo = this.isCurrentRepo();
if (isCurrentRepo && !this.props.selectedPath) { if (isCurrentRepo && this.props.selectedPath == '/') {
repoActive = true; repoActive = true;
} }
@@ -164,7 +175,7 @@ class RepoListItem extends React.Component {
<li> <li>
<div className={`${repoActive ? 'item-active' : ''} item-info`} onClick={this.onRepoItemClick}> <div className={`${repoActive ? 'item-active' : ''} item-info`} onClick={this.onRepoItemClick}>
<div className="item-text"> <div className="item-text">
<span className="name user-select-none ellipsis">{this.props.repo.repo_name}</span> <span className="name user-select-none ellipsis" title={this.props.repo.repo_name}>{this.props.repo.repo_name}</span>
</div> </div>
<div className="item-left-icon"> <div className="item-left-icon">
<span className={`item-toggle icon fa ${this.state.isShowChildren ? 'fa-caret-down' : 'fa-caret-right'}`} onClick={this.onToggleClick}></span> <span className={`item-toggle icon fa ${this.state.isShowChildren ? 'fa-caret-down' : 'fa-caret-right'}`} onClick={this.onToggleClick}></span>

View File

@@ -19,7 +19,7 @@ const propTypes = {
class RepoListView extends React.Component { class RepoListView extends React.Component {
render() { render() {
let { currentRepoInfo, repoList } = this.props; let { currentRepoInfo, currentPath, repoList } = this.props;
if (currentRepoInfo) { if (currentRepoInfo) {
repoList = []; repoList = [];
repoList.push(currentRepoInfo); repoList.push(currentRepoInfo);
@@ -30,6 +30,8 @@ class RepoListView extends React.Component {
return ( return (
<RepoListItem <RepoListItem
key={index} key={index}
isCurrentRepo={currentRepoInfo ? true : false}
currentPath={currentPath}
repo={repoItem} repo={repoItem}
initToShowChildren={this.props.initToShowChildren} initToShowChildren={this.props.initToShowChildren}
selectedRepo={this.props.selectedRepo} selectedRepo={this.props.selectedRepo}