AdminWorkspaceUser.jsx 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import React from 'react'
  2. import { translate } from 'react-i18next'
  3. import i18n from '../i18n.js'
  4. import {
  5. addAllResourceI18n,
  6. // handleFetchResult,
  7. PageWrapper,
  8. PageTitle,
  9. PageContent
  10. } from 'tracim_frontend_lib'
  11. import { debug } from '../helper.js'
  12. import {
  13. } from '../action.async.js'
  14. class AdminWorkspaceUser extends React.Component {
  15. constructor (props) {
  16. super(props)
  17. this.state = {
  18. appName: 'admin_workspace_user',
  19. isVisible: true,
  20. config: props.data ? props.data.config : debug.config,
  21. loggedUser: props.data ? props.data.loggedUser : debug.loggedUser,
  22. content: props.data ? props.data.content : debug.content
  23. }
  24. // i18n has been init, add resources from frontend
  25. addAllResourceI18n(i18n, this.state.config.translation)
  26. i18n.changeLanguage(this.state.loggedUser.lang)
  27. document.addEventListener('appCustomEvent', this.customEventReducer)
  28. }
  29. customEventReducer = ({ detail: { type, data } }) => { // action: { type: '', data: {} }
  30. switch (type) {
  31. // console.log('%c<AdminWorkspaceUser> Custom event', 'color: #28a745', type, data)
  32. default:
  33. break
  34. }
  35. }
  36. componentDidMount () {
  37. console.log('%c<AdminWorkspaceUser> did mount', `color: ${this.state.config.hexcolor}`)
  38. this.loadContent()
  39. }
  40. componentDidUpdate (prevProps, prevState) {
  41. const { state } = this
  42. console.log('%c<AdminWorkspaceUser> did update', `color: ${this.state.config.hexcolor}`, prevState, state)
  43. }
  44. componentWillUnmount () {
  45. console.log('%c<AdminWorkspaceUser> will Unmount', `color: ${this.state.config.hexcolor}`)
  46. document.removeEventListener('appCustomEvent', this.customEventReducer)
  47. }
  48. loadContent = () => {
  49. return null
  50. }
  51. render () {
  52. const { isVisible } = this.state
  53. // const { t } = this.props
  54. if (!isVisible) return null
  55. return (
  56. <div>
  57. <PageWrapper customeClass='admin'>
  58. <PageTitle
  59. parentClass='admin__header'
  60. customClass='justify-content-between'
  61. title={'Admin'}
  62. />
  63. <PageContent parentClass='workspace__content'>
  64. woot { this.state.config.type }
  65. </PageContent>
  66. </PageWrapper>
  67. </div>
  68. )
  69. }
  70. }
  71. export default translate()(AdminWorkspaceUser)