From 58a5d5eea835297b2cece69a9e82973e0e854521 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 18 Aug 2017 23:20:05 +0700 Subject: [PATCH] Refactor Moderation Comment a little bit --- .../routes/Moderation/components/Comment.js | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index 60077e80a..8d543e97b 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -20,6 +20,31 @@ import t, {timeago} from 'coral-framework/services/i18n'; class Comment extends React.Component { + showSuspenUserDialog = () => { + const {comment, showSuspendUserDialog} = this.props; + return showSuspendUserDialog({ + userId: comment.user.id, + username: comment.user.username, + commentId: comment.id, + commentStatus: comment.status, + }); + }; + + showBanUserDialog = () => { + const {comment, showBanUserDialog} = this.props; + return showBanUserDialog({ + userId: comment.user.id, + username: comment.user.username, + commentId: comment.id, + commentStatus: comment.status, + }); + }; + + viewUserDetail = () => { + const {viewUserDetail, comment} = this.props; + return viewUserDetail(comment.user.id); + }; + render() { const { actions = [], @@ -43,20 +68,6 @@ class Comment extends React.Component { let selectionStateCSS = selected ? 'mdl-shadow--16dp' : 'mdl-shadow--2dp'; - const showSuspenUserDialog = () => this.props.showSuspendUserDialog({ - userId: comment.user.id, - username: comment.user.username, - commentId: comment.id, - commentStatus: comment.status, - }); - - const showBanUserDialog = () => this.props.showBanUserDialog({ - userId: comment.user.id, - username: comment.user.username, - commentId: comment.id, - commentStatus: comment.status, - }); - const queryData = {root, comment, asset: comment.asset}; return ( @@ -69,7 +80,7 @@ class Comment extends React.Component {
{ ( - viewUserDetail(comment.user.id)}> + {comment.user.username} ) @@ -86,11 +97,11 @@ class Comment extends React.Component { + onClick={this.showSuspenUserDialog}> Suspend User + onClick={this.showBanUserDialog}> Ban User