import React from 'react'; import PropTypes from 'prop-types'; import CommentEditor from './CommentEditor'; import UserPicture from '../User/UserPicture'; export default class CommentEditorLazyRenderer extends React.Component { constructor(props) { super(props); this.state = { isEditorShown: false, isLayoutTypeGrowi: false, }; this.showCommentFormBtnClickHandler = this.showCommentFormBtnClickHandler.bind(this); } componentWillMount() { this.init(); } init() { const layoutType = this.props.crowi.getConfig().layoutType; this.setState({ isLayoutTypeGrowi: layoutType === 'crowi-plus' || layoutType === 'growi' }); } showCommentFormBtnClickHandler() { this.setState({ isEditorShown: !this.state.isEditorShown }); } render() { const crowi = this.props.crowi; const username = crowi.me; const user = crowi.findUser(username); const isLayoutTypeGrowi = this.state.isLayoutTypeGrowi; return ( { !this.state.isEditorShown && (
{ username && (
{ isLayoutTypeGrowi && (
) }
) }
) } { this.state.isEditorShown && ( ) }
); } } CommentEditorLazyRenderer.propTypes = { crowi: PropTypes.object.isRequired, crowiOriginRenderer: PropTypes.object.isRequired, slackChannels: PropTypes.string, };