1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 17:02:47 +00:00
Files
seahub/frontend/src/components/wiki-dir-list-view/wiki-dir-list-item.js
杨顺强 8a16b4013d optimized getIcon interface (#2904)
* optimized getIcon interface

* optimzied get lib-icon code

* repair share-repo bug
2019-01-29 15:22:02 +08:00

57 lines
1.4 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { siteRoot } from '../../utils/constants';
import { Utils } from '../../utils/utils';
const propTypes = {
path: PropTypes.string.isRequired,
dirent: PropTypes.object.isRequired,
onDirentClick: PropTypes.func.isRequired,
};
class WikiDirListItem extends React.Component {
constructor(props) {
super(props);
this.state = {
highlight: false,
};
}
onMouseEnter = () => {
this.setState({highlight: true});
}
onMouseLeave = () => {
this.setState({highlight: false});
}
onDirentClick = (e) => {
e.preventDefault();
this.props.onDirentClick(this.props.dirent);
}
render() {
let { path, dirent } = this.props;
let href = siteRoot + 'wikis' + Utils.joinPath(path, dirent.name);
let iconUrl = Utils.getDirentIcon(dirent);
return (
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
<td className="text-center">
<img src={iconUrl} width="24" alt="" />
</td>
<td className="name">
<a href={href} onClick={this.onDirentClick}>{dirent.name}</a>
</td>
<td>{dirent.size}</td>
<td title={dirent.mtime_relative}>{dirent.mtime_relative}</td>
</tr>
);
}
}
WikiDirListItem.propTypes = propTypes;
export default WikiDirListItem;