diff --git a/.env b/.env index 0208b01f5b..3c64a8836c 100644 --- a/.env +++ b/.env @@ -44,3 +44,4 @@ TERMS_OF_SERVICE_URL='' TWITTER_HASHTAG='' TWITTER_URL='' USER_INFO_COOKIE_NAME='' +DISABLE_SELF_ENROLLMENT='false' diff --git a/.env.development b/.env.development index 499b947c78..fe91ee9dae 100644 --- a/.env.development +++ b/.env.development @@ -44,3 +44,4 @@ TWITTER_HASHTAG='myedxjourney' TWITTER_URL='https://twitter.com/edXOnline' USER_INFO_COOKIE_NAME='edx-user-info' SESSION_COOKIE_DOMAIN='localhost' +DISABLE_SELF_ENROLLMENT='false' diff --git a/.env.test b/.env.test index 390ba92704..659415a6b0 100644 --- a/.env.test +++ b/.env.test @@ -43,3 +43,4 @@ TERMS_OF_SERVICE_URL='https://www.edx.org/edx-terms-service' TWITTER_HASHTAG='myedxjourney' TWITTER_URL='https://twitter.com/edXOnline' USER_INFO_COOKIE_NAME='edx-user-info' +DISABLE_SELF_ENROLLMENT='false' diff --git a/src/alerts/enrollment-alert/hooks.js b/src/alerts/enrollment-alert/hooks.js index 03df8b616d..8ffcfab8d8 100644 --- a/src/alerts/enrollment-alert/hooks.js +++ b/src/alerts/enrollment-alert/hooks.js @@ -3,6 +3,7 @@ import React, { useContext, useMemo, } from 'react'; import { AppContext } from '@edx/frontend-platform/react'; +import { getConfig } from '@edx/frontend-platform'; import { useAlert } from '../../generic/user-messages'; import { useModel } from '../../generic/model-store'; @@ -23,7 +24,7 @@ export function useEnrollmentAlert(courseId) { */ const isVisible = !enrolledUser && authenticatedUser !== null && privateOutline; const payload = { - canEnroll: outline && outline.enrollAlert ? outline.enrollAlert.canEnroll : false, + canEnroll: getConfig().DISABLE_SELF_ENROLLMENT !== 'true' && outline && outline.enrollAlert ? outline.enrollAlert.canEnroll : false, courseId, extraText: outline && outline.enrollAlert ? outline.enrollAlert.extraText : '', isStaff: course && course.isStaff, diff --git a/src/course-home/outline-tab/alerts/private-course-alert/hooks.js b/src/course-home/outline-tab/alerts/private-course-alert/hooks.js index ec5efc5c4a..58097558f8 100644 --- a/src/course-home/outline-tab/alerts/private-course-alert/hooks.js +++ b/src/course-home/outline-tab/alerts/private-course-alert/hooks.js @@ -1,6 +1,7 @@ /* eslint-disable import/prefer-default-export */ import React, { useContext, useMemo } from 'react'; import { AppContext } from '@edx/frontend-platform/react'; +import { getConfig } from '@edx/frontend-platform'; import { ALERT_TYPES, useAlert } from '../../../../generic/user-messages'; import { useModel } from '../../../../generic/model-store'; @@ -20,7 +21,7 @@ export function usePrivateCourseAlert(courseId) { const isVisible = !enrolledUser && (privateOutline || authenticatedUser !== null); const payload = { anonymousUser: authenticatedUser === null, - canEnroll: outline && outline.enrollAlert ? outline.enrollAlert.canEnroll : false, + canEnroll: getConfig().DISABLE_SELF_ENROLLMENT !== 'true' && outline && outline.enrollAlert ? outline.enrollAlert.canEnroll : false, courseId, };