Skip to content

Commit fc20c94

Browse files
committed
squash! feat: Add slots to add tab links and add mechanism for plugin routes
Refactor to .jsx for redwood
1 parent a7465f6 commit fc20c94

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed
Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
import { useIntl } from '@edx/frontend-platform/i18n';
22
import { PluginSlot } from '@openedx/frontend-plugin-framework';
33
import classNames from 'classnames';
4+
import PropTypes from 'prop-types';
45
import React from 'react';
56
import { CoursewareSearch, CoursewareSearchToggle } from '../course-home/courseware-search';
67
import { useCoursewareSearchState } from '../course-home/courseware-search/hooks';
78
import Tabs from '../generic/tabs/Tabs';
89

910
import messages from './messages';
1011

11-
interface CourseTabsNavigationProps {
12-
activeTabSlug?: string;
13-
className?: string | null;
14-
tabs: Array<{
15-
title: string;
16-
slug: string;
17-
url: string;
18-
}>;
19-
}
20-
21-
const CourseTabsNavigation = ({
22-
activeTabSlug = undefined,
23-
className = null,
24-
tabs,
25-
}:CourseTabsNavigationProps) => {
12+
const CourseTabsNavigation = ({ activeTabSlug, className, tabs }) => {
2613
const { show } = useCoursewareSearchState();
2714
const intl = useIntl();
2815

@@ -33,15 +20,21 @@ const CourseTabsNavigation = ({
3320
className="nav-underline-tabs"
3421
aria-label={intl.formatMessage(messages.courseMaterial)}
3522
>
36-
<PluginSlot id="course_tab_links_slot">{tabs.map(({ url, title, slug }) => (
37-
<a
38-
key={slug}
39-
className={classNames('nav-item flex-shrink-0 nav-link', { active: slug === activeTabSlug })}
40-
href={url}
41-
>
42-
{title}
43-
</a>
44-
))}</PluginSlot>
23+
<PluginSlot id="course_tab_links_slot">
24+
{tabs.map(({
25+
url,
26+
title,
27+
slug,
28+
}) => (
29+
<a
30+
key={slug}
31+
className={classNames('nav-item flex-shrink-0 nav-link', { active: slug === activeTabSlug })}
32+
href={url}
33+
>
34+
{title}
35+
</a>
36+
))}
37+
</PluginSlot>
4538
</Tabs>
4639
</div>
4740
<div className="course-tabs-navigation__search-toggle">
@@ -52,4 +45,19 @@ const CourseTabsNavigation = ({
5245
);
5346
};
5447

48+
CourseTabsNavigation.propTypes = {
49+
activeTabSlug: PropTypes.string,
50+
className: PropTypes.string,
51+
tabs: PropTypes.arrayOf(PropTypes.shape({
52+
title: PropTypes.string.isRequired,
53+
slug: PropTypes.string.isRequired,
54+
url: PropTypes.string.isRequired,
55+
})).isRequired,
56+
};
57+
58+
CourseTabsNavigation.defaultProps = {
59+
activeTabSlug: undefined,
60+
className: null,
61+
};
62+
5563
export default CourseTabsNavigation;

src/setupTest.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ import { appendBrowserTimezoneToUrl, executeThunk } from './utils';
3030
import buildSimpleCourseAndSequenceMetadata from './courseware/data/__factories__/sequenceMetadata.factory';
3131
import { buildOutlineFromBlocks } from './courseware/data/__factories__/learningSequencesOutline.factory';
3232

33-
jest.mock('@openedx/frontend-plugin-framework', () => ({
34-
...jest.requireActual('@openedx/frontend-plugin-framework'),
35-
Plugin: () => 'Plugin',
36-
PluginSlot: () => 'PluginSlot',
37-
}));
38-
3933
jest.mock('@src/generic/plugin-store', () => ({
4034
...jest.requireActual('@src/generic/plugin-store'),
4135
usePluginsCallback: jest.fn((_, cb) => cb),

0 commit comments

Comments
 (0)