* building again * still building * still building * stuck * Suzanne Holmes on the case * make report content a button not a link * revert to link * add tests * revert changes made trying to get ModCenter to work * hide nonworking actions_panel btns in Mod Center * nudge Travis * incorporate PR comments Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
/* global userData */
|
|
import { isModerationPage } from '@utilities/moderation';
|
|
|
|
getCsrfToken().then(() => {
|
|
const articleContainer = document.getElementById('article-show-container');
|
|
|
|
if (articleContainer) {
|
|
const user = userData();
|
|
const { authorId: articleAuthorId, path } = articleContainer.dataset;
|
|
|
|
const initializeModerationsTools = async () => {
|
|
const { initializeActionsPanel } = await import(
|
|
'../actionsPanel/initializeActionsPanelToggle'
|
|
);
|
|
|
|
// If the user can moderate an article give them access to this panel.
|
|
// Note: this assumes we're within the article context (which is the case
|
|
// given the articleContainer)
|
|
const canModerateArticles = user?.policies?.find(
|
|
(o) =>
|
|
o.dom_class === 'js-policy-article-moderate' && o.visible === true,
|
|
);
|
|
|
|
// article show page
|
|
if (canModerateArticles) {
|
|
// <2022-05-09 Mon> [@jeremyf] the user.id is an integer and
|
|
// articleAuthorId is a string so our logic is such that we always
|
|
// initializeActionsPanel and initializeFlagUserModal; I'm asking
|
|
// product to clarify if we want mods to boost their own posts.
|
|
if (user?.id !== articleAuthorId && !isModerationPage()) {
|
|
initializeActionsPanel(user, path);
|
|
// "/mod" page
|
|
} else if (isModerationPage()) {
|
|
initializeActionsPanel(user, path);
|
|
}
|
|
}
|
|
};
|
|
|
|
initializeModerationsTools();
|
|
}
|
|
});
|