Repository navigation
refactor: CourseAuthoringUnitSidebarSlot #2000
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 8 commits into
openedx:master
from
open-craft:tecoholic/BB-9725-refactor-course-unit-sidebar
Jun 10, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c5176fa
refactor: CourseAuthoringUnitSidebarSlot
tecoholic 238a115
docs: update the CourseAuthoringUnitSidebarSlot docs
tecoholic c2467e8
fix: linting issue causing CI failure
tecoholic c259d15
refactor: introduce the changes as slot v2 wrapping v1
tecoholic ea99da2
docs: update the CourseAuthoringUnitSidebarSlot docs
tecoholic b111338
docs: separate the README files for the 2 versions
tecoholic b8f0268
fixup! docs: minor edits around formatting
tecoholic 1775519
docs: improve the docs for v1, remove err alias
tecoholic 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
95 changes: 95 additions & 0 deletions
95
src/plugin-slots/CourseAuthoringUnitSidebarSlot/README.v1.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,95 @@ | ||
| # CourseAuthoringUnitSidebarSlot | ||
|
|
||
| ### Slot ID: `org.openedx.frontend.authoring.course_unit_sidebar.v1` | ||
|
|
||
| ### Slot ID Aliases: `course_authoring_unit_sidebar_slot` | ||
|
|
||
| ### Plugin Props: | ||
|
|
||
| * `courseId` - String. | ||
| * `blockId` - String. The usage id of the current unit being viewed / edited. | ||
| * `unitTitle` - String. The name of the current unit being viewed / edited. | ||
| * `xBlocks` - Array of Objects. List of XBlocks in the Unit. Object structure defined in `index.tsx`. | ||
| * `readOnly` - Boolean. True if the user should not be able to edit the contents of the unit. | ||
|
|
||
| ### Description | ||
|
|
||
| The slot wraps the sidebar that is displayed on the unit editor page. It can | ||
| be used to add additional sidebar components or modify the existing sidebar. | ||
|
|
||
| > [!IMPORTANT] | ||
| > This document describes an older version `v1` of the `CourseAuthoringUnitSidebarSlot`. | ||
| > It is recommended to use the `org.openedx.frontend.authoring.course_unit_sidebar.v2` slot ID for new plugins. | ||
|
|
||
| The `v1` slot has the following limitations compared to the `v2` version: | ||
| * It renders conditionally based on the `isUnitVerticalType` prop, which means the plugins won't be rendered in other scenarios like unit with library blocks. | ||
| * It does **not** wrap the `SplitTestSidebarInfo` component. So it can't be hidden from the sidebar by overriding the components in the slot. | ||
| * As it is not the primary child component of the sidebar, CSS styling for inserted components face limitations, such as an inability to be `sticky` or achieve 100% height. | ||
|
|
||
| ## Example 1 | ||
|
|
||
|  | ||
|
|
||
| The following example configuration surrounds the sidebar in a border as shown above. | ||
|
|
||
| ```js | ||
| import { PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.authoring.course_unit_sidebar.v1': { | ||
| keepDefault: true, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Wrap, | ||
| widgetId: 'default_contents', | ||
| wrapper: ({ component }) => ( | ||
| <div style={{ border: 'thick dashed red' }}>{component}</div> | ||
| ), | ||
| }, | ||
| ], | ||
| }, | ||
| } | ||
| }; | ||
| export default config; | ||
| ``` | ||
|
|
||
| ## Example 2 | ||
|
|
||
|  | ||
|
|
||
| ```js | ||
| import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| const ProblemBlocks = ({unitTitle, xBlocks}) => ( | ||
| <> | ||
| <h4 className="h4">{unitTitle}: Problem Blocks</h4> | ||
| <ul> | ||
| {xBlocks | ||
| .filter(block => block.blockType === "problem") | ||
| .map(block => <li key={block.id}>{block.displayName}</li>) | ||
| } | ||
| </ul> | ||
| </> | ||
| ); | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.authoring.course_unit_sidebar.v1': { | ||
| keepDefault: true, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Insert, | ||
| widget:{ | ||
| id: 'problem-blocks-list', | ||
| priority: 1, | ||
| type: DIRECT_PLUGIN, | ||
| RenderWidget: ProblemBlocks, | ||
| } | ||
| }, | ||
| ], | ||
| }, | ||
| } | ||
| }; | ||
| export default config; | ||
| ``` | ||
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.
Uh oh!
There was an error while loading. Please reload this page.