feat: Add plugin slots for sidebars (#1752)
This commit is contained in:
42
src/plugin-slots/CourseAuthoringUnitSidebarSlot/README.md
Normal file
42
src/plugin-slots/CourseAuthoringUnitSidebarSlot/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# CourseAuthoringUnitSidebarSlot
|
||||
|
||||
### Slot ID: `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.
|
||||
|
||||
## 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.
|
||||
|
||||
## Example
|
||||
|
||||

|
||||
|
||||
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: {
|
||||
course_authoring_unit_sidebar_slot: {
|
||||
keepDefault: true,
|
||||
plugins: [
|
||||
{
|
||||
op: PLUGIN_OPERATIONS.Wrap,
|
||||
widgetId: 'default_contents',
|
||||
wrapper: ({ component }) => (
|
||||
<div style={{ border: 'thick dashed red' }}>{component}</div>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
};
|
||||
export default config;
|
||||
```
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 164 KiB |
37
src/plugin-slots/CourseAuthoringUnitSidebarSlot/index.tsx
Normal file
37
src/plugin-slots/CourseAuthoringUnitSidebarSlot/index.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework/dist';
|
||||
import TagsSidebarControls from '../../content-tags-drawer/tags-sidebar-controls';
|
||||
import Sidebar from '../../course-unit/sidebar';
|
||||
import LocationInfo from '../../course-unit/sidebar/LocationInfo';
|
||||
import PublishControls from '../../course-unit/sidebar/PublishControls';
|
||||
|
||||
export const CourseAuthoringUnitSidebarSlot = (
|
||||
{
|
||||
blockId,
|
||||
courseId,
|
||||
unitTitle,
|
||||
}: CourseAuthoringUnitSidebarSlotProps,
|
||||
) => (
|
||||
<PluginSlot
|
||||
id="course_authoring_unit_sidebar_slot"
|
||||
pluginProps={{ blockId, courseId, unitTitle }}
|
||||
>
|
||||
<Sidebar data-testid="course-unit-sidebar">
|
||||
<PublishControls blockId={blockId} />
|
||||
</Sidebar>
|
||||
{getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true' && (
|
||||
<Sidebar className="tags-sidebar">
|
||||
<TagsSidebarControls />
|
||||
</Sidebar>
|
||||
)}
|
||||
<Sidebar data-testid="course-unit-location-sidebar">
|
||||
<LocationInfo />
|
||||
</Sidebar>
|
||||
</PluginSlot>
|
||||
);
|
||||
|
||||
interface CourseAuthoringUnitSidebarSlotProps {
|
||||
blockId: string;
|
||||
courseId: string;
|
||||
unitTitle: string;
|
||||
}
|
||||
Reference in New Issue
Block a user