-
Notifications
You must be signed in to change notification settings - Fork 96
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
feat: add plugin slot for course card action #464
Conversation
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.
Just a couple nit picks. Thanks for setting this one up!
src/containers/CourseCard/components/CourseCardActions/index.jsx
Outdated
Show resolved
Hide resolved
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.
As per the conversation in today's FWG meeting, this is fine for now.
@sarina here's some screenshots, which I actually liked the custom button example so much that that's what is now going into the repo documentation for this plugin slot! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #464 +/- ##
=======================================
Coverage 97.39% 97.40%
=======================================
Files 156 157 +1
Lines 1380 1385 +5
Branches 227 227
=======================================
+ Hits 1344 1349 +5
Misses 34 34
Partials 2 2 ☔ View full report in Codecov by Sentry. |
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
import ActionButton from 'containers/CourseCard/components/CourseCardActions/ActionButton'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
course_card_action_slot: { | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
// Insert Custom Button in Course Card | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_course_card_action', | ||
priority: 60, | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: ({cardId}) => ( | ||
<ActionButton | ||
variant="outline-primary" | ||
> | ||
Custom Button | ||
</ ActionButton> | ||
), | ||
}, | ||
}, | ||
{ | ||
// Insert Another Button in Course Card | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'another_custom_course_card_action', | ||
priority: 70, | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: ({cardId}) => ( | ||
<ActionButton | ||
variant="outline-primary" | ||
> | ||
Another Button | ||
</ ActionButton> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
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.
This example looks wonderful now! Super pretty.
Would you mind updating one of the buttons to include something about the cardId
? One thing I really liked about the example you had before was that it demonstrated the pluginProps
being used.
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.
Good idea, I sure can!
Thank you this is perfect! |
a3c37fe
to
c9aadd5
Compare
This PR makes the first step toward removing the Upgrade Button from Learner Dashboard's core functionality, by creating a
CourseCardActionSlot
whose default component is the Upgrade Button. A follow up PR will remove the default component entirely, as well as remove the source code itself.To test this locally:
env.config.js
file in your root directory, add the following configuration. To toggle the default component, you can adjust thekeepDefault
.Current Default Content in CourseCardActionSlot:
Replacing Default Content in CourseCardActionSlot:
Using props passed into PluginSlot
Contributes to: #438 #297