1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-24 04:48:03 +00:00

tag-filter-file-show

This commit is contained in:
wangjianhui
2018-11-19 17:44:59 +08:00
committed by shanshuirenjia
parent 04d4f57b4e
commit 821cb29730
5 changed files with 121 additions and 4 deletions

View File

@@ -9,19 +9,27 @@ import '../../css/repo-tag.css';
const tagListItemPropTypes = {
item: PropTypes.object.isRequired,
onTagUpdate: PropTypes.func.isRequired,
onListFileCancel: PropTypes.func.isRequired,
};
class TagListItem extends React.Component {
onTagUpdate = () => {
this.props.onTagUpdate(this.props.item);
}
onListFileCancel = () => {
this.props.onListFileCancel(this.props.item)
}
render() {
let color = this.props.item.color;
return(
<li className="tag-list-item">
<span className={`tag-demo bg-${color}`}>{this.props.item.name}</span>
<span className={`tag-demo bg-${color}`}>
<td width='90%'>{this.props.item.name}</td>
<span onClick={this.onListFileCancel}>{this.props.item.fileCount}</span>
</span>
<i className="tag-edit fa fa-pencil" onClick={this.onTagUpdate}></i>
</li>
);
@@ -35,6 +43,7 @@ const listTagPropTypes = {
onListTagCancel: PropTypes.func.isRequired,
onCreateRepoTag: PropTypes.func.isRequired,
onUpdateRepoTag: PropTypes.func.isRequired,
onListFileCancel: PropTypes.func.isRequired,
};
class ListTagDialog extends React.Component {
@@ -79,7 +88,9 @@ class ListTagDialog extends React.Component {
<ul className="tag-list tag-list-container">
{this.state.repotagList.map((repoTag, index) => {
return (
<TagListItem key={index} item={repoTag} onTagUpdate={this.props.onUpdateRepoTag}/>
<TagListItem key={index} item={repoTag} onTagUpdate={this.props.onUpdateRepoTag}
onListFileCancel={this.props.onListFileCancel}
/>
);
})}
</ul>

View File

@@ -0,0 +1,87 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { gettext, repoID } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
import moment from 'moment';
import { Utils } from '../../utils/utils';
const propTypes = {
repoTagId: PropTypes.number.isRequired,
toggleCancel: PropTypes.func.isRequired,
};
class ListTaggedFilesDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
taggedFileList: [],
};
}
componentDidMount() {
this.getTaggedFiles();
}
getTaggedFiles = () => {
let repoTagId = this.props.repoTagId;
seafileAPI.listTaggedFiles(repoID, repoTagId).then(res => {
let taggedFileList = [];
res.data.tagged_files !== undefined &&
res.data.tagged_files.forEach(file => {
let taggedFile = file;
taggedFileList.push(taggedFile)
});
this.setState({
taggedFileList: taggedFileList,
})
});
}
toggle = () => {
this.props.toggleCancel();
}
render() {
let taggedFileList = this.state.taggedFileList;
return (
<Modal isOpen={true} toggle={this.toggle}>
<ModalHeader toggle={this.toggle}>{gettext('Tagged Files')}</ModalHeader>
<ModalBody>
{
<table>
<thead>
<tr>
<th width='25%'>{gettext('Name')}</th>
<th width='25%'>{gettext('Size')}</th>
<th width='25%'>{gettext('Last Update')}</th>
<th width='25%'>{gettext('Parent Path')}</th>
</tr>
</thead>
<tbody>
{taggedFileList.map((taggedFile, index) => {
return (
<tr key={index}>
<td>{taggedFile.filename}</td>
<td>{Utils.bytesToSize(taggedFile.size)}</td>
<td>{moment.unix(taggedFile.mtime).fromNow()}</td>
<td>{taggedFile.parent_path}</td>
</tr>
);
})}
</tbody>
</table>
}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={this.toggle}>{gettext('Close')}</Button>
</ModalFooter>
</Modal>
);
}
}
ListTaggedFilesDialog.propTypes = propTypes;
export default ListTaggedFilesDialog;