Repository navigation
Fix pb-message boilerplate templates ignored by generic container #3157
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
bradenmacdonald
merged 4 commits into
openedx:master
from
salman2013:salman/fix-fb-message-template-issue
Aug 6, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
52576ed
fix: pass boilerplate to generic container add-component buttons
salman2013 a03122c
style: fix dprint formatting in AddComponent files
salman2013 7be652b
chore: fix type info for 'boilerplate_name'
bradenmacdonald d6883be
chore: fix formatting
bradenmacdonald 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
Some comments aren't visible on the classic Files Changed page.
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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import { useEventListener } from '@src/generic/hooks'; | |
| import VideoSelectorPage from '@src/editors/VideoSelectorPage'; | ||
| import EditorPage from '@src/editors/EditorPage'; | ||
| import { SelectedComponent } from '@src/library-authoring'; | ||
| import { type CreateCourseXBlockParams } from '@src/course-unit/hooks'; | ||
| import { fetchCourseSectionVerticalData } from '../data/thunk'; | ||
| import { messageTypes } from '../constants'; | ||
| import messages from './messages'; | ||
|
|
@@ -31,7 +32,7 @@ type ComponentTemplateData = { | |
| type: string; | ||
| beta?: boolean; | ||
| templates: Array<{ | ||
| boilerplateName?: string; | ||
| boilerplateName?: string | null; | ||
| category?: string; | ||
| displayName: string; | ||
| supportLevel?: string | boolean; | ||
|
|
@@ -57,7 +58,7 @@ export interface AddComponentProps { | |
| isGenericContainerType?: boolean; | ||
| parentLocator: string; | ||
| handleCreateNewCourseXBlock: ( | ||
| args: object, | ||
| args: CreateCourseXBlockParams, | ||
| callback?: (args: { courseKey: string; locator: string; }) => void, | ||
| ) => void; | ||
| isProblemBankType?: boolean; | ||
|
|
@@ -148,7 +149,7 @@ const AddComponent = ({ | |
| closeAddLibraryContentModal(); | ||
| }, [usageId]); | ||
|
|
||
| const handleCreateNewXBlock = (type: string, moduleName?: string) => { | ||
| const handleCreateNewXBlock = (type: string, moduleName?: string | null) => { | ||
| switch (type) { | ||
| case COMPONENT_TYPES.discussion: | ||
| case COMPONENT_TYPES.dragAndDrop: | ||
|
|
@@ -209,7 +210,7 @@ const AddComponent = ({ | |
| }, | ||
| ); | ||
| } else { | ||
| handleCreateNewCourseXBlock({ type: moduleName, category: moduleName, parentLocator: blockId }); | ||
| handleCreateNewCourseXBlock({ type: moduleName!, category: moduleName!, parentLocator: blockId }); | ||
| } | ||
| break; | ||
| case COMPONENT_TYPES.openassessment: | ||
|
|
@@ -231,7 +232,14 @@ const AddComponent = ({ | |
| // Generic handler for container-specific block types declared via | ||
| // StudioContainerWithNestedXBlocksMixin.allowed_nested_blocks that are | ||
| // not one of the MFE's built-in component types (html, video, problem…). | ||
| handleCreateNewCourseXBlock({ type, category: type, parentLocator: blockId }); | ||
| // Pass boilerplate so that blocks with multiple templates (e.g. pb-message) | ||
| // get initialised with the correct template content instead of the default. | ||
| handleCreateNewCourseXBlock({ | ||
| type, | ||
| category: type, | ||
| boilerplate: moduleName, | ||
| parentLocator: blockId, | ||
|
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.
|
||
| }); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -283,7 +291,7 @@ const AddComponent = ({ | |
| return ( | ||
| <li key={type}> | ||
| <AddComponentButton | ||
| onClick={() => handleCreateNewXBlock(type)} | ||
| onClick={() => handleCreateNewXBlock(type, firstTemplate?.boilerplateName)} | ||
| displayName={displayName} | ||
| type={type} | ||
| beta={beta} | ||
|
|
||
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
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.
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.
The new test covers the happy path (boilerplate present → forwarded). Consider adding a sibling test for the inverse: a generic container block whose template has no
boilerplate_name.