diff --git a/.eslintrc.json b/.eslintrc.json index 34b46b83b..eca2dda1f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,6 +3,7 @@ "es6": true, "node": true }, + "parser": "babel-eslint", "extends": "eslint:recommended", "rules": { "indent": ["error", diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index e4ca10743..47fd86cc8 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -112,11 +112,11 @@ class Comment extends React.Component { // @TODO(bengo) Would be best to only create these funcs on prop change const addBestTag = () => addCommentTag({ - comment_id: comment.id, + id: comment.id, tag: BEST_TAG, }); const removeBestTag = () => removeCommentTag({ - comment_id: comment.id, + id: comment.id, tag: BEST_TAG, }); diff --git a/client/coral-framework/graphql/mutations/addCommentTag.graphql b/client/coral-framework/graphql/mutations/addCommentTag.graphql index 27d369775..5fd63868e 100644 --- a/client/coral-framework/graphql/mutations/addCommentTag.graphql +++ b/client/coral-framework/graphql/mutations/addCommentTag.graphql @@ -1,10 +1,11 @@ -mutation AddCommentTag ($comment_id: ID!, $tag: String!) { - addCommentTag(comment_id:$comment_id, tag:$tag) { - comment { - tags { - name - } - } +mutation AddCommentTag ($id: ID!, $tag: String!) { + addCommentTag(id:$id, tag:$tag) { + comment { + id + tags { + name + } + } errors { translation_key } diff --git a/client/coral-framework/graphql/mutations/index.js b/client/coral-framework/graphql/mutations/index.js index b65a6a339..6f6cdc04b 100644 --- a/client/coral-framework/graphql/mutations/index.js +++ b/client/coral-framework/graphql/mutations/index.js @@ -127,9 +127,10 @@ export const deleteAction = graphql(DELETE_ACTION, { export const addCommentTag = graphql(ADD_COMMENT_TAG, { props: ({mutate}) => ({ - addCommentTag: (tag) => { + addCommentTag: ({id, tag}) => { return mutate({ variables: { + id, tag } }); diff --git a/client/coral-plugin-best/BestButton.js b/client/coral-plugin-best/BestButton.js index 9af8b1638..52367c4e0 100644 --- a/client/coral-plugin-best/BestButton.js +++ b/client/coral-plugin-best/BestButton.js @@ -5,7 +5,10 @@ import classnames from 'classnames'; // tag string for best comments export const BEST_TAG = 'BEST'; -export const commentIsBest = ({tags} = {}) => Array.isArray(tags) && tags.some(t => t === BEST_TAG); +export const commentIsBest = ({tags} = {}) => { + const isBest = Array.isArray(tags) && tags.some(t => t.name === BEST_TAG); + return isBest; +}; const name = 'coral-plugin-best'; const lang = new I18n(translations); @@ -38,10 +41,6 @@ export class BestButton extends Component { removeBest: PropTypes.func.isRequired, } - state = { - best: false - } - constructor(props) { super(props); this.onClickAddBest = this.onClickAddBest.bind(this); @@ -75,8 +74,7 @@ export class BestButton extends Component { // @TODO(bengo) Consider adding the comment__action classes to other buttons to add cursor:pointer and never wrap the icons // @TODO(bengo) Should I reuse another element like coral-ui button? Just doing what LikeButton does for now // Oh. I think that's styled for the admin. Don't use coral-ui button until the whole comment bottom bar does. - let {isBest} = this.state; - const {addBest, removeBest} = this.props; + const {isBest, addBest, removeBest} = this.props; return