project-list-root.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import {
  2. ProjectListProvider,
  3. useProjectListContext,
  4. } from '../context/project-list-context'
  5. import { Col, Row } from 'react-bootstrap'
  6. import { useTranslation } from 'react-i18next'
  7. import useWaitForI18n from '../../../shared/hooks/use-wait-for-i18n'
  8. import CurrentPlanWidget from './current-plan-widget/current-plan-widget'
  9. import NewProjectButton from './new-project-button'
  10. import ProjectListTable from './table/project-list-table'
  11. import SidebarFilters from './sidebar/sidebar-filters'
  12. import SurveyWidget from './survey-widget'
  13. import WelcomeMessage from './welcome-message'
  14. import LoadingBranded from '../../../shared/components/loading-branded'
  15. import UserNotifications from './notifications/user-notifications'
  16. import SearchForm from './search-form'
  17. function ProjectListRoot() {
  18. const { isReady } = useWaitForI18n()
  19. return isReady ? (
  20. <ProjectListProvider>
  21. <ProjectListPageContent />
  22. </ProjectListProvider>
  23. ) : null
  24. }
  25. function ProjectListPageContent() {
  26. const { totalProjectsCount, error, isLoading, loadProgress, setSearchText } =
  27. useProjectListContext()
  28. return isLoading ? (
  29. <div className="loading-container">
  30. <LoadingBranded loadProgress={loadProgress} />
  31. </div>
  32. ) : (
  33. <div className="project-list-row row fill">
  34. <div className="project-list-wrapper">
  35. {error ? <DashApiError /> : ''}
  36. {totalProjectsCount > 0 ? (
  37. <>
  38. <Col md={2} xs={3} className="project-list-sidebar-wrapper">
  39. <aside className="project-list-sidebar">
  40. <NewProjectButton />
  41. <SidebarFilters />
  42. </aside>
  43. <SurveyWidget />
  44. </Col>
  45. <Col md={10} xs={9} className="project-list-main">
  46. <Row>
  47. <Col xs={12}>
  48. <UserNotifications />
  49. </Col>
  50. </Row>
  51. <Row>
  52. <Col md={7} xs={12}>
  53. <SearchForm onChange={setSearchText} />
  54. </Col>
  55. <Col md={5} xs={12}>
  56. <div className="project-tools">
  57. <div className="text-right pull-right">
  58. <CurrentPlanWidget />
  59. </div>
  60. </div>
  61. </Col>
  62. </Row>
  63. <Row className="row-spaced">
  64. <Col xs={12}>
  65. <ProjectListTable />
  66. </Col>
  67. </Row>
  68. </Col>
  69. </>
  70. ) : (
  71. <Row className="row-spaced">
  72. <Col
  73. xs={8}
  74. xsOffset={2}
  75. md={8}
  76. mdOffset={2}
  77. className="project-list-empty-col"
  78. >
  79. <WelcomeMessage />
  80. </Col>
  81. </Row>
  82. )}
  83. </div>
  84. </div>
  85. )
  86. }
  87. function DashApiError() {
  88. const { t } = useTranslation()
  89. return (
  90. <Row className="row-spaced">
  91. <Col xs={8} xsOffset={2} aria-live="polite" className="text-center">
  92. <div className="alert alert-danger">
  93. {t('generic_something_went_wrong')}
  94. </div>
  95. </Col>
  96. </Row>
  97. )
  98. }
  99. export default ProjectListRoot