mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-21 19:37:28 +00:00
change search result is library (#6274)
* change search result is library * fix warning
This commit is contained in:
@@ -7,6 +7,7 @@ import searchAPI from '../../utils/search-api';
|
||||
import Icon from '../icon';
|
||||
import { gettext, siteRoot, username } from '../../utils/constants';
|
||||
import SearchResultItem from './search-result-item';
|
||||
import SearchResultLibrary from './search-result-library';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { isMac } from '../../utils/extra-attributes';
|
||||
import toaster from '../toast';
|
||||
@@ -471,10 +472,10 @@ export default class AISearch extends Component {
|
||||
>
|
||||
{resultItems.map((item, index) => {
|
||||
return (
|
||||
<SearchResultItem
|
||||
<SearchResultLibrary
|
||||
key={index}
|
||||
item={item}
|
||||
onItemClickHandler={this.onItemClickHandler}
|
||||
onClick={this.onItemClickHandler}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
@@ -17,8 +17,7 @@ class SearchResultItem extends React.Component {
|
||||
};
|
||||
|
||||
onClickHandler = () => {
|
||||
var item = this.props.item;
|
||||
this.props.onItemClickHandler(item);
|
||||
this.props.onItemClickHandler(this.props.item);
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -28,7 +27,6 @@ class SearchResultItem extends React.Component {
|
||||
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;
|
||||
}
|
||||
|
22
frontend/src/components/search/search-result-library.js
Normal file
22
frontend/src/components/search/search-result-library.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classnames from 'classnames';
|
||||
import { Utils } from '../../utils/utils';
|
||||
|
||||
function SearchResultLibrary(props) {
|
||||
const { item, isHighlight, onClick } = props;
|
||||
return (
|
||||
<li className={classnames('search-result-item', {'search-result-item-highlight': isHighlight })} onClick={() => onClick(item)}>
|
||||
<img className='lib-item-img' src={Utils.getDefaultLibIconUrl(true)} alt="" />
|
||||
<div className="item-content d-flex justify-content-between align-items-center ellipsis">{item.name}</div>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
SearchResultLibrary.propTypes = {
|
||||
item: PropTypes.object.isRequired,
|
||||
onClick: PropTypes.func.isRequired,
|
||||
isHighlight: PropTypes.bool,
|
||||
};
|
||||
|
||||
export default SearchResultLibrary;
|
@@ -6,6 +6,7 @@ import { seafileAPI } from '../../utils/seafile-api';
|
||||
import searchAPI from '../../utils/search-api';
|
||||
import { gettext, siteRoot } from '../../utils/constants';
|
||||
import SearchResultItem from './search-result-item';
|
||||
import SearchResultLibrary from './search-result-library';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { isMac } from '../../utils/extra-attributes';
|
||||
import toaster from '../toast';
|
||||
@@ -470,10 +471,10 @@ class Search extends Component {
|
||||
>
|
||||
{resultItems.map((item, index) => {
|
||||
return (
|
||||
<SearchResultItem
|
||||
<SearchResultLibrary
|
||||
key={index}
|
||||
item={item}
|
||||
onItemClickHandler={this.onItemClickHandler}
|
||||
onClick={this.onItemClickHandler}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
Reference in New Issue
Block a user