Skip to content

Commit f5b6243

Browse files
feat: wrap existing sidebars in frontend-plugin-framework PluginSlots (#1543)
1 parent 98c670a commit f5b6243

File tree

27 files changed

+411
-17
lines changed

27 files changed

+411
-17
lines changed

src/courseware/course/Course.jsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ import { breakpoints, useWindowSize } from '@openedx/paragon';
99
import { AlertList } from '@src/generic/user-messages';
1010
import { useModel } from '@src/generic/model-store';
1111
import { getCoursewareOutlineSidebarSettings } from '../data/selectors';
12-
import { Trigger as CourseOutlineTrigger } from './sidebar/sidebars/course-outline';
1312
import Chat from './chat/Chat';
1413
import SidebarProvider from './sidebar/SidebarContextProvider';
15-
import SidebarTriggers from './sidebar/SidebarTriggers';
1614
import NewSidebarProvider from './new-sidebar/SidebarContextProvider';
17-
import NewSidebarTriggers from './new-sidebar/SidebarTriggers';
15+
import { NotificationsDiscussionsSidebarTriggerSlot } from '../../plugin-slots/NotificationsDiscussionsSidebarTriggerSlot';
1816
import { CelebrationModal, shouldCelebrateOnSectionLoad, WeeklyGoalCelebrationModal } from './celebration';
19-
import CourseBreadcrumbs from './CourseBreadcrumbs';
2017
import ContentTools from './content-tools';
2118
import Sequence from './sequence';
19+
import { CourseOutlineMobileSidebarTriggerSlot } from '../../plugin-slots/CourseOutlineMobileSidebarTriggerSlot';
20+
import { CourseBreadcrumbsSlot } from '../../plugin-slots/CourseBreadcrumbsSlot';
2221

2322
const Course = ({
2423
courseId,
@@ -87,7 +86,7 @@ const Course = ({
8786
<div className="position-relative d-flex align-items-xl-center mb-4 mt-1 flex-column flex-xl-row">
8887
{navigationDisabled || (
8988
<>
90-
<CourseBreadcrumbs
89+
<CourseBreadcrumbsSlot
9190
courseId={courseId}
9291
sectionId={section ? section.id : null}
9392
sequenceId={sequenceId}
@@ -109,8 +108,8 @@ const Course = ({
109108
</>
110109
)}
111110
<div className="w-100 d-flex align-items-center">
112-
<CourseOutlineTrigger isMobileView />
113-
{isNewDiscussionSidebarViewEnabled ? <NewSidebarTriggers /> : <SidebarTriggers /> }
111+
<CourseOutlineMobileSidebarTriggerSlot />
112+
<NotificationsDiscussionsSidebarTriggerSlot courseId={courseId} />
114113
</div>
115114
</div>
116115

src/courseware/course/sequence/Sequence.jsx

+6-10
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ import SequenceContainerSlot from '../../../plugin-slots/SequenceContainerSlot';
1818

1919
import { getCoursewareOutlineSidebarSettings } from '../../data/selectors';
2020
import CourseLicense from '../course-license';
21-
import Sidebar from '../sidebar/Sidebar';
22-
import NewSidebar from '../new-sidebar/Sidebar';
23-
import {
24-
Trigger as CourseOutlineTrigger,
25-
Sidebar as CourseOutlineTray,
26-
} from '../sidebar/sidebars/course-outline';
21+
import { NotificationsDiscussionsSidebarSlot } from '../../../plugin-slots/NotificationsDiscussionsSidebarSlot';
2722
import messages from './messages';
2823
import HiddenAfterDue from './hidden-after-due';
2924
import { SequenceNavigation, UnitNavigation } from './sequence-navigation';
3025
import SequenceContent from './SequenceContent';
26+
import { CourseOutlineSidebarSlot } from '../../../plugin-slots/CourseOutlineSidebarSlot';
27+
import { CourseOutlineSidebarTriggerSlot } from '../../../plugin-slots/CourseOutlineSidebarTriggerSlot';
3128

3229
const Sequence = ({
3330
unitId,
@@ -46,7 +43,6 @@ const Sequence = ({
4643
const {
4744
isStaff,
4845
originalUserIsStaff,
49-
isNewDiscussionSidebarViewEnabled,
5046
} = useModel('courseHomeMeta', courseId);
5147
const sequence = useModel('sequences', sequenceId);
5248
const unit = useModel('units', unitId);
@@ -166,8 +162,8 @@ const Sequence = ({
166162
const defaultContent = (
167163
<>
168164
<div className="sequence-container d-inline-flex flex-row w-100">
169-
<CourseOutlineTrigger />
170-
<CourseOutlineTray />
165+
<CourseOutlineSidebarTriggerSlot />
166+
<CourseOutlineSidebarSlot />
171167
<div className="sequence w-100">
172168
{!isEnabledOutlineSidebar && (
173169
<div className="sequence-navigation-container">
@@ -209,7 +205,7 @@ const Sequence = ({
209205
{unitHasLoaded && renderUnitNavigation(false)}
210206
</div>
211207
</div>
212-
{isNewDiscussionSidebarViewEnabled ? <NewSidebar /> : <Sidebar />}
208+
<NotificationsDiscussionsSidebarSlot courseId={courseId} />
213209
</div>
214210
<SequenceContainerSlot courseId={courseId} unitId={unitId} />
215211
</>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Course Breadcrumbs Slot
2+
3+
### Slot ID: `course_breadcrumbs_slot`
4+
5+
## Description
6+
7+
This slot is used to replace/modify/hide the course breadcrumbs.
8+
9+
## Example
10+
11+
### Default content
12+
![Breadcrumbs slot with default content](./screenshot_default.png)
13+
14+
### Replaced with custom component
15+
![🍞 in breadcrumbs slot](./screenshot_custom.png)
16+
17+
The following `env.config.jsx` will replace the course breadcrumbs entirely.
18+
19+
```js
20+
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
21+
22+
const config = {
23+
pluginSlots: {
24+
course_breadcrumbs_slot: {
25+
keepDefault: false,
26+
plugins: [
27+
{
28+
op: PLUGIN_OPERATIONS.Insert,
29+
widget: {
30+
id: 'custom_breadcrumbs_component',
31+
type: DIRECT_PLUGIN,
32+
RenderWidget: () => (
33+
<h1>🍞</h1>
34+
),
35+
},
36+
},
37+
]
38+
}
39+
},
40+
}
41+
42+
export default config;
43+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
3+
import { PluginSlot } from '@openedx/frontend-plugin-framework';
4+
5+
import CourseBreadcrumbs from '../../courseware/course/CourseBreadcrumbs';
6+
7+
interface Props {
8+
courseId: string;
9+
sectionId?: string;
10+
sequenceId?: string;
11+
unitId?: string;
12+
isStaff?: boolean;
13+
}
14+
15+
export const CourseBreadcrumbsSlot : React.FC<Props> = ({
16+
courseId, sectionId, sequenceId, unitId, isStaff,
17+
}) => (
18+
<PluginSlot
19+
id="course_breadcrumbs_slot"
20+
slotOptions={{
21+
mergeProps: true,
22+
}}
23+
>
24+
<CourseBreadcrumbs
25+
courseId={courseId}
26+
sectionId={sectionId}
27+
sequenceId={sequenceId}
28+
isStaff={isStaff}
29+
unitId={unitId}
30+
/>
31+
</PluginSlot>
32+
);
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Course Outline Mobile Sidebar Trigger Slot
2+
3+
### Slot ID: `course_outline_mobile_sidebar_trigger_slot`
4+
5+
## Description
6+
7+
This slot is used to replace/modify/hide the course outline sidebar mobile trigger.
8+
9+
## Example
10+
11+
### Default content
12+
![Trigger slot with default content](./screenshot_default.png)
13+
14+
### Replaced with custom component
15+
![📌 in trigger slot](./screenshot_custom.png)
16+
17+
The following `env.config.jsx` will replace the course outline sidebar mobile trigger entirely.
18+
19+
```js
20+
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
21+
22+
const config = {
23+
pluginSlots: {
24+
course_outline_mobile_sidebar_trigger_slot: {
25+
keepDefault: false,
26+
plugins: [
27+
{
28+
op: PLUGIN_OPERATIONS.Insert,
29+
widget: {
30+
id: 'custom_sidebar_trigger_component',
31+
type: DIRECT_PLUGIN,
32+
RenderWidget: () => (
33+
<h1 className="d-xl-none">📌</h1>
34+
),
35+
},
36+
},
37+
]
38+
}
39+
},
40+
}
41+
42+
export default config;
43+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
3+
import { PluginSlot } from '@openedx/frontend-plugin-framework';
4+
5+
import CourseOutlineTrigger from '../../courseware/course/sidebar/sidebars/course-outline/CourseOutlineTrigger';
6+
7+
export const CourseOutlineMobileSidebarTriggerSlot : React.FC = () => (
8+
<PluginSlot
9+
id="course_outline_mobile_sidebar_trigger_slot"
10+
slotOptions={{
11+
mergeProps: true,
12+
}}
13+
>
14+
<CourseOutlineTrigger isMobileView />
15+
</PluginSlot>
16+
);
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Course Outline Sidebar Slot
2+
3+
### Slot ID: `course_outline_sidebar_slot`
4+
5+
## Description
6+
7+
This slot is used to replace/modify/hide the course outline sidebar.
8+
9+
## Example
10+
11+
### Default content
12+
![Sidebar slot with default content](./screenshot_default.png)
13+
14+
### Replaced with custom component
15+
![📊 in sidebar slot](./screenshot_custom.png)
16+
17+
The following `env.config.jsx` will replace the course outline sidebar entirely.
18+
19+
```js
20+
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
21+
22+
const config = {
23+
pluginSlots: {
24+
course_outline_sidebar_slot: {
25+
keepDefault: false,
26+
plugins: [
27+
{
28+
op: PLUGIN_OPERATIONS.Insert,
29+
widget: {
30+
id: 'custom_sidebar_component',
31+
type: DIRECT_PLUGIN,
32+
RenderWidget: () => (
33+
<h1>📊</h1>
34+
),
35+
},
36+
},
37+
]
38+
}
39+
},
40+
}
41+
42+
export default config;
43+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
3+
import { PluginSlot } from '@openedx/frontend-plugin-framework';
4+
5+
import CourseOutlineTray from '../../courseware/course/sidebar/sidebars/course-outline/CourseOutlineTray';
6+
7+
export const CourseOutlineSidebarSlot : React.FC = () => (
8+
<PluginSlot
9+
id="course_outline_sidebar_slot"
10+
slotOptions={{
11+
mergeProps: true,
12+
}}
13+
>
14+
<CourseOutlineTray />
15+
</PluginSlot>
16+
);
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Course Outline Sidebar Trigger Slot
2+
3+
### Slot ID: `course_outline_sidebar_trigger_slot`
4+
5+
## Description
6+
7+
This slot is used to replace/modify/hide the course outline sidebar trigger.
8+
9+
## Example
10+
11+
### Default content
12+
![Trigger slot with default content](./screenshot_default.png)
13+
14+
### Replaced with custom component
15+
![📌 in trigger slot](./screenshot_custom.png)
16+
17+
The following `env.config.jsx` will replace the course outline sidebar trigger entirely.
18+
19+
```js
20+
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
21+
22+
const config = {
23+
pluginSlots: {
24+
course_outline_sidebar_trigger_slot: {
25+
keepDefault: false,
26+
plugins: [
27+
{
28+
op: PLUGIN_OPERATIONS.Insert,
29+
widget: {
30+
id: 'custom_sidebar_trigger_component',
31+
type: DIRECT_PLUGIN,
32+
RenderWidget: () => (
33+
<h1 className="d-none d-xl-block">📌</h1>
34+
),
35+
},
36+
},
37+
]
38+
}
39+
},
40+
}
41+
42+
export default config;
43+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
3+
import { PluginSlot } from '@openedx/frontend-plugin-framework';
4+
5+
import CourseOutlineTrigger from '../../courseware/course/sidebar/sidebars/course-outline/CourseOutlineTrigger';
6+
7+
export const CourseOutlineSidebarTriggerSlot : React.FC = () => (
8+
<PluginSlot
9+
id="course_outline_sidebar_trigger_slot"
10+
slotOptions={{
11+
mergeProps: true,
12+
}}
13+
>
14+
<CourseOutlineTrigger isMobileView={false} />
15+
</PluginSlot>
16+
);
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Notifications Discussions Sidebar Slot
2+
3+
### Slot ID: `notifications_discussions_sidebar_slot`
4+
5+
## Description
6+
7+
This slot is used to replace/modify/hide the notifications discussions sidebar.
8+
9+
## Example
10+
11+
### Default content
12+
![Sidebar slot with default content](./screenshot_default.png)
13+
14+
### Replaced with custom component
15+
![📊 in sidebar slot](./screenshot_custom.png)
16+
17+
The following `env.config.jsx` will replace the notifications discussions sidebar.
18+
19+
```js
20+
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
21+
22+
const config = {
23+
pluginSlots: {
24+
notifications_discussions_sidebar_slot: {
25+
keepDefault: false,
26+
plugins: [
27+
{
28+
op: PLUGIN_OPERATIONS.Insert,
29+
widget: {
30+
id: 'custom_sidebar_component',
31+
type: DIRECT_PLUGIN,
32+
RenderWidget: () => (
33+
<h1>📊</h1>
34+
),
35+
},
36+
},
37+
]
38+
}
39+
},
40+
}
41+
42+
export default config;
43+
```

0 commit comments

Comments
 (0)