Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add taxonomies tab in home page #923

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/studio-home/tabs-section/TabsSection.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ describe('<TabsSection />', () => {
});
});

describe('taxonomies tab', () => {
it('should redirect to taxonomies page', async () => {
render(<RootWrapper />);
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(<RootWrapper />);
Expand Down
13 changes: 13 additions & 0 deletions src/studio-home/tabs-section/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -15,10 +16,12 @@ import { fetchLibraryData } from '../data/thunks';
const TabsSection = ({
intl, showNewCourseContainer, onClickNewCourse, isShowProcessing, dispatch,
}) => {
const navigate = useNavigate();
const TABS_LIST = {
courses: 'courses',
libraries: 'libraries',
archived: 'archived',
taxonomies: 'taxonomies',
};
const [tabKey, setTabKey] = useState(TABS_LIST.courses);
const {
Expand Down Expand Up @@ -90,6 +93,14 @@ const TabsSection = ({
);
}

tabs.push(
<Tab
key={TABS_LIST.taxonomies}
eventKey={TABS_LIST.taxonomies}
title={intl.formatMessage(messages.taxonomiesTabTitle)}
/>,
);

return tabs;
}, [archivedCourses, librariesEnabled, showNewCourseContainer, isLoadingCourses, isLoadingLibraries]);

Expand All @@ -98,6 +109,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);
};
Expand Down
5 changes: 5 additions & 0 deletions src/studio-home/tabs-section/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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',
yusuf-musleh marked this conversation as resolved.
Show resolved Hide resolved
description: 'Title of Taxonomies tab on the home page',
},
});

export default messages;
Loading