Skip to content

Commit

Permalink
fix: changed username to simple text for incontext view
Browse files Browse the repository at this point in the history
  • Loading branch information
sohailfatima committed Jan 25, 2024
1 parent db8a513 commit 8db03af
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
41 changes: 22 additions & 19 deletions src/discussions/common/AuthorLabel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useMemo } from 'react';
import PropTypes from 'prop-types';

import classNames from 'classnames';
import { Link, useLocation } from 'react-router-dom';
import { generatePath, Link } from 'react-router-dom';
import * as timeago from 'timeago.js';

import { useIntl } from '@edx/frontend-platform/i18n';
Expand All @@ -11,7 +11,6 @@ import { Institution, School } from '@edx/paragon/icons';

import { Routes } from '../../data/constants';
import messages from '../messages';
import { discussionsPath } from '../utils';
import { DiscussionContext } from './context';
import timeLocale from './time-locale';

Expand Down Expand Up @@ -110,26 +109,30 @@ const AuthorLabel = ({
</>
), [author, authorLabelMessage, authorToolTip, icon, isRetiredUser, postCreatedAt, showTextPrimary, alert]);

const { pathname } = discussionsPath(Routes.LEARNERS.POSTS, {
0: enableInContextSidebar ? 'in-context' : undefined,
learnerUsername: author,
courseId,
})();

const { search } = useLocation();

return showUserNameAsLink
? (
<div className={className}>
<Link
data-testid="learner-posts-link"
id="learner-posts-link"
to={`${pathname}${enableInContextSidebar ? search : ''}`}
className="text-decoration-none"
style={{ width: 'fit-content' }}
>
{!alert && authorName}
</Link>
{ enableInContextSidebar
? (
<div
id="learner-posts"
className="text-decoration-none"
style={{ width: 'fit-content' }}
>
{!alert && authorName}
</div>
)
: (
<Link
data-testid="learner-posts-link"
id="learner-posts-link"
to={generatePath(Routes.LEARNERS.POSTS, { learnerUsername: author, courseId })}
className="text-decoration-none"
style={{ width: 'fit-content' }}
>
{!alert && authorName}
</Link>
)}
{labelContents}
</div>
)
Expand Down
8 changes: 3 additions & 5 deletions src/discussions/learners/learner/LearnerCard.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext } from 'react';

import { Link, useLocation } from 'react-router-dom';
import { Link } from 'react-router-dom';

import { Routes } from '../../../data/constants';
import { DiscussionContext } from '../../common/context';
Expand All @@ -14,18 +14,16 @@ const LearnerCard = ({ learner }) => {
username, threads, inactiveFlags, activeFlags, responses, replies,
} = learner;
const { enableInContextSidebar, learnerUsername, courseId } = useContext(DiscussionContext);
const { pathname } = discussionsPath(Routes.LEARNERS.POSTS, {
const linkUrl = discussionsPath(Routes.LEARNERS.POSTS, {
0: enableInContextSidebar ? 'in-context' : undefined,
learnerUsername: learner.username,
courseId,
})();

const { search } = useLocation();

return (
<Link
className="discussion-post p-0 text-decoration-none text-gray-900 border-bottom border-light-400"
to={`${pathname}${enableInContextSidebar ? search : ''}`}
to={linkUrl}
>
<div
className="d-flex flex-row flex-fill mw-100 py-3 px-4 border-primary-500"
Expand Down
4 changes: 4 additions & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ header {
}
}

#learner-posts-text {
color: inherit;
}

#learner-posts-link {
color: inherit;

Expand Down

0 comments on commit 8db03af

Please sign in to comment.