diff --git a/src/discussions/common/AuthorLabel.jsx b/src/discussions/common/AuthorLabel.jsx index 1334fac1..ea87c0ec 100644 --- a/src/discussions/common/AuthorLabel.jsx +++ b/src/discussions/common/AuthorLabel.jsx @@ -65,7 +65,7 @@ function AuthorLabel({ )} {authorLabelMessage && ( state.courseTabs); - + const topic = useSelector(selectTopic(post.topicId)); + const getTopicSubsection = useSelector(selectorForUnitSubsection); + const topicContext = useSelector(selectTopicContext(post.topicId)); const { reasonCodesEnabled } = useSelector(selectModerationSettings); const [isDeleting, showDeleteConfirmation, hideDeleteConfirmation] = useToggle(false); const [isClosing, showClosePostModal, hideClosePostModal] = useToggle(false); @@ -51,6 +55,10 @@ function Post({ [ContentActions.REPORT]: () => dispatch(updateExistingThread(post.id, { flagged: !post.abuseFlagged })), }; + const getTopicCategoryName = topicData => ( + topicData.usageKey ? getTopicSubsection(topicData.usageKey)?.displayName : topicData.categoryId + ); + return (
- + {topicContext && topic && ( +
+ {intl.formatMessage(messages.relatedTo)}{' '} + + {`${getTopicCategoryName(topic)} / ${topic.name}`} + +
+ )}
diff --git a/src/discussions/posts/post/PostHeader.jsx b/src/discussions/posts/post/PostHeader.jsx index cedcc051..1784f400 100644 --- a/src/discussions/posts/post/PostHeader.jsx +++ b/src/discussions/posts/post/PostHeader.jsx @@ -5,16 +5,12 @@ import classNames from 'classnames'; import { useSelector } from 'react-redux'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; -import { - Avatar, Badge, Hyperlink, Icon, -} from '@edx/paragon'; +import { Avatar, Badge, Icon } from '@edx/paragon'; import { Issue, Question } from '../../../components/icons'; import { AvatarOutlineAndLabelColors, ThreadType } from '../../../data/constants'; -import { selectorForUnitSubsection, selectTopicContext } from '../../../data/selectors'; import { ActionsDropdown, AuthorLabel } from '../../common'; import { useAlertBannerVisible } from '../../data/hooks'; -import { selectTopic } from '../../topics/data/selectors'; import { selectAuthorAvatars } from '../data/selectors'; import messages from './messages'; import { postShape } from './proptypes'; @@ -95,13 +91,6 @@ function PostHeader({ const showAnsweredBadge = preview && post.hasEndorsed && post.type === ThreadType.QUESTION; const authorLabelColor = AvatarOutlineAndLabelColors[post.authorLabel]; const hasAnyAlert = useAlertBannerVisible(post); - const topic = useSelector(selectTopic(post.topicId)); - const topicContext = useSelector(selectTopicContext(post.topicId)); - const getTopicSubsection = useSelector(selectorForUnitSubsection); - - const getTopicCategoryName = topicData => ( - topicData.usageKey ? getTopicSubsection(topicData.usageKey)?.displayName : topicData.categoryId - ); return (
@@ -121,29 +110,12 @@ function PostHeader({
) :

{post.title}

} -
- - {topicContext && topic && ( -
- {`${intl.formatMessage(messages.relatedTo)} `} - -
- {getTopicCategoryName(topic)} - / - {topic.name} -
-
-
- )} -
+ {!preview diff --git a/src/discussions/posts/post/messages.js b/src/discussions/posts/post/messages.js index f890922a..e74fda5c 100644 --- a/src/discussions/posts/post/messages.js +++ b/src/discussions/posts/post/messages.js @@ -60,7 +60,7 @@ const messages = defineMessages({ }, relatedTo: { id: 'discussions.post.relatedTo', - defaultMessage: 'in', + defaultMessage: 'Related to', description: 'Message followed the category and topic of post linking to in-course context', }, deletePostTitle: {