renderSearchMessage.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2015 - present Instructure, Inc.
  3. *
  4. * This file is part of Canvas.
  5. *
  6. * Canvas is free software: you can redistribute it and/or modify it under
  7. * the terms of the GNU Affero General Public License as published by the Free
  8. * Software Foundation, version 3 of the License.
  9. *
  10. * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. * details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. import React from 'react'
  19. import I18n from 'i18n!account_course_user_search'
  20. function renderSearchMessage (collection, loadMore, noneFoundMessage) {
  21. if (!collection || collection.loading) {
  22. return (
  23. <div className="text-center pad-box">
  24. {I18n.t("Loading...")}
  25. </div>
  26. );
  27. } else if (collection.error) {
  28. return (
  29. <div className="text-center pad-box">
  30. <div className="alert alert-error">
  31. {I18n.t("There was an error with your query; please try a different search")}
  32. </div>
  33. </div>
  34. );
  35. } else if (!collection.data.length) {
  36. return (
  37. <div className="text-center pad-box">
  38. <div className="alert alert-info">
  39. {noneFoundMessage}
  40. </div>
  41. </div>
  42. );
  43. } else if (collection.next) {
  44. return (
  45. <div className="text-center pad-box">
  46. <button
  47. className="Button--link load_more"
  48. onClick={loadMore}
  49. >
  50. <i className="icon-refresh"/>
  51. {" "}
  52. {I18n.t("Load more...")}
  53. </button>
  54. </div>
  55. );
  56. }
  57. }
  58. export default renderSearchMessage