diff --git a/lms/djangoapps/courseware/toggles.py b/lms/djangoapps/courseware/toggles.py index a1a342e7bb4f..1cd39a2da966 100644 --- a/lms/djangoapps/courseware/toggles.py +++ b/lms/djangoapps/courseware/toggles.py @@ -81,6 +81,19 @@ f'{WAFFLE_FLAG_NAMESPACE}.disable_navigation_sidebar', __name__ ) +# .. toggle_name: courseware.disable_default_open_discussion_sidebar +# .. toggle_implementation: WaffleFlag +# .. toggle_default: False +# .. toggle_description: Disable opening the discussion sidebar by default on Learning MFE. +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2024-03-13 +# .. toggle_target_removal_date: None +# .. toggle_tickets: AXIMST-629 +# .. toggle_warning: None. +COURSEWARE_MICROFRONTEND_DISCUSSION_SIDEBAR_OPEN_DISABLED = CourseWaffleFlag( + f'{WAFFLE_FLAG_NAMESPACE}.disable_default_open_discussion_sidebar', __name__ +) + # .. toggle_name: courseware.mfe_progress_milestones_streak_discount_enabled # .. toggle_implementation: CourseWaffleFlag # .. toggle_default: False @@ -206,3 +219,10 @@ def courseware_mfe_sidebar_is_disabled(course_key=None): Return whether the courseware.disable_navigation_sidebar flag is on. """ return COURSEWARE_MICROFRONTEND_SIDEBAR_DISABLED.is_enabled(course_key) + + +def courseware_mfe_discussion_sidebar_open_is_disabled(course_key=None): + """ + Return whether the courseware.disable_default_open_discussion_sidebar flag is on. + """ + return COURSEWARE_MICROFRONTEND_DISCUSSION_SIDEBAR_OPEN_DISABLED.is_enabled(course_key) diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index 163bc5807ce0..582355752dd4 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -88,8 +88,9 @@ from lms.djangoapps.courseware.permissions import MASQUERADE_AS_STUDENT, VIEW_COURSE_HOME, VIEW_COURSEWARE from lms.djangoapps.courseware.toggles import ( course_is_invitation_only, + courseware_mfe_discussion_sidebar_open_is_disabled, courseware_mfe_search_is_enabled, - courseware_mfe_sidebar_is_disabled + courseware_mfe_sidebar_is_disabled, ) from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient from lms.djangoapps.courseware.utils import ( @@ -2285,3 +2286,15 @@ def courseware_mfe_sidebar_enabled(request, course_id=None): return JsonResponse({ "enabled": not courseware_mfe_sidebar_is_disabled(course_key) }) + + +@api_view(['GET']) +def courseware_mfe_discussion_sidebar_open_is_enabled(request, course_id=None): + """ + Simple GET endpoint to expose whether the course may open discussion sidebar by default. + """ + course_key = CourseKey.from_string(course_id) if course_id else None + + return JsonResponse({ + "enabled": not courseware_mfe_discussion_sidebar_open_is_disabled(course_key) + }) diff --git a/lms/urls.py b/lms/urls.py index 002c0e2c7e39..7b6bf05dbc37 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -754,6 +754,11 @@ courseware_views.courseware_mfe_sidebar_enabled, name='courseware_sidebar_enabled_view', ), + re_path( + fr'^courses/{settings.COURSE_ID_PATTERN}/discussion-sidebar/enabled/$', + courseware_views.courseware_mfe_discussion_sidebar_open_is_enabled, + name='discussion_sidebar_enabled_view', + ), ] urlpatterns += [