From 6e458e01491bfa4fd8731d1b3ec9949ad4ad6518 Mon Sep 17 00:00:00 2001 From: riley Date: Wed, 31 May 2017 10:54:34 -0600 Subject: [PATCH] resolve missing files --- .../Moderation/components/UserDetail.js | 114 ++++++++++++++++++ .../Moderation/containers/UserDetail.js | 3 + 2 files changed, 117 insertions(+) create mode 100644 client/coral-admin/src/routes/Moderation/components/UserDetail.js diff --git a/client/coral-admin/src/routes/Moderation/components/UserDetail.js b/client/coral-admin/src/routes/Moderation/components/UserDetail.js new file mode 100644 index 000000000..2fe9730b9 --- /dev/null +++ b/client/coral-admin/src/routes/Moderation/components/UserDetail.js @@ -0,0 +1,114 @@ +import React, {PropTypes} from 'react'; +import {Button, Drawer} from 'coral-ui'; +import styles from './UserDetail.css'; +import Slot from 'coral-framework/components/Slot'; +import Comment from './Comment'; +import {actionsMap} from '../helpers/moderationQueueActionsMap'; + +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, + showBanUserDialog: PropTypes.func.isRequired, + showSuspendUserDialog: PropTypes.func.isRequired, + acceptComment: PropTypes.func.isRequired, + rejectComment: PropTypes.func.isRequired, + } + + copyPermalink = () => { + this.profile.select(); + try { + document.execCommand('copy'); + } catch (e) { + + /* nothing */ + } + } + + render () { + const { + root: { + user, + totalComments, + rejectedComments, + comments + }, + bannedWords, + suspectWords, + showBanUserDialog, + showSuspendUserDialog, + acceptComment, + rejectComment, + hideUserDetail + } = this.props; + const localProfile = user.profiles.find((p) => p.provider === 'local'); + + let profile; + if (localProfile) { + profile = localProfile.id; + } + + let rejectedPercent = rejectedComments / totalComments; + 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)}%`}

+
+
+
+ { + comments.map((comment, i) => { + const status = comment.action_summaries ? 'FLAGGED' : comment.status; + return {}} + actions={actionsMap[status]} + showBanUserDialog={showBanUserDialog} + showSuspendUserDialog={showSuspendUserDialog} + acceptComment={acceptComment} + rejectComment={rejectComment} + currentAsset={null} + currentUserId={this.props.id} + minimal={true} />; + }) + } +
+
+ ); + } +} diff --git a/client/coral-admin/src/routes/Moderation/containers/UserDetail.js b/client/coral-admin/src/routes/Moderation/containers/UserDetail.js index d6ab06af6..7a030fb86 100644 --- a/client/coral-admin/src/routes/Moderation/containers/UserDetail.js +++ b/client/coral-admin/src/routes/Moderation/containers/UserDetail.js @@ -45,8 +45,11 @@ export const withUserDetailQuery = withQuery(gql` }) { ...${getDefinitionName(Comment.fragments.comment)} } + ...${getDefinitionName(Comment.fragments.root)} ${pluginFragments.spreads('root')} } + ${Comment.fragments.root} + ${Comment.fragments.comment} ${pluginFragments.definitions('user')} ${pluginFragments.definitions('root')} `, {