+
+ {/* Temporary div to add spacing. This will be replaced with lib search/filters */}
+
+
+ {intl.formatMessage(messages.coursesPaginationInfo, {
+ length: data.results.length,
+ total: data.count,
+ })}
+
+
+
+ {
+ data.results.map(({
+ id, org, slug, title,
+ }) => (
+
+ ))
+ }
+
+ {
+ data.numPages > 1
+ && (
+
+ )
+ }
+
+ )
+ );
+};
+
+LibrariesV2Tab.propTypes = {
+ libraryAuthoringMfeUrl: PropTypes.string.isRequired,
+ redirectToLibraryAuthoringMfe: PropTypes.bool.isRequired,
+};
+
+export default LibrariesV2Tab;
diff --git a/src/studio-home/tabs-section/messages.js b/src/studio-home/tabs-section/messages.js
index 5ae2e139b2..0ed614f55a 100644
--- a/src/studio-home/tabs-section/messages.js
+++ b/src/studio-home/tabs-section/messages.js
@@ -21,6 +21,10 @@ const messages = defineMessages({
id: 'course-authoring.studio-home.libraries.tab.title',
defaultMessage: 'Libraries',
},
+ legacyLibrariesTabTitle: {
+ id: 'course-authoring.studio-home.legacy.libraries.tab.title',
+ defaultMessage: 'Legacy Libraries',
+ },
archivedTabTitle: {
id: 'course-authoring.studio-home.archived.tab.title',
defaultMessage: 'Archived courses',
@@ -46,6 +50,14 @@ const messages = defineMessages({
defaultMessage: 'Taxonomies',
description: 'Title of Taxonomies tab on the home page',
},
+ libraryV2PlaceholderTitle: {
+ id: 'course-authoring.studio-home.libraries.placeholder.title',
+ defaultMessage: 'Library V2 Placeholder',
+ },
+ libraryV2PlaceholderBody: {
+ id: 'course-authoring.studio-home.libraries.placeholder.body',
+ defaultMessage: 'This is a placeholder page, as the Library Authoring MFE is not enabled.',
+ },
});
export default messages;
diff --git a/src/studio-home/tabs-section/utils.js b/src/studio-home/tabs-section/utils.js
index dff32dc95a..ec4fb9303e 100644
--- a/src/studio-home/tabs-section/utils.js
+++ b/src/studio-home/tabs-section/utils.js
@@ -11,5 +11,11 @@ const sortAlphabeticallyArray = (arr) => [...arr]
return firstDisplayName.localeCompare(secondDisplayName);
});
-// eslint-disable-next-line import/prefer-default-export
-export { sortAlphabeticallyArray };
+const isMixedOrV1LibrariesMode = (libMode) => ['mixed', 'v1 only'].includes(libMode);
+const isMixedOrV2LibrariesMode = (libMode) => ['mixed', 'v2 only'].includes(libMode);
+
+export {
+ sortAlphabeticallyArray,
+ isMixedOrV1LibrariesMode,
+ isMixedOrV2LibrariesMode,
+};
diff --git a/src/utils.js b/src/utils.js
index d4bc8f6ff3..2abb63e5be 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -301,3 +301,27 @@ export const getFileSizeToClosestByte = (fileSize) => {
const fileSizeFixedDecimal = Number.parseFloat(size).toFixed(2);
return `${fileSizeFixedDecimal} ${units[divides]}`;
};
+
+/**
+ * Constructs library authoring MFE URL with correct slashes
+ * @param {string} libraryAuthoringMfeUrl - the base library authoring MFE url
+ * @param {string} path - the library authoring MFE url path
+ * @returns {string} - the correct internal route path
+ */
+export const constructLibraryAuthoringURL = (libraryAuthoringMfeUrl, path) => {
+ // Remove '/' at the beginning of path if any
+ const trimmedPath = path.startsWith('/')
+ ? path.slice(1, path.length)
+ : path;
+
+ let constructedUrl = libraryAuthoringMfeUrl;
+ // Remove trailing `/` from base if found
+ if (libraryAuthoringMfeUrl.endsWith('/')) {
+ constructedUrl = constructedUrl.slice(0, -1);
+ }
+
+ // Add the `/` and path to url
+ constructedUrl = `${constructedUrl}/${trimmedPath}`;
+
+ return constructedUrl;
+};
diff --git a/src/utils.test.js b/src/utils.test.js
index e4aada849f..a5b12d6c37 100644
--- a/src/utils.test.js
+++ b/src/utils.test.js
@@ -1,6 +1,6 @@
import { getConfig, getPath } from '@edx/frontend-platform';
-import { getFileSizeToClosestByte, createCorrectInternalRoute } from './utils';
+import { getFileSizeToClosestByte, createCorrectInternalRoute, constructLibraryAuthoringURL } from './utils';
jest.mock('@edx/frontend-platform', () => ({
getConfig: jest.fn(),
@@ -78,3 +78,30 @@ describe('FilesAndUploads utils', () => {
});
});
});
+
+describe('constructLibraryAuthoringURL', () => {
+ it('should construct URL given no trailing `/` in base and no starting `/` in path', () => {
+ const libraryAuthoringMfeUrl = 'http://localhost:3001';
+ const path = 'example';
+ const constructedURL = constructLibraryAuthoringURL(libraryAuthoringMfeUrl, path);
+ expect(constructedURL).toEqual('http://localhost:3001/example');
+ });
+ it('should construct URL given a trailing `/` in base and no starting `/` in path', () => {
+ const libraryAuthoringMfeUrl = 'http://localhost:3001/';
+ const path = 'example';
+ const constructedURL = constructLibraryAuthoringURL(libraryAuthoringMfeUrl, path);
+ expect(constructedURL).toEqual('http://localhost:3001/example');
+ });
+ it('should construct URL with no trailing `/` in base and a starting `/` in path', () => {
+ const libraryAuthoringMfeUrl = 'http://localhost:3001';
+ const path = '/example';
+ const constructedURL = constructLibraryAuthoringURL(libraryAuthoringMfeUrl, path);
+ expect(constructedURL).toEqual('http://localhost:3001/example');
+ });
+ it('should construct URL with a trailing `/` in base and a starting `/` in path', () => {
+ const libraryAuthoringMfeUrl = 'http://localhost:3001/';
+ const path = '/example';
+ const constructedURL = constructLibraryAuthoringURL(libraryAuthoringMfeUrl, path);
+ expect(constructedURL).toEqual('http://localhost:3001/example');
+ });
+});