1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-14 06:11:16 +00:00

Draft review (#2416)

This commit is contained in:
C_Q
2018-10-15 15:51:29 +08:00
committed by Daniel Pan
parent 70aa4a0257
commit 2eef50d05e
46 changed files with 1261 additions and 441 deletions

View File

@@ -0,0 +1,68 @@
import React from 'react';
import PropTypes from 'prop-types';
import { siteRoot, lang } from '../../utils/constants';
import moment from 'moment';
moment.locale(lang);
const propTypes = {
isItemFreezed: PropTypes.bool.isRequired,
}
class ReviewListItem extends React.Component {
constructor(props) {
super(props);
this.state = {
highlight: '',
};
}
onMouseEnter = () => {
if (!this.props.isItemFreezed) {
this.setState({
highlight: 'tr-highlight'
});
}
}
onMouseLeave = () => {
if (!this.props.isItemFreezed) {
this.setState({
highlight: ''
});
}
}
onReviewsClick = () => {
let item = this.props.item;
let filePath = item.draft_file_path;
let itemID = item.id;
window.open(siteRoot + 'drafts/review/' + itemID);
}
getFileName(filePath) {
let lastIndex = filePath.lastIndexOf("/");
return filePath.slice(lastIndex+1);
}
render() {
let item = this.props.item;
let fileName = this.getFileName(item.draft_file_path);
let localTime = moment.utc(item.updated_at).toDate();
localTime = moment(localTime).fromNow();
return (
<tr className={this.state.highlight} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
<td className="icon" style={{width: "4%"}}><img src={siteRoot + "media/img/file/192/txt.png"} /></td>
<td className="name a-simulate" style={{width: "46%"}} onClick={this.onReviewsClick}>{fileName}</td>
<td className='library'>{item.draft_origin_repo_name}</td>
<td className="status" style={{width: "20%"}}>{item.status}</td>
<td className="update" style={{width: "20%"}}>{localTime}</td>
<td className="menu-toggle"></td>
</tr>
);
}
}
ReviewListItem.propTypes = propTypes;
export default ReviewListItem;

View File

@@ -0,0 +1,47 @@
import React from 'react';
import PropTypes from 'prop-types';
import { gettext } from '../../utils/constants';
import ReviewListItem from './review-list-item';
const propTypes = {
isItemFreezed: PropTypes.bool.isRequired,
itemsList: PropTypes.array.isRequired,
};
class ReviewListView extends React.Component {
render() {
let items = this.props.itemsList;
return (
<div className="table-container">
<table>
<thead>
<tr>
<th style={{width: '4%'}}>{/*img*/}</th>
<th style={{width: '26%'}}>{gettext('Name')}</th>
<th style={{width: '20%'}}>{gettext('Library')}</th>
<th style={{width: '20%'}}>{gettext('Status')}</th>
<th style={{width: '20%'}}>{gettext('Last Update')}</th>
<th style={{width: '10%'}}></th>
</tr>
</thead>
<tbody>
{ items && items.map((item) => {
return (
<ReviewListItem
key={item.id}
item={item}
isItemFreezed={this.props.isItemFreezed}
/>
);
})}
</tbody>
</table>
</div>
);
}
}
ReviewListView.propTypes = propTypes;
export default ReviewListView;