1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-21 00:15:26 +00:00
seahub/frontend/src/components/file-chooser/searched-list-item.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-03-09 04:06:11 +00:00
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
2019-03-09 04:06:11 +00:00
import { Utils } from '../../utils/utils';
import './searched-list-item.css';
2019-03-09 04:06:11 +00:00
const propTypes = {
currentItem: PropTypes.object,
onItemClick: PropTypes.func.isRequired,
onSearchedItemDoubleClick: PropTypes.func.isRequired,
item: PropTypes.object,
2019-03-09 04:06:11 +00:00
};
class SearchedListItem extends React.Component {
2019-03-09 04:06:11 +00:00
onClick = () => {
this.props.onItemClick(this.props.item);
};
2019-03-09 04:06:11 +00:00
searchItemDoubleClick = () => {
this.props.onSearchedItemDoubleClick(this.props.item);
};
2019-03-09 04:06:11 +00:00
render() {
let { item, currentItem } = this.props;
return (
<tr
className={classnames('searched-list-item', {
'tr-active': currentItem && item.repo_id === currentItem.repo_id && item.path === currentItem.path,
'searched-dir': item.is_dir,
})}
onClick={this.onClick}
onDoubleClick={this.searchItemDoubleClick}
>
2024-08-13 02:21:32 +00:00
<td className="text-center searched-item-icon">
{item.is_dir ?
<span className="icon sf3-font sf3-font-folder tree-node-icon"></span>
:
<img className="item-img" src={Utils.getFileIconUrl(item.name)} alt="" width="24"/>
}
</td>
2024-08-13 02:21:32 +00:00
<td className='searched-item-link'>
<span className="item-link">{item.repo_name}/{item.link_content}</span>
</td>
2019-03-09 04:06:11 +00:00
</tr>
);
}
}
SearchedListItem.propTypes = propTypes;
export default SearchedListItem;