From f686fb40a15736e92902187f8dff17b7d8598d6d Mon Sep 17 00:00:00 2001
From: ayesha waris <73840786+ayeshoali@users.noreply.github.com>
Date: Mon, 14 Nov 2022 18:11:31 +0500
Subject: [PATCH] Revert "Topic information moved next to username"
---
src/discussions/posts/post/Post.jsx | 24 +++++++++++--
src/discussions/posts/post/PostHeader.jsx | 42 ++++-------------------
src/discussions/posts/post/messages.js | 2 +-
3 files changed, 29 insertions(+), 39 deletions(-)
diff --git a/src/discussions/posts/post/Post.jsx b/src/discussions/posts/post/Post.jsx
index fd40471b..870cfedf 100644
--- a/src/discussions/posts/post/Post.jsx
+++ b/src/discussions/posts/post/Post.jsx
@@ -5,12 +5,14 @@ import { useDispatch, useSelector } from 'react-redux';
import { useHistory, useLocation } from 'react-router-dom';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
-import { useToggle } from '@edx/paragon';
+import { Hyperlink, useToggle } from '@edx/paragon';
import HTMLLoader from '../../../components/HTMLLoader';
import { ContentActions } from '../../../data/constants';
+import { selectorForUnitSubsection, selectTopicContext } from '../../../data/selectors';
import { AlertBanner, DeleteConfirmation } from '../../common';
import { selectModerationSettings } from '../../data/selectors';
+import { selectTopic } from '../../topics/data/selectors';
import { removeThread, updateExistingThread } from '../data/thunks';
import ClosePostReasonModal from './ClosePostReasonModal';
import messages from './messages';
@@ -27,7 +29,9 @@ function Post({
const history = useHistory();
const dispatch = useDispatch();
const { courseId } = useSelector((state) => 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: {