1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 07:27:04 +00:00

File chooser improve (#2790)

This commit is contained in:
杨顺强
2019-01-09 11:28:16 +08:00
committed by Daniel Pan
parent ea465a2f4a
commit ea37b0d83f
6 changed files with 47 additions and 18 deletions

View File

@@ -29,7 +29,13 @@ class DirentListItem extends React.Component {
}
onItemClick = () => {
this.props.onDirentItemClick(this.state.filePath, this.props.dirent);
if (this.props.selectedPath !== this.state.filePath) {
this.props.onDirentItemClick(this.state.filePath, this.props.dirent);
} else {
if (this.props.dirent.type === 'dir') {
this.onToggleClick();
}
}
}
onToggleClick = () => {
@@ -37,13 +43,14 @@ class DirentListItem extends React.Component {
seafileAPI.listDir(this.props.repo.repo_id, this.state.filePath).then(res => {
let direntList = [];
res.data.forEach(item => {
if (this.props.isShowFile === true) {
let dirent = new Dirent(item);
direntList.push(dirent);
}
else if (item.type === 'dir') {
if (this.props.isShowFile === true) { // show dir and file
let dirent = new Dirent(item);
direntList.push(dirent);
} else { // just show dir
if (item.type === 'dir') {
let dirent = new Dirent(item);
direntList.push(dirent);
}
}
this.setState({
hasRequest: true,
@@ -93,7 +100,7 @@ class DirentListItem extends React.Component {
}
<span className={`item-info ${this.state.filePath === this.props.selectedPath ? 'item-active' : ''}`} onClick={this.onItemClick}>
<span className={`icon far ${this.props.dirent.type === 'dir' ? 'fa-folder' : 'fa-file'}`}></span>
<span className="name">{this.props.dirent && this.props.dirent.name}</span>
<span className="name user-select-none ellipsis">{this.props.dirent && this.props.dirent.name}</span>
</span>
{this.state.isShowChildren && this.renderChildren()}
</li>

View File

@@ -31,12 +31,21 @@ class RepoListItem extends React.Component {
}
onRepoItemClick = () => {
this.props.onRepoItemClick(this.props.repo);
if (!this.isCurrentRepo()) {
this.props.onRepoItemClick(this.props.repo);
} else {
this.onToggleClick();
}
}
isCurrentRepo = () => {
let { selectedRepo, repo } = this.props;
return selectedRepo && (repo.repo_id === selectedRepo.repo_id);
}
render() {
let repoActive = false;
let isCurrentRepo = this.props.selectedRepo && (this.props.repo.repo_id === this.props.selectedRepo.repo_id);
let isCurrentRepo = this.isCurrentRepo();
if (isCurrentRepo && !this.props.selectedPath) {
repoActive = true;
}
@@ -45,7 +54,7 @@ class RepoListItem extends React.Component {
<span className={`item-toggle fa ${this.state.isShowChildren ? 'fa-caret-down' : 'fa-caret-right'}`} onClick={this.onToggleClick}></span>
<span className={`item-info ${repoActive ? 'item-active' : ''}`} onClick={this.onRepoItemClick}>
<span className="icon far fa-folder"></span>
<span className="name">{this.props.repo.repo_name}</span>
<span className="name user-select-none ellipsis">{this.props.repo.repo_name}</span>
</span>
{this.state.isShowChildren && (
<DirentListView