UNPKG

827 BJavaScriptView Raw
1import React, { Component } from 'react'
2import ChangePasswordModal from './ChangePasswordModal.js'
3import Studio from 'jsreport-studio'
4
5export default class DataEditor extends Component {
6 componentDidMount () {
7 if (this.props.entity.__isNew && !this.props.entity.password) {
8 Studio.openModal(ChangePasswordModal, { entity: this.props.entity })
9 }
10 }
11
12 render () {
13 const { entity, onUpdate } = this.props
14
15 return <div className='custom-editor'>
16 <h1><i className='fa fa-user' /> {entity.username}</h1>
17 <div>
18 {Studio.authentication.useEditorComponents.map((c, i) => <div key={i}>{c(entity, onUpdate)}</div>)}
19 </div>
20 </div>
21 }
22}
23
24DataEditor.propTypes = {
25 entity: React.PropTypes.object.isRequired,
26 onUpdate: React.PropTypes.func.isRequired
27}
28
\No newline at end of file