WorkspaceContent.jsx 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import React from 'react'
  2. import { connect } from 'react-redux'
  3. import Folder from '../component/Workspace/Folder.jsx'
  4. import FileItem from '../component/Workspace/FileItem.jsx'
  5. import FileItemHeader from '../component/Workspace/FileItemHeader.jsx'
  6. import PageWrapper from '../component/common/layout/PageWrapper.jsx'
  7. import PageTitle from '../component/common/layout/PageTitle.jsx'
  8. import PageContent from '../component/common/layout/PageContent.jsx'
  9. import DropdownCreateButton from '../component/common/Input/DropdownCreateButton.jsx'
  10. // import pluginDatabase from '../plugin/index.js'
  11. import {
  12. getPluginList,
  13. getWorkspaceContent
  14. } from '../action-creator.async.js'
  15. import { setActiveFileContent } from '../action-creator.sync.js'
  16. import { bonjour } from 'tracim_lib'
  17. class WorkspaceContent extends React.Component {
  18. constructor (props) {
  19. super(props)
  20. this.state = {
  21. activeFileType: ''
  22. }
  23. }
  24. componentDidMount () {
  25. this.props.dispatch(getWorkspaceContent(/* this.props.workspace.id */1))
  26. this.props.dispatch(getPluginList())
  27. }
  28. handleClickFileItem = file => {
  29. // this.props.dispatch(setActiveFileContent(file))
  30. GLOBAL_renderPlugin(file.type)
  31. }
  32. handleDummyBtn = () => {
  33. // GLOBAL_dispatchEvent({
  34. // source: 'Tracim',
  35. // type: 'PageHtml_showMsg',
  36. // content: 'Bonjour ?'
  37. // })
  38. bonjour()
  39. }
  40. render () {
  41. const { workspace, plugin } = this.props
  42. // const PluginContainer = (pluginDatabase.find(p => p.name === activeFileContent.type) || {container: '<div>unknow</div>'}).container
  43. return (
  44. <PageWrapper customeClass='workspace'>
  45. <PageTitle
  46. parentClass='workspace__header'
  47. customClass='justify-content-between'
  48. title={workspace.title}
  49. >
  50. <DropdownCreateButton parentClass='workspace__header__btnaddworkspace' />
  51. </PageTitle>
  52. <PageContent parentClass='workspace__content'>
  53. <button onClick={this.handleDummyBtn}>Click Me</button>
  54. <div className='workspace__content__fileandfolder folder__content active'>
  55. <FileItemHeader />
  56. { workspace.content.map(c => c.type === 'folder'
  57. ? <Folder plugin={plugin} folderData={c} key={c.id} />
  58. : (
  59. <FileItem
  60. name={c.title}
  61. type={c.type}
  62. icon={(plugin[c.type] || {icon: ''}).icon}
  63. status={c.status}
  64. onClickItem={() => this.handleClickFileItem(c)}
  65. key={c.id}
  66. />
  67. )
  68. )}
  69. </div>
  70. <DropdownCreateButton customClass='workspace__content__button mb-5' />
  71. <div id='pluginContainer'>
  72. {/* activeFileContent.display && <PluginContainer /> */}
  73. </div>
  74. </PageContent>
  75. </PageWrapper>
  76. )
  77. }
  78. }
  79. const mapStateToProps = ({ workspace, activeFileContent, plugin }) => ({ workspace, activeFileContent, plugin })
  80. export default connect(mapStateToProps)(WorkspaceContent)