1- import PropTypes from 'prop-types ' ;
1+ import { type ReactNode } from 'react ' ;
22import { useLocation } from 'react-router-dom' ;
33import classNames from 'classnames' ;
44import { useIntl } from '@edx/frontend-platform/i18n' ;
5- import { getConfig } from '@edx/frontend-platform' ;
65
76import { useUserPermissions } from '@src/authz/data/apiHooks' ;
87import { COURSE_PERMISSIONS } from '@src/authz/constants' ;
@@ -11,13 +10,21 @@ import { otherLinkURLParams } from './constants';
1110import messages from './messages' ;
1211import HelpSidebarLink from './HelpSidebarLink' ;
1312
13+ interface HelpSidebarProps {
14+ courseId : string ;
15+ showOtherSettings ?: boolean ;
16+ proctoredExamSettingsUrl ?: string ;
17+ children : ReactNode ;
18+ className ?: string ;
19+ }
20+
1421const HelpSidebar = ( {
1522 courseId,
16- showOtherSettings,
17- proctoredExamSettingsUrl,
23+ showOtherSettings = false ,
24+ proctoredExamSettingsUrl = '' ,
1825 children,
1926 className,
20- } ) => {
27+ } : HelpSidebarProps ) => {
2128 const intl = useIntl ( ) ;
2229 const { pathname } = useLocation ( ) ;
2330 const {
@@ -30,16 +37,6 @@ const HelpSidebar = ({
3037 const waffleFlags = useWaffleFlags ( courseId ) ;
3138
3239 const showOtherLink = ( params ) => ! pathname . includes ( params ) ;
33- const generateLegacyURL = ( urlParameter ) => {
34- const referObj = new URL ( `${ urlParameter } /${ courseId } ` , getConfig ( ) . STUDIO_BASE_URL ) ;
35- return referObj . href ;
36- } ;
37-
38- const scheduleAndDetailsDestination = generateLegacyURL ( scheduleAndDetails ) ;
39- const gradingDestination = generateLegacyURL ( grading ) ;
40- const courseTeamDestination = generateLegacyURL ( courseTeam ) ;
41- const advancedSettingsDestination = generateLegacyURL ( advancedSettings ) ;
42- const groupConfigurationsDestination = generateLegacyURL ( groupConfigurations ) ;
4340
4441 /*
4542 AuthZ for Course Authoring
@@ -78,46 +75,41 @@ const HelpSidebar = ({
7875 < ul className = "p-0 mb-0" >
7976 { showOtherLink ( scheduleAndDetails ) && (
8077 < HelpSidebarLink
81- pathToPage = { waffleFlags . useNewScheduleDetailsPage
82- ? `/course/${ courseId } /${ scheduleAndDetails } ` : scheduleAndDetailsDestination }
78+ pathToPage = { `/course/${ courseId } /${ scheduleAndDetails } ` }
8379 title = { intl . formatMessage (
8480 messages . sidebarLinkToScheduleAndDetails ,
8581 ) }
86- isNewPage = { waffleFlags . useNewScheduleDetailsPage }
82+ isNewPage
8783 />
8884 ) }
8985 { showOtherLink ( grading ) && (
9086 < HelpSidebarLink
91- pathToPage = { waffleFlags . useNewGradingPage
92- ? `/course/${ courseId } /${ grading } ` : gradingDestination }
87+ pathToPage = { `/course/${ courseId } /${ grading } ` }
9388 title = { intl . formatMessage ( messages . sidebarLinkToGrading ) }
94- isNewPage = { waffleFlags . useNewGradingPage }
89+ isNewPage
9590 />
9691 ) }
9792 { showOtherLink ( courseTeam ) && (
9893 < HelpSidebarLink
99- pathToPage = { waffleFlags . useNewCourseTeamPage
100- ? `/course/${ courseId } /${ courseTeam } ` : courseTeamDestination }
94+ pathToPage = { `/course/${ courseId } /${ courseTeam } ` }
10195 title = { intl . formatMessage ( messages . sidebarLinkToCourseTeam ) }
102- isNewPage = { waffleFlags . useNewCourseTeamPage }
96+ isNewPage
10397 />
10498 ) }
10599 { showOtherLink ( groupConfigurations ) && (
106100 < HelpSidebarLink
107- pathToPage = { waffleFlags . useNewGroupConfigurationsPage
108- ? `/course/${ courseId } /${ groupConfigurations } ` : groupConfigurationsDestination }
101+ pathToPage = { `/course/${ courseId } /${ groupConfigurations } ` }
109102 title = { intl . formatMessage (
110103 messages . sidebarLinkToGroupConfigurations ,
111104 ) }
112- isNewPage = { waffleFlags . useNewGroupConfigurationsPage }
105+ isNewPage
113106 />
114107 ) }
115108 { showOtherLink ( advancedSettings ) && canManageAdvancedSettings && (
116109 < HelpSidebarLink
117- pathToPage = { waffleFlags . useNewAdvancedSettingsPage
118- ? `/course/${ courseId } /${ advancedSettings } ` : advancedSettingsDestination }
110+ pathToPage = { `/course/${ courseId } /${ advancedSettings } ` }
119111 title = { intl . formatMessage ( messages . sidebarLinkToAdvancedSettings ) }
120- isNewPage = { waffleFlags . useNewAdvancedSettingsPage }
112+ isNewPage
121113 />
122114 ) }
123115 { proctoredExamSettingsUrl && (
@@ -137,19 +129,4 @@ const HelpSidebar = ({
137129 ) ;
138130} ;
139131
140- HelpSidebar . defaultProps = {
141- proctoredExamSettingsUrl : '' ,
142- className : undefined ,
143- courseId : undefined ,
144- showOtherSettings : false ,
145- } ;
146-
147- HelpSidebar . propTypes = {
148- courseId : PropTypes . string ,
149- showOtherSettings : PropTypes . bool ,
150- proctoredExamSettingsUrl : PropTypes . string ,
151- children : PropTypes . node . isRequired ,
152- className : PropTypes . string ,
153- } ;
154-
155132export default HelpSidebar ;
0 commit comments