Merge branch 'gdpr-change-email-bug' of github.com:coralproject/talk into gdpr-change-email-bug

* 'gdpr-change-email-bug' of github.com:coralproject/talk:
  Remove unused variable 2
  Remove unused variable
  Remove ModerationIndicator from container
  Show username already exists error
  No indicator on new queue
  Exclude deleted when loading more
  Remove modqueue counts on the frontend
This commit is contained in:
okbel
2018-05-15 12:07:15 -03:00
8 changed files with 25 additions and 32 deletions
@@ -7,7 +7,6 @@ import styles from './Header.css';
import t from 'coral-framework/services/i18n'; import t from 'coral-framework/services/i18n';
import { Logo } from './Logo'; import { Logo } from './Logo';
import { can } from 'coral-framework/services/perms'; import { can } from 'coral-framework/services/perms';
import ModerationIndicator from '../routes/Moderation/containers/Indicator';
import CommunityIndicator from '../routes/Community/containers/Indicator'; import CommunityIndicator from '../routes/Community/containers/Indicator';
const CoralHeader = ({ const CoralHeader = ({
@@ -32,7 +31,6 @@ const CoralHeader = ({
activeClassName={styles.active} activeClassName={styles.active}
> >
{t('configure.moderate')} {t('configure.moderate')}
<ModerationIndicator root={root} data={data} />
</IndexLink> </IndexLink>
)} )}
<Link <Link
@@ -1,10 +1,8 @@
.indicator { .indicator {
display: inline-block;
background-color: #E46D59; background-color: #E46D59;
border-radius: 10px; border-radius: 10px;
position: absolute;
top: 50%;
width: 7px; width: 7px;
height: 7px; height: 7px;
margin-top: -4px;
margin-left: 7px; margin-left: 7px;
} }
+4 -5
View File
@@ -2,21 +2,20 @@ import { gql } from 'react-apollo';
import withQuery from 'coral-framework/hocs/withQuery'; import withQuery from 'coral-framework/hocs/withQuery';
import Header from '../components/Header'; import Header from '../components/Header';
import CommunityIndicator from '../routes/Community/containers/Indicator'; import CommunityIndicator from '../routes/Community/containers/Indicator';
import ModerationIndicator from '../routes/Moderation/containers/Indicator'; // TODO: eventually we will readd modqueue counts
// import ModerationIndicator from '../routes/Moderation/containers/Indicator';
import { getDefinitionName } from 'coral-framework/utils'; import { getDefinitionName } from 'coral-framework/utils';
export default withQuery( export default withQuery(
gql` gql`
query TalkAdmin_Header($nullID: ID) { query TalkAdmin_Header {
...${getDefinitionName(ModerationIndicator.fragments.root)}
...${getDefinitionName(CommunityIndicator.fragments.root)} ...${getDefinitionName(CommunityIndicator.fragments.root)}
} }
${ModerationIndicator.fragments.root}
${CommunityIndicator.fragments.root} ${CommunityIndicator.fragments.root}
`, `,
{ {
options: { options: {
variables: { nullID: null }, // variables: { nullID: null },
}, },
} }
)(Header); )(Header);
@@ -63,10 +63,6 @@ class Moderation extends Component {
this.props.toggleStorySearch(true); this.props.toggleStorySearch(true);
}; };
getActiveTabCount = (props = this.props) => {
return props.root[`${props.activeTab}Count`];
};
moderate = accept => { moderate = accept => {
const { const {
acceptComment, acceptComment,
@@ -139,12 +135,14 @@ class Moderation extends Component {
const comments = root[activeTab]; const comments = root[activeTab];
const activeTabCount = this.getActiveTabCount();
const menuItems = Object.keys(queueConfig).map(queue => ({ const menuItems = Object.keys(queueConfig).map(queue => ({
key: queue, key: queue,
name: queueConfig[queue].name, name: queueConfig[queue].name,
icon: queueConfig[queue].icon, icon: queueConfig[queue].icon,
count: root[`${queue}Count`], indicator:
['premod', 'reported'].includes(queue) && root[queue].nodes.length > 0,
// TODO: Eventually we'll reintroduce counting
// count: root[`${props.queue}Count`]
})); }));
const slotPassthrough = { const slotPassthrough = {
@@ -189,7 +187,6 @@ class Moderation extends Component {
loadMore={this.loadMore} loadMore={this.loadMore}
commentBelongToQueue={this.props.commentBelongToQueue} commentBelongToQueue={this.props.commentBelongToQueue}
isLoadingMore={this.state.isLoadingMore} isLoadingMore={this.state.isLoadingMore}
commentCount={activeTabCount}
currentUserId={this.props.currentUser.id} currentUserId={this.props.currentUser.id}
viewUserDetail={viewUserDetail} viewUserDetail={viewUserDetail}
selectCommentId={props.selectCommentId} selectCommentId={props.selectCommentId}
@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import CountBadge from '../../../components/CountBadge'; import Indicator from '../../../components/Indicator';
import styles from './ModerationMenu.css'; import styles from './ModerationMenu.css';
import { Icon } from 'coral-ui'; import { Icon } from 'coral-ui';
import { Link } from 'react-router'; import { Link } from 'react-router';
@@ -32,7 +32,7 @@ const ModerationMenu = ({ asset = {}, items, getModPath, activeTab }) => {
activeClassName={styles.active} activeClassName={styles.active}
> >
<Icon name={queue.icon} className={styles.tabIcon} /> {queue.name}{' '} <Icon name={queue.icon} className={styles.tabIcon} /> {queue.name}{' '}
<CountBadge count={queue.count} /> {queue.indicator && <Indicator />}
</Link> </Link>
))} ))}
</div> </div>
@@ -204,7 +204,7 @@ class ModerationQueue extends React.Component {
} }
componentDidUpdate(prev) { componentDidUpdate(prev) {
const { commentCount, selectedCommentId } = this.props; const { selectedCommentId, hasNextPage } = this.props;
const switchedToMultiMode = prev.singleView && !this.props.singleView; const switchedToMultiMode = prev.singleView && !this.props.singleView;
const switchedMode = prev.singleView !== this.props.singleView; const switchedMode = prev.singleView !== this.props.singleView;
@@ -212,7 +212,6 @@ class ModerationQueue extends React.Component {
prev.selectedCommentId !== selectedCommentId && selectedCommentId; prev.selectedCommentId !== selectedCommentId && selectedCommentId;
const moderatedLastComment = const moderatedLastComment =
prev.comments.length > 0 && this.getCommentCountWithoutDagling() === 0; prev.comments.length > 0 && this.getCommentCountWithoutDagling() === 0;
const hasMoreComment = commentCount > 0;
if (switchedToMultiMode) { if (switchedToMultiMode) {
// Reflow virtual list. // Reflow virtual list.
@@ -223,7 +222,7 @@ class ModerationQueue extends React.Component {
this.scrollToSelectedComment(); this.scrollToSelectedComment();
} }
if (moderatedLastComment && hasMoreComment) { if (moderatedLastComment && hasNextPage) {
this.props.loadMore(); this.props.loadMore();
} }
} }
@@ -240,10 +239,7 @@ class ModerationQueue extends React.Component {
const index = view.findIndex( const index = view.findIndex(
({ id }) => id === this.props.selectedCommentId ({ id }) => id === this.props.selectedCommentId
); );
if ( if (index === view.length - 1 && this.props.hasNextPage) {
index === view.length - 1 &&
this.getCommentCountWithoutDagling() !== this.props.commentCount
) {
await this.props.loadMore(); await this.props.loadMore();
this.selectDown(); this.selectDown();
return; return;
@@ -467,7 +463,6 @@ ModerationQueue.propTypes = {
acceptComment: PropTypes.func.isRequired, acceptComment: PropTypes.func.isRequired,
commentBelongToQueue: PropTypes.func.isRequired, commentBelongToQueue: PropTypes.func.isRequired,
cleanUpQueue: PropTypes.func.isRequired, cleanUpQueue: PropTypes.func.isRequired,
commentCount: PropTypes.number.isRequired,
loadMore: PropTypes.func.isRequired, loadMore: PropTypes.func.isRequired,
singleView: PropTypes.bool, singleView: PropTypes.bool,
isLoadingMore: PropTypes.bool, isLoadingMore: PropTypes.bool,
@@ -314,11 +314,11 @@ class ModerationContainer extends Component {
const currentQueueConfig = Object.assign({}, this.props.queueConfig); const currentQueueConfig = Object.assign({}, this.props.queueConfig);
if (premodEnabled && root.newCount === 0) { if (premodEnabled && root.new.nodes.length === 0) {
delete currentQueueConfig.new; delete currentQueueConfig.new;
} }
if (!premodEnabled && root.premodCount === 0) { if (!premodEnabled && root.premod.nodes.length === 0) {
delete currentQueueConfig.premod; delete currentQueueConfig.premod;
} }
@@ -402,7 +402,7 @@ const COMMENT_RESET_SUBSCRIPTION = gql`
const LOAD_MORE_QUERY = gql` const LOAD_MORE_QUERY = gql`
query CoralAdmin_Moderation_LoadMore($limit: Int = 10, $cursor: Cursor, $sortOrder: SORT_ORDER, $asset_id: ID, $tags:[String!], $statuses:[COMMENT_STATUS!], $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}) { comments(query: {limit: $limit, cursor: $cursor, asset_id: $asset_id, statuses: $statuses, sortOrder: $sortOrder, action_type: $action_type, tags: $tags, excludeDeleted: true}) {
nodes { nodes {
...${getDefinitionName(Comment.fragments.comment)} ...${getDefinitionName(Comment.fragments.comment)}
} }
@@ -456,7 +456,11 @@ const withModQueueQuery = withQuery(
} }
` `
)} )}
${Object.keys(queueConfig).map( ${
''
/*
TODO: eventually we'll reintroduce counting..
Object.keys(queueConfig).map(
queue => ` queue => `
${queue}Count: commentCount(query: { ${queue}Count: commentCount(query: {
excludeDeleted: true, excludeDeleted: true,
@@ -478,7 +482,8 @@ const withModQueueQuery = withQuery(
asset_id: $asset_id, asset_id: $asset_id,
}) })
` `
)} )*/
}
asset(id: $asset_id) @skip(if: $allAssets) { asset(id: $asset_id) @skip(if: $allAssets) {
id id
title title
@@ -59,6 +59,7 @@ const withSetUsername = hoistStatics(WrappedComponent => {
} }
const changeSet = { success: false, loading: false, error }; const changeSet = { success: false, loading: false, error };
this.setState(changeSet); this.setState(changeSet);
throw error;
} }
}; };