From 2b0cb6d7285bf3d60406233afd9d2648ac0212bf Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 2 Feb 2019 23:20:40 +0900 Subject: [Client] Resolve #3226 --- .../app/common/views/components/user-menu.vue | 49 +++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/app/common/views/components/user-menu.vue b/src/client/app/common/views/components/user-menu.vue index 7874c43493..bcf0634fa6 100644 --- a/src/client/app/common/views/components/user-menu.vue +++ b/src/client/app/common/views/components/user-menu.vue @@ -8,7 +8,8 @@ import Vue from 'vue'; import i18n from '../../../i18n'; import copyToClipboard from '../../../common/scripts/copy-to-clipboard'; -import { faExclamationCircle } from '@fortawesome/free-solid-svg-icons'; +import { faExclamationCircle, faMicrophoneSlash } from '@fortawesome/free-solid-svg-icons'; +import { faSnowflake } from '@fortawesome/free-regular-svg-icons'; export default Vue.extend({ i18n: i18n('common/views/components/user-menu.vue'), @@ -40,6 +41,18 @@ export default Vue.extend({ action: this.reportAbuse }]; + if (this.$store.getters.isSignedIn && (this.$store.state.i.isAdmin || this.$store.state.i.isModerator)) { + menu = menu.concat([null, { + icon: faMicrophoneSlash, + text: this.user.isSilenced ? this.$t('unsilence') : this.$t('silence'), + action: this.toggleSilence + }, { + icon: faSnowflake, + text: this.user.isSuspended ? this.$t('unsuspend') : this.$t('suspend'), + action: this.toggleSuspend + }]); + } + return { items: menu }; @@ -148,6 +161,40 @@ export default Vue.extend({ text: e }); }); + }, + + toggleSilence() { + this.$root.api(this.user.isSilenced ? 'admin/unsilence-user' : 'admin/silence-user', { + userId: this.user.id + }).then(() => { + this.user.isSilenced = !this.user.isSilenced; + this.$root.dialog({ + type: 'success', + splash: true + }); + }, e => { + this.$root.dialog({ + type: 'error', + text: e + }); + }); + }, + + toggleSuspend() { + this.$root.api(this.user.isSuspended ? 'admin/unsuspend-user' : 'admin/suspend-user', { + userId: this.user.id + }).then(() => { + this.user.isSuspended = !this.user.isSuspended; + this.$root.dialog({ + type: 'success', + splash: true + }); + }, e => { + this.$root.dialog({ + type: 'error', + text: e + }); + }); } } }); -- cgit v1.2.3-freya