mirror of
https://github.com/wassname/talk.git
synced 2026-06-28 16:31:31 +08:00
28 lines
830 B
JavaScript
28 lines
830 B
JavaScript
import React from 'react';
|
|
import cn from 'classnames';
|
|
import styles from './FeaturedButton.css';
|
|
import {name} from '../../package.json';
|
|
import {can} from 'plugin-api/beta/client/services';
|
|
import {withTags} from 'plugin-api/beta/client/hocs';
|
|
import {Icon} from 'plugin-api/beta/client/components/ui';
|
|
|
|
const FeaturedButton = (props) => {
|
|
const {alreadyTagged, deleteTag, postTag, user} = props;
|
|
|
|
return can(user, 'MODERATE_COMMENTS') ? (
|
|
<button
|
|
className={cn([name, styles.button, {[styles.featured] : alreadyTagged}])}
|
|
onClick={alreadyTagged ? deleteTag : postTag} >
|
|
|
|
{alreadyTagged ?
|
|
<Icon name="star" className={styles.icon} /> :
|
|
<Icon name="star_border" className={styles.icon} />
|
|
}
|
|
|
|
</button>
|
|
) : null ;
|
|
};
|
|
|
|
export default withTags('featured')(FeaturedButton);
|
|
|