Working featured comments on the admin side

This commit is contained in:
Belen Curcio
2017-08-01 13:06:21 -03:00
parent 5266bfa647
commit 779260c245
3 changed files with 12 additions and 22 deletions
@@ -93,8 +93,10 @@ class Comment extends React.Component {
<Slot
data={props.data}
root={props.root}
comment={comment}
asset={comment.asset}
fill="adminCommentInfoBar"
comment={comment} />
/>
</div>
</div>
</div>
@@ -2,9 +2,6 @@ import React from 'react';
import cn from 'classnames';
import styles from './ModTag.css';
import {t} from 'plugin-api/beta/client/services';
import {isTagged} from 'plugin-api/beta/client/utils';
// import {isTagged} from 'plugin-api/beta/client/utils';
import {Icon} from 'plugin-api/beta/client/components/ui';
export default class ModTag extends React.Component {
@@ -32,19 +29,21 @@ export default class ModTag extends React.Component {
}
render() {
const isFeatured = isTagged(this.props.comment.tags, 'FEATURED');
const {alreadyTagged, deleteTag, postTag} = this.props;
return isFeatured ? (
return alreadyTagged ? (
<span className={cn(styles.tag, styles.featured)}
onClick={deleteTag}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave }>
onMouseLeave={this.handleMouseLeave} >
<Icon name="star_outline" className={cn(styles.tagIcon)} />
{!this.state.on ? t('talk-plugin-featured-comments.featured') : t('talk-plugin-featured-comments.un_feature')}
</span>
) : (
<span className={cn(styles.tag, {[styles.featured]: isFeatured})}>
<span className={cn(styles.tag, {[styles.featured]: alreadyTagged})}
onClick={postTag} >
<Icon name="star_outline" className={cn(styles.tagIcon)} />
{isFeatured ? t('talk-plugin-featured-comments.featured') : t('talk-plugin-featured-comments.feature')}
{alreadyTagged ? t('talk-plugin-featured-comments.featured') : t('talk-plugin-featured-comments.feature')}
</span>
);
}
@@ -1,15 +1,4 @@
import {gql} from 'react-apollo';
import ModTag from '../components/ModTag';
import {withFragments} from 'plugin-api/beta/client/hocs';
import {withTags} from 'plugin-api/beta/client/hocs';
export default withFragments({
comment: gql`
fragment TalkFeaturedComments_ModTab_comment on Comment {
tags {
tag {
name
}
}
}
`
})(ModTag);
export default withTags('featured')(ModTag);