* init * . * partials * few extras * revert indicators in favor of separate PR * stuff * . * stuff * whoops * . * . * . * . * opacity * partial * cosmetics * move actions to a partial * whoopsy * Added an @admin alias for the frontend and removed the @admin-controllers alias. * Added modal support for admin user actions. * Added modal support for more parts of the user admin. * pills * pills * pills * Added optional chaining for when the overview panel isn't loaded. * styling updates * fix * modals * pass size * tags * . * balance modal * comment * fixes * Improved modal trigger implementation. * Removed default value for dataset. * Moved prevent default to after modal trigger check so forms still submit. * Update app/views/admin/users/widgets/_credits.html.erb Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> * Update app/views/admin/users/reports/_index.html.erb * Apply suggestions from code review * Apply suggestions from code review * Update app/views/admin/users/actions/_export.html.erb * Update app/views/admin/users/widgets/_tag_moderation.html.erb * Update app/views/admin/users/actions/_merge.html.erb * Removed <AdminUserActionsModal /> component as it wasn't necessary. * Fixed duplicate ID errors detected by Axe. * Redirects to the Show page rather than the Edit page * Adjusts quotations within _social_accounts.html.erb * Ensures that Learn More links open in new tab * updates with latests and greatest * . * fixes * wip. Fixed some issues in the credits form. * Changed Subtract to Remove for credits dropdown. * Cleaned up the edits form. * Wraps functionality in feature flag and calls #set_user_details * Wraps /admin/users/show.html.erb in feature flag * wip: Got credit params form working. * empty select * responsiveness * empty commiit * Updates redirects in spec and controller to show rather than edit * Updates tag moderation copy in Admin Member Detail View * Now the note is saved when changing credits. * Fixed label for attributes as it was affecting writing tests and a11y. * Removes unused index.js component * Refactored credit params. * chore: move method under private and update comment * verified email responsiveness * better opacity variables * better org logo * indicators * refactor the credits method Co-authored-by: Nick Taylor <nick@dev.to> Co-authored-by: Nick Taylor <nick@iamdeveloper.com> Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> Co-authored-by: Nick Taylor <nick@forem.com> Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
70 lines
1.8 KiB
JavaScript
70 lines
1.8 KiB
JavaScript
import { initializeDropdown } from '@utilities/dropdownUtils';
|
|
|
|
let preact;
|
|
let AdminModal;
|
|
const modalContents = new Map();
|
|
|
|
function getModalContents(modalContentSelector) {
|
|
if (!modalContents.has(modalContentSelector)) {
|
|
const modelContentElement = document.querySelector(modalContentSelector);
|
|
const modalContent = modelContentElement.innerHTML;
|
|
|
|
// Remove the element from the DOM to avoid duplicate ID errors in regards to a11y.
|
|
modelContentElement.remove();
|
|
modalContents.set(modalContentSelector, modalContent);
|
|
}
|
|
|
|
return modalContents.get(modalContentSelector);
|
|
}
|
|
|
|
// Append an empty div to the end of the document so that is does not affect the layout.
|
|
const modalContainer = document.createElement('div');
|
|
document.body.appendChild(modalContainer);
|
|
|
|
initializeDropdown({
|
|
triggerElementId: 'options-dropdown-trigger',
|
|
dropdownContentId: 'options-dropdown',
|
|
});
|
|
|
|
const openModal = async (event) => {
|
|
const { dataset } = event.target;
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(dataset, 'modalTrigger')) {
|
|
// We're not trying to trigger a modal.
|
|
return;
|
|
}
|
|
|
|
event.preventDefault();
|
|
|
|
// Only load Preact if we haven't already.
|
|
if (!preact) {
|
|
[preact, { Modal: AdminModal }] = await Promise.all([
|
|
import('preact'),
|
|
import('@crayons/Modal/Modal'),
|
|
]);
|
|
}
|
|
|
|
const { h, render } = preact;
|
|
|
|
const { modalTitle, modalSize, modalContentSelector } = dataset;
|
|
|
|
render(
|
|
<AdminModal
|
|
title={modalTitle}
|
|
size={modalSize}
|
|
onClose={() => {
|
|
render(null, modalContainer);
|
|
}}
|
|
>
|
|
<div
|
|
// eslint-disable-next-line react/no-danger
|
|
dangerouslySetInnerHTML={{
|
|
__html: getModalContents(modalContentSelector),
|
|
}}
|
|
/>
|
|
</AdminModal>,
|
|
modalContainer,
|
|
);
|
|
};
|
|
|
|
document.body.addEventListener('click', openModal);
|