mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-05 15:20:39 +01:00
feat: bulk purge flags
This commit is contained in:
@@ -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)",
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user