forked from openedx/frontend-app-learner-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: plugin slot implementation (openedx#465)
- Loading branch information
1 parent
3ea2825
commit 0038756
Showing
27 changed files
with
266 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
src/containers/WidgetContainers/WidgetSidebar/__snapshots__/index.test.jsx.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Course List Slot | ||
|
||
### Slot ID: `course_list_slot` | ||
|
||
## Plugin Props | ||
|
||
* courseListData | ||
|
||
## Description | ||
|
||
This slot is used for replacing or adding content around the `CourseList` component. The `CourseListSlot` is only rendered if the learner has enrolled in at least one course. | ||
|
||
## Example | ||
|
||
The space will show the `CourseList` component by default. This can be disabled in the configuration with the `keepDefault` boolean. | ||
|
||
![Screenshot of the CourseListSlot](./images/course_list_slot.png) | ||
|
||
Setting the MFE's `env.config.jsx` to the following will replace the default experience with a list of course titles. | ||
|
||
![Screenshot of a custom course list](./images/readme_custom_course_list.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
course_list_slot: { | ||
// Hide the default CourseList component | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_course_list', | ||
type: DIRECT_PLUGIN, | ||
priority: 60, | ||
RenderWidget: ({ courseListData }) => { | ||
// Extract the "visibleList" | ||
const courses = courseListData.visibleList; | ||
// Render a list of course names | ||
return ( | ||
<div> | ||
{courses.map(courseData => ( | ||
<p> | ||
{courseData.course.courseName} | ||
</p> | ||
))} | ||
</div> | ||
) | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
|
||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import { CourseList, courseListDataShape } from 'containers/CoursesPanel/CourseList'; | ||
|
||
export const CourseListSlot = ({ courseListData }) => ( | ||
<PluginSlot id="course_list_slot" pluginProps={{ courseListData }}> | ||
<CourseList courseListData={courseListData} /> | ||
</PluginSlot> | ||
); | ||
|
||
CourseListSlot.propTypes = { | ||
courseListData: courseListDataShape, | ||
}; | ||
|
||
export default CourseListSlot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# No Courses View Slot | ||
|
||
### Slot ID: `no_courses_view_slot` | ||
|
||
## Description | ||
|
||
This slot is used for replacing or adding content around the `NoCoursesView` component. The `NoCoursesViewSlot` only renders if the learner has not yet enrolled in any courses. | ||
|
||
## Example | ||
|
||
The space will show the `NoCoursesView` by default. This can be disabled in the configuration with the `keepDefault` boolean. | ||
|
||
![Screenshot of the no courses view](./images/no_courses_view_slot.png) | ||
|
||
Setting the MFE's `env.config.jsx` to the following will replace the default experience with a custom call-to-action component. | ||
|
||
![Screenshot of a custom no courses view](./images/readme_custom_no_courses_view.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
no_courses_view_slot: { | ||
// Hide the default NoCoursesView component | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_no_courses_CTA', | ||
type: DIRECT_PLUGIN, | ||
priority: 60, | ||
RenderWidget: () => ( | ||
<h3> | ||
Check out our catalog of courses and start learning today! | ||
</h3> | ||
), | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.9 KB
src/plugin-slots/NoCoursesViewSlot/images/readme_custom_no_courses.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
|
||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import NoCoursesView from 'containers/CoursesPanel/NoCoursesView'; | ||
|
||
export const NoCoursesViewSlot = () => ( | ||
<PluginSlot id="no_courses_view_slot"> | ||
<NoCoursesView /> | ||
</PluginSlot> | ||
); | ||
|
||
export default NoCoursesViewSlot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# `frontend-app-learner-dashboard` Plugin Slots | ||
|
||
* [`footer_slot`](./FooterSlot/) | ||
* [`widget_sidebar_slot`](./WidgetSidebarSlot/) | ||
* [`course_list_slot`](./CourseListSlot/) | ||
* [`no_courses_view_slot`](./NoCoursesViewSlot/) |
Oops, something went wrong.