Skip to content

Commit

Permalink
feat: hide studio button for limited staff
Browse files Browse the repository at this point in the history
  • Loading branch information
0x29a committed Aug 15, 2024
1 parent 7cbbc72 commit 394b9e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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
6 changes: 6 additions & 0 deletions src/tab-page/LoadedTabPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import useLogistrationAlert from '../alerts/logistration-alert';

import ProductTours from '../product-tours/ProductTours';

const restrictedStudioAccessRoles = ['limited_staff'];

const LoadedTabPage = ({
activeTabSlug,
children,
Expand All @@ -28,6 +30,7 @@ const LoadedTabPage = ({
originalUserIsStaff,
tabs,
title,
userRoles,
verifiedMode,
} = useModel('courseHomeMeta', courseId);

Expand All @@ -38,6 +41,8 @@ const LoadedTabPage = ({

const activeTab = tabs.filter(tab => tab.slug === activeTabSlug)[0];

const canVisitStudio = !restrictedStudioAccessRoles.some(role => userRoles.includes(role));

const streakLengthToCelebrate = celebrations && celebrations.streakLengthToCelebrate;
const streakDiscountCouponEnabled = celebrations && celebrations.streakDiscountEnabled && verifiedMode;
const [isStreakCelebrationOpen,, closeStreakCelebration] = useToggle(streakLengthToCelebrate);
Expand All @@ -58,6 +63,7 @@ const LoadedTabPage = ({
courseId={courseId}
unitId={unitId}
tab={activeTabSlug}
studioButtonVisible={canVisitStudio}
/>
)}
<StreakModal
Expand Down

0 comments on commit 394b9e0

Please sign in to comment.