/* eslint-disable no-return-assign, react/no-unused-prop-types */ import { Component, PropTypes } from 'react'; import { graphql } from 'react-apollo'; import gql from 'graphql-tag'; import { I18n } from 'react-i18nify'; import uuid from 'uuid'; import classnames from 'classnames'; import Icon from '../application/icon.component'; import addCommentMutation from './add_comment_form.mutation.graphql'; import commentThreadFragment from './comment_thread.fragment.graphql' import commentFragment from './comment.fragment.graphql'; import commentDataFragment from './comment_data.fragment.graphql'; import upVoteFragment from './up_vote.fragment.graphql'; import downVoteFragment from './down_vote.fragment.graphql'; import addCommentFormFragment from './add_comment_form.fragment.graphql'; /** * Renders a form to create new comments. * @class * @augments Component */ export class AddCommentForm extends Component { constructor(props) { super(props); this.state = { disabled: true, alignment: 0 }; } render() { const { submitButtonClassName, commentableType, commentableId } = this.props; const { disabled } = this.state; return (
{this._renderHeading()} {this._renderOpinionButtons()}
this._addComment(evt)}> {this._renderCommentAs()}
{this._renderTextArea()}
); } /** * Render the form heading based on showTitle prop * @private * @returns {Void|DOMElement} - The heading or an empty element */ _renderHeading() { const { showTitle } = this.props; if (showTitle) { return (
{ I18n.t("components.add_comment_form.title") }
); } return null; } /** * Render the form heading based on showTitle prop * @private * @returns {Void|DOMElement} - The heading or an empty element */ _renderTextArea() { const { commentableType, commentableId, autoFocus} = this.props; let textAreaProps = { ref: (textarea) => {this.bodyTextArea = textarea}, id: `add-comment-${commentableType}-${commentableId}`, rows: "4", placeholder: I18n.t("components.add_comment_form.form.body.placeholder"), onChange: (evt) => this._checkCommentBody(evt.target.value) }; if (autoFocus) { textAreaProps.autoFocus = 'autoFocus'; } return (