2018-09-29 10:32:53 +00:00
|
|
|
import React from 'react';
|
2018-10-16 10:19:51 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-11-29 09:55:14 +00:00
|
|
|
import { siteRoot } from '../../utils/constants';
|
2019-01-11 07:37:02 +00:00
|
|
|
import { Utils } from '../../utils/utils';
|
2018-09-29 07:47:53 +00:00
|
|
|
|
2018-10-16 10:19:51 +00:00
|
|
|
const propTypes = {
|
|
|
|
node: PropTypes.object.isRequired,
|
|
|
|
onMainNodeClick: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
2018-09-04 09:16:50 +00:00
|
|
|
class TreeDirList extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
2018-09-29 07:47:53 +00:00
|
|
|
highlight: false,
|
|
|
|
isOperationShow: false,
|
|
|
|
};
|
2018-09-04 09:16:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-19 01:57:17 +00:00
|
|
|
onMouseEnter = () => {
|
2018-10-25 05:36:06 +00:00
|
|
|
this.setState({highlight: true});
|
2018-09-29 07:47:53 +00:00
|
|
|
}
|
|
|
|
|
2018-09-19 01:57:17 +00:00
|
|
|
onMouseLeave = () => {
|
2018-10-25 05:36:06 +00:00
|
|
|
this.setState({highlight: false});
|
2018-09-19 01:57:17 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 03:52:19 +00:00
|
|
|
onMainNodeClick = (e) => {
|
|
|
|
e.preventDefault();
|
2018-09-04 09:16:50 +00:00
|
|
|
this.props.onMainNodeClick(this.props.node);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let node = this.props.node;
|
2018-11-30 03:52:19 +00:00
|
|
|
let href = siteRoot + 'wikis' + node.path;
|
2019-01-11 07:37:02 +00:00
|
|
|
|
|
|
|
let size = Utils.isHiDPI() ? 48 : 24;
|
|
|
|
let iconUrl = '';
|
|
|
|
if (node.type === 'file') {
|
|
|
|
iconUrl = Utils.getFileIconUrl(node.name, size);
|
|
|
|
} else {
|
|
|
|
let isReadOnly = false;
|
|
|
|
if (node.permission === 'r' || node.permission === 'preview') {
|
|
|
|
isReadOnly = true;
|
|
|
|
}
|
|
|
|
iconUrl = Utils.getFolderIconUrl({isReadOnly, size});
|
|
|
|
}
|
|
|
|
|
2018-09-04 09:16:50 +00:00
|
|
|
return (
|
2018-10-25 05:36:06 +00:00
|
|
|
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
2018-12-28 03:12:24 +00:00
|
|
|
<td className="text-center">
|
2019-01-11 07:37:02 +00:00
|
|
|
<img src={iconUrl} width="24" alt="" />
|
2018-09-04 09:16:50 +00:00
|
|
|
</td>
|
2018-11-30 03:52:19 +00:00
|
|
|
<td className="name">
|
|
|
|
<a href={href} onClick={this.onMainNodeClick}>{node.name}</a>
|
|
|
|
</td>
|
2018-09-29 07:47:53 +00:00
|
|
|
<td>{node.size}</td>
|
|
|
|
<td title={node.last_update_time}>{node.last_update_time}</td>
|
2018-09-04 09:16:50 +00:00
|
|
|
</tr>
|
2018-09-29 10:32:53 +00:00
|
|
|
);
|
2018-09-04 09:16:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-16 10:19:51 +00:00
|
|
|
TreeDirList.propTypes = propTypes;
|
|
|
|
|
2018-09-18 02:11:37 +00:00
|
|
|
export default TreeDirList;
|