confirm on user menu (#4553)

This commit is contained in:
MeiMei 2019-04-18 03:36:06 +09:00 committed by syuilo
parent adff5382ca
commit 9ec6afa375
2 changed files with 36 additions and 5 deletions

View file

@ -527,8 +527,12 @@ common/views/components/user-menu.vue:
mention: "メンション"
mute: "ミュート"
unmute: "ミュート解除"
mute-confirm: "このユーザーをミュートしますか?"
unmute-confirm: "このユーザーをミュート解除しますか?"
block: "ブロック"
unblock: "ブロック解除"
block-confirm: "このユーザーをブロックしますか?"
unblock-confirm: "このユーザーをブロック解除しますか?"
push-to-list: "リストに追加"
select-list: "リストを選択してください"
report-abuse: "スパムを報告"
@ -536,8 +540,12 @@ common/views/components/user-menu.vue:
report-abuse-reported: "管理者に報告されました。ご協力ありがとうございました。"
silence: "サイレンス"
unsilence: "サイレンス解除"
silence-confirm: "このユーザーをサイレンスしますか?"
unsilence-confirm: "このユーザーをサイレンス解除しますか?"
suspend: "凍結"
unsuspend: "凍結解除"
suspend-confirm: "このユーザーを凍結しますか?"
unsuspend-confirm: "このユーザーを凍結解除しますか?"
common/views/components/poll.vue:
vote-to: "「{}」に投票する"

View file

@ -89,8 +89,10 @@ export default Vue.extend({
});
},
toggleMute() {
async toggleMute() {
if (this.user.isMuted) {
if (!await this.getConfirmed(this.$t('unmute-confirm'))) return;
this.$root.api('mute/delete', {
userId: this.user.id
}).then(() => {
@ -102,6 +104,8 @@ export default Vue.extend({
});
});
} else {
if (!await this.getConfirmed(this.$t('mute-confirm'))) return;
this.$root.api('mute/create', {
userId: this.user.id
}).then(() => {
@ -115,8 +119,10 @@ export default Vue.extend({
}
},
toggleBlock() {
async toggleBlock() {
if (this.user.isBlocking) {
if (!await this.getConfirmed(this.$t('unblock-confirm'))) return;
this.$root.api('blocking/delete', {
userId: this.user.id
}).then(() => {
@ -128,6 +134,8 @@ export default Vue.extend({
});
});
} else {
if (!await this.getConfirmed(this.$t('block-confirm'))) return;
this.$root.api('blocking/create', {
userId: this.user.id
}).then(() => {
@ -164,7 +172,9 @@ export default Vue.extend({
});
},
toggleSilence() {
async toggleSilence() {
if (!await this.getConfirmed(this.$t(this.user.isSilenced ? 'unsilence-confirm' : 'silence-confirm'))) return;
this.$root.api(this.user.isSilenced ? 'admin/unsilence-user' : 'admin/silence-user', {
userId: this.user.id
}).then(() => {
@ -181,7 +191,9 @@ export default Vue.extend({
});
},
toggleSuspend() {
async toggleSuspend() {
if (!await this.getConfirmed(this.$t(this.user.isSuspended ? 'unsuspend-confirm' : 'suspend-confirm'))) return;
this.$root.api(this.user.isSuspended ? 'admin/unsuspend-user' : 'admin/suspend-user', {
userId: this.user.id
}).then(() => {
@ -196,7 +208,18 @@ export default Vue.extend({
text: e
});
});
}
},
async getConfirmed(text: string): Promise<Boolean> {
const confirm = await this.$root.dialog({
type: 'warning',
showCancelButton: true,
title: 'confirm',
text,
});
return !confirm.canceled;
},
}
});
</script>