feat: bulk purge flags

This commit is contained in:
Opliko
2024-04-14 00:20:46 +02:00
parent 9ab1a2d129
commit 7bacbf76f0
2 changed files with 29 additions and 5 deletions

View File

@@ -84,6 +84,7 @@
"modal-reason-offensive": "Offensive",
"modal-reason-other": "Other (specify below)",
"modal-reason-custom": "Reason for reporting this content...",
"modal-notify-remote": "Forward this report to %1",
"modal-submit": "Submit Report",
"modal-submit-success": "Content has been flagged for moderation.",
@@ -91,6 +92,8 @@
"bulk-actions": "Bulk Actions",
"bulk-resolve": "Resolve Flag(s)",
"confirm-purge": "Are you sure you want to permanently delete these flags?",
"purge-cancelled": "Flag Purge Cancelled",
"bulk-purge": "Purge Flag(s)",
"bulk-success": "%1 flags updated",
"flagged-timeago-readable": "Flagged <span class=\"timeago\" title=\"%1\"></span> (%2)",

View File

@@ -213,13 +213,34 @@ export function handleBulkActions() {
const subselector = e.target.closest('[data-action]');
if (subselector) {
const action = subselector.getAttribute('data-action');
let confirmed;
if (action === 'bulk-purge') {
confirmed = new Promise((resolve, reject) => {
bootbox.confirm('[[flags:confirm-purge]]', (confirmed) => {
if (confirmed) {
resolve();
} else {
reject(new Error('[[flags:purge-cancelled]]'));
}
});
});
}
const flagIds = getSelected();
const promises = flagIds.map((flagId) => {
const promises = flagIds.map(async (flagId) => {
const data = {};
if (action === 'bulk-assign') {
data.assignee = app.user.uid;
} else if (action === 'bulk-mark-resolved') {
data.state = 'resolved';
switch (action) {
case 'bulk-assign': {
data.assignee = app.user.uid;
break;
}
case 'bulk-mark-resolved': {
data.state = 'resolved';
break;
}
case 'bulk-purge': {
await confirmed;
return api.del(`/flags/${flagId}`);
}
}
return api.put(`/flags/${flagId}`, data);
});