From e577efbd27bf348c0888c23d16cbf4e3fadb1552 Mon Sep 17 00:00:00 2001 From: Jorg Are Date: Tue, 21 May 2024 17:20:51 +0100 Subject: [PATCH] feat: add unit title to pluginslot (#1383) --- .../course/sequence/Unit/__snapshots__/index.test.jsx.snap | 1 + src/courseware/course/sequence/Unit/index.jsx | 2 +- src/plugin-slots/UnitTitleSlot/README.md | 6 ++++-- src/plugin-slots/UnitTitleSlot/index.jsx | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/courseware/course/sequence/Unit/__snapshots__/index.test.jsx.snap b/src/courseware/course/sequence/Unit/__snapshots__/index.test.jsx.snap index 2249c87122..63b0fb5a11 100644 --- a/src/courseware/course/sequence/Unit/__snapshots__/index.test.jsx.snap +++ b/src/courseware/course/sequence/Unit/__snapshots__/index.test.jsx.snap @@ -31,6 +31,7 @@ exports[`Unit component output snapshot: not bookmarked, do not show content 1`]

{unit.title}

- +

{formatMessage(messages.headerPlaceholder)}

` elements. +The following `env.config.jsx` will render the `course_id`, `unit_id` and `unitTitle` of the course as `

` elements. ![Screenshot of Content added after the Unit Title](./images/post_unit_title.png) @@ -28,10 +29,11 @@ const config = { widget: { id: 'custom_unit_title_content', type: DIRECT_PLUGIN, - RenderWidget: ({courseId, unitId}) => ( + RenderWidget: ({courseId, unitId, unitTitle}) => ( <>

📚: {courseId}

📙: {unitId}

+

📙: {unitTitle}

), }, diff --git a/src/plugin-slots/UnitTitleSlot/index.jsx b/src/plugin-slots/UnitTitleSlot/index.jsx index 40f449cf97..23d501a079 100644 --- a/src/plugin-slots/UnitTitleSlot/index.jsx +++ b/src/plugin-slots/UnitTitleSlot/index.jsx @@ -1,12 +1,13 @@ import PropTypes from 'prop-types'; import { PluginSlot } from '@openedx/frontend-plugin-framework'; -const UnitTitleSlot = ({ courseId, unitId }) => ( +const UnitTitleSlot = ({ courseId, unitId, unitTitle }) => ( ); @@ -14,6 +15,7 @@ const UnitTitleSlot = ({ courseId, unitId }) => ( UnitTitleSlot.propTypes = { courseId: PropTypes.string.isRequired, unitId: PropTypes.string.isRequired, + unitTitle: PropTypes.string.isRequired, }; export default UnitTitleSlot;