From e0e481373bddee6ac0d1fe84dc5f78239d5a8293 Mon Sep 17 00:00:00 2001 From: Facu Date: Thu, 12 Oct 2017 17:59:04 -0300 Subject: [PATCH 1/4] bulk approve/reject actions for moderators --- client/coral-admin/src/actions/userDetail.js | 6 + .../coral-admin/src/components/UserDetail.css | 192 ++++++++++-------- .../coral-admin/src/components/UserDetail.js | 101 +++++---- .../coral-admin/src/constants/userDetail.js | 2 +- .../coral-admin/src/containers/UserDetail.js | 3 + client/coral-admin/src/reducers/userDetail.js | 5 + 6 files changed, 189 insertions(+), 120 deletions(-) diff --git a/client/coral-admin/src/actions/userDetail.js b/client/coral-admin/src/actions/userDetail.js index f8b22008c..3a1de5745 100644 --- a/client/coral-admin/src/actions/userDetail.js +++ b/client/coral-admin/src/actions/userDetail.js @@ -20,3 +20,9 @@ export const toggleSelectCommentInUserDetail = (id, active) => { }; }; +export const toggleSelectAllCommentInUserDetail = (ids, active) => { + return { + type: active ? actions.SELECT_ALL_USER_DETAIL_COMMENT : actions.CLEAR_USER_DETAIL_SELECTIONS, + ids + }; +}; diff --git a/client/coral-admin/src/components/UserDetail.css b/client/coral-admin/src/components/UserDetail.css index 5cbe0fe32..fbde4a626 100644 --- a/client/coral-admin/src/components/UserDetail.css +++ b/client/coral-admin/src/components/UserDetail.css @@ -1,144 +1,168 @@ .copyButton { - background-color: white; - border: solid 1px; - padding: 2px 6px; - height: auto; - line-height: initial; - min-width: auto; - letter-spacing: normal; - font-size: 0.9em; - margin-left: 10px; + background-color: white; + border: solid 1px; + padding: 2px 6px; + height: auto; + line-height: initial; + min-width: auto; + letter-spacing: normal; + font-size: 0.9em; + margin-left: 10px; } .userDetailList { - list-style: none; - padding: 0; - margin: 0; + list-style: none; + padding: 0; + margin: 0; } .userDetailItem { - margin: 0 5px; - font-weight: 500; + margin: 0 5px; + font-weight: 500; } .stats { - display: flex; - list-style: none; - padding: 0; - margin: 0; - text-align: center; - margin: 15px 0 5px; - color: #595959; + display: flex; + list-style: none; + padding: 0; + margin: 0; + text-align: center; + margin: 15px 0 5px; + color: #595959; } .stat { - margin-right: 20px; + margin-right: 20px; } .stat:last-child { - margin-right: 0px; + margin-right: 0px; } .statItem, .statReportResult { - padding: 3px 5px; - background-color: #D8D8D8; - border-radius: 3px; - font-weight: 500; - display: block; - font-size: 0.9em; - line-height: normal; - letter-spacing: 0.4px; - min-width: 60px; + padding: 3px 5px; + background-color: #D8D8D8; + border-radius: 3px; + font-weight: 500; + display: block; + font-size: 0.9em; + line-height: normal; + letter-spacing: 0.4px; + min-width: 60px; } .statResult { - font-size: 1.5em; - padding: 5px 0; - display: inline-block; + font-size: 1.5em; + padding: 5px 0; + display: inline-block; } .statReportResult { - color: white; - margin: 5px 0; - font-weight: 400; + color: white; + margin: 5px 0; + font-weight: 400; } .statReportResult.reliable { - background-color: #749C48; + background-color: #749C48; } .statReportResult.neutral { - background-color: #616161; + background-color: #616161; } .statReportResult.unreliable { - background-color: #F44336; + background-color: #F44336; } .memberSince { - clear: both; + clear: both; } .small { - color: #888888; - font-size: 0.9em; - letter-spacing: 0.4px; + color: #888888; + font-size: 0.9em; + letter-spacing: 0.4px; } .profileEmail { - border: none; - background-color: transparent; - font-size: 16px; - outline: none; - width: calc(100% - 90px); + border: none; + background-color: transparent; + font-size: 16px; + outline: none; + width: calc(100% - 90px); } .commentStatuses { - padding: 10px 0 0 0; - margin: 0; - height: 52px; - list-style: none; - box-sizing: border-box; - - li { - display: inline-block; - margin-right: 10px; - cursor: pointer; - padding: 0 10px; - } + padding: 0 0 0 10px; + margin: 0; + align-self: center; + list-style: none; + box-sizing: border-box; + li { + display: inline-block; + margin-right: 10px; + cursor: pointer; + padding: 0 10px; + } } .active { - font-weight: bold; - border-bottom: 3px solid #F36451; + font-weight: bold; + border-bottom: 3px solid #F36451; } .bulkActionGroup { - height: 52px; - background-color: #efefef; + height: 52px; + background-color: #efefef; + padding: 0 0 0 10px; + display: flex; + i { + margin-right: 0; + } - i { - margin-right: 0; - } + .bulkAction { + display: inline-block; + width: 48px; + height: 48px; + transform: scale(.7); + min-width: 0; + } - .bulkAction { - display: inline-block; - width: 48px; - height: 48px; - transform: scale(.7); - min-width: 0; - } + .bulkAction:last-child { + margin-left: -10px; + } - .bulkAction:last-child { - margin-left: -10px; - } + span{ + align-self: center; + font-weight: 500; + margin-left: 15px; + } } .loadMore > button { - background-color: #696969; + background-color: #696969; - &:hover { - background-color: #404040; - color: white; - } + &:hover { + background-color: #404040; + color: white; + } } + +.toggleAll { + padding: 0 10px 0 0; + align-self: center; +} + +.commentList { + clear: both; +} + +.bulkActionHeader{ + display: flex; + justify-content: space-between; + height: 52px; + &.selected{ + background-color: #efefef; + } +} \ 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 275503085..ab609fbfb 100644 --- a/client/coral-admin/src/components/UserDetail.js +++ b/client/coral-admin/src/components/UserDetail.js @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import Comment from '../containers/UserDetailComment'; import styles from './UserDetail.css'; -import {Icon, Button, Drawer, Spinner} from 'coral-ui'; +import {Icon, Drawer, Spinner} from 'coral-ui'; import {Slot} from 'coral-framework/components'; import ButtonCopyToClipboard from './ButtonCopyToClipboard'; import ClickOutside from 'coral-framework/components/ClickOutside'; @@ -10,6 +10,8 @@ import LoadMore from '../components/LoadMore'; import cn from 'classnames'; import capitalize from 'lodash/capitalize'; import {getReliability} from 'coral-framework/utils/user'; +import ApproveButton from './ApproveButton'; +import RejectButton from './RejectButton'; export default class UserDetail extends React.Component { @@ -23,6 +25,7 @@ export default class UserDetail extends React.Component { toggleSelect: PropTypes.func.isRequired, bulkAccept: PropTypes.func.isRequired, bulkReject: PropTypes.func.isRequired, + toggleSelectAll: PropTypes.func.isRequired } rejectThenReload = async (info) => { @@ -47,6 +50,28 @@ export default class UserDetail extends React.Component { } } + bulkAcceptThenReload = async () => { + try { + await this.props.bulkAccept(); + this.props.data.refetch(); + } catch (err) { + + // TODO: handle error. + console.error(err); + } + } + + bulkRejectThenReload = async () => { + try { + await this.props.bulkReject(); + this.props.data.refetch(); + } catch (err) { + + // TODO: handle error. + console.error(err); + } + } + showAll = () => { this.props.changeStatus('all'); } @@ -78,11 +103,10 @@ export default class UserDetail extends React.Component { activeTab, selectedCommentIds, toggleSelect, - bulkAccept, - bulkReject, hideUserDetail, viewUserDetail, loadMore, + toggleSelectAll } = this.props; let rejectedPercent = (rejectedComments / totalComments) * 100; @@ -100,14 +124,14 @@ export default class UserDetail extends React.Component {