Skip to content

Commit 3662fad

Browse files
feat!: Remove support for the (deprecated) library authoring MFE (#1327)
1 parent ccce44a commit 3662fad

File tree

14 files changed

+12
-201
lines changed

14 files changed

+12
-201
lines changed

src/editors/data/services/cms/api.test.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('cms api', () => {
6969

7070
it('should call get with normal accept header for prod', async () => {
7171
process.env.NODE_ENV = 'production';
72-
process.env.MFE_NAME = 'frontend-app-library-authoring';
72+
process.env.MFE_NAME = 'frontend-app-course-authoring';
7373
// eslint-disable-next-line no-shadow, @typescript-eslint/no-shadow
7474
const { apiMethods } = await import('./api');
7575
// eslint-disable-next-line no-shadow, @typescript-eslint/no-shadow
@@ -90,18 +90,6 @@ describe('cms api', () => {
9090
apiMethods.fetchByUnitId({ blockId, studioEndpointUrl });
9191
expect(getSpy).toHaveBeenCalledWith(urls.blockAncestor({ studioEndpointUrl, blockId }), {});
9292
});
93-
94-
it('should call get with special accept header "*/*" for course-authoring', async () => {
95-
process.env.NODE_ENV = 'development';
96-
process.env.MFE_NAME = 'frontend-app-library-authoring';
97-
// eslint-disable-next-line no-shadow, @typescript-eslint/no-shadow
98-
const { apiMethods } = await import('./api');
99-
// eslint-disable-next-line no-shadow, @typescript-eslint/no-shadow
100-
const utils = await import('./utils');
101-
const getSpy = jest.spyOn(utils, 'get');
102-
apiMethods.fetchByUnitId({ blockId, studioEndpointUrl });
103-
expect(getSpy).toHaveBeenCalledWith(urls.blockAncestor({ studioEndpointUrl, blockId }), { headers: { Accept: '*/*' } });
104-
});
10593
});
10694
});
10795

src/editors/data/services/cms/api.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ import { durationStringFromValue } from '../../../containers/VideoEditor/compone
77

88
const fetchByUnitIdOptions: AxiosRequestConfig = {};
99

10-
// For some reason, the local webpack-dev-server of library-authoring does not accept the normal Accept header.
11-
// This is a workaround only for that specific case; the idea is to only do this locally and only for library-authoring.
12-
if (process.env.NODE_ENV === 'development' && process.env.MFE_NAME === 'frontend-app-library-authoring') {
13-
fetchByUnitIdOptions.headers = {
14-
Accept: '*/*',
15-
};
16-
}
17-
1810
interface Pagination {
1911
start: number;
2012
end: number;

src/search-modal/SearchResult.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ import {
77
Stack,
88
} from '@openedx/paragon';
99
import { OpenInNew } from '@openedx/paragon/icons';
10-
import { useSelector } from 'react-redux';
1110
import { useNavigate } from 'react-router-dom';
1211

1312
import { getItemIcon } from '../generic/block-type-utils';
1413
import { isLibraryKey } from '../generic/key-utils';
1514
import { useSearchContext, type ContentHit, Highlight } from '../search-manager';
16-
import { getStudioHomeData } from '../studio-home/data/selectors';
17-
import { constructLibraryAuthoringURL } from '../utils';
1815
import messages from './messages';
1916

2017
/**
@@ -100,7 +97,6 @@ const SearchResult: React.FC<{ hit: ContentHit }> = ({ hit }) => {
10097
const intl = useIntl();
10198
const navigate = useNavigate();
10299
const { closeSearchModal } = useSearchContext();
103-
const { libraryAuthoringMfeUrl, redirectToLibraryAuthoringMfe } = useSelector(getStudioHomeData);
104100

105101
/**
106102
* Returns the URL for the context of the hit
@@ -119,10 +115,6 @@ const SearchResult: React.FC<{ hit: ContentHit }> = ({ hit }) => {
119115

120116
if (isLibraryKey(contextKey)) {
121117
const urlSuffix = getLibraryComponentUrlSuffix(hit);
122-
if (redirectToLibraryAuthoringMfe && libraryAuthoringMfeUrl) {
123-
return constructLibraryAuthoringURL(libraryAuthoringMfeUrl, urlSuffix);
124-
}
125-
126118
if (newWindow) {
127119
return `${getPath(getConfig().PUBLIC_PATH)}${urlSuffix}`;
128120
}
@@ -131,7 +123,7 @@ const SearchResult: React.FC<{ hit: ContentHit }> = ({ hit }) => {
131123

132124
// istanbul ignore next - This case should never be reached
133125
return undefined;
134-
}, [libraryAuthoringMfeUrl, redirectToLibraryAuthoringMfe, hit]);
126+
}, [hit]);
135127

136128
/**
137129
* Opens the context of the hit in a new window

src/search-modal/SearchUI.test.tsx

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ import fetchMock from 'fetch-mock-jest';
1616
import type { Store } from 'redux';
1717

1818
import initializeStore from '../store';
19-
import { executeThunk } from '../utils';
20-
import { getStudioHomeApiUrl } from '../studio-home/data/api';
21-
import { fetchStudioHomeData } from '../studio-home/data/thunks';
22-
import { generateGetStudioHomeDataApiResponse } from '../studio-home/factories/mockApiResponses';
2319
import mockResult from './__mocks__/search-result.json';
2420
import mockEmptyResult from './__mocks__/empty-search-result.json';
2521
import mockTagsFacetResult from './__mocks__/facet-search.json';
@@ -316,43 +312,7 @@ describe('<SearchUI />', () => {
316312
);
317313
});
318314

319-
test('click lib component result navigates to the context', async () => {
320-
const data = generateGetStudioHomeDataApiResponse();
321-
data.redirectToLibraryAuthoringMfe = true;
322-
axiosMock.onGet(getStudioHomeApiUrl()).reply(200, data);
323-
324-
await executeThunk(fetchStudioHomeData(), store.dispatch);
325-
326-
const { findByRole } = rendered;
327-
328-
const resultItem = await findByRole('button', { name: /Library Content/ });
329-
330-
// Clicking the "Open in new window" button should open the result in a new window:
331-
const { open, location } = window;
332-
window.open = jest.fn();
333-
fireEvent.click(within(resultItem).getByRole('button', { name: 'Open in new window' }));
334-
expect(window.open).toHaveBeenCalledWith(
335-
'http://localhost:3001/library/lib:org1:libafter1',
336-
'_blank',
337-
);
338-
window.open = open;
339-
340-
// @ts-ignore
341-
window.location = { href: '' };
342-
// Clicking in the result should navigate to the result's URL:
343-
fireEvent.click(resultItem);
344-
expect(window.location.href = 'http://localhost:3001/library/lib:org1:libafter1');
345-
window.location = location;
346-
});
347-
348-
test('click lib component result navigates to course-authoring/library without libraryAuthoringMfe', async () => {
349-
const data = generateGetStudioHomeDataApiResponse();
350-
data.redirectToLibraryAuthoringMfe = false;
351-
data.libraryAuthoringMfeUrl = '';
352-
axiosMock.onGet(getStudioHomeApiUrl()).reply(200, data);
353-
354-
await executeThunk(fetchStudioHomeData(), store.dispatch);
355-
315+
test('click lib component result navigates to course-authoring/library', async () => {
356316
const { findByRole } = rendered;
357317

358318
const resultItem = await findByRole('button', { name: /Library Content/ });

src/studio-home/StudioHome.test.jsx

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import MockAdapter from 'axios-mock-adapter';
1414
import initializeStore from '../store';
1515
import { RequestStatus } from '../data/constants';
1616
import { COURSE_CREATOR_STATES } from '../constants';
17-
import { executeThunk, constructLibraryAuthoringURL } from '../utils';
17+
import { executeThunk } from '../utils';
1818
import { studioHomeMock } from './__mocks__';
1919
import { getStudioHomeApiUrl } from './data/api';
2020
import { fetchStudioHomeData } from './data/thunks';
@@ -193,27 +193,6 @@ describe('<StudioHome />', () => {
193193
window.open = open;
194194
});
195195

196-
it('should navigate to the library authoring mfe', () => {
197-
useSelector.mockReturnValue({
198-
...studioHomeMock,
199-
courseCreatorStatus: COURSE_CREATOR_STATES.granted,
200-
splitStudioHome: true,
201-
redirectToLibraryAuthoringMfe: true,
202-
});
203-
const libraryAuthoringMfeUrl = 'http://localhost:3001';
204-
205-
const { getByTestId } = render(<RootWrapper />);
206-
const createNewLibraryButton = getByTestId('new-library-button');
207-
208-
const { open } = window;
209-
window.open = jest.fn();
210-
fireEvent.click(createNewLibraryButton);
211-
expect(window.open).toHaveBeenCalledWith(
212-
`${constructLibraryAuthoringURL(libraryAuthoringMfeUrl, 'create')}`,
213-
);
214-
window.open = open;
215-
});
216-
217196
it('should navigate to the library authoring page in course authoring', () => {
218197
useSelector.mockReturnValue({
219198
...studioHomeMock,

src/studio-home/StudioHome.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { StudioFooter } from '@edx/frontend-component-footer';
1313
import { getConfig } from '@edx/frontend-platform';
1414
import { useLocation, useNavigate } from 'react-router-dom';
1515

16-
import { constructLibraryAuthoringURL } from '../utils';
1716
import Loading from '../generic/Loading';
1817
import InternetConnectionAlert from '../generic/internet-connection-alert';
1918
import Header from '../header';
@@ -58,8 +57,6 @@ const StudioHome = () => {
5857
userIsActive,
5958
studioShortName,
6059
studioRequestEmail,
61-
libraryAuthoringMfeUrl,
62-
redirectToLibraryAuthoringMfe,
6360
showNewLibraryButton,
6461
} = studioHomeData;
6562

@@ -93,13 +90,7 @@ const StudioHome = () => {
9390
if (showNewLibraryButton || showV2LibraryURL) {
9491
const newLibraryClick = () => {
9592
if (showV2LibraryURL) {
96-
if (libraryAuthoringMfeUrl && redirectToLibraryAuthoringMfe) {
97-
// Library authoring MFE
98-
window.open(constructLibraryAuthoringURL(libraryAuthoringMfeUrl, 'create'));
99-
} else {
100-
// Use course-authoring route
101-
navigate('/library/create');
102-
}
93+
navigate('/library/create');
10394
} else {
10495
// Studio home library for legacy libraries
10596
window.open(`${getConfig().STUDIO_BASE_URL}/home_library`);

src/studio-home/__mocks__/studioHomeMock.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ module.exports = {
6262
},
6363
],
6464
librariesEnabled: true,
65-
libraryAuthoringMfeUrl: 'http://localhost:3001',
6665
optimizationEnabled: false,
67-
redirectToLibraryAuthoringMfe: false,
6866
requestCourseCreatorUrl: '/request_course_creator',
6967
rerunCreatorStatus: true,
7068
showNewLibraryButton: true,

src/studio-home/card-item/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const CardItem: React.FC<Props> = ({
6262
} = useSelector(getStudioHomeData);
6363
const destinationUrl: string = path ?? new URL(url, getConfig().STUDIO_BASE_URL).toString();
6464
const subtitle = isLibraries ? `${org} / ${number}` : `${org} / ${number} / ${run}`;
65-
const readOnlyItem = !(lmsLink || rerunLink || url);
65+
const readOnlyItem = !(lmsLink || rerunLink || url || path);
6666
const showActions = !(readOnlyItem || isLibraries);
6767
const isShowRerunLink = allowCourseReruns
6868
&& rerunCreatorStatus

src/studio-home/factories/mockApiResponses.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ export const generateGetStudioHomeDataApiResponse = () => ({
3232
inProcessCourseActions: [],
3333
libraries: [],
3434
librariesEnabled: true,
35-
libraryAuthoringMfeUrl: 'http://localhost:3001/',
3635
optimizationEnabled: false,
37-
redirectToLibraryAuthoringMfe: false,
3836
requestCourseCreatorUrl: '/request_course_creator',
3937
rerunCreatorStatus: true,
4038
showNewLibraryButton: true,

src/studio-home/tabs-section/TabsSection.test.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -428,22 +428,6 @@ describe('<TabsSection />', () => {
428428
expect(screen.queryByText(tabMessages.legacyLibrariesTabTitle.defaultMessage)).toBeNull();
429429
});
430430

431-
it('should redirect to library authoring mfe', async () => {
432-
const data = generateGetStudioHomeDataApiResponse();
433-
data.redirectToLibraryAuthoringMfe = true;
434-
435-
render();
436-
axiosMock.onGet(getStudioHomeApiUrl()).reply(200, data);
437-
await executeThunk(fetchStudioHomeData(), store.dispatch);
438-
439-
const librariesTab = screen.getByText(tabMessages.legacyLibrariesTabTitle.defaultMessage);
440-
fireEvent.click(librariesTab);
441-
442-
waitFor(() => {
443-
expect(window.location.href).toBe(data.libraryAuthoringMfeUrl);
444-
});
445-
});
446-
447431
it('should render libraries fetch failure alert', async () => {
448432
render();
449433
axiosMock.onGet(getStudioHomeApiUrl()).reply(200, generateGetStudioHomeDataApiResponse());

0 commit comments

Comments
 (0)