mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
file chooser bug repair (#2963)
This commit is contained in:
@@ -8,6 +8,7 @@ const propTypes = {
|
|||||||
isShowFile: PropTypes.bool,
|
isShowFile: PropTypes.bool,
|
||||||
filePath: PropTypes.string,
|
filePath: PropTypes.string,
|
||||||
selectedPath: PropTypes.string,
|
selectedPath: PropTypes.string,
|
||||||
|
selectedRepo: PropTypes.object,
|
||||||
dirent: PropTypes.object.isRequired,
|
dirent: PropTypes.object.isRequired,
|
||||||
repo: PropTypes.object.isRequired,
|
repo: PropTypes.object.isRequired,
|
||||||
onDirentItemClick: PropTypes.func.isRequired,
|
onDirentItemClick: PropTypes.func.isRequired,
|
||||||
@@ -31,12 +32,17 @@ class DirentListItem extends React.Component {
|
|||||||
|
|
||||||
onItemClick = (e) => {
|
onItemClick = (e) => {
|
||||||
e.stopPropagation(); // need prevent event popup
|
e.stopPropagation(); // need prevent event popup
|
||||||
if (this.props.selectedPath !== this.state.filePath) {
|
let isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id;
|
||||||
this.props.onDirentItemClick(this.state.filePath, this.props.dirent);
|
if (isCurrentRepo) {
|
||||||
} else {
|
if (this.props.selectedPath !== this.state.filePath) {
|
||||||
if (this.props.dirent.type === 'dir') {
|
this.props.onDirentItemClick(this.state.filePath, this.props.dirent);
|
||||||
this.onToggleClick(e);
|
} 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() {
|
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 (
|
return (
|
||||||
<li className="file-chooser-item">
|
<li className="file-chooser-item">
|
||||||
{
|
{
|
||||||
this.state.hasChildren && this.props.dirent.type !== 'file' &&
|
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-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={`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 className="name user-select-none ellipsis">{this.props.dirent && this.props.dirent.name}</span>
|
||||||
</span>
|
</span>
|
||||||
|
@@ -8,6 +8,7 @@ import { Utils } from '../../utils/utils';
|
|||||||
const propTypes = {
|
const propTypes = {
|
||||||
isShowFile: PropTypes.bool,
|
isShowFile: PropTypes.bool,
|
||||||
selectedPath: PropTypes.string,
|
selectedPath: PropTypes.string,
|
||||||
|
selectedRepo: PropTypes.object,
|
||||||
repo: PropTypes.object.isRequired,
|
repo: PropTypes.object.isRequired,
|
||||||
isShowChildren: PropTypes.bool.isRequired,
|
isShowChildren: PropTypes.bool.isRequired,
|
||||||
onDirentItemClick: PropTypes.func.isRequired
|
onDirentItemClick: PropTypes.func.isRequired
|
||||||
@@ -52,6 +53,7 @@ class DirentListView extends React.Component {
|
|||||||
key={index}
|
key={index}
|
||||||
repo={this.props.repo}
|
repo={this.props.repo}
|
||||||
dirent={dirent}
|
dirent={dirent}
|
||||||
|
selectedRepo={this.props.selectedRepo}
|
||||||
onDirentItemClick={this.props.onDirentItemClick}
|
onDirentItemClick={this.props.onDirentItemClick}
|
||||||
selectedPath={this.props.selectedPath}
|
selectedPath={this.props.selectedPath}
|
||||||
isShowFile={this.props.isShowFile}
|
isShowFile={this.props.isShowFile}
|
||||||
|
@@ -61,6 +61,7 @@ class RepoListItem extends React.Component {
|
|||||||
repo={this.props.repo}
|
repo={this.props.repo}
|
||||||
isShowChildren={this.state.isShowChildren}
|
isShowChildren={this.state.isShowChildren}
|
||||||
onDirentItemClick={this.onDirentItemClick}
|
onDirentItemClick={this.onDirentItemClick}
|
||||||
|
selectedRepo={this.props.selectedRepo}
|
||||||
selectedPath={this.props.selectedPath}
|
selectedPath={this.props.selectedPath}
|
||||||
isShowFile={this.props.isShowFile}
|
isShowFile={this.props.isShowFile}
|
||||||
/>
|
/>
|
||||||
|
Reference in New Issue
Block a user