From dee4c436de1f090419733d32fe802bb42e7ebb8c Mon Sep 17 00:00:00 2001 From: 0x29a Date: Wed, 14 Aug 2024 18:39:53 +0200 Subject: [PATCH] feat: hide studio button for limited staff (cherry picked from https://github.com/openedx/frontend-app-learning/pull/1436/) --- src/course-home/data/pact-tests/lmsPact.test.jsx | 2 ++ src/instructor-toolbar/InstructorToolbar.jsx | 7 +++++-- src/tab-page/LoadedTabPage.jsx | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/course-home/data/pact-tests/lmsPact.test.jsx b/src/course-home/data/pact-tests/lmsPact.test.jsx index 523e84f9b3..5c163564b5 100644 --- a/src/course-home/data/pact-tests/lmsPact.test.jsx +++ b/src/course-home/data/pact-tests/lmsPact.test.jsx @@ -89,6 +89,7 @@ describe('Course Home Service', () => { }), title: string('Demonstration Course'), username: string('edx'), + has_course_author_access: boolean(true), }, }, }); @@ -133,6 +134,7 @@ describe('Course Home Service', () => { ], title: 'Demonstration Course', username: 'edx', + hasCourseAuthorAccess: true, }; const response = getCourseHomeCourseMetadata(courseId, 'outline'); expect(response).toBeTruthy(); diff --git a/src/instructor-toolbar/InstructorToolbar.jsx b/src/instructor-toolbar/InstructorToolbar.jsx index 71d968c869..1646a5dc89 100644 --- a/src/instructor-toolbar/InstructorToolbar.jsx +++ b/src/instructor-toolbar/InstructorToolbar.jsx @@ -55,6 +55,7 @@ const InstructorToolbar = (props) => { const { courseId, unitId, + studioButtonVisible, tab, } = props; @@ -72,13 +73,13 @@ const InstructorToolbar = (props) => {
- {(urlStudio || urlInsights) && ( + {((urlStudio && studioButtonVisible) || urlInsights) && ( <>
View course in: )} - {urlStudio && ( + {urlStudio && studioButtonVisible && ( Studio @@ -114,12 +115,14 @@ const InstructorToolbar = (props) => { InstructorToolbar.propTypes = { courseId: PropTypes.string, unitId: PropTypes.string, + studioButtonVisible: PropTypes.bool, tab: PropTypes.string, }; InstructorToolbar.defaultProps = { courseId: undefined, unitId: undefined, + studioButtonVisible: true, tab: '', }; diff --git a/src/tab-page/LoadedTabPage.jsx b/src/tab-page/LoadedTabPage.jsx index 0259aa1bfd..1ed83d3285 100644 --- a/src/tab-page/LoadedTabPage.jsx +++ b/src/tab-page/LoadedTabPage.jsx @@ -29,6 +29,7 @@ const LoadedTabPage = ({ tabs, title, verifiedMode, + hasCourseAuthorAccess, } = useModel('courseHomeMeta', courseId); // Logistration and enrollment alerts are only really used for the outline tab, but loaded here to put them above @@ -58,6 +59,7 @@ const LoadedTabPage = ({ courseId={courseId} unitId={unitId} tab={activeTabSlug} + studioButtonVisible={hasCourseAuthorAccess} /> )}