import React, {PropTypes} from 'react'; import Comment from './UserDetailComment'; import styles from './UserDetail.css'; import {Button, Drawer, Spinner} from 'coral-ui'; import {Slot} from 'coral-framework/components'; import ButtonCopyToClipboard from './ButtonCopyToClipboard'; import {actionsMap} from '../utils/moderationQueueActionsMap'; import ClickOutside from 'coral-framework/components/ClickOutside'; export default class UserDetail extends React.Component { static propTypes = { id: PropTypes.string.isRequired, hideUserDetail: PropTypes.func.isRequired, root: PropTypes.object.isRequired, bannedWords: PropTypes.array.isRequired, suspectWords: PropTypes.array.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, } rejectThenReload = (info) => { this.props.rejectComment(info).then(() => { this.props.data.refetch(); }); } acceptThenReload = (info) => { this.props.acceptComment(info).then(() => { this.props.data.refetch(); }); } showAll = () => { this.props.changeStatus('all'); } showRejected = () => { this.props.changeStatus('rejected'); } renderLoading() { return ( ); } renderLoaded() { const { root: { user, totalComments, rejectedComments, comments: {nodes} }, activeTab, selectedIds, bannedWords, suspectWords, toggleSelect, bulkAccept, bulkReject, hideUserDetail, viewUserDetail, } = this.props; const localProfile = user.profiles.find((p) => p.provider === 'local'); let profile; if (localProfile) { profile = localProfile.id; } let rejectedPercent = (rejectedComments / totalComments) * 100; if (rejectedPercent === Infinity || isNaN(rejectedPercent)) { // if totalComments is 0, you're dividing by zero, which is naughty rejectedPercent = 0; } return (

{user.username}

{profile && this.profile = ref} value={profile} />}

Member since {new Date(user.created_at).toLocaleString()}


Account summary
Data represents the last six months of activity

Total Comments

{totalComments}

Reject Rate

{`${(rejectedPercent).toFixed(1)}%`}

{ selectedIds.length === 0 ? (
  • All
  • Rejected
) : (
{`${selectedIds.length} comments selected`}
) }
{ nodes.map((comment) => { const status = comment.action_summaries ? 'FLAGGED' : comment.status; const selected = selectedIds.indexOf(comment.id) !== -1; return ; }) }
); } render () { if (this.props.loading) { return this.renderLoading(); } return this.renderLoaded(); } }