Commit 7b4184cb authored by Angelina Filippova's avatar Angelina Filippova

Add ability to change status scope

parent 7a0180c7
...@@ -12,6 +12,16 @@ export async function changeState(state, id, authHost, token) { ...@@ -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) { export async function fetchReports(limit, max_id, authHost, token) {
return await request({ return await request({
baseURL: baseName(authHost), baseURL: baseName(authHost),
......
import { changeState, fetchReports, filterReports } from '@/api/reports' import { changeState, changeStatusScope, fetchReports, filterReports } from '@/api/reports'
const reports = { const reports = {
state: { state: {
...@@ -28,6 +28,18 @@ const reports = { ...@@ -28,6 +28,18 @@ const reports = {
const updatedReports = state.fetchedReports.map(report => report.id === reportId ? data : report) const updatedReports = state.fetchedReports.map(report => report.id === reportId ? data : report)
commit('SET_REPORTS', updatedReports) 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 }) { async FetchReports({ commit, getters, state }) {
commit('SET_LOADING', true) commit('SET_LOADING', true)
const response = await fetchReports(state.page_limit, state.idOfLastReport, getters.authHost, getters.token) const response = await fetchReports(state.page_limit, state.idOfLastReport, getters.authHost, getters.token)
......
...@@ -13,11 +13,31 @@ ...@@ -13,11 +13,31 @@
<el-dropdown trigger="click"> <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-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-menu slot="dropdown">
<el-dropdown-item v-if="!status.sensitive">{{ $t('reports.addSensitive') }}</el-dropdown-item> <el-dropdown-item
<el-dropdown-item v-if="status.sensitive">{{ $t('reports.removeSensitive') }}</el-dropdown-item> v-if="!status.sensitive"
<el-dropdown-item v-if="status.visibility !== 'public'">{{ $t('reports.public') }}</el-dropdown-item> @click.native="changeStatus(status.id, true, status.visibility, report.id)">
<el-dropdown-item v-if="status.visibility !== 'private'">{{ $t('reports.private') }}</el-dropdown-item> {{ $t('reports.addSensitive') }}
<el-dropdown-item v-if="status.visibility !== 'unlisted'">{{ $t('reports.unlisted') }}</el-dropdown-item> </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-menu>
</el-dropdown> </el-dropdown>
</div> </div>
...@@ -51,8 +71,10 @@ export default { ...@@ -51,8 +71,10 @@ export default {
capitalizeFirstLetter(str) { capitalizeFirstLetter(str) {
return str.charAt(0).toUpperCase() + str.slice(1) return str.charAt(0).toUpperCase() + str.slice(1)
}, },
changeStatus(statusId, isSensitive, visibility, reportId) {
this.$store.dispatch('ChangeStatusScope', { statusId, isSensitive, visibility, reportId })
},
getStatusesTitle(statuses) { getStatusesTitle(statuses) {
console.log(this.report)
return `Reported statuses: ${statuses.length} item(s)` return `Reported statuses: ${statuses.length} item(s)`
}, },
parseTimestamp(timestamp) { parseTimestamp(timestamp) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment