diff --git a/src/studio-home/StudioHome.test.tsx b/src/studio-home/StudioHome.test.tsx index ec3d195e76..6b91524bca 100644 --- a/src/studio-home/StudioHome.test.tsx +++ b/src/studio-home/StudioHome.test.tsx @@ -1,5 +1,6 @@ import * as reactRedux from 'react-redux'; import { getConfig, setConfig } from '@edx/frontend-platform'; +import { mockWaffleFlags } from '@src/data/apiHooks.mock'; import { fireEvent, @@ -92,11 +93,12 @@ describe('', () => { within(header).getByRole('button', { name: 'New course' }); // will error if not found }); - it('should render roles and permissions button', async () => { + it('should render roles and permissions button when authz is enabled', async () => { setConfig({ ...getConfig(), ADMIN_CONSOLE_URL: 'https://admin-console.example.com', }); + mockWaffleFlags({ enableAuthzCourseAuthoring: true }); render(, { path: '/home' }); const header = getHeaderElement(); @@ -104,6 +106,18 @@ describe('', () => { expect(rolesButton).toHaveAttribute('href', 'https://admin-console.example.com/authz'); }); + it('should not render roles and permissions button when authz is disabled', async () => { + setConfig({ + ...getConfig(), + ADMIN_CONSOLE_URL: 'https://admin-console.example.com', + }); + mockWaffleFlags({ enableAuthzCourseAuthoring: false }); + + render(, { path: '/home' }); + const header = getHeaderElement(); + expect(within(header).queryByRole('link', { name: 'Roles and permissions' })).not.toBeInTheDocument(); + }); + it('should show verify email layout if user inactive', async () => { mockUseSelector.mockReturnValue({ ...studioHomeMock, diff --git a/src/studio-home/StudioHome.tsx b/src/studio-home/StudioHome.tsx index a2be1984da..a7fbb72511 100644 --- a/src/studio-home/StudioHome.tsx +++ b/src/studio-home/StudioHome.tsx @@ -13,6 +13,7 @@ import { getConfig } from '@edx/frontend-platform'; import { StudioFooterSlot } from '@edx/frontend-component-footer'; import { useLocation, useNavigate } from 'react-router-dom'; +import { useWaffleFlags } from '@src/data/apiHooks'; import Loading from '../generic/Loading'; import InternetConnectionAlert from '../generic/internet-connection-alert'; import Header from '../header'; @@ -48,6 +49,8 @@ const StudioHome = () => { librariesV2Enabled, } = useStudioHome(); + const waffleFlags = useWaffleFlags(); + const isAuthzEnabled = waffleFlags?.enableAuthzCourseAuthoring ?? false; const adminConsoleUrl = `${getConfig().ADMIN_CONSOLE_URL}/authz`; const v1LibraryTab = librariesV1Enabled && location?.pathname.split('/').pop() === 'libraries-v1'; @@ -74,20 +77,22 @@ const StudioHome = () => { ); } - headerButtons.push( -
- -
, - ); + if (isAuthzEnabled && getConfig().ADMIN_CONSOLE_URL) { + headerButtons.push( +
+ +
, + ); + } if (hasAbilityToCreateNewCourse) { headerButtons.push( @@ -125,7 +130,7 @@ const StudioHome = () => { } return headerButtons; - }, [location, userIsActive, isFailedLoadingPage]); + }, [location, userIsActive, isFailedLoadingPage, isAuthzEnabled]); const headerButtons = userIsActive ? getHeaderButtons() : []; if (isLoadingPage && !isFiltered) {