From 627d4fd750f299bf88a0c9a270d662c40edf36d1 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 --- 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 157495469e..6fc533d350 100644 --- a/src/instructor-toolbar/InstructorToolbar.jsx +++ b/src/instructor-toolbar/InstructorToolbar.jsx @@ -57,6 +57,7 @@ const InstructorToolbar = (props) => { const { courseId, unitId, + isStudioButtonVisible, tab, } = props; @@ -74,13 +75,13 @@ const InstructorToolbar = (props) => {
- {(urlStudio || urlInsights) && ( + {((urlStudio && isStudioButtonVisible) || urlInsights) && ( <>
)} - {urlStudio && ( + {urlStudio && isStudioButtonVisible && ( {formatMessage(messages.titleStudio)} @@ -116,12 +117,14 @@ const InstructorToolbar = (props) => { InstructorToolbar.propTypes = { courseId: PropTypes.string, unitId: PropTypes.string, + isStudioButtonVisible: PropTypes.bool, tab: PropTypes.string, }; InstructorToolbar.defaultProps = { courseId: undefined, unitId: undefined, + isStudioButtonVisible: true, tab: '', }; diff --git a/src/tab-page/LoadedTabPage.jsx b/src/tab-page/LoadedTabPage.jsx index 938d95cefd..67a1b86595 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} + isStudioButtonVisible={hasCourseAuthorAccess} /> )}