2018-11-23 12:19:42 +00:00
|
|
|
import React from 'react';
|
2018-10-13 09:07:54 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-11-23 12:19:42 +00:00
|
|
|
import { gettext } from '../../utils/constants';
|
2018-10-25 05:36:06 +00:00
|
|
|
import Loading from '../loading';
|
2018-10-13 09:07:54 +00:00
|
|
|
import DirentListItem from './dirent-list-item';
|
|
|
|
|
|
|
|
const propTypes = {
|
2018-11-22 03:26:00 +00:00
|
|
|
path: PropTypes.string.isRequired,
|
2018-11-28 04:41:49 +00:00
|
|
|
repoID: PropTypes.string.isRequired,
|
|
|
|
isRepoOwner: PropTypes.bool,
|
|
|
|
currentRepo: PropTypes.object,
|
|
|
|
isAllItemSelected: PropTypes.bool.isRequired,
|
|
|
|
isDirentListLoading: PropTypes.bool.isRequired,
|
2018-10-13 09:07:54 +00:00
|
|
|
direntList: PropTypes.array.isRequired,
|
|
|
|
onItemDelete: PropTypes.func.isRequired,
|
2018-11-23 12:19:42 +00:00
|
|
|
onAllItemSelected: PropTypes.func.isRequired,
|
|
|
|
onItemSelected: PropTypes.func.isRequired,
|
2018-10-25 05:36:06 +00:00
|
|
|
onItemRename: PropTypes.func.isRequired,
|
2018-10-13 09:07:54 +00:00
|
|
|
onItemClick: PropTypes.func.isRequired,
|
2018-11-27 06:47:19 +00:00
|
|
|
onItemMove: PropTypes.func.isRequired,
|
|
|
|
onItemCopy: PropTypes.func.isRequired,
|
2018-10-25 05:36:06 +00:00
|
|
|
onItemDetails: PropTypes.func.isRequired,
|
2018-11-22 03:26:00 +00:00
|
|
|
updateDirent: PropTypes.func.isRequired,
|
2018-10-13 09:07:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DirentListView extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isItemFreezed: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
onFreezedItem = () => {
|
2018-10-13 09:07:54 +00:00
|
|
|
this.setState({isItemFreezed: true});
|
|
|
|
}
|
2018-11-22 03:26:00 +00:00
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
onUnfreezedItem = () => {
|
2018-10-13 09:07:54 +00:00
|
|
|
this.setState({isItemFreezed: false});
|
|
|
|
}
|
|
|
|
|
2018-11-23 12:19:42 +00:00
|
|
|
onItemRenameToggle = () => {
|
2018-10-25 05:36:06 +00:00
|
|
|
this.onFreezedItem();
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
|
|
|
|
2018-11-29 09:55:14 +00:00
|
|
|
onItemDetails = (dirent) => {
|
|
|
|
this.props.onItemDetails(dirent);
|
2018-10-25 05:36:06 +00:00
|
|
|
}
|
|
|
|
|
2018-10-13 09:07:54 +00:00
|
|
|
render() {
|
|
|
|
const { direntList } = this.props;
|
2018-10-25 05:36:06 +00:00
|
|
|
|
|
|
|
if (this.props.isDirentListLoading) {
|
|
|
|
return (<Loading />);
|
|
|
|
}
|
|
|
|
|
2018-10-13 09:07:54 +00:00
|
|
|
return (
|
2018-11-23 12:19:42 +00:00
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th width="3%" className="select">
|
|
|
|
<input type="checkbox" className="vam" onChange={this.props.onAllItemSelected} checked={this.props.isAllItemSelected}/>
|
|
|
|
</th>
|
|
|
|
<th width="3%"></th>
|
|
|
|
<th width="5%"></th>
|
|
|
|
<th width="35%">{gettext('Name')}</th>
|
|
|
|
<th width="10%"></th>
|
|
|
|
<th width="20%"></th>
|
|
|
|
<th width="11%">{gettext('Size')}</th>
|
|
|
|
<th width="13%">{gettext('Last Update')}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{
|
|
|
|
direntList.length !== 0 && direntList.map((dirent, index) => {
|
|
|
|
return (
|
|
|
|
<DirentListItem
|
|
|
|
key={index}
|
|
|
|
dirent={dirent}
|
|
|
|
path={this.props.path}
|
2018-11-28 04:41:49 +00:00
|
|
|
repoID={this.props.repoID}
|
2018-11-23 12:19:42 +00:00
|
|
|
currentRepo={this.props.currentRepo}
|
|
|
|
isRepoOwner={this.props.isRepoOwner}
|
|
|
|
onItemClick={this.props.onItemClick}
|
|
|
|
onItemRenameToggle={this.onItemRenameToggle}
|
|
|
|
onItemSelected={this.props.onItemSelected}
|
|
|
|
onItemDelete={this.props.onItemDelete}
|
|
|
|
onItemRename={this.props.onItemRename}
|
2018-11-27 06:47:19 +00:00
|
|
|
onItemMove={this.props.onItemMove}
|
|
|
|
onItemCopy={this.props.onItemCopy}
|
2018-11-23 12:19:42 +00:00
|
|
|
updateDirent={this.props.updateDirent}
|
|
|
|
isItemFreezed={this.state.isItemFreezed}
|
|
|
|
onFreezedItem={this.onFreezedItem}
|
|
|
|
onUnfreezedItem={this.onUnfreezedItem}
|
|
|
|
onItemDetails={this.onItemDetails}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2018-10-13 09:07:54 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DirentListView.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default DirentListView;
|