fix: fix for reported alert banner

This commit is contained in:
SaadYousaf
2022-10-10 13:46:00 +05:00
committed by Saad Yousaf
parent 9c1d68a5ad
commit cd204c8e05
3 changed files with 4 additions and 11 deletions

View File

@@ -23,12 +23,11 @@ function AlertBanner({
const { reasonCodesEnabled } = useSelector(selectModerationSettings);
const userIsContentAuthor = getAuthenticatedUser().username === content.author;
const canSeeLastEditOrClosedAlert = (userHasModerationPrivileges || userIsContentAuthor || userIsGroupTa);
const isReportedByCurrentUser = getAuthenticatedUser().username === content?.abuseFlaggedBy;
const canSeeReportedBanner = (userHasModerationPrivileges || userIsGroupTa || isReportedByCurrentUser);
const canSeeReportedBanner = content?.abuseFlagged;
return (
<>
{content.abuseFlagged && canSeeReportedBanner && (
{canSeeReportedBanner && (
<Alert icon={Error} variant="danger" className="px-3 mb-2 py-10px shadow-none flex-fill">
{intl.formatMessage(messages.abuseFlaggedMessage)}
</Alert>

View File

@@ -142,8 +142,7 @@ export const useAlertBannerVisible = (content) => {
const { reasonCodesEnabled } = useSelector(selectModerationSettings);
const userIsContentAuthor = getAuthenticatedUser().username === content.author;
const canSeeLastEditOrClosedAlert = (userHasModerationPrivileges || userIsContentAuthor || userIsGroupTa);
const isReportedByCurrentUser = getAuthenticatedUser().username === content?.abuseFlaggedBy;
const canSeeReportedBanner = (userHasModerationPrivileges || userIsGroupTa || isReportedByCurrentUser);
const canSeeReportedBanner = content.abuseFlagged;
return (
(reasonCodesEnabled && canSeeLastEditOrClosedAlert && (content.lastEdit?.reason || content.closed))

View File

@@ -2,7 +2,6 @@ import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { useSelector } from 'react-redux';
import { Link } from 'react-router-dom';
import { useIntl } from '@edx/frontend-platform/i18n';
@@ -12,7 +11,6 @@ import { PushPin } from '../../../components/icons';
import { AvatarOutlineAndLabelColors, Routes, ThreadType } from '../../../data/constants';
import AuthorLabel from '../../common/AuthorLabel';
import { DiscussionContext } from '../../common/context';
import { selectUserHasModerationPrivileges, selectUserIsGroupTa } from '../../data/selectors';
import { discussionsPath, isPostPreviewAvailable } from '../../utils';
import messages from './messages';
import PostFooter from './PostFooter';
@@ -42,12 +40,9 @@ function PostLink({
category,
learnerUsername,
});
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges);
const userIsGroupTa = useSelector(selectUserIsGroupTa);
const showAnsweredBadge = post.hasEndorsed && post.type === ThreadType.QUESTION;
const authorLabelColor = AvatarOutlineAndLabelColors[post.authorLabel];
const postReported = post.abuseFlagged || post.abuseFlaggedCount;
const canSeeReportedBadge = postReported && (userHasModerationPrivileges || userIsGroupTa);
const canSeeReportedBadge = post.abuseFlagged;
const read = post.read || (!post.read && post.commentCount !== post.unreadCommentCount);
return (