Update Reports for cases when actor or account is missing

This commit is contained in:
Angelina Filippova 2020-04-19 02:25:04 +03:00
parent 992d07b1c4
commit 1f7d78406c
3 changed files with 49 additions and 32 deletions

View file

@ -293,6 +293,7 @@ export default {
}, },
reports: { reports: {
reports: 'Reports', reports: 'Reports',
report: 'Report',
reply: 'Reply', reply: 'Reply',
from: 'From', from: 'From',
showNotes: 'Show notes', showNotes: 'Show notes',
@ -332,7 +333,8 @@ export default {
statusDeleted: 'This status has been deleted', statusDeleted: 'This status has been deleted',
leaveNote: 'Leave a note', leaveNote: 'Leave a note',
postNote: 'Send', postNote: 'Send',
deleteNote: 'Delete' deleteNote: 'Delete',
notFound: 'account not found'
}, },
reportsFilter: { reportsFilter: {
inputPlaceholder: 'Select filter', inputPlaceholder: 'Select filter',

View file

@ -1,6 +1,6 @@
<template> <template>
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<el-button plain size="small" icon="el-icon-files">{{ $t('reports.moderateUser') }} <el-button :disabled="!account.id" plain size="small" icon="el-icon-files">{{ $t('reports.moderateUser') }}
<i class="el-icon-arrow-down el-icon--right"/> <i class="el-icon-arrow-down el-icon--right"/>
</el-button> </el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
@ -16,42 +16,42 @@
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:divided="true" :divided="true"
:class="{ 'active-tag': account.tags.includes('force_nsfw') }" :class="{ 'active-tag': tags.includes('force_nsfw') }"
@click.native="toggleTag(account, 'force_nsfw')"> @click.native="toggleTag(account, 'force_nsfw')">
{{ $t('users.forceNsfw') }} {{ $t('users.forceNsfw') }}
<i v-if="account.tags.includes('force_nsfw')" class="el-icon-check"/> <i v-if="tags.includes('force_nsfw')" class="el-icon-check"/>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:class="{ 'active-tag': account.tags.includes('strip_media') }" :class="{ 'active-tag': tags.includes('strip_media') }"
@click.native="toggleTag(account, 'strip_media')"> @click.native="toggleTag(account, 'strip_media')">
{{ $t('users.stripMedia') }} {{ $t('users.stripMedia') }}
<i v-if="account.tags.includes('strip_media')" class="el-icon-check"/> <i v-if="tags.includes('strip_media')" class="el-icon-check"/>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:class="{ 'active-tag': account.tags.includes('force_unlisted') }" :class="{ 'active-tag': tags.includes('force_unlisted') }"
@click.native="toggleTag(account, 'force_unlisted')"> @click.native="toggleTag(account, 'force_unlisted')">
{{ $t('users.forceUnlisted') }} {{ $t('users.forceUnlisted') }}
<i v-if="account.tags.includes('force_unlisted')" class="el-icon-check"/> <i v-if="tags.includes('force_unlisted')" class="el-icon-check"/>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:class="{ 'active-tag': account.tags.includes('sandbox') }" :class="{ 'active-tag': tags.includes('sandbox') }"
@click.native="toggleTag(account, 'sandbox')"> @click.native="toggleTag(account, 'sandbox')">
{{ $t('users.sandbox') }} {{ $t('users.sandbox') }}
<i v-if="account.tags.includes('sandbox')" class="el-icon-check"/> <i v-if="tags.includes('sandbox')" class="el-icon-check"/>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
v-if="account.local" v-if="account.local"
:class="{ 'active-tag': account.tags.includes('disable_remote_subscription') }" :class="{ 'active-tag': tags.includes('disable_remote_subscription') }"
@click.native="toggleTag(account, 'disable_remote_subscription')"> @click.native="toggleTag(account, 'disable_remote_subscription')">
{{ $t('users.disableRemoteSubscription') }} {{ $t('users.disableRemoteSubscription') }}
<i v-if="account.tags.includes('disable_remote_subscription')" class="el-icon-check"/> <i v-if="tags.includes('disable_remote_subscription')" class="el-icon-check"/>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
v-if="account.local" v-if="account.local"
:class="{ 'active-tag': account.tags.includes('disable_any_subscription') }" :class="{ 'active-tag': tags.includes('disable_any_subscription') }"
@click.native="toggleTag(account, 'disable_any_subscription')"> @click.native="toggleTag(account, 'disable_any_subscription')">
{{ $t('users.disableAnySubscription') }} {{ $t('users.disableAnySubscription') }}
<i v-if="account.tags.includes('disable_any_subscription')" class="el-icon-check"/> <i v-if="tags.includes('disable_any_subscription')" class="el-icon-check"/>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -66,6 +66,11 @@ export default {
required: true required: true
} }
}, },
computed: {
tags() {
return this.account.tags || []
}
},
methods: { methods: {
handleDeactivation({ nickname }) { handleDeactivation({ nickname }) {
this.$store.dispatch('ToggleUserActivation', nickname) this.$store.dispatch('ToggleUserActivation', nickname)

View file

@ -10,7 +10,8 @@
<el-card class="report"> <el-card class="report">
<div class="report-header-container"> <div class="report-header-container">
<div class="title-container"> <div class="title-container">
<h3 class="report-title">{{ $t('reports.reportOn') }} {{ report.account.display_name }}</h3> <h3 v-if="accountExists(report.account, 'display_name')" class="report-title">{{ $t('reports.reportOn') }} {{ report.account.display_name }}</h3>
<h3 v-else class="report-title">{{ $t('reports.report') }}</h3>
<h5 class="id">{{ $t('reports.id') }}: {{ report.id }}</h5> <h5 class="id">{{ $t('reports.id') }}: {{ report.id }}</h5>
</div> </div>
<div> <div>
@ -29,6 +30,7 @@
<div> <div>
<el-divider class="divider"/> <el-divider class="divider"/>
<span class="report-row-key">{{ $t('reports.account') }}:</span> <span class="report-row-key">{{ $t('reports.account') }}:</span>
<span v-if="accountExists(report.account, 'avatar') && accountExists(report.account, 'display_name')">
<img <img
:src="report.account.avatar" :src="report.account.avatar"
alt="avatar" alt="avatar"
@ -40,6 +42,8 @@
{{ report.account.display_name }} {{ report.account.display_name }}
<span class="deactivated"> (deactivated)</span> <span class="deactivated"> (deactivated)</span>
</span> </span>
</span>
<span v-else class="deactivated">({{ $t('reports.notFound') }})</span>
</div> </div>
<div v-if="report.content && report.content.length > 0"> <div v-if="report.content && report.content.length > 0">
<el-divider class="divider"/> <el-divider class="divider"/>
@ -50,6 +54,7 @@
<div :style="showStatuses(report.statuses) ? '' : 'margin-bottom:15px'"> <div :style="showStatuses(report.statuses) ? '' : 'margin-bottom:15px'">
<el-divider class="divider"/> <el-divider class="divider"/>
<span class="report-row-key">{{ $t('reports.actor') }}:</span> <span class="report-row-key">{{ $t('reports.actor') }}:</span>
<span v-if="accountExists(report.actor, 'avatar') && accountExists(report.actor, 'display_name')">
<img <img
:src="report.actor.avatar" :src="report.actor.avatar"
alt="avatar" alt="avatar"
@ -57,6 +62,8 @@
<a :href="report.actor.url" target="_blank" class="account"> <a :href="report.actor.url" target="_blank" class="account">
<span>{{ report.actor.display_name }}</span> <span>{{ report.actor.display_name }}</span>
</a> </a>
</span>
<span v-else class="deactivated">({{ $t('reports.notFound') }})</span>
</div> </div>
<div v-if="showStatuses(report.statuses)" class="statuses"> <div v-if="showStatuses(report.statuses)" class="statuses">
<el-collapse> <el-collapse>
@ -135,6 +142,9 @@ export default {
} }
}, },
methods: { methods: {
accountExists(account, key) {
return account[key]
},
changeReportState(state, id) { changeReportState(state, id) {
this.$store.dispatch('ChangeReportState', [{ state, id }]) this.$store.dispatch('ChangeReportState', [{ state, id }])
}, },