2021-07-24 05:54:15 -07:00
|
|
|
<template>
|
2021-11-23 05:48:14 -08:00
|
|
|
<div v-if="config.profile.editorEnabled && $user() && $user().username !== user.username">
|
2021-07-24 10:18:39 -07:00
|
|
|
<section v-if="$user()">
|
|
|
|
<a v-if="!showReportForm" href="#" @click.prevent="showReportForm = true" class="small">
|
|
|
|
<Icon v="spider"/>
|
|
|
|
<T>report.action</T>
|
|
|
|
</a>
|
|
|
|
<div v-else-if="!reported">
|
|
|
|
<textarea v-model="reportComment" class="form-control" rows="3" :placeholder="$t('report.comment')" :disabled="saving" required></textarea>
|
2022-01-15 14:56:18 -08:00
|
|
|
<div class="alert alert-info small mt-3">
|
|
|
|
<p><T>report.terms</T><T>quotation.colon</T></p>
|
|
|
|
<blockquote>
|
|
|
|
<T>terms.content.content.violations</T>
|
|
|
|
<template v-for="(violation, i) in forbidden"><T>terms.content.content.violationsExamples.{{violation}}</T><template v-if="i !== forbidden.length - 1">, </template></template>.
|
|
|
|
</blockquote>
|
|
|
|
<p class="mb-0"><T>report.hoarding</T></p>
|
|
|
|
</div>
|
2021-07-24 10:18:39 -07:00
|
|
|
<button class="btn btn-danger d-block w-100 mt-2" :disabled="saving || !reportComment" @click="report">
|
|
|
|
<Icon v="spider"/>
|
|
|
|
<T>report.action</T>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div v-else class="alert alert-success">
|
|
|
|
<T>report.sent</T>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-07-24 05:54:15 -07:00
|
|
|
<section v-if="$isGranted('users')">
|
2021-07-24 10:18:39 -07:00
|
|
|
<a v-if="!showBanForm" href="#" @click.prevent="showBanForm = true" class="small">
|
|
|
|
<Icon v="ban"/>
|
|
|
|
<T>ban.action</T>
|
|
|
|
</a>
|
|
|
|
<div v-else>
|
2021-07-24 05:54:15 -07:00
|
|
|
<textarea v-model="user.bannedReason" class="form-control" rows="3" :placeholder="$t('ban.reason') + ' ' + $t('ban.visible')" :disabled="saving"></textarea>
|
2021-08-12 03:14:34 -07:00
|
|
|
<div class="form-group">
|
2021-12-02 08:18:25 -08:00
|
|
|
<p class="my-1"><label><strong><T>ban.terms</T><T>quotation.colon</T></strong></label></p>
|
2021-08-12 03:14:34 -07:00
|
|
|
<div style="columns: 3" class="small">
|
2021-12-11 02:37:15 -08:00
|
|
|
<div class="form-check ps-0" v-for="violation in forbidden">
|
2021-08-12 03:14:34 -07:00
|
|
|
<label>
|
2021-12-11 02:37:15 -08:00
|
|
|
<input type="checkbox" :value="violation" v-model="user.bannedTerms"/>
|
|
|
|
<T>terms.content.content.violationsExamples.{{violation}}</T>
|
2021-08-12 03:14:34 -07:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-24 05:54:15 -07:00
|
|
|
<button class="btn btn-danger d-block w-100 mt-2" :disabled="saving" @click="ban">
|
|
|
|
<Icon v="ban"/>
|
2021-07-24 10:18:39 -07:00
|
|
|
<T>ban.action</T>
|
2021-07-24 05:54:15 -07:00
|
|
|
</button>
|
|
|
|
</div>
|
2022-04-06 04:52:14 -07:00
|
|
|
<ModerationRules type="rulesUsers" emphasise class="mt-4"/>
|
|
|
|
<AbuseReports v-if="abuseReports.length" :abuseReports="abuseReports" allowResolving/>
|
2021-07-24 05:54:15 -07:00
|
|
|
</section>
|
2021-07-24 10:18:39 -07:00
|
|
|
</div>
|
2021-07-24 05:54:15 -07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import ClientOnly from 'vue-client-only'
|
2021-08-12 03:14:34 -07:00
|
|
|
import forbidden from "../src/forbidden";
|
2021-07-24 05:54:15 -07:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: { ClientOnly },
|
|
|
|
props: {
|
|
|
|
user: { required: true },
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-07-24 10:18:39 -07:00
|
|
|
showReportForm: false,
|
|
|
|
reportComment: '',
|
|
|
|
reported: false,
|
|
|
|
|
|
|
|
showBanForm: !!this.user.bannedReason,
|
|
|
|
|
2021-07-24 05:54:15 -07:00
|
|
|
saving: false,
|
2021-08-12 03:14:34 -07:00
|
|
|
|
|
|
|
forbidden,
|
2022-04-06 04:52:14 -07:00
|
|
|
|
|
|
|
abuseReports: [],
|
2021-07-24 05:54:15 -07:00
|
|
|
}
|
|
|
|
},
|
2022-04-06 04:52:14 -07:00
|
|
|
async mounted() {
|
|
|
|
if (!this.$isGranted('users')) { return; }
|
|
|
|
this.abuseReports = await this.$axios.$get(`/admin/reports/${this.user.id}`);
|
|
|
|
},
|
2021-07-24 05:54:15 -07:00
|
|
|
methods: {
|
|
|
|
async ban() {
|
|
|
|
await this.$confirm(this.$t('ban.confirm', {username: this.user.username}), 'danger');
|
|
|
|
this.saving = true;
|
|
|
|
try {
|
|
|
|
await this.$post(`/admin/ban/${encodeURIComponent(this.user.username)}`, {
|
|
|
|
reason: this.user.bannedReason,
|
2021-08-12 03:14:34 -07:00
|
|
|
terms: this.user.bannedTerms,
|
2021-07-24 05:54:15 -07:00
|
|
|
});
|
|
|
|
window.location.reload();
|
|
|
|
} finally {
|
|
|
|
this.saving = false;
|
|
|
|
}
|
2021-07-24 10:18:39 -07:00
|
|
|
},
|
|
|
|
async report() {
|
|
|
|
if (!this.reportComment) { return; }
|
|
|
|
await this.$confirm(this.$t('report.confirm', {username: this.user.username}), 'danger');
|
|
|
|
this.saving = true;
|
|
|
|
try {
|
|
|
|
await this.$post(`/profile/report/${encodeURIComponent(this.user.username)}`, {
|
|
|
|
comment: this.reportComment,
|
|
|
|
});
|
|
|
|
this.reported = true;
|
|
|
|
} finally {
|
|
|
|
this.saving = false;
|
|
|
|
}
|
|
|
|
},
|
2021-07-24 05:54:15 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|