SearchResultList.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. toggleCheckBox={this.props.toggleCheckBox}
  21. isSelected={page._id === focusedPageId || false}
  22. noLink
  23. />
  24. );
  25. })}
  26. {this.props.searchResultCount != null && this.props.searchResultCount > 0 && (
  27. <div className="my-4 mx-auto">
  28. <PaginationWrapper
  29. activePage={this.props.activePage}
  30. changePage={this.props.onPagingNumberChanged}
  31. totalItemsCount={this.props.searchResultCount || 0}
  32. pagingLimit={this.props.pagingLimit}
  33. />
  34. </div>
  35. )}
  36. </>
  37. );
  38. }
  39. }
  40. SearchResultList.propTypes = {
  41. pages: PropTypes.array.isRequired,
  42. deletionMode: PropTypes.bool.isRequired,
  43. focusedPage: PropTypes.object,
  44. selectedPages: PropTypes.array.isRequired,
  45. searchResultCount: PropTypes.number,
  46. activePage: PropTypes.number.isRequired,
  47. pagingLimit: PropTypes.number,
  48. onClickInvoked: PropTypes.func,
  49. toggleCheckBox: PropTypes.func.isRequired,
  50. onPagingNumberChanged: PropTypes.func,
  51. };
  52. export default SearchResultList;