-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add plugin slots for progress page components
Adds a slot for different components in the progress tab to allow them to be overridden with custom components.
- Loading branch information
Showing
9 changed files
with
276 additions
and
18 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
44 changes: 44 additions & 0 deletions
44
src/plugin-slots/ProgressTabCertificateStatusSlot/README.md
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,44 @@ | ||
# Progress Tab Certificate Status Slot | ||
|
||
### Slot ID: `progress_tab_certificate_status_slot` | ||
### Props: | ||
* `courseId` | ||
|
||
## Description | ||
|
||
This slot is used to replace or modify the Certificate Status component in the | ||
Progress Tab. | ||
|
||
## Example | ||
|
||
The following `env.config.jsx` will render the `course_id` and `unit_id` of the course as `<p>` elements in a `<div>`. | ||
|
||
![Screenshot of Content added after the Sequence Container](./images/post_sequence_container.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
progress_tab_certificate_status_slot: { | ||
plugins: [ | ||
{ | ||
// Insert custom content after certificate status | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_certificate_status_content', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: ({courseId}) => ( | ||
<div> | ||
<p>📚: {courseId}</p> | ||
</div> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
20 changes: 20 additions & 0 deletions
20
src/plugin-slots/ProgressTabCertificateStatusSlot/index.jsx
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,20 @@ | ||
import PropTypes from 'prop-types'; | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import CertificateStatus from '../../course-home/progress-tab/certificate-status/CertificateStatus'; | ||
|
||
const ProgressTabCertificateStatusSlot = ({ courseId }) => ( | ||
<PluginSlot | ||
id="progress_tab_certificate_status_slot" | ||
pluginProps={{ | ||
courseId, | ||
}} | ||
> | ||
<CertificateStatus /> | ||
</PluginSlot> | ||
); | ||
|
||
ProgressTabCertificateStatusSlot.propTypes = { | ||
courseId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default ProgressTabCertificateStatusSlot; |
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,43 @@ | ||
# Progress Tab Course Grade Slot | ||
|
||
### Slot ID: `progress_tab_course_grade_slot` | ||
### Props: | ||
* `courseId` | ||
|
||
## Description | ||
|
||
This slot is used to replace or modify the Course Grades view in the Progress Tab. | ||
|
||
## Example | ||
|
||
The following `env.config.jsx` will render the `course_id` and `unit_id` of the course as `<p>` elements in a `<div>`. | ||
|
||
![Screenshot of Content added after the Sequence Container](./images/post_sequence_container.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
progress_tab_course_grade_slot: { | ||
plugins: [ | ||
{ | ||
// Insert custom content after course grade widget | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_course_grade_content', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: ({courseId}) => ( | ||
<div> | ||
<p>📚: {courseId}</p> | ||
</div> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
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,20 @@ | ||
import PropTypes from 'prop-types'; | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import CourseGrade from '../../course-home/progress-tab/grades/course-grade/CourseGrade'; | ||
|
||
const ProgressTabCourseGradeSlot = ({ courseId }) => ( | ||
<PluginSlot | ||
id="progress_tab_course_grade_slot" | ||
pluginProps={{ | ||
courseId, | ||
}} | ||
> | ||
<CourseGrade /> | ||
</PluginSlot> | ||
); | ||
|
||
ProgressTabCourseGradeSlot.propTypes = { | ||
courseId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default ProgressTabCourseGradeSlot; |
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,43 @@ | ||
# Progress Tab Grade Summary Slot | ||
|
||
### Slot ID: `progress_tab_grade_summary_slot` | ||
### Props: | ||
* `courseId` | ||
|
||
## Description | ||
|
||
This slot is used to replace or modify the Grade Summary view in the Progress Tab. | ||
|
||
## Example | ||
|
||
The following `env.config.jsx` will render the `course_id` and `unit_id` of the course as `<p>` elements in a `<div>`. | ||
|
||
![Screenshot of Content added after the Sequence Container](./images/post_sequence_container.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
progress_tab_grade_summary_slot: { | ||
plugins: [ | ||
{ | ||
// Insert custom content after grade summary widget | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_grade_summary_content', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: ({courseId}) => ( | ||
<div> | ||
<p>📚: {courseId}</p> | ||
</div> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
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,33 @@ | ||
import { useModel } from '@src/generic/model-store'; | ||
import PropTypes from 'prop-types'; | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import React from 'react'; | ||
import DetailedGrades from '../../course-home/progress-tab/grades/detailed-grades/DetailedGrades'; | ||
import GradeSummary from '../../course-home/progress-tab/grades/grade-summary/GradeSummary'; | ||
|
||
const ProgressTabGradeBreakdownSlot = ({ courseId }) => { | ||
const { gradesFeatureIsFullyLocked } = useModel('progress', courseId); | ||
const applyLockedOverlay = gradesFeatureIsFullyLocked ? 'locked-overlay' : ''; | ||
return ( | ||
<PluginSlot | ||
id="progress_tab_grade_breakdown_slot" | ||
pluginProps={{ | ||
courseId, | ||
}} | ||
> | ||
<div | ||
className={`grades my-4 p-4 rounded raised-card ${applyLockedOverlay}`} | ||
aria-hidden={gradesFeatureIsFullyLocked} | ||
> | ||
<GradeSummary /> | ||
<DetailedGrades /> | ||
</div> | ||
</PluginSlot> | ||
); | ||
}; | ||
|
||
ProgressTabGradeBreakdownSlot.propTypes = { | ||
courseId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default ProgressTabGradeBreakdownSlot; |
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,43 @@ | ||
# Progress Tab Related Links Slot | ||
|
||
### Slot ID: `progress_tab_related_links_slot` | ||
### Props: | ||
* `courseId` | ||
|
||
## Description | ||
|
||
This slot is used to replace or modify the related links view in the Progress Tab. | ||
|
||
## Example | ||
|
||
The following `env.config.jsx` will render the `course_id` and `unit_id` of the course as `<p>` elements in a `<div>`. | ||
|
||
![Screenshot of Content added after the Sequence Container](./images/post_sequence_container.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
progress_tab_related_links_slot: { | ||
plugins: [ | ||
{ | ||
// Insert custom content after related links widget | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_related_links_content', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: ({courseId}) => ( | ||
<div> | ||
<p>📚: {courseId}</p> | ||
</div> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
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,20 @@ | ||
import PropTypes from 'prop-types'; | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import RelatedLinks from '../../course-home/progress-tab/related-links/RelatedLinks'; | ||
|
||
const ProgressTabRelatedLinksSlot = ({ courseId }) => ( | ||
<PluginSlot | ||
id="progress_tab_related_links_slot" | ||
pluginProps={{ | ||
courseId, | ||
}} | ||
> | ||
<RelatedLinks /> | ||
</PluginSlot> | ||
); | ||
|
||
ProgressTabRelatedLinksSlot.propTypes = { | ||
courseId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default ProgressTabRelatedLinksSlot; |