From e6b7fcbd9d079d0953330ce554994baf87781e8c Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 2 Aug 2017 23:41:26 +0700 Subject: [PATCH] Show success notification --- .../client/components/ModTag.js | 21 ++++++++++++++----- .../client/translations.yml | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/talk-plugin-featured-comments/client/components/ModTag.js b/plugins/talk-plugin-featured-comments/client/components/ModTag.js index f4dbcd614..a80c3a8a6 100644 --- a/plugins/talk-plugin-featured-comments/client/components/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/components/ModTag.js @@ -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 ? ( - {!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')} ) : ( + onClick={this.postTag} > - {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')} ); } diff --git a/plugins/talk-plugin-featured-comments/client/translations.yml b/plugins/talk-plugin-featured-comments/client/translations.yml index 69f38f8e1..ea504cc9e 100644 --- a/plugins/talk-plugin-featured-comments/client/translations.yml +++ b/plugins/talk-plugin-featured-comments/client/translations.yml @@ -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: