SearchResultList.jsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import SearchResultListItem from './SearchResultListItem';
  4. import PaginationWrapper from '../PaginationWrapper';
  5. class SearchResultList extends React.Component {
  6. render() {
  7. const { focusedPage } = this.props;
  8. const focusedPageId = focusedPage != null && focusedPage.id != null ? focusedPage.id : '';
  9. return (
  10. <>
  11. {this.props.pages.map((page) => {
  12. // TODO : send cetain length of body (revisionBody) from elastisearch by adding some settings to the query and
  13. // when keyword is not in page content, display revisionBody.
  14. // TASK : https://estoc.weseek.co.jp/redmine/issues/79606
  15. return (
  16. <SearchResultListItem
  17. key={page._id}
  18. page={page}
  19. onClickInvoked={this.props.onClickInvoked}
  20. isSelected={page._id === focusedPageId || false}
  21. noLink
  22. />
  23. );
  24. })}
  25. {this.props.searchResultCount != null && this.props.searchResultCount > 0 && (
  26. <div className="my-4 mx-auto">
  27. <PaginationWrapper
  28. activePage={this.props.activePage}
  29. changePage={this.props.onPagingNumberChanged}
  30. totalItemsCount={this.props.searchResultCount || 0}
  31. pagingLimit={this.props.pagingLimit}
  32. />
  33. </div>
  34. )}
  35. </>
  36. );
  37. }
  38. }
  39. SearchResultList.propTypes = {
  40. pages: PropTypes.array.isRequired,
  41. deletionMode: PropTypes.bool.isRequired,
  42. focusedPage: PropTypes.object,
  43. selectedPages: PropTypes.array.isRequired,
  44. searchResultCount: PropTypes.number,
  45. activePage: PropTypes.number.isRequired,
  46. pagingLimit: PropTypes.number,
  47. onClickInvoked: PropTypes.func,
  48. onChangeInvoked: PropTypes.func,
  49. onPagingNumberChanged: PropTypes.func,
  50. };
  51. export default SearchResultList;