Skip to content

Commit

Permalink
feat: hide studio button for limited staff
Browse files Browse the repository at this point in the history
(cherry picked from openedx#1436)
  • Loading branch information
0x29a committed Sep 9, 2024
1 parent 3a14850 commit dee4c43
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/course-home/data/pact-tests/lmsPact.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe('Course Home Service', () => {
}),
title: string('Demonstration Course'),
username: string('edx'),
has_course_author_access: boolean(true),
},
},
});
Expand Down Expand Up @@ -133,6 +134,7 @@ describe('Course Home Service', () => {
],
title: 'Demonstration Course',
username: 'edx',
hasCourseAuthorAccess: true,
};
const response = getCourseHomeCourseMetadata(courseId, 'outline');
expect(response).toBeTruthy();
Expand Down
7 changes: 5 additions & 2 deletions src/instructor-toolbar/InstructorToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const InstructorToolbar = (props) => {
const {
courseId,
unitId,
studioButtonVisible,
tab,
} = props;

Expand All @@ -72,13 +73,13 @@ const InstructorToolbar = (props) => {
<div className="align-items-center flex-grow-1 d-md-flex mx-1 my-1">
<MasqueradeWidget courseId={courseId} onError={showMasqueradeError} />
</div>
{(urlStudio || urlInsights) && (
{((urlStudio && studioButtonVisible) || urlInsights) && (
<>
<hr className="border-light" />
<span className="mr-2 mt-1 col-form-label">View course in:</span>
</>
)}
{urlStudio && (
{urlStudio && studioButtonVisible && (
<span className="mx-1 my-1">
<a className="btn btn-inverse-outline-primary" href={urlStudio}>Studio</a>
</span>
Expand Down Expand Up @@ -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: '',
};

Expand Down
2 changes: 2 additions & 0 deletions src/tab-page/LoadedTabPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -58,6 +59,7 @@ const LoadedTabPage = ({
courseId={courseId}
unitId={unitId}
tab={activeTabSlug}
studioButtonVisible={hasCourseAuthorAccess}
/>
)}
<StreakModal
Expand Down

0 comments on commit dee4c43

Please sign in to comment.