feat: stop calling course blocks rest API and assume LS exists (#803)
- Assume that Learning Sequences is available (waffle has been removed) - Stop calling course blocks API, which provided mostly duplicated information now. - Refactor a bit to avoid needing to globally know which units exist in sequences. That is now provided just-in-time for only the current sequence. - Add /first and /last URLs that you can use instead of unit IDs in URL paths, in service of the above point. AA-1040 AA-1153
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
|
||||
import { ALERT_TYPES, AlertList } from '../generic/user-messages';
|
||||
@@ -37,6 +36,14 @@ function getStudioUrl(courseId, unitId) {
|
||||
return urlFull;
|
||||
}
|
||||
|
||||
function getLegacyWebUrl(canViewLegacyCourseware, courseId, unitId) {
|
||||
if (!canViewLegacyCourseware || !unitId) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return `${getConfig().LMS_BASE_URL}/courses/${courseId}/jump_to/${unitId}?experience=legacy`;
|
||||
}
|
||||
|
||||
export default function InstructorToolbar(props) {
|
||||
// This didMount logic became necessary once we had a page that does a redirect on a quick exit.
|
||||
// As a result, it unmounts the InstructorToolbar (which will be remounted by the new component),
|
||||
@@ -60,18 +67,7 @@ export default function InstructorToolbar(props) {
|
||||
} = props;
|
||||
|
||||
const urlInsights = getInsightsUrl(courseId);
|
||||
const urlLegacy = useSelector((state) => {
|
||||
if (!canViewLegacyCourseware) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!unitId) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const activeUnit = state.models.units[props.unitId];
|
||||
return activeUnit ? activeUnit.legacyWebUrl : undefined;
|
||||
});
|
||||
const urlLegacy = getLegacyWebUrl(canViewLegacyCourseware, courseId, unitId);
|
||||
const urlStudio = getStudioUrl(courseId, unitId);
|
||||
const [masqueradeErrorMessage, showMasqueradeError] = useState(null);
|
||||
|
||||
|
||||
@@ -15,24 +15,27 @@ jest.mock('@edx/frontend-platform', () => ({
|
||||
getConfig.mockImplementation(() => originalConfig);
|
||||
|
||||
describe('Instructor Toolbar', () => {
|
||||
let courseware;
|
||||
let models;
|
||||
let mockData;
|
||||
let axiosMock;
|
||||
let masqueradeUrl;
|
||||
|
||||
beforeAll(async () => {
|
||||
const store = await initializeTestStore({ excludeFetchSequence: true });
|
||||
const { courseware, models } = store.getState();
|
||||
mockData = {
|
||||
courseId: courseware.courseId,
|
||||
unitId: Object.values(models.units)[0].id,
|
||||
canViewLegacyCourseware: true,
|
||||
};
|
||||
const store = await initializeTestStore();
|
||||
courseware = store.getState().courseware;
|
||||
models = store.getState().models;
|
||||
|
||||
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
|
||||
masqueradeUrl = `${getConfig().LMS_BASE_URL}/courses/${courseware.courseId}/masquerade`;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
mockData = {
|
||||
courseId: courseware.courseId,
|
||||
unitId: Object.values(models.units)[0].id,
|
||||
canViewLegacyCourseware: true,
|
||||
};
|
||||
axiosMock.reset();
|
||||
axiosMock.onGet(masqueradeUrl).reply(200, { success: true });
|
||||
logUnhandledRequests(axiosMock);
|
||||
|
||||
Reference in New Issue
Block a user