From 0483aae3692ee7501fde32902e9ae9c76018fe6f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Sun, 3 Dec 2017 14:54:28 -0300 Subject: [PATCH 1/9] 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, From a3d83efd7de3fd30911c139ba3038883d6b6b50c Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Sun, 3 Dec 2017 15:01:06 -0300 Subject: [PATCH 2/9] Styling and functionality --- .../coral-admin/src/components/UserDetail.css | 8 ++++++++ client/coral-admin/src/components/UserDetail.js | 17 +++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/client/coral-admin/src/components/UserDetail.css b/client/coral-admin/src/components/UserDetail.css index 8b86a133c..e62f584c4 100644 --- a/client/coral-admin/src/components/UserDetail.css +++ b/client/coral-admin/src/components/UserDetail.css @@ -163,4 +163,12 @@ &.selected { background-color: #efefef; } +} + +.username { + display: inline-block; +} + +.actionsMenu { + display: inline-block; } \ No newline at end of file diff --git a/client/coral-admin/src/components/UserDetail.js b/client/coral-admin/src/components/UserDetail.js index c43d39ac7..49543a534 100644 --- a/client/coral-admin/src/components/UserDetail.js +++ b/client/coral-admin/src/components/UserDetail.js @@ -71,13 +71,13 @@ class UserDetail extends React.Component { } showSuspenUserDialog = () => this.props.showSuspendUserDialog({ - userId: this.props.user.id, - username: this.props.user.username, + userId: this.props.root.user.id, + username: this.props.root.user.username, }); showBanUserDialog = () => this.props.showBanUserDialog({ - userId: this.props.user.id, - username: this.props.user.username, + userId: this.props.root.user.id, + username: this.props.root.user.username, }); renderLoading() { @@ -119,10 +119,12 @@ class UserDetail extends React.Component { return ( -

{user.username}

+

+ {user.username} +

- {user.id !== user.id && - + {user.id && + @@ -251,7 +253,6 @@ class UserDetail extends React.Component { } UserDetail.propTypes = { - user: PropTypes.object.isRequired, hideUserDetail: PropTypes.func.isRequired, root: PropTypes.object.isRequired, acceptComment: PropTypes.func.isRequired, From 6557c6036f958835579f98fed994d77b61ccd747 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Sun, 3 Dec 2017 15:48:37 -0300 Subject: [PATCH 3/9] Functionality and styling --- .../src/components/ActionsMenu.css | 13 ++++---- .../coral-admin/src/components/ActionsMenu.js | 8 +++-- .../coral-admin/src/components/UserDetail.css | 12 +++++++ .../coral-admin/src/components/UserDetail.js | 32 +++++++++++++++---- .../coral-admin/src/containers/UserDetail.js | 1 + package.json | 2 +- yarn.lock | 12 +++---- 7 files changed, 57 insertions(+), 23 deletions(-) diff --git a/client/coral-admin/src/components/ActionsMenu.css b/client/coral-admin/src/components/ActionsMenu.css index 1d2f91f74..cd127790f 100644 --- a/client/coral-admin/src/components/ActionsMenu.css +++ b/client/coral-admin/src/components/ActionsMenu.css @@ -6,11 +6,9 @@ .root { color: black; + vertical-align: super; > :global(.mdl-menu__container) { margin-left: 10px; - > :global(.mdl-menu__outline) { - box-shadow: none; - } } } @@ -18,6 +16,7 @@ box-shadow: none; color: white; background-color: #616161; + border-color: #616161; } .arrowIcon { @@ -33,8 +32,10 @@ } .menuItem { - background-color: #2a2a2a; - color: white; + color: #2a2a2a; + background-color: white; + font-size: 0.95em; + &:first-child { margin-bottom: 1px; border-radius: 2px 2px 0px 0px; @@ -43,7 +44,7 @@ border-radius: 0px 0px 2px 2px; } &:hover, &:active, &:focus { - background-color: #767676; + background-color: #e2e2e2; } &[disabled], &[disabled]:hover, &[disabled]:focus, &[disabled]:active { background-color: #262626; diff --git a/client/coral-admin/src/components/ActionsMenu.js b/client/coral-admin/src/components/ActionsMenu.js index 6351afda7..ef4e46573 100644 --- a/client/coral-admin/src/components/ActionsMenu.js +++ b/client/coral-admin/src/components/ActionsMenu.js @@ -32,18 +32,18 @@ class ActionsMenu extends React.Component { }; render() { - const {className = ''} = this.props; + const {className = '', buttonClassNames = '', label = ''} = this.props; return (