Add ability to delete status
This commit is contained in:
parent
93866e78ae
commit
c9d6402c37
5 changed files with 47 additions and 3 deletions
|
@ -22,6 +22,15 @@ export async function changeStatusScope(id, sensitive, visibility, authHost, tok
|
|||
})
|
||||
}
|
||||
|
||||
export async function deleteStatus(id, authHost, token) {
|
||||
return await request({
|
||||
baseURL: baseName(authHost),
|
||||
url: `/api/pleroma/admin/statuses/${id}`,
|
||||
method: 'delete',
|
||||
headers: authHeaders(token)
|
||||
})
|
||||
}
|
||||
|
||||
export async function fetchReports(limit, max_id, authHost, token) {
|
||||
return await request({
|
||||
baseURL: baseName(authHost),
|
||||
|
|
|
@ -223,7 +223,8 @@ export default {
|
|||
public: 'Make status public',
|
||||
private: 'Make status private',
|
||||
unlisted: 'Make status unlisted',
|
||||
sensitive: 'Sensitive'
|
||||
sensitive: 'Sensitive',
|
||||
deleteStatus: 'Delete status'
|
||||
},
|
||||
reportsFilter: {
|
||||
inputPlaceholder: 'Select filter',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { changeState, changeStatusScope, fetchReports, filterReports } from '@/api/reports'
|
||||
import { changeState, changeStatusScope, deleteStatus, fetchReports, filterReports } from '@/api/reports'
|
||||
|
||||
const reports = {
|
||||
state: {
|
||||
|
@ -40,6 +40,18 @@ const reports = {
|
|||
})
|
||||
commit('SET_REPORTS', updatedReports)
|
||||
},
|
||||
async DeleteStatus({ commit, getters, state }, { statusId, reportId }) {
|
||||
deleteStatus(statusId, getters.authHost, getters.token)
|
||||
const updatedReports = state.fetchedReports.map(report => {
|
||||
if (report.id === reportId) {
|
||||
const statuses = report.statuses.filter(status => status.id !== statusId)
|
||||
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)
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
@click.native="changeStatus(status.id, status.sensitive, 'unlisted', report.id)">
|
||||
{{ $t('reports.unlisted') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click.native="deleteStatus(status.id, report.id)">
|
||||
{{ $t('reports.deleteStatus') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
|
@ -74,6 +78,24 @@ export default {
|
|||
changeStatus(statusId, isSensitive, visibility, reportId) {
|
||||
this.$store.dispatch('ChangeStatusScope', { statusId, isSensitive, visibility, reportId })
|
||||
},
|
||||
deleteStatus(statusId, reportId) {
|
||||
this.$confirm('Are you sure you want to delete this status?', 'Warning', {
|
||||
confirmButtonText: 'OK',
|
||||
cancelButtonText: 'Cancel',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$store.dispatch('DeleteStatus', { statusId, reportId })
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: 'Delete completed'
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: 'Delete canceled'
|
||||
})
|
||||
})
|
||||
},
|
||||
getStatusesTitle(statuses) {
|
||||
return `Reported statuses: ${statuses.length} item(s)`
|
||||
},
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<span class="report-row-key">Account:</span>
|
||||
<img
|
||||
:src="report.account.avatar"
|
||||
alt="User's avatar"
|
||||
alt="avatar"
|
||||
class="avatar-img">
|
||||
<a :href="report.account.url" target="_blank" class="account">
|
||||
<span class="report-row-value">{{ report.account.acct }}</span>
|
||||
|
|
Loading…
Reference in a new issue