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 14, 2024
1 parent 4655b34 commit aa8b47a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/instructor-toolbar/InstructorToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default function InstructorToolbar(props) {
courseId,
unitId,
canViewLegacyCourseware,
studioButtonVisible,

Check failure on line 59 in src/instructor-toolbar/InstructorToolbar.jsx

View workflow job for this annotation

GitHub Actions / build (12)

'studioButtonVisible' is missing in props validation
tab,
} = props;

Expand Down Expand Up @@ -85,7 +86,7 @@ export default function InstructorToolbar(props) {
<div className="align-items-center flex-grow-1 d-md-flex mx-1 my-1">
<MasqueradeWidget courseId={courseId} onError={showMasqueradeError} />
</div>
{(urlLegacy || urlStudio || urlInsights) && (
{(urlLegacy || urlStudio && studioButtonVisible || urlInsights) && (

Check failure on line 89 in src/instructor-toolbar/InstructorToolbar.jsx

View workflow job for this annotation

GitHub Actions / build (12)

Unexpected mix of '||' and '&&'

Check failure on line 89 in src/instructor-toolbar/InstructorToolbar.jsx

View workflow job for this annotation

GitHub Actions / build (12)

Unexpected mix of '||' and '&&'
<>
<hr className="border-light" />
<span className="mr-2 mt-1 col-form-label">View course in:</span>
Expand All @@ -96,7 +97,7 @@ export default function InstructorToolbar(props) {
<a className="btn btn-inverse-outline-primary" href={urlLegacy}>Legacy experience</a>
</span>
)}
{urlStudio && (
{urlStudio && studioButtonVisible && (
<span className="mx-1 my-1">
<a className="btn btn-inverse-outline-primary" href={urlStudio}>Studio</a>
</span>
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"];

Check failure on line 18 in src/tab-page/LoadedTabPage.jsx

View workflow job for this annotation

GitHub Actions / build (12)

Strings must use singlequote

function LoadedTabPage({
activeTabSlug,
children,
Expand All @@ -29,6 +31,7 @@ function LoadedTabPage({
originalUserIsStaff,
tabs,
title,
userRoles,
verifiedMode,
} = useModel(metadataModel, courseId);

Expand All @@ -39,6 +42,8 @@ function 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 @@ -61,6 +66,7 @@ function LoadedTabPage({
unitId={unitId}
canViewLegacyCourseware={canViewLegacyCourseware}
tab={activeTabSlug}
studioButtonVisible={canVisitStudio}
/>
)}
<StreakModal
Expand Down

0 comments on commit aa8b47a

Please sign in to comment.