* gotta commit at some point * out of gas * IT'S WORKING NOW! 💥 * Cypress tests * fix Travis failures * incorporate PR review suggestions * fix one failing Cypress test * update API call * add Unsuspend flow; fix Travis failures * add tests for unsuspend flow * remove unnecessary atrribute * add article_policy spec * fix failing Travis * nudge Travis * fix apparent typo o o 🤷 * refactor a bunch of duplication * nudge Travis * fix Cypress failure related to authorizing moderator for user_status action * rename modal partial * remove unnecessary button-exists check * address PR review suggestions * hide suspend user btn after action * toggle btn based on author suspension status * add data-testids * use data-testids * controller refactor
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
import {
|
|
showWindowModal,
|
|
closeWindowModal,
|
|
WINDOW_MODAL_ID,
|
|
} from '@utilities/showModal';
|
|
|
|
// The GDPR Delete Requests table may have up to 50 entries at once. Instead of adding an event listener for every row, we
|
|
// instead listen for clicks anywhere in the table, and only trigger the modal if the click target was a confirm delete button
|
|
document
|
|
.getElementById('gdpr-delete-requests-content')
|
|
?.addEventListener('click', ({ target }) => {
|
|
const {
|
|
dataset: { username, gdprFormAction },
|
|
} = target;
|
|
if (gdprFormAction) {
|
|
handleConfirmDelete(username, gdprFormAction);
|
|
}
|
|
});
|
|
|
|
const handleConfirmDelete = (username, formAction) => {
|
|
showWindowModal({
|
|
title: `Are you sure you have deleted all external data for @${username}?`,
|
|
contentSelector: '#gdpr-confirm-delete-modal',
|
|
onOpen: () => {
|
|
// Set the action of the form
|
|
document.getElementById(WINDOW_MODAL_ID).querySelector('form').action =
|
|
formAction;
|
|
|
|
// Update cancel button to close the modal
|
|
document
|
|
.querySelector(`#${WINDOW_MODAL_ID} .js-gdpr-cancel-deleted`)
|
|
.addEventListener('click', () => closeWindowModal());
|
|
},
|
|
});
|
|
};
|