2019-03-09 04:06:11 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2024-08-07 06:01:37 +00:00
|
|
|
import classnames from 'classnames';
|
2019-03-09 04:06:11 +00:00
|
|
|
import { Utils } from '../../utils/utils';
|
2024-11-11 04:31:12 +00:00
|
|
|
import './searched-list-item.css';
|
2019-03-09 04:06:11 +00:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
currentItem: PropTypes.object,
|
|
|
|
onItemClick: PropTypes.func.isRequired,
|
2019-05-27 09:13:15 +00:00
|
|
|
onSearchedItemDoubleClick: PropTypes.func.isRequired,
|
2023-09-13 00:40:50 +00:00
|
|
|
item: PropTypes.object,
|
2019-03-09 04:06:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SearchedListItem extends React.Component {
|
2020-11-02 05:56:35 +00:00
|
|
|
|
2019-03-09 04:06:11 +00:00
|
|
|
onClick = () => {
|
2024-11-11 04:31:12 +00:00
|
|
|
this.props.onItemClick(this.props.item);
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-03-09 04:06:11 +00:00
|
|
|
|
2024-11-11 04:31:12 +00:00
|
|
|
searchItemDoubleClick = () => {
|
|
|
|
this.props.onSearchedItemDoubleClick(this.props.item);
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-05-27 09:13:15 +00:00
|
|
|
|
2019-03-09 04:06:11 +00:00
|
|
|
render() {
|
|
|
|
let { item, currentItem } = this.props;
|
|
|
|
return (
|
2024-08-07 06:01:37 +00:00
|
|
|
<tr
|
|
|
|
className={classnames('searched-list-item', {
|
2024-09-23 01:48:43 +00:00
|
|
|
'tr-active': currentItem && item.repo_id === currentItem.repo_id && item.path === currentItem.path,
|
|
|
|
'searched-dir': item.is_dir,
|
2024-08-07 06:01:37 +00:00
|
|
|
})}
|
|
|
|
onClick={this.onClick}
|
|
|
|
onDoubleClick={this.searchItemDoubleClick}
|
|
|
|
>
|
2024-08-13 02:21:32 +00:00
|
|
|
<td className="text-center searched-item-icon">
|
2024-11-11 04:31:12 +00:00
|
|
|
{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"/>
|
|
|
|
}
|
2024-08-07 06:01:37 +00:00
|
|
|
</td>
|
2024-08-13 02:21:32 +00:00
|
|
|
<td className='searched-item-link'>
|
2024-08-07 06:01:37 +00:00
|
|
|
<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;
|