This commit is contained in:
Belen Curcio
2017-04-11 13:46:27 -03:00
parent aeaa9ae80f
commit 536b2ed371
4 changed files with 28 additions and 16 deletions
@@ -3,7 +3,6 @@ import {I18n} from '../coral-framework';
import translations from './translations.json';
import {Button} from 'coral-ui';
import {Slot} from 'coral-framework';
import styles from './styles.css';
import merge from 'lodash/merge';
const name = 'coral-plugin-commentbox';
@@ -1,15 +1,20 @@
import React from 'react';
import styles from './styles.css';
import {addCommentTag} from 'coral-framework/graphql/mutations';
import {compose} from 'react-apollo';
class OffTopicCheckbox extends React.Component {
handleChange = (e) => {
if (e.target.checked) {
this.props.addCommentHooks({
postSubmit: {
addTag: (data) => {
console.log('This is a hook after posting')
const {comment} = data.createComment;
this.props.addCommentTag({
id: comment.id,
tag: 'OFF_TOPIC',
});
}
}
})
@@ -23,9 +28,6 @@ class OffTopicCheckbox extends React.Component {
}
render() {
return (
<div className={styles.offTopic}>
<label>
@@ -37,4 +39,4 @@ class OffTopicCheckbox extends React.Component {
}
}
export default OffTopicCheckbox;
export default compose(addCommentTag)(OffTopicCheckbox);
@@ -1,8 +1,18 @@
import React from 'react';
import styles from './styles.css';
const isOffTopic = (tags) => {
return !!tags.filter(tag => tag.name === 'OFF_TOPIC').length
}
export default (props) => (
<span className={styles.tag}>
Off-topic
<span>
{
isOffTopic(props.comment.tags) ? (
<span className={styles.tag}>
Off-topic
</span>
) : null
}
</span>
);
+8 -7
View File
@@ -3,10 +3,10 @@ const CommentModel = require('../models/comment');
const ActionModel = require('../models/action');
const ActionsService = require('./actions');
const ALLOWED_TAGS = [
{name: 'STAFF'},
{name: 'BEST'},
];
// const ALLOWED_TAGS = [
// {name: 'STAFF'},
// {name: 'BEST'},
// ];
const STATUSES = [
'ACCEPTED',
@@ -53,9 +53,10 @@ module.exports = class CommentsService {
*/
static addTag(id, name, assigned_by) {
if (ALLOWED_TAGS.find((t) => t.name === name) == null) {
return Promise.reject(new Error('tag not allowed'));
}
// Disabling allowed tags until we are able to extend them
// if (ALLOWED_TAGS.find((t) => t.name === name) == null) {
// return Promise.reject(new Error('tag not allowed'));
// }
const filter = {
id,