From 0483aae3692ee7501fde32902e9ae9c76018fe6f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Sun, 3 Dec 2017 14:54:28 -0300 Subject: [PATCH] Moving ActionsMenu --- .../coral-admin/src/actions/banUserDialog.js | 1 - .../coral-admin/src/components/UserDetail.js | 77 +++++++++++++------ .../coral-admin/src/containers/UserDetail.js | 4 + .../Community/components/FlaggedAccounts.js | 6 -- .../Community/components/FlaggedUser.js | 31 +------- .../Community/containers/FlaggedAccounts.js | 8 -- .../routes/Moderation/components/Comment.js | 38 --------- .../Moderation/components/Moderation.js | 4 - .../Moderation/components/ModerationQueue.js | 6 -- .../Moderation/containers/Moderation.js | 5 -- 10 files changed, 60 insertions(+), 120 deletions(-) diff --git a/client/coral-admin/src/actions/banUserDialog.js b/client/coral-admin/src/actions/banUserDialog.js index 8b068051c..8134318cb 100644 --- a/client/coral-admin/src/actions/banUserDialog.js +++ b/client/coral-admin/src/actions/banUserDialog.js @@ -4,4 +4,3 @@ export const showBanUserDialog = ({userId, username, commentId, commentStatus}) ({type: SHOW_BAN_USER_DIALOG, userId, username, commentId, commentStatus}); export const hideBanUserDialog = () => ({type: HIDE_BAN_USER_DIALOG}); - diff --git a/client/coral-admin/src/components/UserDetail.js b/client/coral-admin/src/components/UserDetail.js index 140774eae..c43d39ac7 100644 --- a/client/coral-admin/src/components/UserDetail.js +++ b/client/coral-admin/src/components/UserDetail.js @@ -13,30 +13,10 @@ import {getReliability} from 'coral-framework/utils/user'; import ApproveButton from './ApproveButton'; import RejectButton from './RejectButton'; import {getErrorMessages} from 'coral-framework/utils'; +import ActionsMenu from 'coral-admin/src/components/ActionsMenu'; +import ActionsMenuItem from 'coral-admin/src/components/ActionsMenuItem'; -export default class UserDetail extends React.Component { - - static propTypes = { - userId: PropTypes.string.isRequired, - hideUserDetail: PropTypes.func.isRequired, - root: PropTypes.object.isRequired, - acceptComment: PropTypes.func.isRequired, - rejectComment: PropTypes.func.isRequired, - changeStatus: PropTypes.func.isRequired, - toggleSelect: PropTypes.func.isRequired, - bulkAccept: PropTypes.func.isRequired, - bulkReject: PropTypes.func.isRequired, - toggleSelectAll: PropTypes.func.isRequired, - loading: PropTypes.bool.isRequired, - data: PropTypes.shape({ - refetch: PropTypes.func.isRequired, - }), - activeTab: PropTypes.string.isRequired, - selectedCommentIds: PropTypes.array.isRequired, - viewUserDetail: PropTypes.any.isRequired, - loadMore: PropTypes.any.isRequired, - notify: PropTypes.func.isRequired - } +class UserDetail extends React.Component { rejectThenReload = async (info) => { try { @@ -90,6 +70,16 @@ export default class UserDetail extends React.Component { this.props.changeStatus('rejected'); } + showSuspenUserDialog = () => this.props.showSuspendUserDialog({ + userId: this.props.user.id, + username: this.props.user.username, + }); + + showBanUserDialog = () => this.props.showBanUserDialog({ + userId: this.props.user.id, + username: this.props.user.username, + }); + renderLoading() { return ( @@ -131,6 +121,21 @@ export default class UserDetail extends React.Component {

{user.username}

+ {user.id !== user.id && + + + Suspend User + + + Ban User + + + } +
  • @@ -244,3 +249,29 @@ export default class UserDetail extends React.Component { return this.renderLoaded(); } } + +UserDetail.propTypes = { + user: PropTypes.object.isRequired, + hideUserDetail: PropTypes.func.isRequired, + root: PropTypes.object.isRequired, + acceptComment: PropTypes.func.isRequired, + rejectComment: PropTypes.func.isRequired, + changeStatus: PropTypes.func.isRequired, + toggleSelect: PropTypes.func.isRequired, + bulkAccept: PropTypes.func.isRequired, + bulkReject: PropTypes.func.isRequired, + toggleSelectAll: PropTypes.func.isRequired, + loading: PropTypes.bool.isRequired, + data: PropTypes.shape({ + refetch: PropTypes.func.isRequired, + }), + activeTab: PropTypes.string.isRequired, + selectedCommentIds: PropTypes.array.isRequired, + viewUserDetail: PropTypes.any.isRequired, + loadMore: PropTypes.any.isRequired, + notify: PropTypes.func.isRequired, + showSuspendUserDialog: PropTypes.func, + showBanUserDialog: PropTypes.func, +}; + +export default UserDetail; diff --git a/client/coral-admin/src/containers/UserDetail.js b/client/coral-admin/src/containers/UserDetail.js index 3a458ff83..5fc84708f 100644 --- a/client/coral-admin/src/containers/UserDetail.js +++ b/client/coral-admin/src/containers/UserDetail.js @@ -17,6 +17,8 @@ import {withSetCommentStatus} from 'coral-framework/graphql/mutations'; import UserDetailComment from './UserDetailComment'; import update from 'immutability-helper'; import {notify} from 'coral-framework/actions/notification'; +import {showBanUserDialog} from 'actions/banUserDialog'; +import {showSuspendUserDialog} from 'actions/suspendUserDialog'; const commentConnectionFragment = gql` fragment CoralAdmin_Moderation_CommentConnection on CommentConnection { @@ -181,6 +183,8 @@ const mapStateToProps = (state) => ({ const mapDispatchToProps = (dispatch) => ({ ...bindActionCreators({ + showBanUserDialog, + showSuspendUserDialog, changeUserDetailStatuses, clearUserDetailSelections, toggleSelectCommentInUserDetail, diff --git a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js index cbfd903c6..1d01e1714 100644 --- a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js @@ -13,8 +13,6 @@ class FlaggedAccounts extends React.Component { const { users, loadMore, - showBanUserDialog, - showSuspendUserDialog, showRejectUsernameDialog, approveUser, me, @@ -48,8 +46,6 @@ class FlaggedAccounts extends React.Component { this.props.showSuspendUserDialog({ - userId: this.props.user.id, - username: this.props.user.username, - }); - - showBanUserDialog = () => this.props.showBanUserDialog({ - userId: this.props.user.id, - username: this.props.user.username, - }); - viewAuthorDetail = () => this.props.viewUserDetail(this.props.user.id); + showRejectUsernameDialog = () => this.props.showRejectUsernameDialog({id: this.props.user.id}); + approveUser = () => this.props.approveUser({ userId: this.props.user.id, }); @@ -40,7 +30,6 @@ class User extends React.Component { user, viewUserDetail, selected, - me, className, } = this.props; @@ -55,20 +44,6 @@ class User extends React.Component { className={styles.button}> {user.username} - {me.id !== user.id && - - - Suspend User - - - Ban User - - - }
@@ -136,8 +111,6 @@ class User extends React.Component { } User.propTypes = { - showSuspendUserDialog: PropTypes.func, - showBanUserDialog: PropTypes.func, viewUserDetail: PropTypes.func, showRejectUsernameDialog: PropTypes.func, approveUser: PropTypes.func, diff --git a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js index b7f918d8c..cfd2ea8e9 100644 --- a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js @@ -7,8 +7,6 @@ import {Spinner} from 'coral-ui'; import PropTypes from 'prop-types'; import {withSetUserStatus} from 'coral-framework/graphql/mutations'; -import {showBanUserDialog} from 'actions/banUserDialog'; -import {showSuspendUserDialog} from 'actions/suspendUserDialog'; import {showRejectUsernameDialog} from '../../../actions/community'; import {viewUserDetail} from '../../../actions/userDetail'; import {getDefinitionName} from 'coral-framework/utils'; @@ -63,8 +61,6 @@ class FlaggedAccountsContainer extends Component { } return ( bindActionCreators({ - showBanUserDialog, - showSuspendUserDialog, showRejectUsernameDialog, viewUserDetail, }, dispatch); diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index cea49720b..362e7189d 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -8,8 +8,6 @@ import styles from './Comment.css'; import CommentLabels from 'coral-admin/src/components/CommentLabels'; import CommentAnimatedEdit from 'coral-admin/src/components/CommentAnimatedEdit'; import Slot from 'coral-framework/components/Slot'; -import ActionsMenu from 'coral-admin/src/components/ActionsMenu'; -import ActionsMenuItem from 'coral-admin/src/components/ActionsMenuItem'; import CommentBodyHighlighter from 'coral-admin/src/components/CommentBodyHighlighter'; import IfHasLink from 'coral-admin/src/components/IfHasLink'; import cn from 'classnames'; @@ -20,26 +18,6 @@ import t, {timeago} from 'coral-framework/services/i18n'; class Comment extends React.Component { - showSuspendUserDialog = () => { - 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); @@ -63,7 +41,6 @@ class Comment extends React.Component { data, root, root: {settings}, - currentUserId, currentAsset, } = this.props; @@ -94,19 +71,6 @@ class Comment extends React.Component { ?  ({t('comment.edited')}) : null } - {currentUserId !== comment.user.id && - - - Suspend User - - Ban User - - - }
({ ...bindActionCreators({ toggleModal, singleView, - showBanUserDialog, hideShortcutsNote, toggleStorySearch, - showSuspendUserDialog, viewUserDetail, setSortOrder, storySearchChange,