diff --git a/src/course-unit/CourseUnit.jsx b/src/course-unit/CourseUnit.jsx index 5aae700e5..f63dad09e 100644 --- a/src/course-unit/CourseUnit.jsx +++ b/src/course-unit/CourseUnit.jsx @@ -4,6 +4,7 @@ import { useSelector } from 'react-redux'; import { useParams } from 'react-router-dom'; import { Container, Layout, Stack, Button, TransitionReplace, + Alert, } from '@openedx/paragon'; import { useIntl } from '@edx/frontend-platform/i18n'; import { @@ -139,6 +140,24 @@ const CourseUnit = ({ courseId }) => { /> ) : null} + {courseUnit.upstreamInfo.upstreamLink && ( + + {intl.formatMessage(messages.alertLibraryUnitReadOnlyLinkText)} + + ), + }, + )} + variant="info" + /> + )} ', () => { ...courseUnitIndexMock, upstreamInfo: { upstreamRef: 'lct:org:lib:unit:unit-1', + upstreamLink: 'some-link', }, }); await executeThunk(fetchCourseUnitQuery(courseId), store.dispatch); + expect(screen.getByText(/this unit can only be edited from the \./i)).toBeInTheDocument(); + // Disable the "Edit" button const unitHeaderTitle = screen.getByTestId('unit-header-title'); const editButton = within(unitHeaderTitle).getByRole( diff --git a/src/course-unit/__mocks__/courseUnitIndex.js b/src/course-unit/__mocks__/courseUnitIndex.js index 12b1f0fb1..69b083d17 100644 --- a/src/course-unit/__mocks__/courseUnitIndex.js +++ b/src/course-unit/__mocks__/courseUnitIndex.js @@ -1120,4 +1120,7 @@ module.exports = { has_partition_group_components: false, release_date_from: 'Section "Example Week 1: Getting Started"', staff_lock_from: null, + upstreamInfo: { + upstreamLink: undefined, + }, }; diff --git a/src/course-unit/messages.js b/src/course-unit/messages.js index 83779747a..bbda3588e 100644 --- a/src/course-unit/messages.js +++ b/src/course-unit/messages.js @@ -43,6 +43,16 @@ const messages = defineMessages({ defaultMessage: 'Take me to the new location', description: 'Text for the button allowing users to navigate to the new location after an XBlock has been moved', }, + alertLibraryUnitReadOnlyText: { + id: 'course-authoring.course-unit.alert.read-only.text', + defaultMessage: 'This unit can only be edited from the {link}.', + description: 'Text of the alert when the unit is read only because is a library unit', + }, + alertLibraryUnitReadOnlyLinkText: { + id: 'course-authoring.course-unit.alert.read-only.link.text', + defaultMessage: 'library', + description: 'Text of the link in the alert when the unit is read only because is a library unit', + }, }); export default messages;