@@ -6,6 +6,10 @@ import {
66import { CheckCircle , Info , Warning } from '@openedx/paragon/icons' ;
77import { FormattedMessage , useIntl } from '@edx/frontend-platform/i18n' ;
88import { useCourseAuthoringContext } from '@src/CourseAuthoringContext' ;
9+ import { useWaffleFlags } from '@src/data/apiHooks' ;
10+ import { useUserPermissions } from '@src/authz/data/apiHooks' ;
11+ import { COURSE_PERMISSIONS } from '@src/authz/constants' ;
12+ import PermissionDeniedAlert from 'CourseAuthoring/generic/PermissionDeniedAlert' ;
913import Placeholder from '../editors/Placeholder' ;
1014
1115import AlertProctoringError from '../generic/AlertProctoringError' ;
@@ -41,6 +45,15 @@ const AdvancedSettings = () => {
4145 const { courseId, courseDetails } = useCourseAuthoringContext ( ) ;
4246 document . title = getPageHeadTitle ( courseDetails ?. name , intl . formatMessage ( messages . headingTitle ) ) ;
4347
48+ const waffleFlags = useWaffleFlags ( courseId ) ;
49+ const isAuthzEnabled = waffleFlags . enableAuthzCourseAuthoring ;
50+ const { isLoading : isLoadingUserPermissions , data : userPermissions } = useUserPermissions ( {
51+ canManageAdvancedSettings : {
52+ action : COURSE_PERMISSIONS . MANAGE_ADVANCED_SETTINGS ,
53+ scope : courseId ,
54+ } ,
55+ } , isAuthzEnabled ) ;
56+
4457 useEffect ( ( ) => {
4558 dispatch ( fetchCourseAppSettings ( courseId ) ) ;
4659 dispatch ( fetchProctoringExamErrors ( courseId ) ) ;
@@ -52,7 +65,7 @@ const AdvancedSettings = () => {
5265 const settingsWithSendErrors = useSelector ( getSendRequestErrors ) || { } ;
5366 const loadingSettingsStatus = useSelector ( getLoadingStatus ) ;
5467
55- const isLoading = loadingSettingsStatus === RequestStatus . IN_PROGRESS ;
68+ const isLoading = loadingSettingsStatus === RequestStatus . IN_PROGRESS || ( isAuthzEnabled && isLoadingUserPermissions ) ;
5669 const updateSettingsButtonState = {
5770 labels : {
5871 default : intl . formatMessage ( messages . buttonSaveText ) ,
@@ -128,6 +141,15 @@ const AdvancedSettings = () => {
128141 showSaveSettingsPrompt ( true ) ;
129142 } ;
130143
144+ // Show permission denied alert when authz is enabled and user doesn't have permission
145+ const authzIsEnabledAndNoPermission = isAuthzEnabled
146+ && ! isLoadingUserPermissions
147+ && ! userPermissions ?. canManageAdvancedSettings ;
148+
149+ if ( authzIsEnabledAndNoPermission ) {
150+ return < PermissionDeniedAlert /> ;
151+ }
152+
131153 return (
132154 < >
133155 < Container size = "xl" className = "advanced-settings px-4" >
@@ -192,8 +214,8 @@ const AdvancedSettings = () => {
192214 defaultMessage = "{visibility} deprecated settings"
193215 values = { {
194216 visibility :
195- showDeprecated ? intl . formatMessage ( messages . deprecatedButtonHideText )
196- : intl . formatMessage ( messages . deprecatedButtonShowText ) ,
217+ showDeprecated ? intl . formatMessage ( messages . deprecatedButtonHideText )
218+ : intl . formatMessage ( messages . deprecatedButtonShowText ) ,
197219 } }
198220 />
199221 </ Button >
0 commit comments