diff --git a/client/coral-embed-stream/src/tabs/stream/components/Comment.js b/client/coral-embed-stream/src/tabs/stream/components/Comment.js index 6165d126b..5df119fbc 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/Comment.js +++ b/client/coral-embed-stream/src/tabs/stream/components/Comment.js @@ -16,7 +16,7 @@ import mapValues from 'lodash/mapValues'; import get from 'lodash/get'; import LoadMore from './LoadMore'; -import { getEditableUntilDate } from './util'; +import { getEditableUntilDate } from '../util'; import { findCommentWithId } from '../../../graphql/utils'; import CommentContent from 'coral-framework/components/CommentContent'; import Slot from 'coral-framework/components/Slot'; diff --git a/client/coral-embed-stream/src/tabs/stream/components/CommentForm.js b/client/coral-embed-stream/src/tabs/stream/components/CommentForm.js index 65937b3ce..64e0fbf84 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/CommentForm.js +++ b/client/coral-embed-stream/src/tabs/stream/components/CommentForm.js @@ -37,15 +37,15 @@ class CommentForm extends React.Component { submitButtonCStyle: PropTypes.string, // return whether the submit button should be enabled for the provided - // comment ({ body }) (for reasons other than charCount) + // input (for reasons other than charCount) submitEnabled: PropTypes.func, // className to add to buttons submitButtonClassName: PropTypes.string, cancelButtonClassName: PropTypes.string, - body: PropTypes.string.isRequired, - onBodyChange: PropTypes.func.isRequired, + input: PropTypes.object.isRequired, + onInputChange: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired, onCancel: PropTypes.func, state: PropTypes.string, @@ -53,6 +53,7 @@ class CommentForm extends React.Component { registerHook: PropTypes.func, unregisterHook: PropTypes.func, isReply: PropTypes.bool, + isEdit: PropTypes.bool, root: PropTypes.object.isRequired, comment: PropTypes.object, }; @@ -90,20 +91,20 @@ class CommentForm extends React.Component { cancelButtonClassName, submitButtonClassName, charCountEnable, - body, + input, loadingState, comment, root, } = this.props; - const length = body.length; + const length = input.body.length; const isRespectingMaxCount = length => charCountEnable && maxCharCount && length > maxCharCount; const disableSubmitButton = !length || - body.trim().length === 0 || + input.body.trim().length === 0 || isRespectingMaxCount(length) || - !submitEnabled({ body }) || + !submitEnabled(input) || loadingState === 'loading'; const disableCancelButton = loadingState === 'loading'; const disableTextArea = loadingState === 'loading'; @@ -115,15 +116,16 @@ class CommentForm extends React.Component { comment={comment} id={this.props.bodyInputId} label={this.props.bodyLabel} - value={body} + input={input} placeholder={this.props.bodyPlaceholder} - onChange={this.props.onBodyChange} + onInputChange={this.props.onInputChange} disabled={disableTextArea} charCountEnable={this.props.charCountEnable} maxCharCount={this.props.maxCharCount} registerHook={this.props.registerHook} unregisterHook={this.props.unregisterHook} isReply={this.props.isReply} + isEdit={this.props.isEdit} />
{this.props.buttonContainerStart} diff --git a/client/coral-embed-stream/src/tabs/stream/components/DraftArea.js b/client/coral-embed-stream/src/tabs/stream/components/DraftArea.js index 7150a124d..ce469f201 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/DraftArea.js +++ b/client/coral-embed-stream/src/tabs/stream/components/DraftArea.js @@ -13,17 +13,17 @@ import styles from './DraftArea.css'; */ export default class DraftArea extends React.Component { renderCharCount() { - const { value, maxCharCount } = this.props; + const { input, maxCharCount } = this.props; const className = cn( styles.charCount, 'talk-plugin-commentbox-char-count', { [`${styles.charMax} talk-plugin-commentbox-char-max`]: - value.length > maxCharCount, + input.body.length > maxCharCount, } ); - const remaining = maxCharCount - value.length; + const remaining = maxCharCount - input.body.length; return (
@@ -34,7 +34,7 @@ export default class DraftArea extends React.Component { render() { const { - value, + input, placeholder, id, disabled, @@ -42,8 +42,9 @@ export default class DraftArea extends React.Component { label, charCountEnable, maxCharCount, - onChange, + onInputChange, isReply, + isEdit, registerHook, unregisterHook, root, @@ -51,7 +52,7 @@ export default class DraftArea extends React.Component { } = this.props; return ( -
+
@@ -67,13 +68,14 @@ export default class DraftArea extends React.Component { comment, registerHook, unregisterHook, - value, + input, placeholder, id, - onChange, + onInputChange, rows, disabled, isReply, + isEdit, }} /> @@ -92,10 +94,10 @@ DraftArea.propTypes = { charCountEnable: PropTypes.bool, maxCharCount: PropTypes.number, id: PropTypes.string, - value: PropTypes.string, + input: PropTypes.object, placeholder: PropTypes.string, label: PropTypes.string, - onChange: PropTypes.func, + onInputChange: PropTypes.func, disabled: PropTypes.bool, rows: PropTypes.number, root: PropTypes.object.isRequired, @@ -103,4 +105,5 @@ DraftArea.propTypes = { registerHook: PropTypes.func, unregisterHook: PropTypes.func, isReply: PropTypes.bool, + isEdit: PropTypes.bool, }; diff --git a/client/coral-embed-stream/src/tabs/stream/components/DraftAreaContent.js b/client/coral-embed-stream/src/tabs/stream/components/DraftAreaContent.js index 50a481f6f..5c77b20aa 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/DraftAreaContent.js +++ b/client/coral-embed-stream/src/tabs/stream/components/DraftAreaContent.js @@ -4,19 +4,19 @@ import cn from 'classnames'; import styles from './DraftAreaContent.css'; const DraftAreaContent = ({ - value, + input, placeholder, id, - onChange, + onInputChange, rows, disabled, }) => (