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..8b86a133c 100644 --- a/client/coral-admin/src/components/UserDetail.css +++ b/client/coral-admin/src/components/UserDetail.css @@ -39,7 +39,8 @@ margin-right: 0px; } -.statItem, .statReportResult { +.statItem, +.statReportResult { padding: 3px 5px; background-color: #D8D8D8; border-radius: 3px; @@ -48,7 +49,7 @@ font-size: 0.9em; line-height: normal; letter-spacing: 0.4px; - min-width: 60px; + min-width: 60px; } .statResult { @@ -94,12 +95,11 @@ } .commentStatuses { - padding: 10px 0 0 0; + padding: 0 0 0 10px; margin: 0; - height: 52px; + align-self: center; list-style: none; box-sizing: border-box; - li { display: inline-block; margin-right: 10px; @@ -116,11 +116,11 @@ .bulkActionGroup { height: 52px; background-color: #efefef; - + padding: 0 0 0 10px; + display: flex; i { margin-right: 0; } - .bulkAction { display: inline-block; width: 48px; @@ -128,17 +128,39 @@ transform: scale(.7); min-width: 0; } - .bulkAction:last-child { margin-left: -10px; } } -.loadMore > button { - background-color: #696969; +.selectedCommentsInfo { + align-self: center; + font-weight: 500; + margin-left: 15px; +} +.loadMore>button { + background-color: #696969; &: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 4d9ed3cc6..1c6362791 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,9 @@ 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'; +import {getErrorMessages} from 'coral-framework/utils'; export default class UserDetail extends React.Component { @@ -23,6 +26,7 @@ export default class UserDetail extends React.Component { 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, @@ -30,7 +34,8 @@ export default class UserDetail extends React.Component { activeTab: PropTypes.string.isRequired, selectedCommentIds: PropTypes.array.isRequired, viewUserDetail: PropTypes.any.isRequired, - loadMore: PropTypes.any.isRequired + loadMore: PropTypes.any.isRequired, + notify: PropTypes.func.isRequired } rejectThenReload = async (info) => { @@ -41,6 +46,7 @@ export default class UserDetail extends React.Component { // TODO: handle error. console.error(err); + this.props.notify('error', getErrorMessages(err)); } } @@ -52,6 +58,31 @@ export default class UserDetail extends React.Component { // TODO: handle error. console.error(err); + this.props.notify('error', getErrorMessages(err)); + } + } + + bulkAcceptThenReload = async () => { + try { + await this.props.bulkAccept(); + this.props.data.refetch(); + } catch (err) { + + // TODO: handle error. + console.error(err); + this.props.notify('error', getErrorMessages(err)); + } + } + + bulkRejectThenReload = async () => { + try { + await this.props.bulkReject(); + this.props.data.refetch(); + } catch (err) { + + // TODO: handle error. + console.error(err); + this.props.notify('error', getErrorMessages(err)); } } @@ -86,11 +117,10 @@ export default class UserDetail extends React.Component { activeTab, selectedCommentIds, toggleSelect, - bulkAccept, - bulkReject, hideUserDetail, viewUserDetail, loadMore, + toggleSelectAll } = this.props; let rejectedPercent = (rejectedComments / totalComments) * 100; @@ -108,14 +138,14 @@ export default class UserDetail extends React.Component {