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;
});
}
};