-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add progress certificate status plugin slot (#1551)
- Loading branch information
1 parent
dafdcad
commit 8a6fa93
Showing
5 changed files
with
100 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Unit Title Slot | ||
|
||
### Slot ID: `progress_certificate_status_slot` | ||
### Props: | ||
* `courseId` | ||
|
||
## Description | ||
|
||
This slot is used for modify the content in the CertificateStatus in the progress page for specific enrollment tracks. | ||
|
||
## Example | ||
|
||
The following `env.config.jsx` will render the `RenderWidget.props.id` of the course as `<p>` element. | ||
|
||
### Default content | ||
![Certificate Status slot with default content](./screenshot_default.png) | ||
|
||
### Replaced with custom component | ||
![Default content id showing in trigger slot](./screenshot_custom.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const modifyWidget = (widget) => { | ||
const { RenderWidget } = widget; | ||
if (RenderWidget.props.id.includes('upgrade')) { | ||
widget.RenderWidget = ( | ||
<div className='m-3'> | ||
<h3>Upgrade certificate</h3> | ||
<p>{RenderWidget.props.id}</p> | ||
</div> | ||
) | ||
} | ||
|
||
return widget; | ||
} | ||
|
||
const config = { | ||
pluginSlots: { | ||
progress_certificate_status_slot: { | ||
keepDefault: true, | ||
plugins: [{ | ||
op: PLUGIN_OPERATIONS.Modify, | ||
widgetId: 'default_contents', | ||
// Insert custom content top modify certificate status | ||
fn: modifyWidget, | ||
}], | ||
} | ||
}, | ||
} | ||
|
||
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,18 @@ | ||
import PropTypes from 'prop-types'; | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
const ProgressCertificateStatusSlot = ({ courseId, children }) => ( | ||
<PluginSlot | ||
id="progress_certificate_status_slot" | ||
pluginProps={{ courseId }} | ||
> | ||
{children} | ||
</PluginSlot> | ||
); | ||
|
||
ProgressCertificateStatusSlot.propTypes = { | ||
courseId: PropTypes.string.isRequired, | ||
children: PropTypes.node.isRequired, | ||
}; | ||
|
||
export default ProgressCertificateStatusSlot; |
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
+58.2 KB
src/plugin-slots/ProgressCertificateStatusSlot/screenshot_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.