[Client] Resolve #3226
This commit is contained in:
		
							parent
							
								
									4ea7e711ce
								
							
						
					
					
						commit
						2b0cb6d728
					
				
					 3 changed files with 53 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
				});
 | 
			
		||||
			});
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue