mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 13:50:07 +00:00
[file chooser] directly open current folder for 'mv/cp dialog'
This commit is contained in:
@@ -158,6 +158,7 @@ class CopyDirent extends React.Component {
|
||||
<ModalBody>
|
||||
<FileChooser
|
||||
repoID={this.props.repoID}
|
||||
currentPath={this.props.path}
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
mode={mode}
|
||||
|
@@ -255,7 +255,8 @@ class LibSubFolderSerGroupPermissionDialog extends React.Component {
|
||||
if (this.state.showFileChooser) {
|
||||
return (
|
||||
<div>
|
||||
<FileChooser repoID={this.props.repoID}
|
||||
<FileChooser
|
||||
repoID={this.props.repoID}
|
||||
mode={'only_current_library'}
|
||||
onDirentItemClick={this.toggleSubFolder}
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
|
@@ -230,7 +230,8 @@ class LibSubFolderSetUserPermissionDialog extends React.Component {
|
||||
if (this.state.showFileChooser) {
|
||||
return (
|
||||
<div>
|
||||
<FileChooser repoID={this.props.repoID}
|
||||
<FileChooser
|
||||
repoID={this.props.repoID}
|
||||
mode={'only_current_library'}
|
||||
onDirentItemClick={this.toggleSubFolder}
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
|
@@ -172,6 +172,7 @@ class MoveDirent extends React.Component {
|
||||
<ModalBody>
|
||||
<FileChooser
|
||||
repoID={this.props.repoID}
|
||||
currentPath={this.props.path}
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
mode={mode}
|
||||
|
@@ -32,7 +32,7 @@ class FileChooser extends React.Component {
|
||||
repoList: [],
|
||||
currentRepoInfo: null,
|
||||
selectedRepo: null,
|
||||
selectedPath: '',
|
||||
selectedPath: this.props.currentPath || '/',
|
||||
isSearching: false,
|
||||
isResultGot: false,
|
||||
searchInfo: '',
|
||||
@@ -132,7 +132,7 @@ class FileChooser extends React.Component {
|
||||
}
|
||||
this.setState({
|
||||
selectedRepo: repo,
|
||||
selectedPath: '',
|
||||
selectedPath: '/',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -386,6 +386,7 @@ class FileChooser extends React.Component {
|
||||
<RepoListView
|
||||
initToShowChildren={true}
|
||||
currentRepoInfo={this.state.currentRepoInfo}
|
||||
currentPath={this.props.currentPath}
|
||||
selectedRepo={this.state.selectedRepo}
|
||||
selectedPath={this.state.selectedPath}
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
@@ -429,6 +430,7 @@ class FileChooser extends React.Component {
|
||||
<RepoListView
|
||||
initToShowChildren={true}
|
||||
currentRepoInfo={this.state.currentRepoInfo}
|
||||
currentPath={this.props.currentPath}
|
||||
selectedRepo={this.state.selectedRepo}
|
||||
selectedPath={this.state.selectedPath}
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
|
@@ -32,7 +32,7 @@ class RepoListItem extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
let repoID = this.props.repo.repo_id;
|
||||
const repoID = this.props.repo.repo_id;
|
||||
seafileAPI.listDir(repoID, '/').then(res => {
|
||||
let tree = this.state.treeData.clone();
|
||||
let direntList = [];
|
||||
@@ -43,7 +43,13 @@ class RepoListItem extends React.Component {
|
||||
}
|
||||
|
||||
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 => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
@@ -98,7 +104,7 @@ class RepoListItem extends React.Component {
|
||||
this.setState({treeData: tree});
|
||||
}
|
||||
|
||||
loadNodeAndParentsByPath = (repoID, path) => {
|
||||
loadNodeAndParentsByPath = (repoID, path, expandNode) => {
|
||||
|
||||
let tree = this.state.treeData.clone();
|
||||
|
||||
@@ -121,8 +127,13 @@ class RepoListItem extends React.Component {
|
||||
this.addResponseListToNode(results[key], node);
|
||||
}
|
||||
}
|
||||
|
||||
this.setState({
|
||||
treeData: tree
|
||||
}, () => {
|
||||
if (expandNode) {
|
||||
this.onNodeExpanded(tree.getNodeByPath(path));
|
||||
}
|
||||
});
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
@@ -156,7 +167,7 @@ class RepoListItem extends React.Component {
|
||||
render() {
|
||||
let repoActive = false;
|
||||
let isCurrentRepo = this.isCurrentRepo();
|
||||
if (isCurrentRepo && !this.props.selectedPath) {
|
||||
if (isCurrentRepo && this.props.selectedPath == '/') {
|
||||
repoActive = true;
|
||||
}
|
||||
|
||||
@@ -164,7 +175,7 @@ class RepoListItem extends React.Component {
|
||||
<li>
|
||||
<div className={`${repoActive ? 'item-active' : ''} item-info`} onClick={this.onRepoItemClick}>
|
||||
<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 className="item-left-icon">
|
||||
<span className={`item-toggle icon fa ${this.state.isShowChildren ? 'fa-caret-down' : 'fa-caret-right'}`} onClick={this.onToggleClick}></span>
|
||||
|
@@ -19,7 +19,7 @@ const propTypes = {
|
||||
class RepoListView extends React.Component {
|
||||
|
||||
render() {
|
||||
let { currentRepoInfo, repoList } = this.props;
|
||||
let { currentRepoInfo, currentPath, repoList } = this.props;
|
||||
if (currentRepoInfo) {
|
||||
repoList = [];
|
||||
repoList.push(currentRepoInfo);
|
||||
@@ -30,6 +30,8 @@ class RepoListView extends React.Component {
|
||||
return (
|
||||
<RepoListItem
|
||||
key={index}
|
||||
isCurrentRepo={currentRepoInfo ? true : false}
|
||||
currentPath={currentPath}
|
||||
repo={repoItem}
|
||||
initToShowChildren={this.props.initToShowChildren}
|
||||
selectedRepo={this.props.selectedRepo}
|
||||
|
Reference in New Issue
Block a user