* Fixed an issue with the moderation button not appearing on some posts. * Added some E2E tests to ensure moderation button is on posts for trusted users. * Added some more tests. * Added a test to ensure moderation button does not appear when logged out.
28 lines
833 B
JavaScript
28 lines
833 B
JavaScript
/* global userData */
|
|
import { isModerationPage } from '@utilities/moderation';
|
|
|
|
const user = userData();
|
|
const { authorId: articleAuthorId, path } = document.getElementById(
|
|
'article-show-container',
|
|
).dataset;
|
|
|
|
const initializeModerationsTools = async () => {
|
|
const { initializeActionsPanel } = await import(
|
|
'../actionsPanel/initializeActionsPanelToggle'
|
|
);
|
|
const { initializeFlagUserModal } = await import('./flagUserModal');
|
|
|
|
// article show page
|
|
if (user?.trusted) {
|
|
if (user?.id !== articleAuthorId && !isModerationPage()) {
|
|
initializeActionsPanel(user, path);
|
|
initializeFlagUserModal(articleAuthorId);
|
|
// dev.to/mod
|
|
} else if (isModerationPage()) {
|
|
initializeActionsPanel(user, path);
|
|
initializeFlagUserModal(articleAuthorId);
|
|
}
|
|
}
|
|
};
|
|
|
|
initializeModerationsTools();
|