From d25ded18b1d799363a30fa8fc270ad4e17b8eda6 Mon Sep 17 00:00:00 2001
From: Jeff Chaves <58956521+chavesj@users.noreply.github.com>
Date: Thu, 8 Apr 2021 16:30:04 -0400
Subject: [PATCH] refactor: opens all B2C course page links in a new tab (#252)
* refactor: opens all B2C course page links in a new tab
* refactor: removes subject link, adds active label with course title to course page breadcrumbs
---
.../course/CourseAssociatedPrograms.jsx | 6 ++---
src/components/course/CourseHeader.jsx | 25 ++++++++++---------
src/components/course/CourseMainContent.jsx | 17 ++++++++++---
src/components/course/CourseSidebar.jsx | 9 ++++---
src/components/course/CreatedBy.jsx | 22 ++++++++++++----
.../course/tests/CourseHeader.test.jsx | 5 ++--
6 files changed, 53 insertions(+), 31 deletions(-)
diff --git a/src/components/course/CourseAssociatedPrograms.jsx b/src/components/course/CourseAssociatedPrograms.jsx
index 94ca834ff1..7828b35c0a 100644
--- a/src/components/course/CourseAssociatedPrograms.jsx
+++ b/src/components/course/CourseAssociatedPrograms.jsx
@@ -1,7 +1,7 @@
import React, { useContext } from 'react';
+import { Hyperlink } from '@edx/paragon';
import { CourseContext } from './CourseContextProvider';
-
import { getProgramIcon, formatProgramType } from './data/utils';
export default function CourseAssociatedPrograms() {
@@ -28,9 +28,9 @@ export default function CourseAssociatedPrograms() {
{primarySubject && (
-
+
+
+
)}
{partners.length > 0 && (
@@ -85,6 +84,8 @@ export default function CourseHeader() {
className="d-inline-block mr-4"
href={partner.marketingUrl}
key={partner.uuid}
+ target="_blank"
+ rel="noopener noreferrer"
>
(
))}
diff --git a/src/components/course/CourseSidebar.jsx b/src/components/course/CourseSidebar.jsx
index db7ec2a175..233b43c8e5 100644
--- a/src/components/course/CourseSidebar.jsx
+++ b/src/components/course/CourseSidebar.jsx
@@ -11,6 +11,7 @@ import {
} from '@fortawesome/free-solid-svg-icons';
import ISO6391 from 'iso-639-1';
+import { Hyperlink } from '@edx/paragon';
import { CourseContext } from './CourseContextProvider';
import CourseSidebarListItem from './CourseSidebarListItem';
import CourseAssociatedPrograms from './CourseAssociatedPrograms';
@@ -66,9 +67,9 @@ export default function CourseSidebar() {
label={institutionLabel}
content={partners.map(partner => (
-
+
{partner.key}
-
+
))}
/>
@@ -78,9 +79,9 @@ export default function CourseSidebar() {
icon={faGraduationCap}
label="Subject"
content={(
-
+
{primarySubject.name}
-
+
)}
/>
)}
diff --git a/src/components/course/CreatedBy.jsx b/src/components/course/CreatedBy.jsx
index c2586e2620..91581025ce 100644
--- a/src/components/course/CreatedBy.jsx
+++ b/src/components/course/CreatedBy.jsx
@@ -1,8 +1,8 @@
import React, { useContext } from 'react';
import { AppContext } from '@edx/frontend-platform/react';
+import { Hyperlink } from '@edx/paragon';
import { CourseContext } from './CourseContextProvider';
-
import { useCoursePartners } from './data/hooks';
export default function CreatedBy() {
@@ -25,11 +25,19 @@ export default function CreatedBy() {
{partners.map(partner => (
))}
@@ -45,9 +53,13 @@ export default function CreatedBy() {
style={{ width: 72, height: 72 }}
/>
-
+
{formatStaffFullName(staff)}
-
+
{staff.position && (
<>
{staff.position.title}
diff --git a/src/components/course/tests/CourseHeader.test.jsx b/src/components/course/tests/CourseHeader.test.jsx
index 68f0ce0755..d3ada4b794 100644
--- a/src/components/course/tests/CourseHeader.test.jsx
+++ b/src/components/course/tests/CourseHeader.test.jsx
@@ -91,8 +91,7 @@ describe('
', () => {
/>,
);
expect(screen.queryByText('Find a Course')).toBeInTheDocument();
- const subject = initialCourseState.course.subjects[0];
- expect(screen.queryByText(`${subject.name} Courses`)).toBeInTheDocument();
+ expect(screen.queryAllByText(initialCourseState.course.title)[0]).toBeInTheDocument();
});
test('renders course title and short description', () => {
@@ -105,7 +104,7 @@ describe('
', () => {
);
const { title, shortDescription } = initialCourseState.course;
- expect(screen.queryByText(title)).toBeInTheDocument();
+ expect(screen.queryAllByText(title)[1]).toBeInTheDocument();
expect(screen.queryByText(shortDescription)).toBeInTheDocument();
});