From 806591f1cc28772cc84dda98ccae844a0a508159 Mon Sep 17 00:00:00 2001 From: Yusuf Musleh Date: Thu, 4 Apr 2024 15:04:13 +0300 Subject: [PATCH] feat: Add taxonomies tab in home page (#923) --- src/studio-home/tabs-section/TabsSection.test.jsx | 15 +++++++++++++++ src/studio-home/tabs-section/index.jsx | 13 +++++++++++++ src/studio-home/tabs-section/messages.js | 5 +++++ 3 files changed, 33 insertions(+) diff --git a/src/studio-home/tabs-section/TabsSection.test.jsx b/src/studio-home/tabs-section/TabsSection.test.jsx index 73b2205e88..215c3ee288 100644 --- a/src/studio-home/tabs-section/TabsSection.test.jsx +++ b/src/studio-home/tabs-section/TabsSection.test.jsx @@ -157,6 +157,21 @@ describe('', () => { }); }); + describe('taxonomies tab', () => { + it('should redirect to taxonomies page', async () => { + render(); + axiosMock.onGet(getStudioHomeApiUrl()).reply(200, generateGetStudioHomeDataApiResponse()); + await executeThunk(fetchStudioHomeData(), store.dispatch); + + const taxonomiesTab = screen.getByText(tabMessages.taxonomiesTabTitle.defaultMessage); + fireEvent.click(taxonomiesTab); + + waitFor(() => { + expect(window.location.href).toContain('/taxonomies'); + }); + }); + }); + describe('archived tab', () => { it('should switch to Archived tab and render specific archived course details', async () => { render(); diff --git a/src/studio-home/tabs-section/index.jsx b/src/studio-home/tabs-section/index.jsx index 471b515647..1e0cb3848c 100644 --- a/src/studio-home/tabs-section/index.jsx +++ b/src/studio-home/tabs-section/index.jsx @@ -3,6 +3,7 @@ import { useSelector } from 'react-redux'; import PropTypes from 'prop-types'; import { Tab, Tabs } from '@openedx/paragon'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { useNavigate } from 'react-router-dom'; import { getLoadingStatuses, getStudioHomeData } from '../data/selectors'; import messages from './messages'; @@ -20,10 +21,12 @@ const TabsSection = ({ dispatch, isPaginationCoursesEnabled, }) => { + const navigate = useNavigate(); const TABS_LIST = { courses: 'courses', libraries: 'libraries', archived: 'archived', + taxonomies: 'taxonomies', }; const [tabKey, setTabKey] = useState(TABS_LIST.courses); const { @@ -100,6 +103,14 @@ const TabsSection = ({ ); } + tabs.push( + , + ); + return tabs; }, [archivedCourses, librariesEnabled, showNewCourseContainer, isLoadingCourses, isLoadingLibraries]); @@ -108,6 +119,8 @@ const TabsSection = ({ window.location.assign(libraryAuthoringMfeUrl); } else if (tab === TABS_LIST.libraries && !redirectToLibraryAuthoringMfe) { dispatch(fetchLibraryData()); + } else if (tab === TABS_LIST.taxonomies) { + navigate('/taxonomies'); } setTabKey(tab); }; diff --git a/src/studio-home/tabs-section/messages.js b/src/studio-home/tabs-section/messages.js index 05e8d0fce2..40c3d95c70 100644 --- a/src/studio-home/tabs-section/messages.js +++ b/src/studio-home/tabs-section/messages.js @@ -29,6 +29,11 @@ const messages = defineMessages({ id: 'course-authoring.studio-home.archived.tab.error.message', defaultMessage: 'Failed to fetch archived courses. Please try again later.', }, + taxonomiesTabTitle: { + id: 'course-authoring.studio-home.taxonomies.tab.title', + defaultMessage: 'Taxonomies', + description: 'Title of Taxonomies tab on the home page', + }, }); export default messages;