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

file chooser bug repair (#2963)

This commit is contained in:
杨顺强
2019-02-19 16:52:54 +08:00
committed by Daniel Pan
parent 89b23ed3fe
commit a9d01546e7
3 changed files with 21 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ const propTypes = {
isShowFile: PropTypes.bool,
filePath: PropTypes.string,
selectedPath: PropTypes.string,
selectedRepo: PropTypes.object,
dirent: PropTypes.object.isRequired,
repo: PropTypes.object.isRequired,
onDirentItemClick: PropTypes.func.isRequired,
@@ -31,12 +32,17 @@ class DirentListItem extends React.Component {
onItemClick = (e) => {
e.stopPropagation(); // need prevent event popup
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(e);
let isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id;
if (isCurrentRepo) {
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(e);
}
}
} else {
this.props.onDirentItemClick(this.state.filePath, this.props.dirent);
}
}
@@ -92,13 +98,19 @@ class DirentListItem extends React.Component {
}
render() {
let isCurrentRepo = false;
if (this.props.selectedRepo) {
isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id;
}
let isCurrentPath = this.props.selectedPath === this.state.filePath;
return (
<li className="file-chooser-item">
{
this.state.hasChildren && this.props.dirent.type !== 'file' &&
<span className={`item-toggle fa ${this.state.isShowChildren ? 'fa-caret-down' : 'fa-caret-right'}`} onClick={this.onToggleClick}></span>
}
<span className={`item-info ${this.state.filePath === this.props.selectedPath ? 'item-active' : ''}`} onClick={this.onItemClick}>
<span className={`item-info ${(isCurrentRepo && isCurrentPath) ? 'item-active' : ''}`} onClick={this.onItemClick}>
<span className={`icon far ${this.props.dirent.type === 'dir' ? 'fa-folder' : 'fa-file'}`}></span>
<span className="name user-select-none ellipsis">{this.props.dirent && this.props.dirent.name}</span>
</span>

View File

@@ -8,6 +8,7 @@ import { Utils } from '../../utils/utils';
const propTypes = {
isShowFile: PropTypes.bool,
selectedPath: PropTypes.string,
selectedRepo: PropTypes.object,
repo: PropTypes.object.isRequired,
isShowChildren: PropTypes.bool.isRequired,
onDirentItemClick: PropTypes.func.isRequired
@@ -52,6 +53,7 @@ class DirentListView extends React.Component {
key={index}
repo={this.props.repo}
dirent={dirent}
selectedRepo={this.props.selectedRepo}
onDirentItemClick={this.props.onDirentItemClick}
selectedPath={this.props.selectedPath}
isShowFile={this.props.isShowFile}

View File

@@ -61,6 +61,7 @@ class RepoListItem extends React.Component {
repo={this.props.repo}
isShowChildren={this.state.isShowChildren}
onDirentItemClick={this.onDirentItemClick}
selectedRepo={this.props.selectedRepo}
selectedPath={this.props.selectedPath}
isShowFile={this.props.isShowFile}
/>