Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions client/coral-admin/src/components/CommentLabels.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.root {
display: flex;
justify-content: flex-end;
}

.coreLabels {
> *:not(:last-child) {
margin-right: 3px;
}
}

.slot {
&:not(:empty) {
padding-left: 3px;
}
> *:not(:last-child) {
margin-right: 3px;
}
}

.replyLabel {
background-color: #3D73D5;
}

.premodLabel {
background-color: #063B9A;
}
45 changes: 45 additions & 0 deletions client/coral-admin/src/components/CommentLabels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import PropTypes from 'prop-types';
import Label from 'coral-ui/components/Label';
import Slot from 'coral-framework/components/Slot';
import FlagLabel from 'coral-ui/components/FlagLabel';
import cn from 'classnames';
import styles from './CommentLabels.css';

function isUserFlagged(actions) {
return actions.some((action) => action.__typename === 'FlagAction' && action.user);
}

function hasSuspectedWords(actions) {
return actions.some((action) => action.__typename === 'FlagAction' && action.reason === 'Matched suspect word filter');
}

function hasHistoryFlag(actions) {
return actions.some((action) => action.__typename === 'FlagAction' && action.reason === 'TRUST');
}

const CommentLabels = ({comment, comment: {className, status, actions, hasParent}}) => {
return (
<div className={cn(className, styles.root)}>
<div className={styles.coreLabels}>
{hasParent && <Label iconName="reply" className={styles.replyLabel}>reply</Label>}
{status === 'PREMOD' && <Label iconName="query_builder" className={styles.premodLabel}>Pre-Mod</Label>}
{isUserFlagged(actions) && <FlagLabel iconName="person">User</FlagLabel>}
{hasSuspectedWords(actions) && <FlagLabel iconName="sms_failed">Suspect</FlagLabel>}
{hasHistoryFlag(actions) && <FlagLabel iconName="sentiment_very_dissatisfied">History</FlagLabel>}
</div>
<Slot className={styles.slot} fill="adminCommentLabels" queryData={{comment}} />
</div>
);
};

CommentLabels.propTypes = {
comment: PropTypes.shape({
className: PropTypes.string,
status: PropTypes.string,
actions: PropTypes.array,
hasParent: PropTypes.bool,
}),
};

export default CommentLabels;
30 changes: 0 additions & 30 deletions client/coral-admin/src/components/CommentType.css

This file was deleted.

32 changes: 0 additions & 32 deletions client/coral-admin/src/components/CommentType.js

This file was deleted.

11 changes: 0 additions & 11 deletions client/coral-admin/src/components/ReplyBadge.js

This file was deleted.

2 changes: 1 addition & 1 deletion client/coral-admin/src/components/UserDetailComment.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
position: relative;
}

.badgeBar {
.labels {
position: absolute;
right: 0px;
}
Expand Down
10 changes: 3 additions & 7 deletions client/coral-admin/src/components/UserDetailComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ import {Link} from 'react-router';

import {Icon} from 'coral-ui';
import FlagBox from './FlagBox';
import ReplyBadge from './ReplyBadge';
import styles from './UserDetailComment.css';
import CommentType from './CommentType';
import {getActionSummary} from 'coral-framework/utils';
import ActionButton from 'coral-admin/src/components/ActionButton';
import CommentBodyHighlighter from 'coral-admin/src/components/CommentBodyHighlighter';
import IfHasLink from 'coral-admin/src/components/IfHasLink';
import cn from 'classnames';
import {getCommentType} from 'coral-admin/src/utils/comment';
import CommentAnimatedEdit from './CommentAnimatedEdit';
import CommentLabels from '../containers/CommentLabels';

import t, {timeago} from 'coral-framework/services/i18n';

Expand All @@ -35,7 +33,6 @@ class UserDetailComment extends React.Component {

const flagActionSummaries = getActionSummary('FlagActionSummary', comment);
const flagActions = comment.actions && comment.actions.filter((a) => a.__typename === 'FlagAction');
const commentType = getCommentType(comment);

return (
<li
Expand All @@ -59,9 +56,8 @@ class UserDetailComment extends React.Component {
: null
}

<div className={styles.badgeBar}>
{comment.hasParent && <ReplyBadge/>}
<CommentType type={commentType}/>
<div className={styles.labels}>
<CommentLabels comment={comment} />
</div>
</div>
<div className={styles.story}>
Expand Down
27 changes: 27 additions & 0 deletions client/coral-admin/src/containers/CommentLabels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {gql} from 'react-apollo';
import CommentLabels from '../components/CommentLabels';
import withFragments from 'coral-framework/hocs/withFragments';
import {getSlotFragmentSpreads} from 'coral-framework/utils';

const slots = [
'adminCommentLabels',
];

export default withFragments({
comment: gql`
fragment CoralAdmin_CommentLabels_comment on Comment {
hasParent
status
actions {
__typename
... on FlagAction {
reason
}
user {
id
}
}
${getSlotFragmentSpreads(slots, 'comment')}
}
`
})(CommentLabels);
4 changes: 4 additions & 0 deletions client/coral-admin/src/containers/UserDetailComment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {gql} from 'react-apollo';
import UserDetailComment from '../components/UserDetailComment';
import withFragments from 'coral-framework/hocs/withFragments';
import {getDefinitionName} from 'coral-framework/utils';
import CommentLabels from './CommentLabels';

export default withFragments({
comment: gql`
Expand Down Expand Up @@ -35,6 +37,8 @@ export default withFragments({
editing {
edited
}
...${getDefinitionName(CommentLabels.fragments.comment)}
}
${CommentLabels.fragments.comment}
`
})(UserDetailComment);
10 changes: 4 additions & 6 deletions client/coral-admin/src/routes/Moderation/components/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import PropTypes from 'prop-types';
import {Link} from 'react-router';

import {Icon} from 'coral-ui';
import ReplyBadge from 'coral-admin/src/components/ReplyBadge';
import FlagBox from 'coral-admin/src/components/FlagBox';
import styles from './styles.css';
import CommentType from 'coral-admin/src/components/CommentType';
import CommentLabels from 'coral-admin/src/components/CommentLabels';
import CommentAnimatedEdit from 'coral-admin/src/components/CommentAnimatedEdit';
import Slot from 'coral-framework/components/Slot';
import {getActionSummary} from 'coral-framework/utils';
Expand All @@ -16,7 +15,6 @@ 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';
import {getCommentType} from 'coral-admin/src/utils/comment';

import t, {timeago} from 'coral-framework/services/i18n';

Expand Down Expand Up @@ -66,7 +64,6 @@ class Comment extends React.Component {

const flagActionSummaries = getActionSummary('FlagActionSummary', comment);
const flagActions = comment.actions && comment.actions.filter((a) => a.__typename === 'FlagAction');
const commentType = getCommentType(comment);

const selectionStateCSS = selected ? 'mdl-shadow--16dp' : 'mdl-shadow--2dp';

Expand Down Expand Up @@ -109,8 +106,9 @@ class Comment extends React.Component {
</ActionsMenu>
}
<div className={styles.adminCommentInfoBar}>
{comment.hasParent && <ReplyBadge/>}
<CommentType type={commentType} className={styles.commentType}/>
<CommentLabels
comment={comment}
/>
<Slot
fill="adminCommentInfoBar"
data={data}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {gql} from 'react-apollo';
import Comment from '../components/Comment';
import CommentLabels from '../../../containers/CommentLabels';
import withFragments from 'coral-framework/hocs/withFragments';
import {getSlotFragmentSpreads} from 'coral-framework/utils';
import {getSlotFragmentSpreads, getDefinitionName} from 'coral-framework/utils';

const slots = [
'adminCommentInfoBar',
Expand Down Expand Up @@ -58,6 +59,8 @@ export default withFragments({
}
hasParent
${getSlotFragmentSpreads(slots, 'comment')}
...${getDefinitionName(CommentLabels.fragments.comment)}
}
${CommentLabels.fragments.comment}
`
})(Comment);
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ class ModerationContainer extends Component {
cursor: this.props.root[tab].endCursor,
sortOrder: this.props.data.variables.sortOrder,
asset_id: this.props.data.variables.asset_id,
statuses: this.props.queueConfig[tab].statuses,
statuses: this.props.queueConfig[tab].statuses || null,
tags: this.props.queueConfig[tab].tags || null,
action_type: this.props.queueConfig[tab].action_type,
};
return this.props.data.fetchMore({
Expand Down Expand Up @@ -214,7 +215,7 @@ class ModerationContainer extends Component {
return <Spinner />;
}

const premodEnabled = assetId ? isPremod(asset.settings.moderation) :
const premodEnabled = assetId ? isPremod(asset.settings.moderation) :
isPremod(settings.moderation);

const currentQueueConfig = Object.assign({}, this.props.queueConfig);
Expand Down Expand Up @@ -293,8 +294,8 @@ const COMMENT_REJECTED_SUBSCRIPTION = gql`
`;

const LOAD_MORE_QUERY = gql`
query CoralAdmin_Moderation_LoadMore($limit: Int = 10, $cursor: Cursor, $sortOrder: SORT_ORDER, $asset_id: ID, $statuses:[COMMENT_STATUS!], $action_type: ACTION_TYPE) {
comments(query: {limit: $limit, cursor: $cursor, asset_id: $asset_id, statuses: $statuses, sortOrder: $sortOrder, action_type: $action_type}) {
query CoralAdmin_Moderation_LoadMore($limit: Int = 10, $cursor: Cursor, $sortOrder: SORT_ORDER, $asset_id: ID, $tags:[String!], $statuses:[COMMENT_STATUS!], $action_type: ACTION_TYPE) {
comments(query: {limit: $limit, cursor: $cursor, asset_id: $asset_id, statuses: $statuses, sortOrder: $sortOrder, action_type: $action_type, tags: $tags}) {
nodes {
...${getDefinitionName(Comment.fragments.comment)}
}
Expand All @@ -319,10 +320,10 @@ const commentConnectionFragment = gql`
`;

const withModQueueQuery = withQuery(({queueConfig}) => gql`
query CoralAdmin_Moderation($asset_id: ID, $sortOrder: SORT_ORDER, $allAssets: Boolean!) {
query CoralAdmin_Moderation($asset_id: ID, $sortOrder: SORT_ORDER, $allAssets: Boolean!, $nullStatuses: [COMMENT_STATUS!]) {
${Object.keys(queueConfig).map((queue) => `
${queue}: comments(query: {
${queueConfig[queue].statuses ? `statuses: [${queueConfig[queue].statuses.join(', ')}],` : ''}
statuses: ${queueConfig[queue].statuses ? `[${queueConfig[queue].statuses.join(', ')}],` : '$nullStatuses'}
${queueConfig[queue].tags ? `tags: ["${queueConfig[queue].tags.join('", "')}"],` : ''}
${queueConfig[queue].action_type ? `action_type: ${queueConfig[queue].action_type}` : ''}
asset_id: $asset_id,
Expand All @@ -333,7 +334,7 @@ const withModQueueQuery = withQuery(({queueConfig}) => gql`
`)}
${Object.keys(queueConfig).map((queue) => `
${queue}Count: commentCount(query: {
${queueConfig[queue].statuses ? `statuses: [${queueConfig[queue].statuses.join(', ')}],` : ''}
statuses: ${queueConfig[queue].statuses ? `[${queueConfig[queue].statuses.join(', ')}],` : '$nullStatuses'}
${queueConfig[queue].tags ? `tags: ["${queueConfig[queue].tags.join('", "')}"],` : ''}
${queueConfig[queue].action_type ? `action_type: ${queueConfig[queue].action_type}` : ''}
asset_id: $asset_id,
Expand Down Expand Up @@ -361,6 +362,7 @@ const withModQueueQuery = withQuery(({queueConfig}) => gql`
asset_id: id,
sortOrder: props.moderation.sortOrder,
allAssets: id === null,
nullStatuses: null,
},
fetchPolicy: 'network-only'
};
Expand Down
1 change: 0 additions & 1 deletion client/coral-admin/src/routes/Moderation/queueConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default {
name: t('modqueue.rejected'),
},
all: {
statuses: ['NONE', 'PREMOD', 'ACCEPTED', 'REJECTED'],
icon: 'question_answer',
name: t('modqueue.all'),
},
Expand Down
9 changes: 0 additions & 9 deletions client/coral-admin/src/utils/comment.js

This file was deleted.

Loading