From fc880de9bf7b6ae25280ba9fde193b80d5ab315c Mon Sep 17 00:00:00 2001 From: gaba Date: Tue, 7 Feb 2017 16:31:39 -0800 Subject: [PATCH 01/11] Backend for the tags staff on staff users. --- models/comment.js | 9 +++++++++ services/comments.js | 3 +++ services/users.js | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/models/comment.js b/models/comment.js index b656f9238..a2733f551 100644 --- a/models/comment.js +++ b/models/comment.js @@ -9,6 +9,11 @@ const STATUSES = [ null ]; +const TAGS = [ + 'STAFF', + null +]; + /** * The Mongo schema for a Comment Status. * @type {Schema} @@ -49,6 +54,10 @@ const CommentSchema = new Schema({ author_id: String, status_history: [StatusSchema], status: {type: String, default: null}, + tag: { + type: String, + enum: TAGS, + }, parent_id: String }, { timestamps: { diff --git a/services/comments.js b/services/comments.js index 5d39a129e..9055afcfa 100644 --- a/services/comments.js +++ b/services/comments.js @@ -3,6 +3,8 @@ const CommentModel = require('../models/comment'); const ActionModel = require('../models/action'); const ActionsService = require('./actions'); +const UsersService = require('./users'); + module.exports = class CommentsService { /** @@ -34,6 +36,7 @@ module.exports = class CommentsService { created_at: new Date() }] : [], status, + tag: UsersService.isStaff(author_id) ? 'STAFF' : null, author_id }); diff --git a/services/users.js b/services/users.js index 408d5c618..e7049a347 100644 --- a/services/users.js +++ b/services/users.js @@ -687,4 +687,15 @@ module.exports = class UsersService { Promise.reject(new Error('You do not have permission to update your username.')); }); } + + /** + * Returns true if the user is staff. + * @param {String} id the id of the user to be enabled. + * @return {Promise} + */ + static isStaff(id) { + return UserModel.findById(id).then((user) => { + return user.hasRoles('ADMIN'); + }); + } }; From 075e62581e4161a00755c0551fcde977aad3aa89 Mon Sep 17 00:00:00 2001 From: gaba Date: Wed, 8 Feb 2017 09:03:21 -0800 Subject: [PATCH 02/11] Tags should be an array --- models/comment.js | 14 +++++--------- services/comments.js | 8 +++++++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/models/comment.js b/models/comment.js index a2733f551..42b7425b9 100644 --- a/models/comment.js +++ b/models/comment.js @@ -9,11 +9,6 @@ const STATUSES = [ null ]; -const TAGS = [ - 'STAFF', - null -]; - /** * The Mongo schema for a Comment Status. * @type {Schema} @@ -54,10 +49,11 @@ const CommentSchema = new Schema({ author_id: String, status_history: [StatusSchema], status: {type: String, default: null}, - tag: { - type: String, - enum: TAGS, - }, + tags: [{ + name: String, + assigned_by: String, + created_at: Date + }], parent_id: String }, { timestamps: { diff --git a/services/comments.js b/services/comments.js index 9055afcfa..bca56a2db 100644 --- a/services/comments.js +++ b/services/comments.js @@ -36,7 +36,13 @@ module.exports = class CommentsService { created_at: new Date() }] : [], status, - tag: UsersService.isStaff(author_id) ? 'STAFF' : null, + tags: [ + { + name: UsersService.isStaff(author_id) ? 'STAFF' : null, + assigned_by: null, + created_at: new Date() + } + ], author_id }); From f2341ca9d3c1335cbd04322c123d98d03a401e7d Mon Sep 17 00:00:00 2001 From: gaba Date: Thu, 9 Feb 2017 09:17:56 -0800 Subject: [PATCH 03/11] Adds tag label plugin. --- client/coral-embed-stream/src/Comment.js | 9 +++++++ client/coral-plugin-tag-label/TagLabel.js | 18 +++++++++++++ client/coral-plugin-tag-label/styles.css | 5 ++++ models/comment.js | 32 ++++++++++++++++++---- services/comments.js | 33 +++++++++++------------ services/users.js | 7 +++-- 6 files changed, 80 insertions(+), 24 deletions(-) create mode 100644 client/coral-plugin-tag-label/TagLabel.js create mode 100644 client/coral-plugin-tag-label/styles.css diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index c0c0d57d1..83a950a9f 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -10,6 +10,7 @@ import React, {PropTypes} from 'react'; import PermalinkButton from 'coral-plugin-permalinks/PermalinkButton'; import AuthorName from 'coral-plugin-author-name/AuthorName'; +import TagLabel from 'coral-plugin-tag-label/TagLabel'; import Content from 'coral-plugin-commentcontent/CommentContent'; import PubDate from 'coral-plugin-pubdate/PubDate'; import {ReplyBox, ReplyButton} from 'coral-plugin-replies'; @@ -58,6 +59,12 @@ class Comment extends React.Component { PropTypes.shape({ body: PropTypes.string.isRequired, id: PropTypes.string.isRequired + })), + tags: PropTypes.arrayOf( + PropTypes.shape({ + name: PropTypes.string, + assigned_by: PropTypes.string, + created_at: PropTypes.string }) ), user: PropTypes.shape({ @@ -95,6 +102,8 @@ class Comment extends React.Component {
+
diff --git a/client/coral-plugin-tag-label/TagLabel.js b/client/coral-plugin-tag-label/TagLabel.js new file mode 100644 index 000000000..103982138 --- /dev/null +++ b/client/coral-plugin-tag-label/TagLabel.js @@ -0,0 +1,18 @@ +import React, {Component} from 'react'; +const packagename = 'coral-plugin-tag-label'; +import styles from './styles.css'; + +export default class TagLabel extends Component { + + render () { + const {tags} = this.props; + console.log('DEBUG ', tags); + return ( +
+ {tags && tags} +
+ ); + } +} diff --git a/client/coral-plugin-tag-label/styles.css b/client/coral-plugin-tag-label/styles.css new file mode 100644 index 000000000..eee8d7201 --- /dev/null +++ b/client/coral-plugin-tag-label/styles.css @@ -0,0 +1,5 @@ +.tagLabel { + color: black; + display: inline-block; + margin: 10px 0; +} diff --git a/models/comment.js b/models/comment.js index 42b7425b9..b6848d0bc 100644 --- a/models/comment.js +++ b/models/comment.js @@ -9,6 +9,11 @@ const STATUSES = [ null ]; +const TAGS = [ + 'STAFF', + null +]; + /** * The Mongo schema for a Comment Status. * @type {Schema} @@ -30,6 +35,27 @@ const StatusSchema = new Schema({ _id: false }); +/** + * The Mongo schema for a Comment Tag. + * @type {Schema} + */ +const TagSchema = new Schema({ + name: { + type: String, + enum: TAGS, + }, + + // The User ID of the user that assigned the status. + assigned_by: { + type: String, + default: null + }, + + created_at: Date +}, { + _id: false +}); + /** * The Mongo schema for a Comment. * @type {Schema} @@ -49,11 +75,7 @@ const CommentSchema = new Schema({ author_id: String, status_history: [StatusSchema], status: {type: String, default: null}, - tags: [{ - name: String, - assigned_by: String, - created_at: Date - }], + tags: [TagSchema], parent_id: String }, { timestamps: { diff --git a/services/comments.js b/services/comments.js index bca56a2db..876128c47 100644 --- a/services/comments.js +++ b/services/comments.js @@ -27,26 +27,25 @@ module.exports = class CommentsService { author_id } = comment; - comment = new CommentModel({ - body, - asset_id, - parent_id, - status_history: status ? [{ - type: status, - created_at: new Date() - }] : [], - status, - tags: [ - { - name: UsersService.isStaff(author_id) ? 'STAFF' : null, + return UsersService.isStaff(author_id).then((isStaff) => { + comment = new CommentModel({ + body, + asset_id, + parent_id, + status_history: status ? [{ + type: status, + created_at: new Date() + }] : [], + status, + tags: isStaff ? [{ + name: 'STAFF', assigned_by: null, created_at: new Date() - } - ], - author_id + }] : [], + author_id + }); + return comment.save(); }); - - return comment.save(); } /** diff --git a/services/users.js b/services/users.js index e7049a347..9d3d57532 100644 --- a/services/users.js +++ b/services/users.js @@ -694,8 +694,11 @@ module.exports = class UsersService { * @return {Promise} */ static isStaff(id) { - return UserModel.findById(id).then((user) => { - return user.hasRoles('ADMIN'); + return UsersService.findById(id).then((user) => { + if (user) { + return user.hasRoles('ADMIN'); + } + return false; }); } }; From 1c26e64c71ef3da862681d1cbb079ca7eab9d197 Mon Sep 17 00:00:00 2001 From: gaba Date: Thu, 9 Feb 2017 12:23:40 -0800 Subject: [PATCH 04/11] Adds Tags to the graphql. --- client/coral-embed-stream/src/Comment.js | 7 ------- .../graphql/fragments/commentView.graphql | 3 +++ client/coral-plugin-tag-label/TagLabel.js | 2 +- graph/typeDefs.graphql | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 83a950a9f..8563fe5e5 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -60,13 +60,6 @@ class Comment extends React.Component { body: PropTypes.string.isRequired, id: PropTypes.string.isRequired })), - tags: PropTypes.arrayOf( - PropTypes.shape({ - name: PropTypes.string, - assigned_by: PropTypes.string, - created_at: PropTypes.string - }) - ), user: PropTypes.shape({ id: PropTypes.string.isRequired, name: PropTypes.string.isRequired diff --git a/client/coral-framework/graphql/fragments/commentView.graphql b/client/coral-framework/graphql/fragments/commentView.graphql index 29f9b3bfe..352c65571 100644 --- a/client/coral-framework/graphql/fragments/commentView.graphql +++ b/client/coral-framework/graphql/fragments/commentView.graphql @@ -3,6 +3,9 @@ fragment commentView on Comment { body created_at status + tags { + name + } user { id name: displayName diff --git a/client/coral-plugin-tag-label/TagLabel.js b/client/coral-plugin-tag-label/TagLabel.js index 103982138..ee5b22f23 100644 --- a/client/coral-plugin-tag-label/TagLabel.js +++ b/client/coral-plugin-tag-label/TagLabel.js @@ -11,7 +11,7 @@ export default class TagLabel extends Component {
- {tags && tags} + {tags}
); } diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index b1f9b82f7..d5dc727eb 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -63,12 +63,26 @@ type User { comments(query: CommentsQuery): [Comment] } +type Tag { + # the actual tag for the comment. + name: COMMENT_TAG + + # the user that assigned the tag. If NULL then the system automatically tagged it. + assigned_by: User + + # the time when the tag was assigned. + created_at: Date! +} + type Comment { id: ID! # the actual comment data. body: String! + # the tags on the comment + tags: [Tag] + # the user who authored the comment. user: User @@ -165,6 +179,11 @@ type Asset { created_at: Date } +enum COMMENT_TAG { + # For the comments submitted by staff members (ADMIN or MODERATOR users). + STAFF +} + enum COMMENT_STATUS { ACCEPTED REJECTED From 647ae2fca09210da09f956d41a73d8e99d5c12aa Mon Sep 17 00:00:00 2001 From: gaba Date: Thu, 9 Feb 2017 14:25:35 -0800 Subject: [PATCH 05/11] Assigned by will be a string for now. --- graph/typeDefs.graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index d5dc727eb..07bc8ebdc 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -68,7 +68,7 @@ type Tag { name: COMMENT_TAG # the user that assigned the tag. If NULL then the system automatically tagged it. - assigned_by: User + assigned_by: String # the time when the tag was assigned. created_at: Date! From 10937cf717292df728600815f6159c66f5dfdd30 Mon Sep 17 00:00:00 2001 From: gaba Date: Thu, 9 Feb 2017 15:28:09 -0800 Subject: [PATCH 06/11] Tag.name as string. Debuging comment.tag in Embed stream. --- client/coral-embed-stream/src/Comment.js | 9 ++++++-- .../coral-framework/graphql/queries/index.js | 2 +- client/coral-plugin-stream/Stream.js | 3 +++ client/coral-plugin-tag-label/TagLabel.js | 22 +++++-------------- models/comment.js | 10 +-------- 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 8563fe5e5..257c076b1 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -10,6 +10,7 @@ import React, {PropTypes} from 'react'; import PermalinkButton from 'coral-plugin-permalinks/PermalinkButton'; import AuthorName from 'coral-plugin-author-name/AuthorName'; + import TagLabel from 'coral-plugin-tag-label/TagLabel'; import Content from 'coral-plugin-commentcontent/CommentContent'; import PubDate from 'coral-plugin-pubdate/PubDate'; @@ -55,6 +56,11 @@ class Comment extends React.Component { actions: PropTypes.array.isRequired, body: PropTypes.string.isRequired, id: PropTypes.string.isRequired, + tags: PropTypes.arrayOf( + PropTypes.shape({ + name: PropTypes.string + }) + ), replies: PropTypes.arrayOf( PropTypes.shape({ body: PropTypes.string.isRequired, @@ -95,8 +101,7 @@ class Comment extends React.Component {
- +
diff --git a/client/coral-framework/graphql/queries/index.js b/client/coral-framework/graphql/queries/index.js index 7ce065baa..01c707e8d 100644 --- a/client/coral-framework/graphql/queries/index.js +++ b/client/coral-framework/graphql/queries/index.js @@ -13,7 +13,7 @@ function getQueryVariable(variable) { } // If no query is included, return a default string for development - return 'http://dev.default.stream'; + return 'http://localhost:3030'; } export const queryStream = graphql(STREAM_QUERY, { diff --git a/client/coral-plugin-stream/Stream.js b/client/coral-plugin-stream/Stream.js index 633a98502..c62ef7081 100644 --- a/client/coral-plugin-stream/Stream.js +++ b/client/coral-plugin-stream/Stream.js @@ -58,6 +58,9 @@ const StreamQuery = gql`fragment commentView on Comment { user { name: displayName } + tags { + name + } actions { type: action_type count diff --git a/client/coral-plugin-tag-label/TagLabel.js b/client/coral-plugin-tag-label/TagLabel.js index ee5b22f23..dcfee8bf1 100644 --- a/client/coral-plugin-tag-label/TagLabel.js +++ b/client/coral-plugin-tag-label/TagLabel.js @@ -1,18 +1,8 @@ -import React, {Component} from 'react'; -const packagename = 'coral-plugin-tag-label'; -import styles from './styles.css'; +import React from 'react'; +const name = 'coral-plugin-tag-label'; -export default class TagLabel extends Component { +const TagLabel = () =>
+ oh yeah +
; - render () { - const {tags} = this.props; - console.log('DEBUG ', tags); - return ( -
- {tags} -
- ); - } -} +export default TagLabel; diff --git a/models/comment.js b/models/comment.js index b6848d0bc..ac44d904e 100644 --- a/models/comment.js +++ b/models/comment.js @@ -9,11 +9,6 @@ const STATUSES = [ null ]; -const TAGS = [ - 'STAFF', - null -]; - /** * The Mongo schema for a Comment Status. * @type {Schema} @@ -40,10 +35,7 @@ const StatusSchema = new Schema({ * @type {Schema} */ const TagSchema = new Schema({ - name: { - type: String, - enum: TAGS, - }, + name: String, // The User ID of the user that assigned the status. assigned_by: { From 71fcf9cd3f1c29cbcef3098c2d314ee83bcabd8a Mon Sep 17 00:00:00 2001 From: gaba Date: Fri, 10 Feb 2017 10:20:34 -0800 Subject: [PATCH 07/11] FE for the Staff Tag. Modifed typedfs graphql. --- client/coral-embed-stream/src/Comment.js | 3 ++- client/coral-plugin-tag-label/TagLabel.js | 7 ++++--- client/coral-plugin-tag-label/styles.css | 7 ++++--- graph/typeDefs.graphql | 10 ++++------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 257c076b1..12ee56d0c 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -21,6 +21,7 @@ import LikeButton from 'coral-plugin-likes/LikeButton'; import styles from './Comment.css'; const getAction = (type, comment) => comment.actions.filter((a) => a.type === type)[0]; +const isStaff = (tags) => !tags.every((t) => t.name !== 'STAFF') ; class Comment extends React.Component { @@ -101,7 +102,7 @@ class Comment extends React.Component {
- +
diff --git a/client/coral-plugin-tag-label/TagLabel.js b/client/coral-plugin-tag-label/TagLabel.js index dcfee8bf1..f9ad898ec 100644 --- a/client/coral-plugin-tag-label/TagLabel.js +++ b/client/coral-plugin-tag-label/TagLabel.js @@ -1,8 +1,9 @@ import React from 'react'; -const name = 'coral-plugin-tag-label'; -const TagLabel = () =>
- oh yeah +import styles from './styles.css'; + +const TagLabel = ({isStaff}) =>
+ {(isStaff) ? 'Staff' : ''}
; export default TagLabel; diff --git a/client/coral-plugin-tag-label/styles.css b/client/coral-plugin-tag-label/styles.css index eee8d7201..5408b43d4 100644 --- a/client/coral-plugin-tag-label/styles.css +++ b/client/coral-plugin-tag-label/styles.css @@ -1,5 +1,6 @@ -.tagLabel { - color: black; +.staff { + background-color: #4C1066; + color: white; display: inline-block; - margin: 10px 0; + margin: 10px 10px; } diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index 07bc8ebdc..2ca815ad3 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -27,6 +27,9 @@ input CommentsQuery { # limit the number of results to be returned. limit: Int = 10 + # filter by a specific tag name. + tag: [String] + # skip results from the last created_at timestamp. cursor: Date @@ -65,7 +68,7 @@ type User { type Tag { # the actual tag for the comment. - name: COMMENT_TAG + name: String! # the user that assigned the tag. If NULL then the system automatically tagged it. assigned_by: String @@ -179,11 +182,6 @@ type Asset { created_at: Date } -enum COMMENT_TAG { - # For the comments submitted by staff members (ADMIN or MODERATOR users). - STAFF -} - enum COMMENT_STATUS { ACCEPTED REJECTED From c637be364a32baabc4b8062fe25ac32476ab0d8b Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Fri, 10 Feb 2017 12:00:50 -0700 Subject: [PATCH 08/11] Moved tag creation into mutator --- graph/mutators/comment.js | 6 ++++ services/comments.js | 60 +++++++++++++++++++++++++++------------ services/users.js | 14 --------- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/graph/mutators/comment.js b/graph/mutators/comment.js index 3c35b0e60..8e3510920 100644 --- a/graph/mutators/comment.js +++ b/graph/mutators/comment.js @@ -36,6 +36,12 @@ const createComment = ({user, loaders: {Comments}}, {body, asset_id, parent_id = } } + if (user.hasRoles('ADMIN')) { + return CommentsService + .addTag(comment.id, 'STAFF', user.id) + .then(() => comment); + } + return comment; }); }; diff --git a/services/comments.js b/services/comments.js index 876128c47..fc05341cb 100644 --- a/services/comments.js +++ b/services/comments.js @@ -3,7 +3,9 @@ const CommentModel = require('../models/comment'); const ActionModel = require('../models/action'); const ActionsService = require('./actions'); -const UsersService = require('./users'); +const ALLOWED_TAGS = [ + {name: 'STAFF'} +]; module.exports = class CommentsService { @@ -27,24 +29,46 @@ module.exports = class CommentsService { author_id } = comment; - return UsersService.isStaff(author_id).then((isStaff) => { - comment = new CommentModel({ - body, - asset_id, - parent_id, - status_history: status ? [{ - type: status, + comment = new CommentModel({ + body, + asset_id, + parent_id, + status_history: status ? [{ + type: status, + created_at: new Date() + }] : [], + tags: [], + status, + author_id + }); + + return comment.save(); + } + + /** + * Adds a tag if it doesn't already exist on the comment. + */ + static addTag(id, name, assigned_by) { + + if (ALLOWED_TAGS.find((t) => t.name === name) == null) { + return Promise.reject(new Error('tag not allowed')); + } + + return CommentModel.update({ + id, + tags: { + $ne: { + name + } + } + }, { + $push: { + tags: { + name, + assigned_by, created_at: new Date() - }] : [], - status, - tags: isStaff ? [{ - name: 'STAFF', - assigned_by: null, - created_at: new Date() - }] : [], - author_id - }); - return comment.save(); + } + } }); } diff --git a/services/users.js b/services/users.js index 9d3d57532..408d5c618 100644 --- a/services/users.js +++ b/services/users.js @@ -687,18 +687,4 @@ module.exports = class UsersService { Promise.reject(new Error('You do not have permission to update your username.')); }); } - - /** - * Returns true if the user is staff. - * @param {String} id the id of the user to be enabled. - * @return {Promise} - */ - static isStaff(id) { - return UsersService.findById(id).then((user) => { - if (user) { - return user.hasRoles('ADMIN'); - } - return false; - }); - } }; From c80f406b2111f3f819669acc2355ee9a97a78cb1 Mon Sep 17 00:00:00 2001 From: gaba Date: Fri, 10 Feb 2017 11:51:34 -0800 Subject: [PATCH 09/11] Add tests --- test/services/comments.js | 41 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/test/services/comments.js b/test/services/comments.js index fc2105cb1..82ceb1b61 100644 --- a/test/services/comments.js +++ b/test/services/comments.js @@ -70,11 +70,14 @@ describe('services.CommentsService', () => { const users = [{ email: 'stampi@gmail.com', displayName: 'Stampi', - password: '1Coral!!' + password: '1Coral!!', + roles: ['ADMIN'], + _id: '1' }, { email: 'sockmonster@gmail.com', displayName: 'Sockmonster', - password: '2Coral!!' + password: '2Coral!!', + _id : '2' }]; const actions = [{ @@ -256,4 +259,38 @@ describe('services.CommentsService', () => { }); }); + + describe('#tagByStaff()', () => { + + it('creates a new comment by admin', () => { + return UsersService.findLocalUser('stampi@gmail.com', '1Coral!!').then((user) => { + return UsersService.addRoleToUser(user.id, 'ADMIN').then(() => { + return CommentsService + .publicCreate({ + body: 'This is a comment!', + status: 'ACCEPTED', + author_id: user.id + }).then((c) => { + expect(c).to.not.be.null; + expect(c.tags).to.not.have.length(0); + expect(c.tags[0].name).to.be.equal('STAFF'); + }); + }); + }); + }); + + it('creates a new comment by non admin', () => { + return UsersService.findLocalUser('sockmonster@gmail.com', '2Coral!!').then((user) => { + return CommentsService + .publicCreate({ + body: 'This is a comment!', + status: 'ACCEPTED', + author_id: user.id + }).then((c) => { + expect(c).to.not.be.null; + expect(c.tags).to.have.length(0); + }); + }); + }); + }); }); From 498eb5eb91104b05433e9e83c624d1efc160500c Mon Sep 17 00:00:00 2001 From: gaba Date: Fri, 10 Feb 2017 12:06:36 -0800 Subject: [PATCH 10/11] Fix the test. --- test/services/comments.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/services/comments.js b/test/services/comments.js index 82ceb1b61..c27050ae7 100644 --- a/test/services/comments.js +++ b/test/services/comments.js @@ -265,16 +265,18 @@ describe('services.CommentsService', () => { it('creates a new comment by admin', () => { return UsersService.findLocalUser('stampi@gmail.com', '1Coral!!').then((user) => { return UsersService.addRoleToUser(user.id, 'ADMIN').then(() => { - return CommentsService - .publicCreate({ - body: 'This is a comment!', - status: 'ACCEPTED', - author_id: user.id - }).then((c) => { - expect(c).to.not.be.null; - expect(c.tags).to.not.have.length(0); - expect(c.tags[0].name).to.be.equal('STAFF'); - }); + UsersService.findById(user.id).then((u) => { + return CommentsService + .publicCreate({ + body: 'This is a comment!', + status: 'ACCEPTED', + author_id: u.id + }).then((c) => { + expect(c).to.not.be.null; + expect(c.tags).to.not.have.length(0); + expect(c.tags[0].name).to.be.equal('STAFF'); + }); + }); }); }); }); From 11ef12c14ced589b37b06331a87de12556c06ba2 Mon Sep 17 00:00:00 2001 From: gaba Date: Fri, 10 Feb 2017 13:33:57 -0800 Subject: [PATCH 11/11] Adds padding and resolves when is not staff. --- client/coral-embed-stream/src/Comment.js | 6 ++++-- client/coral-plugin-tag-label/TagLabel.js | 2 +- client/coral-plugin-tag-label/styles.css | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 12ee56d0c..c038be7a6 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -93,7 +93,7 @@ class Comment extends React.Component { const like = getAction('LIKE', comment); const flag = getAction('FLAG', comment); - + return (
- + { isStaff(comment.tags) + ? + : null }
diff --git a/client/coral-plugin-tag-label/TagLabel.js b/client/coral-plugin-tag-label/TagLabel.js index f9ad898ec..0bceca225 100644 --- a/client/coral-plugin-tag-label/TagLabel.js +++ b/client/coral-plugin-tag-label/TagLabel.js @@ -3,7 +3,7 @@ import React from 'react'; import styles from './styles.css'; const TagLabel = ({isStaff}) =>
- {(isStaff) ? 'Staff' : ''} + {isStaff ? 'Staff' : ''}
; export default TagLabel; diff --git a/client/coral-plugin-tag-label/styles.css b/client/coral-plugin-tag-label/styles.css index 5408b43d4..03dc3dbc8 100644 --- a/client/coral-plugin-tag-label/styles.css +++ b/client/coral-plugin-tag-label/styles.css @@ -3,4 +3,5 @@ color: white; display: inline-block; margin: 10px 10px; + padding: 5px 5px; }