diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index d798b446c..4233325c5 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -180,10 +180,10 @@ export default class Comment extends React.Component { commentIsIgnored: React.PropTypes.func, // dispatch action to add a tag to a comment - addCommentTag: React.PropTypes.func, + addTag: React.PropTypes.func, // dispatch action to remove a tag from a comment - removeCommentTag: React.PropTypes.func, + removeTag: React.PropTypes.func, // dispatch action to ignore another user ignoreUser: React.PropTypes.func, @@ -286,11 +286,11 @@ export default class Comment extends React.Component { deleteAction, disableReply, maxCharCount, - addCommentTag, addNotification, charCountEnable, showSignInDialog, - removeCommentTag, + addTag, + removeTag, liveUpdates, commentIsIgnored, commentClassNames = [] @@ -333,18 +333,20 @@ export default class Comment extends React.Component { const addBestTag = notifyOnError( () => - addCommentTag({ + addTag({ id: comment.id, - tag: BEST_TAG + name: BEST_TAG, + assetId: asset.id }), () => 'Failed to tag comment as best' ); const removeBestTag = notifyOnError( () => - removeCommentTag({ + removeTag({ id: comment.id, - tag: BEST_TAG + name: BEST_TAG, + assetId: asset.id }), () => 'Failed to remove best comment tag' ); @@ -547,8 +549,8 @@ export default class Comment extends React.Component { currentUser={currentUser} postFlag={postFlag} deleteAction={deleteAction} - addCommentTag={addCommentTag} - removeCommentTag={removeCommentTag} + addTag={addTag} + removeTag={removeTag} ignoreUser={ignoreUser} charCountEnable={charCountEnable} maxCharCount={maxCharCount} diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index 586d28f23..91e696652 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -129,10 +129,10 @@ class Stream extends React.Component { postDontAgree, deleteAction, showSignInDialog, - addCommentTag, + addTag, ignoreUser, auth: {loggedIn, user}, - removeCommentTag, + removeTag, pluginProps, editName } = this.props; @@ -264,8 +264,8 @@ class Stream extends React.Component { currentUser={user} postFlag={postFlag} postDontAgree={postDontAgree} - addCommentTag={addCommentTag} - removeCommentTag={removeCommentTag} + addTag={addTag} + removeTag={removeTag} ignoreUser={ignoreUser} commentIsIgnored={commentIsIgnored} loadMore={this.props.loadNewReplies} @@ -298,10 +298,10 @@ Stream.propTypes = { postComment: PropTypes.func.isRequired, // dispatch action to add a tag to a comment - addCommentTag: PropTypes.func, + addTag: PropTypes.func, // dispatch action to remove a tag from a comment - removeCommentTag: PropTypes.func, + removeTag: PropTypes.func, // dispatch action to ignore another user ignoreUser: React.PropTypes.func, diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index 7f62240b5..dab648c8b 100644 --- a/client/coral-embed-stream/src/graphql/index.js +++ b/client/coral-embed-stream/src/graphql/index.js @@ -18,8 +18,8 @@ const extension = { } } `, - RemoveCommentTagResponse: gql` - fragment CoralEmbedStream_RemoveCommentTagResponse on RemoveCommentTagResponse { + RemoveTagResponse: gql` + fragment CoralEmbedStream_RemoveTagResponse on RemoveTagResponse { comment { id tags { @@ -28,8 +28,8 @@ const extension = { } } `, - AddCommentTagResponse: gql` - fragment CoralEmbedStream_AddCommentTagResponse on AddCommentTagResponse { + AddTagResponse: gql` + fragment CoralEmbedStream_AddTagResponse on AddTagResponse { comment { id tags { diff --git a/client/coral-framework/graphql/mutations.js b/client/coral-framework/graphql/mutations.js index 183dead09..6660af999 100644 --- a/client/coral-framework/graphql/mutations.js +++ b/client/coral-framework/graphql/mutations.js @@ -174,7 +174,7 @@ export const withDeleteAction = withMutation( }); const COMMENT_FRAGMENT = gql` - fragment CoraBest_UpdateFragment on Comment { + fragment CoralBest_UpdateFragment on Comment { tags { tag { name @@ -185,9 +185,11 @@ const COMMENT_FRAGMENT = gql` export const withAddTag = withMutation( gql` - mutation AddCommentTag($id: ID!, $asset_id: ID!, $name: String!) { + mutation AddTag($id: ID!, $asset_id: ID!, $name: String!) { addTag(tag: {name: $name, id: $id, item_type: COMMENTS, asset_id: $asset_id}) { - ...ModifyTagResponse + errors { + translation_key + } } } `, { @@ -228,7 +230,7 @@ export const withAddTag = withMutation( export const withRemoveTag = withMutation( gql` - mutation RemoveCommentTag($id: ID!, $asset_id: ID!, $name: String!) { + mutation RemoveTag($id: ID!, $asset_id: ID!, $name: String!) { removeTag(tag: {name: $name, id: $id, item_type: COMMENTS, asset_id: $asset_id}) { errors { translation_key @@ -237,12 +239,12 @@ export const withRemoveTag = withMutation( } `, { props: ({mutate}) => ({ - removeTag: ({id, name, asset_id}) => { + removeTag: ({id, name, assetId}) => { return mutate({ variables: { id, name, - asset_id + asset_id: assetId }, update: (proxy) => { const fragmentId = `Comment_${id}`; @@ -250,7 +252,7 @@ export const withRemoveTag = withMutation( // Read the data from our cache for this query. const data = proxy.readFragment({fragment: COMMENT_FRAGMENT, id: fragmentId}); - const idx = data.tags.findIndex((i) => i.tag.name === 'BEST'); + const idx = data.tags.findIndex(i => i.tag.name === 'BEST'); data.tags = [...data.tags.slice(0, idx), ...data.tags.slice(idx + 1)]; diff --git a/plugins/coral-plugin-offtopic/client/components/OffTopicTag.js b/plugins/coral-plugin-offtopic/client/components/OffTopicTag.js index e8029ce5e..0e028c6bf 100644 --- a/plugins/coral-plugin-offtopic/client/components/OffTopicTag.js +++ b/plugins/coral-plugin-offtopic/client/components/OffTopicTag.js @@ -1,11 +1,8 @@ import React from 'react'; import styles from './styles.css'; - import {t} from 'plugin-api/beta/client/services'; -const isOffTopic = (tags) => { - return !!tags.filter((tag) => tag.name === 'OFF_TOPIC').length; -}; +const isOffTopic = (tags) => !!tags.filter((t) => t.tag.name === 'OFF_TOPIC').length; export default (props) => ( diff --git a/test/server/graph/mutations/removeTag.js b/test/server/graph/mutations/removeTag.js index 95b3e8bd2..a1521c2ce 100644 --- a/test/server/graph/mutations/removeTag.js +++ b/test/server/graph/mutations/removeTag.js @@ -23,7 +23,7 @@ describe('graph.mutations.removeTag', () => { }); const query = ` - mutation RemoveCommentTag($id: ID!, $asset_id: ID!, $name: String!) { + mutation RemoveTag($id: ID!, $asset_id: ID!, $name: String!) { removeTag(tag: {name: $name, id: $id, item_type: COMMENTS, asset_id: $asset_id}) { errors { translation_key