diff --git a/client/coral-admin/src/services/fragmentMatcher.js b/client/coral-admin/src/services/fragmentMatcher.js index 3b57de0b1..231c0fa2b 100644 --- a/client/coral-admin/src/services/fragmentMatcher.js +++ b/client/coral-admin/src/services/fragmentMatcher.js @@ -26,8 +26,7 @@ const fm = new IntrospectionFragmentMatcher({ {name: 'SetUserStatusResponse'}, {name: 'SuspendUserResponse'}, {name: 'SetCommentStatusResponse'}, - {name: 'AddCommentTagResponse'}, - {name: 'RemoveCommentTagResponse'}, + {name: 'ModifyTagResponse'}, {name: 'IgnoreUserResponse'}, {name: 'StopIgnoringUserResponse'} ] diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index dabac433c..6525f528f 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -109,10 +109,10 @@ 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, @@ -171,8 +171,8 @@ class Comment extends React.Component { setActiveReplyBox, activeReplyBox, deleteAction, - addCommentTag, - removeCommentTag, + addTag, + removeTag, ignoreUser, disableReply, commentIsIgnored, @@ -213,18 +213,20 @@ class Comment extends React.Component { const addBestTag = notifyOnError( () => - addCommentTag({ + addTag({ id: comment.id, - tag: BEST_TAG + name: BEST_TAG, + asset_id: asset.id }), () => 'Failed to tag comment as best' ); const removeBestTag = notifyOnError( () => - removeCommentTag({ + removeTag({ id: comment.id, - tag: BEST_TAG + name: BEST_TAG, + asset_id: asset.id }), () => 'Failed to remove best comment tag' ); @@ -394,8 +396,8 @@ 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 b7b325cf6..848427aa3 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -33,8 +33,8 @@ class Stream extends React.Component { loadMore, deleteAction, showSignInDialog, - addCommentTag, - removeCommentTag, + addTag, + removeTag, pluginProps, ignoreUser, auth: {loggedIn, isAdmin, user}, @@ -166,8 +166,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={loadMore} @@ -201,10 +201,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/containers/Stream.js b/client/coral-embed-stream/src/containers/Stream.js index f19cc0a34..69f3c5491 100644 --- a/client/coral-embed-stream/src/containers/Stream.js +++ b/client/coral-embed-stream/src/containers/Stream.js @@ -8,7 +8,7 @@ import isNil from 'lodash/isNil'; import {NEW_COMMENT_COUNT_POLL_INTERVAL} from '../constants/stream'; import { withPostComment, withPostFlag, withPostDontAgree, withDeleteAction, - withAddCommentTag, withRemoveCommentTag, withIgnoreUser, withEditComment, + withAddTag, withRemoveTag, withIgnoreUser, withEditComment, } from 'coral-framework/graphql/mutations'; import {notificationActions, authActions} from 'coral-framework'; @@ -243,10 +243,9 @@ export default compose( withPostComment, withPostFlag, withPostDontAgree, - withAddCommentTag, - withRemoveCommentTag, + withAddTag, + withRemoveTag, withIgnoreUser, withDeleteAction, withEditComment, )(StreamContainer); - diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index 77041f554..201f088dc 100644 --- a/client/coral-embed-stream/src/graphql/index.js +++ b/client/coral-embed-stream/src/graphql/index.js @@ -28,39 +28,8 @@ const extension = { } } `, - RemoveCommentTagResponse: gql` - fragment CoralEmbedStream_RemoveCommentTagResponse on RemoveCommentTagResponse { - comment { - id - tags { - tag { - name - created_at - } - assigned_by { - id - } - } - } - errors { - translation_key - } - } - `, - AddCommentTagResponse: gql` - fragment CoralEmbedStream_AddCommentTagResponse on AddCommentTagResponse { - comment { - id - tags { - tag { - name - created_at - } - assigned_by { - id - } - } - } + ModifyTagResponse: gql` + fragment CoralEmbedStream_ModifyTagResponse on ModifyTagResponse { errors { translation_key } diff --git a/client/coral-framework/graphql/mutations.js b/client/coral-framework/graphql/mutations.js index 1d5318853..ab07b4441 100644 --- a/client/coral-framework/graphql/mutations.js +++ b/client/coral-framework/graphql/mutations.js @@ -95,39 +95,43 @@ export const withDeleteAction = withMutation( }}), }); -export const withAddCommentTag = withMutation( +export const withAddTag = withMutation( gql` - mutation AddCommentTag($id: ID!, $tag: String!) { - addCommentTag(id:$id, tag:$tag) { - ...AddCommentTagResponse + mutation AddCommentTag($id: ID!, $asset_id: ID!, $name: String!) { + addTag(tag: {name: $name, id: $id, item_type: COMMENTS, asset_id: $asset_id}) { + ...ModifyTagResponse } } `, { props: ({mutate}) => ({ - addCommentTag: ({id, tag}) => { + addTag: ({id, name, asset_id}) => { return mutate({ variables: { id, - tag + name, + asset_id } }); }}), }); -export const withRemoveCommentTag = withMutation( +export const withRemoveTag = withMutation( gql` - mutation RemoveCommentTag($id: ID!, $tag: String!) { - removeCommentTag(id:$id, tag:$tag) { - ...RemoveCommentTagResponse + mutation RemoveCommentTag($id: ID!, $asset_id: ID!, $name: String!) { + removeTag(tag: {name: $name, id: $id, item_type: COMMENTS, asset_id: $asset_id}) { + errors { + translation_key + } } } `, { props: ({mutate}) => ({ - removeCommentTag: ({id, tag}) => { + removeTag: ({id, name, asset_id}) => { return mutate({ variables: { id, - tag + name, + asset_id } }); }}), diff --git a/client/coral-framework/graphql/mutations/addCommentTag.graphql b/client/coral-framework/graphql/mutations/addCommentTag.graphql deleted file mode 100644 index aa4ce7f5b..000000000 --- a/client/coral-framework/graphql/mutations/addCommentTag.graphql +++ /dev/null @@ -1,15 +0,0 @@ -mutation AddCommentTag ($id: ID!, $tag: String!) { - addCommentTag(id:$id, tag:$tag) { - comment { - id - tags { - tag { - name - } - } - } - errors { - translation_key - } - } -} diff --git a/client/coral-framework/graphql/mutations/removeCommentTag.graphql b/client/coral-framework/graphql/mutations/removeCommentTag.graphql deleted file mode 100644 index c89fc24f9..000000000 --- a/client/coral-framework/graphql/mutations/removeCommentTag.graphql +++ /dev/null @@ -1,15 +0,0 @@ -mutation RemoveCommentTag ($id: ID!, $tag: String!) { - removeCommentTag(id:$id, tag:$tag) { - comment { - id - tags { - tag { - name - } - } - } - errors { - translation_key - } - } -} diff --git a/client/coral-plugin-best/BestButton.js b/client/coral-plugin-best/BestButton.js index 96ef45f86..691b3c889 100644 --- a/client/coral-plugin-best/BestButton.js +++ b/client/coral-plugin-best/BestButton.js @@ -6,10 +6,10 @@ import classnames from 'classnames'; // tag string for best comments export const BEST_TAG = 'BEST'; -export const commentIsBest = ({tags} = {}) => { - const isBest = Array.isArray(tags) && tags.some(t => t.name === BEST_TAG); - return isBest; -}; + +export const commentIsBest = ({tags} = {}) => tags.some(t => t.tag.name === BEST_TAG); + +// const commentIsBest = tags => !!tags.filter(i => i.tag.name === 'BEST_TAG).length; const name = 'coral-plugin-best'; const lang = new I18n(translations);