Skip to content

Commit 3b527d9

Browse files
feat: added tooltip for author role (#795)
1 parent d36c4af commit 3b527d9

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

src/discussions/common/AuthorLabel.jsx

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ const AuthorLabel = ({
5555
placement={authorToolTip ? 'top' : 'right'}
5656
overlay={(
5757
<Tooltip id={authorToolTip ? `endorsed-by-${author}-tooltip` : `${authorLabel}-label-tooltip`}>
58-
{authorToolTip ? author : authorLabel}
58+
<>
59+
{authorToolTip ? author : authorLabel}
60+
<br />
61+
{intl.formatMessage(messages.authorAdminDescription)}
62+
</>
5963
</Tooltip>
6064
)}
6165
trigger={['hover', 'focus']}
@@ -97,18 +101,38 @@ const AuthorLabel = ({
97101
</>
98102
), [author, authorLabelMessage, authorToolTip, icon, isRetiredUser, postCreatedAt, showTextPrimary, alert]);
99103

104+
const learnerPostsLink = (
105+
<Link
106+
data-testid="learner-posts-link"
107+
id="learner-posts-link"
108+
to={generatePath(Routes.LEARNERS.POSTS, { learnerUsername: author, courseId })}
109+
className="text-decoration-none text-reset"
110+
style={{ width: 'fit-content' }}
111+
>
112+
{!alert && authorName}
113+
</Link>
114+
);
115+
100116
return showUserNameAsLink
101117
? (
102118
<div className={`${className} flex-wrap`}>
103-
<Link
104-
data-testid="learner-posts-link"
105-
id="learner-posts-link"
106-
to={generatePath(Routes.LEARNERS.POSTS, { learnerUsername: author, courseId })}
107-
className="text-decoration-none text-reset"
108-
style={{ width: 'fit-content' }}
109-
>
110-
{!alert && authorName}
111-
</Link>
119+
{!authorLabel ? (
120+
<OverlayTrigger
121+
placement={authorToolTip ? 'top' : 'right'}
122+
overlay={(
123+
<Tooltip id={authorToolTip ? `endorsed-by-${author}-tooltip` : `${authorLabel}-label-tooltip`}>
124+
<>
125+
{intl.formatMessage(messages.authorLearnerTitle)}
126+
<br />
127+
{intl.formatMessage(messages.authorLearnerDescription)}
128+
</>
129+
</Tooltip>
130+
)}
131+
trigger={['hover', 'focus']}
132+
>
133+
{learnerPostsLink}
134+
</OverlayTrigger>
135+
) : learnerPostsLink }
112136
{labelContents}
113137
</div>
114138
)

src/discussions/messages.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,21 @@ const messages = defineMessages({
208208
defaultMessage: 'Enroll',
209209
description: 'Action button on content page when the user has not logged into the MFE or not enrolled in the course.',
210210
},
211+
authorAdminDescription: {
212+
id: 'discussions.author.admin.description',
213+
defaultMessage: 'Part of the team that runs this course',
214+
description: 'tooltip for course admins',
215+
},
216+
authorLearnerTitle: {
217+
id: 'discussions.author.learner.title',
218+
defaultMessage: 'Learner',
219+
description: 'tooltip for course learners title',
220+
},
221+
authorLearnerDescription: {
222+
id: 'discussions.author.learner.description',
223+
defaultMessage: 'Taking the course just like you',
224+
description: 'tooltip for course learners',
225+
},
211226
});
212227

213228
export default messages;

0 commit comments

Comments
 (0)