Skip to content

Commit

Permalink
fix: assume that dates & outline legacy tabs don't exist
Browse files Browse the repository at this point in the history
They've both been removed from the LMS now. It would be harmless
to keep support for them in place, but it's pointless because
any redirects to the LMS will just come right back to us.

AA-799
  • Loading branch information
mikix committed Apr 15, 2022
1 parent 9b316bd commit ee88a12
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 35 deletions.
22 changes: 3 additions & 19 deletions src/course-home/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ export async function getDatesTabData(courseId) {
return camelCaseObject(data);
} catch (error) {
const { httpErrorStatus } = error && error.customAttributes;
if (httpErrorStatus === 404) {
global.location.replace(`${getConfig().LMS_BASE_URL}/courses/${courseId}/dates`);
return {};
}
if (httpErrorStatus === 401) {
// The backend sends this for unenrolled and unauthenticated learners, but we handle those cases by examining
// courseAccess in the metadata call, so just ignore this status for now.
Expand Down Expand Up @@ -328,21 +324,9 @@ export function getTimeOffsetMillis(headerDate, requestTime, responseTime) {

export async function getOutlineTabData(courseId) {
const url = `${getConfig().LMS_BASE_URL}/api/course_home/outline/${courseId}`;
let { tabData } = {};
let requestTime = Date.now();
let responseTime = requestTime;
try {
requestTime = Date.now();
tabData = await getAuthenticatedHttpClient().get(url);
responseTime = Date.now();
} catch (error) {
const { httpErrorStatus } = error && error.customAttributes;
if (httpErrorStatus === 404) {
global.location.replace(`${getConfig().LMS_BASE_URL}/courses/${courseId}/course/`);
return {};
}
throw error;
}
const requestTime = Date.now();
const tabData = await getAuthenticatedHttpClient().get(url);
const responseTime = Date.now();

const {
data,
Expand Down
4 changes: 2 additions & 2 deletions src/course-home/dates-tab/DatesTab.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@ describe('DatesTab', () => {

it('redirects to the home page when unauthenticated', async () => {
await renderDenied('authentication_required');
expect(global.location.href).toEqual(`http://localhost/redirect/course-home/${courseMetadata.id}`);
expect(global.location.href).toEqual(`http://localhost/course/${courseMetadata.id}/home`);
});

it('redirects to the home page when unenrolled', async () => {
await renderDenied('enrollment_required');
expect(global.location.href).toEqual(`http://localhost/redirect/course-home/${courseMetadata.id}`);
expect(global.location.href).toEqual(`http://localhost/course/${courseMetadata.id}/home`);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { useSelector } from 'react-redux';

import { getConfig } from '@edx/frontend-platform';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
Expand Down Expand Up @@ -41,7 +40,7 @@ function DetailedGrades({ intl }) {
<Hyperlink
variant="muted"
isInline
destination={`${getConfig().LMS_BASE_URL}/courses/${courseId}/course`}
destination={`/course/${courseId}/home`}
onClick={logOutlineLinkClick}
tabIndex={gradesFeatureIsFullyLocked ? '-1' : '0'}
>
Expand Down
5 changes: 2 additions & 3 deletions src/course-home/progress-tab/related-links/RelatedLinks.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { useSelector } from 'react-redux';

import { getConfig } from '@edx/frontend-platform';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
Expand Down Expand Up @@ -33,13 +32,13 @@ function RelatedLinks({ intl }) {
<h3 className="h4">{intl.formatMessage(messages.relatedLinks)}</h3>
<ul className="pl-4">
<li>
<Hyperlink destination={`${getConfig().LMS_BASE_URL}/courses/${courseId}/dates`} onClick={() => logLinkClicked('dates')}>
<Hyperlink destination={`/course/${courseId}/dates`} onClick={() => logLinkClicked('dates')}>
{intl.formatMessage(messages.datesCardLink)}
</Hyperlink>
<p>{intl.formatMessage(messages.datesCardDescription)}</p>
</li>
<li>
<Hyperlink destination={`${getConfig().LMS_BASE_URL}/courses/${courseId}/course`} onClick={() => logLinkClicked('course_outline')}>
<Hyperlink destination={`/course/${courseId}/home`} onClick={() => logLinkClicked('course_outline')}>
{intl.formatMessage(messages.outlineCardLink)}
</Hyperlink>
<p>{intl.formatMessage(messages.outlineCardDescription)}</p>
Expand Down
4 changes: 2 additions & 2 deletions src/courseware/CoursewareContainer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ describe('CoursewareContainer', () => {
const { courseMetadata } = setUpWithDeniedStatus('enrollment_required');
await loadContainer();

expect(global.location.href).toEqual(`http://localhost/redirect/course-home/${courseMetadata.id}`);
expect(global.location.href).toEqual(`http://localhost/course/${courseMetadata.id}/home`);
});

it('should go to course survey for a survey_required error code', async () => {
Expand All @@ -479,7 +479,7 @@ describe('CoursewareContainer', () => {
const { courseMetadata } = setUpWithDeniedStatus('authentication_required');
await loadContainer();

expect(global.location.href).toEqual(`http://localhost/redirect/course-home/${courseMetadata.id}`);
expect(global.location.href).toEqual(`http://localhost/course/${courseMetadata.id}/home`);
});

it('should go to dashboard for an unfulfilled_milestones error code', async () => {
Expand Down
6 changes: 0 additions & 6 deletions src/courseware/CoursewareRedirectLandingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ export default () => {
global.location.assign(`${getConfig().LMS_BASE_URL}/courses/${match.params.courseId}/jump_to/${match.params.unitId}?experience=legacy`);
}}
/>
<PageRoute
path={`${path}/course-home/:courseId`}
render={({ match }) => {
global.location.assign(`${getConfig().LMS_BASE_URL}/courses/${match.params.courseId}/course/`);
}}
/>
<PageRoute
path={`${path}/survey/:courseId`}
render={({ match }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function getAccessDeniedRedirectUrl(courseId, activeTabSlug, canLoadCours
if (activeTabSlug === 'courseware' && canLoadCourseware === false && unitId) {
url = `/redirect/courseware/${courseId}/unit/${unitId}`;
} else if (activeTabSlug !== 'outline') {
url = `/redirect/course-home/${courseId}`;
url = `/course/${courseId}/home`;
}
}
return url;
Expand Down

0 comments on commit ee88a12

Please sign in to comment.