diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-02-02 23:20:40 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-02-02 23:20:40 +0900 |
| commit | 2b0cb6d7285bf3d60406233afd9d2648ac0212bf (patch) | |
| tree | cfc40b28b90c69c604a240941bab5925d29f6f0b /src | |
| parent | [Client] Improve usability (diff) | |
| download | sharkey-2b0cb6d7285bf3d60406233afd9d2648ac0212bf.tar.gz sharkey-2b0cb6d7285bf3d60406233afd9d2648ac0212bf.tar.bz2 sharkey-2b0cb6d7285bf3d60406233afd9d2648ac0212bf.zip | |
[Client] Resolve #3226
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/app/common/views/components/user-menu.vue | 49 |
1 files changed, 48 insertions, 1 deletions
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 + }); + }); } } }); |