1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-17 16:52:09 +00:00
seahub/frontend/src/components/tree-dir-view/tree-dir-list.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
2018-10-16 10:19:51 +00:00
import PropTypes from 'prop-types';
import { serviceUrl } from '../../utils/constants';
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 = () => {
this.setState({highlight: true});
2018-09-29 07:47:53 +00:00
}
2018-09-19 01:57:17 +00:00
onMouseLeave = () => {
this.setState({highlight: false});
2018-09-19 01:57:17 +00:00
}
2018-09-04 09:16:50 +00:00
onMainNodeClick = () => {
this.props.onMainNodeClick(this.props.node);
}
render() {
let node = this.props.node;
return (
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
2018-09-29 07:47:53 +00:00
<td className="icon">
2018-10-16 10:19:51 +00:00
<img src={node.type === 'dir' ? serviceUrl + '/media/img/folder-192.png' : serviceUrl + '/media/img/file/192/txt.png'} alt='icon'></img>
2018-09-04 09:16:50 +00:00
</td>
2018-09-29 07:47:53 +00:00
<td className="name a-simulate" onClick={this.onMainNodeClick}>{node.name}</td>
<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-04 09:16:50 +00:00
}
}
2018-10-16 10:19:51 +00:00
TreeDirList.propTypes = propTypes;
export default TreeDirList;