mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 17:02:47 +00:00
tag-filter-file-show
This commit is contained in:
committed by
shanshuirenjia
parent
04d4f57b4e
commit
821cb29730
@@ -5,6 +5,7 @@ import PropTypes from 'prop-types';
|
|||||||
import ListTagDialog from '../dialog/list-tag-dialog';
|
import ListTagDialog from '../dialog/list-tag-dialog';
|
||||||
import CreateTagDialog from '../dialog/create-tag-dialog';
|
import CreateTagDialog from '../dialog/create-tag-dialog';
|
||||||
import UpdateTagDialog from '../dialog/update-tag-dialog';
|
import UpdateTagDialog from '../dialog/update-tag-dialog';
|
||||||
|
import ListTaggedFilesDialog from '../dialog/list-taggedfiles-dialog';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
repoID: PropTypes.string.isRequired,
|
repoID: PropTypes.string.isRequired,
|
||||||
@@ -22,6 +23,7 @@ class DirTool extends React.Component {
|
|||||||
isListRepoTagShow: false,
|
isListRepoTagShow: false,
|
||||||
isUpdateRepoTagShow: false,
|
isUpdateRepoTagShow: false,
|
||||||
isCreateRepoTagShow: false,
|
isCreateRepoTagShow: false,
|
||||||
|
isListTaggedFileShow: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +46,14 @@ class DirTool extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onListTaggedFileToggle = (currentTag) => {
|
||||||
|
this.setState({
|
||||||
|
currentTag: currentTag,
|
||||||
|
isListRepoTagShow: !this.state.isListRepoTagShow,
|
||||||
|
isListTaggedFileShow: !this.state.isListTaggedFileShow,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
isMarkdownFile(filePath) {
|
isMarkdownFile(filePath) {
|
||||||
let name = Utils.getFileName(filePath);
|
let name = Utils.getFileName(filePath);
|
||||||
return name.indexOf('.md') > -1 ? true : false;
|
return name.indexOf('.md') > -1 ? true : false;
|
||||||
@@ -70,6 +80,7 @@ class DirTool extends React.Component {
|
|||||||
onListTagCancel={this.onListRepoTagToggle}
|
onListTagCancel={this.onListRepoTagToggle}
|
||||||
onCreateRepoTag={this.onCreateRepoTagToggle}
|
onCreateRepoTag={this.onCreateRepoTagToggle}
|
||||||
onUpdateRepoTag={this.onUpdateRepoTagToggle}
|
onUpdateRepoTag={this.onUpdateRepoTagToggle}
|
||||||
|
onListFileCancel={this.onListTaggedFileToggle}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -87,6 +98,13 @@ class DirTool extends React.Component {
|
|||||||
toggleCancel={this.onUpdateRepoTagToggle}
|
toggleCancel={this.onUpdateRepoTagToggle}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
this.state.isListTaggedFileShow &&
|
||||||
|
<ListTaggedFilesDialog
|
||||||
|
repoTagId={this.state.currentTag.id}
|
||||||
|
toggleCancel={this.onListTaggedFileToggle}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
} else if (!isFile && permission) {
|
} else if (!isFile && permission) {
|
||||||
|
@@ -9,19 +9,27 @@ import '../../css/repo-tag.css';
|
|||||||
const tagListItemPropTypes = {
|
const tagListItemPropTypes = {
|
||||||
item: PropTypes.object.isRequired,
|
item: PropTypes.object.isRequired,
|
||||||
onTagUpdate: PropTypes.func.isRequired,
|
onTagUpdate: PropTypes.func.isRequired,
|
||||||
|
onListFileCancel: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
class TagListItem extends React.Component {
|
class TagListItem extends React.Component {
|
||||||
|
|
||||||
onTagUpdate = () => {
|
onTagUpdate = () => {
|
||||||
this.props.onTagUpdate(this.props.item);
|
this.props.onTagUpdate(this.props.item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onListFileCancel = () => {
|
||||||
|
this.props.onListFileCancel(this.props.item)
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let color = this.props.item.color;
|
let color = this.props.item.color;
|
||||||
return(
|
return(
|
||||||
<li className="tag-list-item">
|
<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>
|
<i className="tag-edit fa fa-pencil" onClick={this.onTagUpdate}></i>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
@@ -35,6 +43,7 @@ const listTagPropTypes = {
|
|||||||
onListTagCancel: PropTypes.func.isRequired,
|
onListTagCancel: PropTypes.func.isRequired,
|
||||||
onCreateRepoTag: PropTypes.func.isRequired,
|
onCreateRepoTag: PropTypes.func.isRequired,
|
||||||
onUpdateRepoTag: PropTypes.func.isRequired,
|
onUpdateRepoTag: PropTypes.func.isRequired,
|
||||||
|
onListFileCancel: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ListTagDialog extends React.Component {
|
class ListTagDialog extends React.Component {
|
||||||
@@ -79,7 +88,9 @@ class ListTagDialog extends React.Component {
|
|||||||
<ul className="tag-list tag-list-container">
|
<ul className="tag-list tag-list-container">
|
||||||
{this.state.repotagList.map((repoTag, index) => {
|
{this.state.repotagList.map((repoTag, index) => {
|
||||||
return (
|
return (
|
||||||
<TagListItem key={index} item={repoTag} onTagUpdate={this.props.onUpdateRepoTag}/>
|
<TagListItem key={index} item={repoTag} onTagUpdate={this.props.onUpdateRepoTag}
|
||||||
|
onListFileCancel={this.props.onListFileCancel}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
|
87
frontend/src/components/dialog/list-taggedfiles-dialog.js
Normal file
87
frontend/src/components/dialog/list-taggedfiles-dialog.js
Normal 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;
|
@@ -1,7 +1,7 @@
|
|||||||
class RepoTag {
|
class RepoTag {
|
||||||
constructor(object) {
|
constructor(object) {
|
||||||
this.id = object.repo_tag_id;
|
this.id = object.repo_tag_id;
|
||||||
this.repo_id = object.repo_id;
|
this.fileCount = object.files_count;
|
||||||
this.name = object.tag_name;
|
this.name = object.tag_name;
|
||||||
this.color = object.tag_color;
|
this.color = object.tag_color;
|
||||||
}
|
}
|
||||||
|
@@ -48,6 +48,7 @@ def get_tagged_files(repo, repo_tag_id):
|
|||||||
tagged_file["parent_path"] = parent_path
|
tagged_file["parent_path"] = parent_path
|
||||||
tagged_file["filename"] = filename
|
tagged_file["filename"] = filename
|
||||||
tagged_file["size"] = file_obj.size
|
tagged_file["size"] = file_obj.size
|
||||||
|
tagged_file["mtime"] = file_obj.mtime
|
||||||
tagged_file["last_modified"] = timestamp_to_isoformat_timestr(file_obj.mtime)
|
tagged_file["last_modified"] = timestamp_to_isoformat_timestr(file_obj.mtime)
|
||||||
tagged_file["modifier_email"] = file_obj.modifier
|
tagged_file["modifier_email"] = file_obj.modifier
|
||||||
tagged_file["modifier_contact_email"] = email2contact_email(file_obj.modifier)
|
tagged_file["modifier_contact_email"] = email2contact_email(file_obj.modifier)
|
||||||
|
Reference in New Issue
Block a user