mirror of
https://github.com/wassname/talk.git
synced 2026-07-08 18:09:23 +08:00
Show success notification
This commit is contained in:
@@ -3,6 +3,7 @@ import cn from 'classnames';
|
||||
import styles from './ModTag.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import {Icon} from 'plugin-api/beta/client/components/ui';
|
||||
import * as notification from 'coral-admin/src/services/notification';
|
||||
|
||||
export default class ModTag extends React.Component {
|
||||
constructor() {
|
||||
@@ -27,9 +28,19 @@ export default class ModTag extends React.Component {
|
||||
on: false
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
postTag = async () => {
|
||||
try {
|
||||
await this.props.postTag();
|
||||
notification.success(t('talk-plugin-featured-comments.notify_self_featured', this.props.comment.user.username));
|
||||
}
|
||||
catch(err) {
|
||||
notification.showMutationErrors(err);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {alreadyTagged, deleteTag, postTag} = this.props;
|
||||
const {alreadyTagged, deleteTag} = this.props;
|
||||
|
||||
return alreadyTagged ? (
|
||||
<span className={cn(styles.tag, styles.featured)}
|
||||
@@ -37,13 +48,13 @@ export default class ModTag extends React.Component {
|
||||
onMouseEnter={this.handleMouseEnter}
|
||||
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')}
|
||||
{!this.state.on ? t('talk-plugin-featured-comments.featured') : t('talk-plugin-featured-comments.un_feature')}
|
||||
</span>
|
||||
) : (
|
||||
<span className={cn(styles.tag, {[styles.featured]: alreadyTagged})}
|
||||
onClick={postTag} >
|
||||
onClick={this.postTag} >
|
||||
<Icon name="star_outline" className={cn(styles.tagIcon)} />
|
||||
{alreadyTagged ? 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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ en:
|
||||
featured_comments: Featured Comments
|
||||
go_to_conversation: Go to conversation
|
||||
tooltip_description: Comments selected by our team as worth reading
|
||||
notify_self_featured: 'The comment from {0} is now featured and approved'
|
||||
notify_featured: '{0} featured and approved comment "{1}"'
|
||||
notify_unfeatured: '{0} unfeatured comment "{1}"'
|
||||
es:
|
||||
|
||||
Reference in New Issue
Block a user