Merge branch 'master' into shortcut-hint

This commit is contained in:
Belén Curcio
2017-04-25 14:38:47 -03:00
committed by GitHub
6 changed files with 48 additions and 8 deletions
+8
View File
@@ -64,6 +64,8 @@ class Comment extends React.Component {
currentUser: PropTypes.shape({
id: PropTypes.string.isRequired
}),
charCountEnable: PropTypes.bool.isRequired,
maxCharCount: PropTypes.number,
comment: PropTypes.shape({
depth: PropTypes.number,
action_summaries: PropTypes.array.isRequired,
@@ -121,6 +123,8 @@ class Comment extends React.Component {
ignoreUser,
disableReply,
commentIsIgnored,
maxCharCount,
charCountEnable,
} = this.props;
const likeSummary = getActionSummary('LikeActionSummary', comment);
@@ -243,6 +247,8 @@ class Comment extends React.Component {
commentPostedHandler={() => {
setActiveReplyBox('');
}}
charCountEnable={charCountEnable}
maxCharCount={maxCharCount}
setActiveReplyBox={setActiveReplyBox}
parentId={parentId || comment.id}
addNotification={addNotification}
@@ -273,6 +279,8 @@ class Comment extends React.Component {
addCommentTag={addCommentTag}
removeCommentTag={removeCommentTag}
ignoreUser={ignoreUser}
charCountEnable={charCountEnable}
maxCharCount={maxCharCount}
showSignInDialog={showSignInDialog}
reactKey={reply.id}
key={reply.id}
+9 -1
View File
@@ -159,6 +159,10 @@ class Embed extends React.Component {
const userBox = <UserBox user={user} logout={() => this.props.logout().then(refetch)} changeTab={this.changeTab}/>;
// TODO: This is a quickfix and will be replaced after our refactor.
const ignoredUsers = this.props.userData.ignoredUsers;
const commentIsIgnored = (comment) => ignoredUsers && ignoredUsers.includes(comment.user.id);
return (
<div style={expandForLogin}>
<div className="commentStream">
@@ -210,7 +214,8 @@ class Embed extends React.Component {
isReply={false}
currentUser={this.props.auth.user}
authorId={user.id}
charCount={asset.settings.charCountEnable && asset.settings.charCount} />
charCountEnable={asset.settings.charCountEnable}
maxCharCount={asset.settings.charCount} />
: null
}
</RestrictedContent>
@@ -242,6 +247,7 @@ class Embed extends React.Component {
loadMore={this.props.loadMore}
deleteAction={this.props.deleteAction}
showSignInDialog={this.props.showSignInDialog}
commentIsIgnored={commentIsIgnored}
key={highlightedComment.id}
reactKey={highlightedComment.id}
comment={highlightedComment} />
@@ -273,6 +279,8 @@ class Embed extends React.Component {
deleteAction={this.props.deleteAction}
showSignInDialog={this.props.showSignInDialog}
comments={asset.comments}
maxCharCount={asset.settings.charCount}
charCountEnable={asset.settings.charCountEnable}
ignoredUsers={this.props.userData.ignoredUsers} />
</div>
<LoadMore
+7
View File
@@ -15,6 +15,9 @@ class Stream extends React.Component {
id: PropTypes.string
}),
charCountEnable: PropTypes.bool.isRequired,
maxCharCount: PropTypes.number,
// dispatch action to add a tag to a comment
addCommentTag: PropTypes.func,
@@ -52,6 +55,8 @@ class Stream extends React.Component {
pluginProps,
ignoreUser,
ignoredUsers,
charCountEnable,
maxCharCount,
} = this.props;
const commentIsIgnored = (comment) => ignoredUsers && ignoredUsers.includes(comment.user.id);
return (
@@ -84,6 +89,8 @@ class Stream extends React.Component {
key={comment.id}
reactKey={comment.id}
comment={comment}
maxCharCount={maxCharCount}
charCountEnable={charCountEnable}
pluginProps={pluginProps}
/>
)
+2 -2
View File
@@ -280,13 +280,13 @@ hr {
.commentActionsRight, .replyActionsRight {
display: flex;
justify-content: flex-end;
width: 50%;
width: 30%;
}
.commentActionsLeft, .replyActionsLeft {
display: flex;
justify-content: flex-start;
float: left;
width: 50%;
width: 70%;
}
.comment__action-container .material-icons {
+6 -4
View File
@@ -121,11 +121,11 @@ class CommentBox extends Component {
handleChange = e => this.setState({body: e.target.value});
render () {
const {styles, isReply, authorId, charCount} = this.props;
const {styles, isReply, authorId, maxCharCount} = this.props;
let {cancelButtonClicked} = this.props;
const length = this.state.body.length;
const enablePostComment = !length || (charCount && length > charCount);
const enablePostComment = !length || (maxCharCount && length > maxCharCount);
if (isReply && typeof cancelButtonClicked !== 'function') {
console.warn('the CommentBox component should have a cancelButtonClicked callback defined if it lives in a Reply');
@@ -150,8 +150,8 @@ class CommentBox extends Component {
onChange={this.handleChange}
rows={3}/>
</div>
<div className={`${name}-char-count ${length > charCount ? `${name}-char-max` : ''}`}>
{charCount && `${charCount - length} ${lang.t('characters-remaining')}`}
<div className={`${name}-char-count ${length > maxCharCount ? `${name}-char-max` : ''}`}>
{maxCharCount && `${maxCharCount - length} ${lang.t('characters-remaining')}`}
</div>
<div className={`${name}-button-container`}>
<Slot
@@ -186,6 +186,8 @@ class CommentBox extends Component {
}
CommentBox.propTypes = {
charCountEnable: PropTypes.bool.isRequired,
maxCharCount: PropTypes.number,
commentPostedHandler: PropTypes.func,
postItem: PropTypes.func.isRequired,
cancelButtonClicked: PropTypes.func,
+16 -1
View File
@@ -10,9 +10,22 @@ class ReplyBox extends Component {
}
render() {
const {styles, postItem, assetId, authorId, addNotification, parentId, commentPostedHandler, setActiveReplyBox} = this.props;
const {
styles,
postItem,
assetId,
authorId,
addNotification,
parentId,
commentPostedHandler,
setActiveReplyBox,
maxCharCount,
charCountEnable
} = this.props;
return <div className={`${name}-textarea`} style={styles && styles.container}>
<CommentBox
maxCharCount={maxCharCount}
charCountEnable={charCountEnable}
commentPostedHandler={commentPostedHandler}
parentId={parentId}
cancelButtonClicked={setActiveReplyBox}
@@ -26,6 +39,8 @@ class ReplyBox extends Component {
}
ReplyBox.propTypes = {
charCountEnable: PropTypes.bool.isRequired,
maxCharCount: PropTypes.number,
setActiveReplyBox: PropTypes.func.isRequired,
commentPostedHandler: PropTypes.func,
parentId: PropTypes.string,