1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-31 06:34:40 +00:00
Files
seahub/frontend/src/components/search/search-result-item.js

38 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-09-18 20:57:17 -05:00
import React from 'react';
import PropTypes from 'prop-types';
import { siteRoot } from '../../utils/constants';
import { Utils } from '../../utils/utils';
const propTypes = {
item: PropTypes.object.isRequired,
onItemClickHandler: PropTypes.func.isRequired,
};
2018-08-17 12:23:55 +08:00
class SearchResultItem extends React.Component {
onClickHandler = () => {
var item = this.props.item;
this.props.onItemClickHandler(item);
2018-08-17 12:23:55 +08:00
}
render() {
let item = this.props.item;
let fileIconSize = Utils.isHiDPI() ? 48 : 24;
let fileIconUrl = item.is_dir ? siteRoot + 'media/img/folder-192.png' : Utils.getFileIconUrl(item.name, fileIconSize);
2018-08-17 12:23:55 +08:00
return (
<li className="search-result-item" onClick={this.onClickHandler}>
<img className="item-img" src={fileIconUrl} alt="" />
<div className="item-content">
<dt className="item-name ellipsis">{item.name}</dt>
<dd className="item-link ellipsis">{item.repo_name}/{item.link_content}</dd>
<dd className="item-text ellipsis" dangerouslySetInnerHTML={{__html: item.content}}></dd>
</div>
2018-08-17 12:23:55 +08:00
</li>
);
2018-08-17 12:23:55 +08:00
}
}
SearchResultItem.propTypes = propTypes;
export default SearchResultItem;