From ed105f876eb2e85544f207e93324403ebc150adc Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 15 Feb 2017 16:19:31 -0300 Subject: [PATCH 1/3] not Accepted ones in the Flagged queue --- client/coral-admin/src/graphql/queries/modQueueQuery.graphql | 1 + 1 file changed, 1 insertion(+) diff --git a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql index ca7f7aa07..8f5bdd31f 100644 --- a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql +++ b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql @@ -9,6 +9,7 @@ query ModQueue ($asset_id: ID!) { } flagged: comments(query: { action_type: FLAG, + statuses: [null, PREMOD], asset_id: $asset_id }) { ...commentView From 675f8238494b8afbe2dd39300435e4373ff8ab27 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 15 Feb 2017 17:32:54 -0300 Subject: [PATCH 2/3] no comments endpoints in /admin :tada: --- client/coral-admin/src/AppRouter.js | 2 - client/coral-admin/src/actions/comments.js | 103 ------------------ .../CommentStream/CommentStream.css | 13 --- .../containers/CommentStream/CommentStream.js | 66 ----------- .../src/graphql/queries/modQueueQuery.graphql | 1 - 5 files changed, 185 deletions(-) delete mode 100644 client/coral-admin/src/actions/comments.js delete mode 100644 client/coral-admin/src/containers/CommentStream/CommentStream.css delete mode 100644 client/coral-admin/src/containers/CommentStream/CommentStream.js diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index b28c4582b..bd72bbb8c 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -4,7 +4,6 @@ import {Router, Route, IndexRoute, IndexRedirect, browserHistory} from 'react-ro import Streams from 'containers/Streams/Streams'; import Configure from 'containers/Configure/Configure'; import LayoutContainer from 'containers/LayoutContainer'; -import CommentStream from 'containers/CommentStream/CommentStream'; import InstallContainer from 'containers/Install/InstallContainer'; import CommunityContainer from 'containers/Community/CommunityContainer'; @@ -16,7 +15,6 @@ const routes = ( - diff --git a/client/coral-admin/src/actions/comments.js b/client/coral-admin/src/actions/comments.js deleted file mode 100644 index 14f33bf36..000000000 --- a/client/coral-admin/src/actions/comments.js +++ /dev/null @@ -1,103 +0,0 @@ -import coralApi from '../../../coral-framework/helpers/response'; -import * as commentTypes from '../constants/comments'; -import * as actionTypes from '../constants/actions'; - -function addUsersCommentsActions (dispatch, {comments, users, actions}) { - dispatch({type: commentTypes.USERS_MODERATION_QUEUE_FETCH_SUCCESS, users}); - dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_SUCCESS, comments}); - dispatch({type: actionTypes.ACTIONS_MODERATION_QUEUE_FETCH_SUCCESS, actions}); -} - -// Get comments to fill each of the three lists on the mod queue -export const fetchModerationQueueComments = () => { - return dispatch => { - dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_REQUEST}); - - return Promise.all([ - coralApi('/queue/comments/premod'), - coralApi('/queue/users/flagged'), - coralApi('/queue/comments/rejected'), - coralApi('/queue/comments/flagged') - ]) - .then(([premodComments, pendingUsers, rejected, flagged]) => { - - /* Combine seperate calls into a single object */ - flagged.comments.forEach(comment => comment.flagged = true); - return { - comments: [...premodComments.comments, ...rejected.comments, ...flagged.comments], - users: [...premodComments.users, ...pendingUsers.users, ...rejected.users, ...flagged.users], - actions: [...premodComments.actions, ...pendingUsers.actions, ...rejected.actions, ...flagged.actions] - }; - }) - .then(addUsersCommentsActions.bind(this, dispatch)); - }; -}; - -export const fetchPremodQueue = () => { - return dispatch => { - dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_REQUEST}); - - return coralApi('/queue/comments/premod') - .then(addUsersCommentsActions.bind(this, dispatch)); - }; -}; - -export const fetchPendingUsersQueue = () => { - return dispatch => { - dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_REQUEST}); - - return coralApi('/queue/users/flagged') - .then(addUsersCommentsActions.bind(this, dispatch)); - }; -}; - -export const fetchRejectedQueue = () => { - return dispatch => { - dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_REQUEST}); - - return coralApi('/queue/comments/rejected') - .then(addUsersCommentsActions.bind(this, dispatch)); - }; -}; - -export const fetchFlaggedQueue = () => { - return dispatch => { - dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_REQUEST}); - - return coralApi('/queue/comments/flagged') - .then(results => { - results.comments.forEach(comment => comment.flagged = true); - return results; - }) - .then(addUsersCommentsActions.bind(this, dispatch)); - }; -}; - -// Create a new comment -export const createComment = (name, body) => { - return (dispatch) => { - const formData = {body, name}; - return coralApi('/comments', {method: 'POST', body: formData}) - .then(res => dispatch({type: commentTypes.COMMENT_CREATE_SUCCESS, comment: res})) - .catch(error => dispatch({type: commentTypes.COMMENT_CREATE_FAILED, error})); - }; -}; - -/** - * Action disptacher related to comments - */ - -// Update a comment. Now to update a comment we need to send back the whole object -export const updateStatus = (status, comment) => { - return dispatch => { - dispatch({type: commentTypes.COMMENT_STATUS_UPDATE_REQUEST, id: comment.id, status}); - return coralApi(`/comments/${comment.id}/status`, {method: 'PUT', body: {status}}) - .then(res => dispatch({type: commentTypes.COMMENT_STATUS_UPDATE_SUCCESS, res})) - .catch(error => dispatch({type: commentTypes.COMMENT_STATUS_UPDATE_FAILURE, error})); - }; -}; - -export const flagComment = id => (dispatch, getState) => { - dispatch({type: commentTypes.COMMENT_FLAG, id}); - dispatch({type: 'COMMENT_UPDATE', comment: getState().comments.get('byId').get(id)}); -}; diff --git a/client/coral-admin/src/containers/CommentStream/CommentStream.css b/client/coral-admin/src/containers/CommentStream/CommentStream.css deleted file mode 100644 index 9247183e5..000000000 --- a/client/coral-admin/src/containers/CommentStream/CommentStream.css +++ /dev/null @@ -1,13 +0,0 @@ - -@custom-media --big-viewport (min-width: 780px); - -.container { - max-width: 860px; - margin: 0 auto; -} - -@media (--big-viewport) { - .tab { - flex: none; - } -} diff --git a/client/coral-admin/src/containers/CommentStream/CommentStream.js b/client/coral-admin/src/containers/CommentStream/CommentStream.js deleted file mode 100644 index e2fac3702..000000000 --- a/client/coral-admin/src/containers/CommentStream/CommentStream.js +++ /dev/null @@ -1,66 +0,0 @@ -import React from 'react'; -import styles from './CommentStream.css'; -import {Snackbar} from 'react-mdl'; -import {connect} from 'react-redux'; -import {createComment, flagComment} from 'actions/comments'; -import ModerationList from 'components/ModerationList'; -import CommentBox from 'components/CommentBox'; - -/** - * Renders a comment stream using a ModerationList component - * and adds a box for adding a new comment - */ - -class CommentStream extends React.Component { - constructor (props) { - super(props); - this.state = {snackbar: false, snackbarMsg: ''}; - this.onSubmit = this.onSubmit.bind(this); - this.onClickAction = this.onClickAction.bind(this); - } - - // Fetch the comments before mounting - componentWillMount () { - this.props.dispatch({type: 'COMMENT_STREAM_FETCH'}); - } - - // Submit the new comment - onSubmit (comment) { - this.props.dispatch(createComment(comment.name, comment.body)); - } - - // The only action for now is flagging - onClickAction (action, id) { - if (action === 'flag') { - this.props.dispatch(flagComment(id)); - clearTimeout(this._snackTimeout); - this.setState({snackbar: true, snackbarMsg: 'Thank you for reporting this comment. Our moderation team has been notified and will review it shortly.'}); - this._snackTimeout = setTimeout(() => this.setState({snackbar: false}), 30000); - } - } - - // Render the comment box along with the ModerationList - render ({comments, users}, {snackbar, snackbarMsg}) { - return ( -
- - - {snackbarMsg} -
- ); - } -} - -const mapStateToProps = state => ({ - comments: state.comments.toJS(), - users: state.users.toJS() -}); - -export default connect(mapStateToProps)(CommentStream); diff --git a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql index 8f5bdd31f..ca7f7aa07 100644 --- a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql +++ b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql @@ -9,7 +9,6 @@ query ModQueue ($asset_id: ID!) { } flagged: comments(query: { action_type: FLAG, - statuses: [null, PREMOD], asset_id: $asset_id }) { ...commentView From 1796efd3ba21a84cb61f48f3e0103a8800a28e5d Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 15 Feb 2017 17:34:29 -0300 Subject: [PATCH 3/3] =?UTF-8?q?=C3=81dding=20NONE=20to=20the=20FE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/coral-admin/src/graphql/queries/modQueueQuery.graphql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql index ca7f7aa07..735f3294e 100644 --- a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql +++ b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql @@ -9,7 +9,8 @@ query ModQueue ($asset_id: ID!) { } flagged: comments(query: { action_type: FLAG, - asset_id: $asset_id + asset_id: $asset_id, + statuses: [NONE, PREMOD] }) { ...commentView action_summaries {