2018-09-15 16:14:17 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-10-09 10:56:59 +08:00
|
|
|
import { gettext } from '../../utils/constants';
|
2018-09-29 10:24:46 +08:00
|
|
|
import DraftListItem from './draft-list-item';
|
2018-09-15 16:14:17 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
draftList: PropTypes.array.isRequired,
|
2019-02-22 11:10:33 +08:00
|
|
|
onDeleteHandler: PropTypes.func.isRequired,
|
2019-03-01 16:49:35 +08:00
|
|
|
onPublishHandler: PropTypes.func.isRequired,
|
2018-09-15 16:14:17 +08:00
|
|
|
};
|
|
|
|
|
2018-09-29 10:24:46 +08:00
|
|
|
class DraftListView extends React.Component {
|
2018-09-15 16:14:17 +08:00
|
|
|
|
2019-02-22 11:10:33 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isItemFreezed: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
onFreezedItem = () => {
|
|
|
|
this.setState({isItemFreezed: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
onUnfreezedItem = () => {
|
|
|
|
this.setState({isItemFreezed: false});
|
|
|
|
}
|
|
|
|
|
2018-09-15 16:14:17 +08:00
|
|
|
render() {
|
|
|
|
let drafts = this.props.draftList;
|
|
|
|
return (
|
2018-11-22 11:05:47 +08:00
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th style={{width: '4%'}}>{/*img*/}</th>
|
|
|
|
<th style={{width: '46%'}}>{gettext('Name')}</th>
|
2019-03-01 16:49:35 +08:00
|
|
|
<th style={{width: '30%'}}>{gettext('Library')}</th>
|
2018-11-22 11:05:47 +08:00
|
|
|
<th style={{width: '10%'}}>{gettext('Last Update')}</th>
|
|
|
|
<th style={{width: '10%'}}></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{ drafts && drafts.map((draft) => {
|
|
|
|
return (
|
|
|
|
<DraftListItem
|
|
|
|
key={draft.id}
|
|
|
|
draft={draft}
|
2019-02-22 11:10:33 +08:00
|
|
|
isItemFreezed={this.state.isItemFreezed}
|
|
|
|
onFreezedItem={this.onFreezedItem}
|
|
|
|
onUnfreezedItem={this.onUnfreezedItem}
|
|
|
|
onDeleteHandler={this.props.onDeleteHandler}
|
2019-03-01 16:49:35 +08:00
|
|
|
onPublishHandler={this.props.onPublishHandler}
|
2018-11-22 11:05:47 +08:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2018-09-15 16:14:17 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-29 10:24:46 +08:00
|
|
|
DraftListView.propTypes = propTypes;
|
2018-09-15 16:14:17 +08:00
|
|
|
|
2018-09-29 10:24:46 +08:00
|
|
|
export default DraftListView;
|