Add ability to change status scope
This commit is contained in:
parent
7a0180c727
commit
7b4184cbde
3 changed files with 51 additions and 7 deletions
|
@ -12,6 +12,16 @@ export async function changeState(state, id, authHost, token) {
|
|||
})
|
||||
}
|
||||
|
||||
export async function changeStatusScope(id, sensitive, visibility, authHost, token) {
|
||||
return await request({
|
||||
baseURL: baseName(authHost),
|
||||
url: `/api/pleroma/admin/statuses/${id}`,
|
||||
method: 'put',
|
||||
headers: authHeaders(token),
|
||||
data: { sensitive, visibility }
|
||||
})
|
||||
}
|
||||
|
||||
export async function fetchReports(limit, max_id, authHost, token) {
|
||||
return await request({
|
||||
baseURL: baseName(authHost),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { changeState, fetchReports, filterReports } from '@/api/reports'
|
||||
import { changeState, changeStatusScope, fetchReports, filterReports } from '@/api/reports'
|
||||
|
||||
const reports = {
|
||||
state: {
|
||||
|
@ -28,6 +28,18 @@ const reports = {
|
|||
const updatedReports = state.fetchedReports.map(report => report.id === reportId ? data : report)
|
||||
commit('SET_REPORTS', updatedReports)
|
||||
},
|
||||
async ChangeStatusScope({ commit, getters, state }, { statusId, isSensitive, visibility, reportId }) {
|
||||
const { data } = await changeStatusScope(statusId, isSensitive, visibility, getters.authHost, getters.token)
|
||||
const updatedReports = state.fetchedReports.map(report => {
|
||||
if (report.id === reportId) {
|
||||
const statuses = report.statuses.map(status => status.id === statusId ? data : status)
|
||||
return { ...report, statuses }
|
||||
} else {
|
||||
return report
|
||||
}
|
||||
})
|
||||
commit('SET_REPORTS', updatedReports)
|
||||
},
|
||||
async FetchReports({ commit, getters, state }) {
|
||||
commit('SET_LOADING', true)
|
||||
const response = await fetchReports(state.page_limit, state.idOfLastReport, getters.authHost, getters.token)
|
||||
|
|
|
@ -13,11 +13,31 @@
|
|||
<el-dropdown trigger="click">
|
||||
<el-button plain size="small" icon="el-icon-edit">{{ $t('reports.changeScope') }}<i class="el-icon-arrow-down el-icon--right"/></el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item v-if="!status.sensitive">{{ $t('reports.addSensitive') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="status.sensitive">{{ $t('reports.removeSensitive') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="status.visibility !== 'public'">{{ $t('reports.public') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="status.visibility !== 'private'">{{ $t('reports.private') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="status.visibility !== 'unlisted'">{{ $t('reports.unlisted') }}</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="!status.sensitive"
|
||||
@click.native="changeStatus(status.id, true, status.visibility, report.id)">
|
||||
{{ $t('reports.addSensitive') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="status.sensitive"
|
||||
@click.native="changeStatus(status.id, false, status.visibility, report.id)">
|
||||
{{ $t('reports.removeSensitive') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="status.visibility !== 'public'"
|
||||
@click.native="changeStatus(status.id, status.sensitive, 'public', report.id)">
|
||||
{{ $t('reports.public') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="status.visibility !== 'private'"
|
||||
@click.native="changeStatus(status.id, status.sensitive, 'private', report.id)">
|
||||
{{ $t('reports.private') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="status.visibility !== 'unlisted'"
|
||||
@click.native="changeStatus(status.id, status.sensitive, 'unlisted', report.id)">
|
||||
{{ $t('reports.unlisted') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
|
@ -51,8 +71,10 @@ export default {
|
|||
capitalizeFirstLetter(str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||
},
|
||||
changeStatus(statusId, isSensitive, visibility, reportId) {
|
||||
this.$store.dispatch('ChangeStatusScope', { statusId, isSensitive, visibility, reportId })
|
||||
},
|
||||
getStatusesTitle(statuses) {
|
||||
console.log(this.report)
|
||||
return `Reported statuses: ${statuses.length} item(s)`
|
||||
},
|
||||
parseTimestamp(timestamp) {
|
||||
|
|
Loading…
Reference in a new issue