Repository navigation
feat: [FC-86] Added plugin slots for catalog page #63
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
Merged
brian-smith-tcril
merged 4 commits into
openedx:master
from
raccoongang:Peter_Kulko/plugin-slots-for-catalog-page
Dec 1, 2025
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,9 +1,7 @@ | ||
| import { IntlShape } from '@edx/frontend-platform/i18n'; | ||
|
|
||
| import type { CourseListSearchResponse } from '@src/data/course-list-search/types'; | ||
|
|
||
| export interface GetPageTitleProps { | ||
| intl: IntlShape; | ||
| searchString: string; | ||
| courseData: CourseListSearchResponse | undefined; | ||
| courseDataResultsLength?: number; | ||
| } |
This file contains hidden or 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
113 changes: 113 additions & 0 deletions
113
...urseCatalogDataTableCardViewSlot/CourseCatalogDataTableCourseCardSlot/README.md
This file contains hidden or 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,113 @@ | ||
| # Course catalog page data table course card slot | ||
|
|
||
| ### Slot ID: `org.openedx.frontend.catalog.course_catalog_page.data_table.course_card` | ||
|
|
||
| ## Description | ||
|
|
||
| This slot is used to replace/modify/hide the entire Course catalog page data table course card. | ||
|
|
||
| ### Plugin Props: | ||
|
|
||
| * `courseData` - Object. The course object containing course information such as id, display name, organization, number, image URL, and other course metadata. | ||
| * `isLoading` - Boolean. Indicates whether the course card is currently in a loading state. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Default content | ||
|
|
||
|  | ||
|
|
||
| ### Replaced with custom component | ||
|
|
||
|  | ||
|
|
||
| The following `env.config.tsx` will replace the Course catalog page data table course card entirely (in this case with a centered `h1` tag) | ||
|
|
||
| ```tsx | ||
| import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.catalog.course_catalog_page.data_table.course_card': { | ||
| keepDefault: false, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Insert, | ||
| widget: { | ||
| id: 'custom_course_catalog_page_data_table_course_card_component', | ||
| type: DIRECT_PLUGIN, | ||
| RenderWidget: () => ( | ||
| <h1 style={{textAlign: 'center'}}>🦶</h1> | ||
| ), | ||
| }, | ||
| }, | ||
| ] | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| export default config; | ||
| ``` | ||
|
|
||
| ### Custom component with plugin props | ||
|
|
||
|  | ||
|
|
||
| The following `env.config.tsx` example demonstrates how to replace the Course catalog page data table course card slot with a custom component that uses the plugin props (`original` and `isLoading`). In this case, it creates a custom card component that displays course information in a different format. | ||
|
|
||
| ```tsx | ||
| import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
| import { Card, Badge } from '@openedx/paragon'; | ||
| import { Link } from 'react-router-dom'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.catalog.course_catalog_page.data_table.course_card': { | ||
| keepDefault: false, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Insert, | ||
| widget: { | ||
| id: 'custom_course_catalog_page_data_table_course_card_component', | ||
| type: DIRECT_PLUGIN, | ||
| RenderWidget: ({ original: courseData, isLoading }) => { | ||
| if (isLoading) { | ||
| return <Card isLoading />; | ||
| } | ||
|
|
||
| if (!courseData) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <Card | ||
| as={Link} | ||
| to={`/courses/${courseData.id}/about`} | ||
| isClickable | ||
| > | ||
| <Card.Header | ||
| title={courseData.data.content.displayName} | ||
| subtitle={ | ||
| <Badge>{courseData.data.org}</Badge> | ||
| } | ||
| /> | ||
| <Card.Section> | ||
| {courseData.data.content.overview && ( | ||
| <p className="text-muted font-size-sm"> | ||
| {courseData.data.content.overview.substring(0, 150)}... | ||
| </p> | ||
| )} | ||
| </Card.Section> | ||
| <Card.Footer textElement={`Language: ${courseData.data.language}`} /> | ||
| </Card> | ||
| ); | ||
| }, | ||
| }, | ||
| }, | ||
| ] | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| export default config; | ||
| ``` |
Binary file added
BIN
+288 KB
...eCardViewSlot/CourseCatalogDataTableCourseCardSlot/images/screenshot_custom.png
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
+443 KB
...lot/CourseCatalogDataTableCourseCardSlot/images/screenshot_custom_with_card.png
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
+1.16 MB
...CardViewSlot/CourseCatalogDataTableCourseCardSlot/images/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.
21 changes: 21 additions & 0 deletions
21
...leSlots/CourseCatalogDataTableCardViewSlot/CourseCatalogDataTableCourseCardSlot/index.tsx
This file contains hidden or 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,21 @@ | ||
| import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| import { CourseCard } from '@src/generic'; | ||
| import { CourseCardProps } from '@src/generic/course-card/types'; | ||
|
|
||
| const CourseCatalogDataTableCourseCardSlot = ({ original: courseData, isLoading }: CourseCardProps) => ( | ||
| <PluginSlot | ||
| id="org.openedx.frontend.catalog.course_catalog_page.data_table.course_card" | ||
| slotOptions={{ | ||
| mergeProps: true, | ||
| }} | ||
| pluginProps={{ | ||
| original: courseData, | ||
| isLoading, | ||
| }} | ||
| > | ||
| <CourseCard original={courseData} isLoading={isLoading} /> | ||
| </PluginSlot> | ||
| ); | ||
|
|
||
| export default CourseCatalogDataTableCourseCardSlot; | ||
98 changes: 98 additions & 0 deletions
98
...-slots/CourseCatalogDataTableSlots/CourseCatalogDataTableCardViewSlot/README.md
This file contains hidden or 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,98 @@ | ||
| # Course catalog page data table card view slot | ||
|
|
||
| ### Slot ID: `org.openedx.frontend.catalog.course_catalog_page.data_table.card_view` | ||
|
|
||
| ## Description | ||
|
|
||
| This slot is used to replace/modify/hide the entire Course catalog page data table card view section. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Default content | ||
|
|
||
|  | ||
|
|
||
| ### Replaced with custom component | ||
|
|
||
|  | ||
|
|
||
| The following `env.config.tsx` will replace the Course catalog page data table card view section entirely (in this case with a centered `h1` tag) | ||
|
|
||
| ```tsx | ||
| import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.catalog.course_catalog_page.data_table.card_view': { | ||
| keepDefault: false, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Insert, | ||
| widget: { | ||
| id: 'custom_course_catalog_page_data_table_footer_component', | ||
| type: DIRECT_PLUGIN, | ||
| RenderWidget: () => ( | ||
| <h1 style={{textAlign: 'center'}}>🦶</h1> | ||
| ), | ||
| }, | ||
| }, | ||
| ] | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| export default config; | ||
| ``` | ||
|
|
||
| ### Custom component with plugin props | ||
|
|
||
|  | ||
|
|
||
| The following `env.config.tsx` example demonstrates how to replace the Course catalog page data table card view slot with a custom component that uses the plugin props (`displayData`). In this case, it creates a custom grid layout (2 columns) while using the standard course card component through the plugin slot system. | ||
|
|
||
| ```tsx | ||
| import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
| import CourseCatalogDataTableCourseCardSlot from '@src/plugin-slots/CourseCatalogDataTableSlots/CourseCatalogDataTableCardViewSlot/CourseCatalogDataTableCourseCardSlot'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.catalog.course_catalog_page.data_table.card_view': { | ||
| keepDefault: false, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Insert, | ||
| widget: { | ||
| id: 'custom_course_catalog_page_data_table_card_view_component', | ||
| type: DIRECT_PLUGIN, | ||
| RenderWidget: ({ displayData }) => { | ||
| if (!displayData || !displayData.results) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div | ||
| style={{ | ||
| display: 'grid', | ||
| gridTemplateColumns: 'repeat(2, 1fr)', | ||
| gap: '2rem', | ||
| }} | ||
| > | ||
| {displayData.results.map((course) => ( | ||
| <CourseCatalogDataTableCourseCardSlot | ||
| key={course.id} | ||
| original={course} | ||
| isLoading={false} | ||
| /> | ||
| ))} | ||
| </div> | ||
| ); | ||
| }, | ||
| }, | ||
| }, | ||
| ] | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| export default config; | ||
| ``` |
Binary file added
BIN
+285 KB
...gDataTableSlots/CourseCatalogDataTableCardViewSlot/images/screenshot_custom.png
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
+1.16 MB
...DataTableSlots/CourseCatalogDataTableCardViewSlot/images/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.
Binary file added
BIN
+1.4 MB
...Slots/CourseCatalogDataTableCardViewSlot/images/screenshot_with_custom_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
src/plugin-slots/CourseCatalogDataTableSlots/CourseCatalogDataTableCardViewSlot/index.tsx
This file contains hidden or 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,25 @@ | ||
| import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
| import { CardView } from '@openedx/paragon'; | ||
|
|
||
| import { DEFAULT_PAGE_SIZE } from '@src/data/course-list-search/constants'; | ||
| import { CourseListSearchResponse } from '@src/data/course-list-search/types'; | ||
| import CourseCatalogDataTableCourseCardSlot from './CourseCatalogDataTableCourseCardSlot'; | ||
|
|
||
| const CourseCatalogDataTableCardViewSlot = ({ displayData }: { displayData?: CourseListSearchResponse }) => ( | ||
| <PluginSlot | ||
| id="org.openedx.frontend.catalog.course_catalog_page.data_table.card_view" | ||
| slotOptions={{ | ||
| mergeProps: true, | ||
| }} | ||
| pluginProps={{ | ||
| displayData, | ||
| }} | ||
| > | ||
| <CardView | ||
| CardComponent={CourseCatalogDataTableCourseCardSlot} | ||
| skeletonCardCount={Math.min(displayData?.total ?? DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE)} | ||
| /> | ||
| </PluginSlot> | ||
| ); | ||
|
|
||
| export default CourseCatalogDataTableCardViewSlot; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.