1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

Add related documents UI (#2577)

This commit is contained in:
王健辉
2018-12-28 14:25:25 +08:00
committed by Daniel Pan
parent 8637abde8d
commit dd15cd0ea8
12 changed files with 436 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import { seafileAPI } from '../../utils/seafile-api';
import Dirent from '../../models/dirent';
const propTypes = {
isShowFile: PropTypes.bool,
filePath: PropTypes.string,
selectedPath: PropTypes.string,
dirent: PropTypes.object.isRequired,
@@ -28,7 +29,7 @@ class DirentListItem extends React.Component {
}
onItemClick = () => {
this.props.onDirentItemClick(this.state.filePath);
this.props.onDirentItemClick(this.state.filePath, this.props.dirent);
}
onToggleClick = () => {
@@ -36,7 +37,11 @@ class DirentListItem extends React.Component {
seafileAPI.listDir(this.props.repo.repo_id, this.state.filePath).then(res => {
let direntList = [];
res.data.forEach(item => {
if (item.type === 'dir') {
if (this.props.isShowFile === true) {
let dirent = new Dirent(item);
direntList.push(dirent);
}
else if (item.type === 'dir') {
let dirent = new Dirent(item);
direntList.push(dirent);
}
@@ -71,6 +76,7 @@ class DirentListItem extends React.Component {
onItemClick={this.onItemClick}
selectedPath={this.props.selectedPath}
onDirentItemClick={this.props.onDirentItemClick}
isShowFile={this.props.isShowFile}
/>
);
})}
@@ -82,11 +88,11 @@ class DirentListItem extends React.Component {
return (
<li className="file-chooser-item">
{
this.state.hasChildren &&
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="icon far fa-folder"></span>
<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>
{this.state.isShowChildren && this.renderChildren()}

View File

@@ -5,6 +5,7 @@ import Dirent from '../../models/dirent';
import DirentListItem from './dirent-list-item';
const propTypes = {
isShowFile: PropTypes.bool,
selectedPath: PropTypes.string,
repo: PropTypes.object.isRequired,
isShowChildren: PropTypes.bool.isRequired,
@@ -25,7 +26,11 @@ class DirentListView extends React.Component {
seafileAPI.listDir(repo.repo_id, '/').then(res => {
let direntList = [];
res.data.forEach(item => {
if (item.type === 'dir') {
if (this.props.isShowFile === true) {
let dirent = new Dirent(item);
direntList.push(dirent);
}
else if (item.type === 'dir') {
let dirent = new Dirent(item);
direntList.push(dirent);
}
@@ -48,6 +53,7 @@ class DirentListView extends React.Component {
dirent={dirent}
onDirentItemClick={this.props.onDirentItemClick}
selectedPath={this.props.selectedPath}
isShowFile={this.props.isShowFile}
/>
);
})}

View File

@@ -8,6 +8,7 @@ import RepoInfo from '../../models/repo-info';
import '../../css/file-chooser.css';
const propTypes = {
isShowFile: PropTypes.bool,
repoID: PropTypes.string.isRequired,
onDirentItemClick: PropTypes.func,
onRepoItemClick: PropTypes.func,
@@ -71,8 +72,8 @@ class FileChooser extends React.Component {
this.setState({isCurrentRepoShow: !this.state.isCurrentRepoShow})
]
onDirentItemClick = (repo, filePath) => {
this.props.onDirentItemClick(repo, filePath);
onDirentItemClick = (repo, filePath, dirent) => {
this.props.onDirentItemClick(repo, filePath, dirent);
this.setState({
selectedRepo: repo,
selectedPath: filePath
@@ -80,7 +81,9 @@ class FileChooser extends React.Component {
}
onRepoItemClick = (repo) => {
this.props.onRepoItemClick(repo);
if (this.props.onRepoItemClick) {
this.props.onRepoItemClick(repo);
}
this.setState({
selectedRepo: repo,
selectedPath: '',
@@ -104,6 +107,7 @@ class FileChooser extends React.Component {
selectedPath={this.state.selectedPath}
onRepoItemClick={this.onRepoItemClick}
onDirentItemClick={this.onDirentItemClick}
isShowFile={this.props.isShowFile}
/>
}
</div>
@@ -121,6 +125,7 @@ class FileChooser extends React.Component {
selectedPath={this.state.selectedPath}
onRepoItemClick={this.onRepoItemClick}
onDirentItemClick={this.onDirentItemClick}
isShowFile={this.props.isShowFile}
/>
}
</div>

View File

@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import DirentListView from './dirent-list-view';
const propTypes = {
isShowFile: PropTypes.bool,
selectedPath: PropTypes.string,
selectedRepo: PropTypes.object,
repo: PropTypes.object.isRequired,
@@ -24,9 +25,9 @@ class RepoListItem extends React.Component {
this.setState({isShowChildren: !this.state.isShowChildren});
}
onDirentItemClick = (filePath) => {
onDirentItemClick = (filePath, dirent) => {
let repo = this.props.repo;
this.props.onDirentItemClick(repo, filePath);
this.props.onDirentItemClick(repo, filePath, dirent);
}
onRepoItemClick = () => {
@@ -52,6 +53,7 @@ class RepoListItem extends React.Component {
isShowChildren={this.state.isShowChildren}
onDirentItemClick={this.onDirentItemClick}
selectedPath={this.props.selectedPath}
isShowFile={this.props.isShowFile}
/>
)}
</li>

View File

@@ -4,6 +4,8 @@ import RepoListItem from './repo-list-item';
const propTypes = {
currentRepoInfo: PropTypes.object,
isShowFile: PropTypes.bool,
repo: PropTypes.object,
repoList: PropTypes.array,
selectedRepo: PropTypes.object,
initToShowChildren: PropTypes.bool.isRequired,
@@ -32,6 +34,7 @@ class RepoListView extends React.Component {
selectedPath={this.props.selectedPath}
onRepoItemClick={this.props.onRepoItemClick}
onDirentItemClick={this.props.onDirentItemClick}
isShowFile={this.props.isShowFile}
/>
);
})}