モデレーション周りのv11の機能復元 (#6249)
* モデレーション周りのv11の機能復元 * i18n * wip * wip Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
This commit is contained in:
@ -561,13 +561,13 @@ export default Vue.extend({
|
||||
}]
|
||||
: []
|
||||
),
|
||||
...(this.appearNote.userId == this.$store.state.i.id ? [
|
||||
...(this.appearNote.userId == this.$store.state.i.id || this.$store.state.i.isModerator || this.$store.state.i.isAdmin ? [
|
||||
null,
|
||||
{
|
||||
this.appearNote.userId == this.$store.state.i.id ? {
|
||||
icon: faEdit,
|
||||
text: this.$t('deleteAndEdit'),
|
||||
action: this.delEdit
|
||||
},
|
||||
} : undefined,
|
||||
{
|
||||
icon: faTrashAlt,
|
||||
text: this.$t('delete'),
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import { faAt, faListUl, faEye, faEyeSlash, faBan, faPencilAlt, faComments, faUsers } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faAt, faListUl, faEye, faEyeSlash, faBan, faPencilAlt, faComments, faUsers, faMicrophoneSlash } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faSnowflake, faEnvelope } from '@fortawesome/free-regular-svg-icons';
|
||||
import i18n from '../i18n';
|
||||
import XMenu from './menu.vue';
|
||||
@ -60,8 +60,12 @@ export default Vue.extend({
|
||||
action: this.toggleBlock
|
||||
}]);
|
||||
|
||||
if (this.$store.state.i.isAdmin) {
|
||||
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
|
||||
@ -194,6 +198,25 @@ export default Vue.extend({
|
||||
});
|
||||
},
|
||||
|
||||
async toggleSilence() {
|
||||
if (!await this.getConfirmed(this.$t(this.user.isSilenced ? 'unsilenceConfirm' : 'silenceConfirm'))) return;
|
||||
|
||||
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',
|
||||
iconOnly: true, autoClose: true
|
||||
});
|
||||
}, e => {
|
||||
this.$root.dialog({
|
||||
type: 'error',
|
||||
text: e
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
async toggleSuspend() {
|
||||
if (!await this.getConfirmed(this.$t(this.user.isSuspended ? 'unsuspendConfirm' : 'suspendConfirm'))) return;
|
||||
|
||||
|
@ -1,105 +0,0 @@
|
||||
<template>
|
||||
<x-window @closed="() => { $emit('closed'); destroyDom(); }" :avatar="user">
|
||||
<template #header><mk-user-name :user="user"/></template>
|
||||
<div class="vrcsvlkm">
|
||||
<mk-button @click="resetPassword()" primary>{{ $t('resetPassword') }}</mk-button>
|
||||
<mk-switch v-if="$store.state.i.isAdmin && (this.moderator || !user.isAdmin)" @change="toggleModerator()" v-model="moderator">{{ $t('moderator') }}</mk-switch>
|
||||
<mk-switch @change="toggleSilence()" v-model="silenced">{{ $t('silence') }}</mk-switch>
|
||||
<mk-switch @change="toggleSuspend()" v-model="suspended">{{ $t('suspend') }}</mk-switch>
|
||||
</div>
|
||||
</x-window>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import i18n from '../i18n';
|
||||
import MkButton from './ui/button.vue';
|
||||
import MkSwitch from './ui/switch.vue';
|
||||
import XWindow from './window.vue';
|
||||
|
||||
export default Vue.extend({
|
||||
i18n,
|
||||
|
||||
components: {
|
||||
MkButton,
|
||||
MkSwitch,
|
||||
XWindow,
|
||||
},
|
||||
|
||||
props: {
|
||||
user: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
moderator: this.user.isModerator,
|
||||
silenced: this.user.isSilenced,
|
||||
suspended: this.user.isSuspended,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
async resetPassword() {
|
||||
const dialog = this.$root.dialog({
|
||||
type: 'waiting',
|
||||
iconOnly: true
|
||||
});
|
||||
|
||||
this.$root.api('admin/reset-password', {
|
||||
userId: this.user.id,
|
||||
}).then(({ password }) => {
|
||||
this.$root.dialog({
|
||||
type: 'success',
|
||||
text: this.$t('newPasswordIs', { password })
|
||||
});
|
||||
}).catch(e => {
|
||||
this.$root.dialog({
|
||||
type: 'error',
|
||||
text: e
|
||||
});
|
||||
}).finally(() => {
|
||||
dialog.close();
|
||||
});
|
||||
},
|
||||
|
||||
async toggleSilence() {
|
||||
const confirm = await this.$root.dialog({
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
text: this.silenced ? this.$t('silenceConfirm') : this.$t('unsilenceConfirm'),
|
||||
});
|
||||
if (confirm.canceled) {
|
||||
this.silenced = !this.silenced;
|
||||
} else {
|
||||
this.$root.api(this.silenced ? 'admin/silence-user' : 'admin/unsilence-user', { userId: this.user.id });
|
||||
}
|
||||
},
|
||||
|
||||
async toggleSuspend() {
|
||||
const confirm = await this.$root.dialog({
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
text: this.suspended ? this.$t('suspendConfirm') : this.$t('unsuspendConfirm'),
|
||||
});
|
||||
if (confirm.canceled) {
|
||||
this.suspended = !this.suspended;
|
||||
} else {
|
||||
this.$root.api(this.suspended ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: this.user.id });
|
||||
}
|
||||
},
|
||||
|
||||
async toggleModerator() {
|
||||
this.$root.api(this.moderator ? 'admin/moderators/add' : 'admin/moderators/remove', { userId: this.user.id });
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.vrcsvlkm {
|
||||
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user