app.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2016 - 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 ReactDOM from 'react-dom'
  20. import { connect, Provider } from 'react-redux'
  21. import BreakdownGraphs from './components/breakdown-graphs'
  22. import BreakdownDetails from './components/breakdown-details'
  23. const Graphs = connect((state) => ({
  24. assignment: state.assignment,
  25. ranges: state.ranges,
  26. enrolled: state.enrolled,
  27. isLoading: state.isInitialDataLoading,
  28. }))(BreakdownGraphs)
  29. const Details = connect((state) => ({
  30. isStudentDetailsLoading: state.isStudentDetailsLoading,
  31. selectedPath: state.selectedPath,
  32. assignment: state.assignment,
  33. ranges: state.ranges,
  34. students: state.studentCache,
  35. showDetails: state.showDetails,
  36. }))(BreakdownDetails)
  37. export default class CRSApp {
  38. constructor (store, actions) {
  39. this.store = store
  40. this.actions = actions
  41. }
  42. renderGraphs (root) {
  43. const actions = {
  44. openSidebar: this.actions.openSidebar,
  45. selectRange: this.actions.selectRange,
  46. }
  47. ReactDOM.render(
  48. <Provider store={this.store}>
  49. <Graphs {...actions} />
  50. </Provider>,
  51. root
  52. )
  53. }
  54. renderDetails (root) {
  55. const detailActions = {
  56. selectRange: this.actions.selectRange,
  57. selectStudent: this.actions.selectStudent,
  58. closeSidebar: this.actions.closeSidebar
  59. }
  60. ReactDOM.render(
  61. <Provider store={this.store}>
  62. <Details {...detailActions} />
  63. </Provider>,
  64. root
  65. )
  66. }
  67. }