import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { Utils } from '../../utils/utils'; const propTypes = { item: PropTypes.object.isRequired, onItemClickHandler: PropTypes.func.isRequired, isHighlight: PropTypes.bool, setRef: PropTypes.func, }; class SearchResultItem extends React.Component { static defaultProps = { setRef: () => {}, }; onClickHandler = () => { this.props.onItemClickHandler(this.props.item); }; render() { let item = this.props.item; let folderIconUrl = item.link_content ? Utils.getFolderIconUrl(false, 192) : Utils.getDefaultLibIconUrl(true); let fileIconUrl = item.is_dir ? folderIconUrl : Utils.getFileIconUrl(item.name, 192); let showName = item.repo_name + '/' + item.link_content; showName = showName.endsWith('/') ? showName.slice(0, showName.length - 1) : showName; if (item.thumbnail_url) { fileIconUrl = item.thumbnail_url; } return (
  • this.props.setRef(ref)} >
    {item.name}
    {showName}
  • ); } } SearchResultItem.propTypes = propTypes; export default SearchResultItem;