diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index c91548d78a..d1e515e819 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1276,6 +1276,8 @@ admin/views/moderators.vue: title: "モデレーターの登録" add: "登録" added: "モデレーターを登録しました" + remove: "解除" + removed: "モデレーター登録を解除しました" admin/views/emoji.vue: add-emoji: diff --git a/src/client/app/admin/views/moderators.vue b/src/client/app/admin/views/moderators.vue index 296c553bb7..6391aef240 100644 --- a/src/client/app/admin/views/moderators.vue +++ b/src/client/app/admin/views/moderators.vue @@ -6,7 +6,8 @@ <ui-input v-model="username" type="text"> <span slot="prefix">@</span> </ui-input> - <ui-button @click="add" :disabled="adding">{{ $t('add-moderator.add') }}</ui-button> + <ui-button @click="add" :disabled="changing">{{ $t('add-moderator.add') }}</ui-button> + <ui-button @click="remove" :disabled="changing">{{ $t('add-moderator.remove') }}</ui-button> </section> </ui-card> </div> @@ -23,13 +24,13 @@ export default Vue.extend({ data() { return { username: '', - adding: false + changing: false }; }, methods: { async add() { - this.adding = true; + this.changing = true; const process = async () => { const user = await this.$root.api('users/show', parseAcct(this.username)); @@ -47,7 +48,29 @@ export default Vue.extend({ }); }); - this.adding = false; + this.changing = false; + }, + + async remove() { + this.changing = true; + + const process = async () => { + const user = await this.$root.api('users/show', parseAcct(this.username)); + await this.$root.api('admin/moderators/remove', { userId: user.id }); + this.$root.dialog({ + type: 'success', + text: this.$t('add-moderator.removed') + }); + }; + + await process().catch(e => { + this.$root.dialog({ + type: 'error', + text: e.toString() + }); + }); + + this.changing = false; }, } });