ThreadPagination.jsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import React from "react"
  2. import { Link } from "react-router"
  3. const ThreadPagination = ({ baseUrl, posts }) => (
  4. <div className="misago-pagination">
  5. {posts.isLoaded && posts.first ? (
  6. <Link
  7. className="btn btn-default btn-outline btn-icon"
  8. to={baseUrl}
  9. title={gettext("Go to first page")}
  10. >
  11. <span className="material-icon">first_page</span>
  12. </Link>
  13. ) : (
  14. <button
  15. className="btn btn-default btn-outline btn-icon"
  16. title={gettext("Go to first page")}
  17. type="button"
  18. disabled
  19. >
  20. <span className="material-icon">first_page</span>
  21. </button>
  22. )}
  23. {posts.isLoaded && posts.previous ? (
  24. <Link
  25. className="btn btn-default btn-outline btn-icon"
  26. to={baseUrl + (posts.previous > 1 ? posts.previous + "/" : "")}
  27. title={gettext("Go to previous page")}
  28. >
  29. <span className="material-icon">chevron_left</span>
  30. </Link>
  31. ) : (
  32. <button
  33. className="btn btn-default btn-outline btn-icon"
  34. title={gettext("Go to previous page")}
  35. type="button"
  36. disabled
  37. >
  38. <span className="material-icon">chevron_left</span>
  39. </button>
  40. )}
  41. {posts.isLoaded && posts.next ? (
  42. <Link
  43. className="btn btn-default btn-outline btn-icon"
  44. to={baseUrl + posts.next + "/"}
  45. title={gettext("Go to next page")}
  46. >
  47. <span className="material-icon">chevron_right</span>
  48. </Link>
  49. ) : (
  50. <button
  51. className="btn btn-default btn-outline btn-icon"
  52. title={gettext("Go to next page")}
  53. type="button"
  54. disabled
  55. >
  56. <span className="material-icon">chevron_right</span>
  57. </button>
  58. )}
  59. {posts.isLoaded && posts.last ? (
  60. <Link
  61. className="btn btn-default btn-outline btn-icon"
  62. to={baseUrl + posts.last + "/"}
  63. title={gettext("Go to last page")}
  64. >
  65. <span className="material-icon">last_page</span>
  66. </Link>
  67. ) : (
  68. <button
  69. className="btn btn-default btn-outline btn-icon"
  70. title={gettext("Go to last page")}
  71. type="button"
  72. disabled
  73. >
  74. <span className="material-icon">last_page</span>
  75. </button>
  76. )}
  77. </div>
  78. )
  79. export default ThreadPagination