-
Notifications
You must be signed in to change notification settings - Fork 322
feat: Created the plugin slot for UpgradeToCompleteAlert #1909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Banner Dates Upgrade Slot | ||
|
|
||
| ### Slot ID: `org.openedx.frontend.learning.banner_dates_upgrade.v1` | ||
|
|
||
| ### Slot ID Aliases | ||
|
|
||
| - `dates_upgrade_banner_slot` | ||
|
|
||
| ## Description | ||
|
|
||
| This slot is used for rendering upgrade messaging in the dates tab banner area. | ||
|
|
||
| By default, the slot renders `UpgradeToCompleteAlert`. You can disable the default and fully replace it with a custom plugin experience using `keepDefault: false`. | ||
|
|
||
| ## Props | ||
|
|
||
| - `courseId` - The course ID (string) | ||
| - `logUpgradeLinkClick` - Callback used for upgrade-click analytics | ||
|
|
||
| ## Screenshots | ||
|
|
||
| Default banner screenshot: | ||
|
|
||
|  | ||
|
|
||
|
|
||
|
|
||
| ## Example | ||
|
|
||
| The following `env.config.jsx` example replaces the default banner experience with a custom plugin widget: | ||
|
|
||
| ```js | ||
| import { | ||
| DIRECT_PLUGIN, | ||
| PLUGIN_OPERATIONS, | ||
| } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| dates_upgrade_banner_slot: { | ||
| keepDefault: false, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Insert, | ||
| widget: { | ||
| id: 'org.openedx.frontend.learning.banner_dates_upgrade.v1', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the widget id: it's arbitrary, and ideally it'll be different from the slot id where it's used. |
||
| type: DIRECT_PLUGIN, | ||
| priority: 50, | ||
| RenderWidget: (pluginProps) => ( | ||
| <div> | ||
| Replacement Banner | ||
| <button>Upgrade here</button> | ||
| </div> | ||
| ), | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default config; | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
| import UpgradeToCompleteAlert from '../../course-home/suggested-schedule-messaging/UpgradeToCompleteAlert'; | ||
|
|
||
| export const BannerDatesUpgradeSlot = ({ | ||
| courseId, | ||
| logUpgradeLinkClick, | ||
| }: BannerDatesUpgradeSlotProps) => ( | ||
| <PluginSlot | ||
| id="org.openedx.frontend.learning.banner_dates_upgrade.v1" | ||
| idAliases={['dates_upgrade_banner_slot']} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aliases exist to support a deprecation window for slots that are being renamed. Since this is a new slot, it shouldn't have an alias. |
||
| pluginProps={{ | ||
| courseId, | ||
| logUpgradeLinkClick, | ||
| }} | ||
| > | ||
| <UpgradeToCompleteAlert logUpgradeLinkClick={logUpgradeLinkClick} /> | ||
| </PluginSlot> | ||
| ); | ||
|
|
||
| interface BannerDatesUpgradeSlotProps { | ||
| courseId: string; | ||
| logUpgradeLinkClick: () => void; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the full id, here.