diff --git a/lms/djangoapps/courseware/toggles.py b/lms/djangoapps/courseware/toggles.py index ca4584b19ba6..565b759f23fa 100644 --- a/lms/djangoapps/courseware/toggles.py +++ b/lms/djangoapps/courseware/toggles.py @@ -83,6 +83,21 @@ f'{WAFFLE_FLAG_NAMESPACE}.disable_navigation_sidebar_blocks_caching', __name__ ) +# .. toggle_name: courseware.show_default_right_sidebar +# .. toggle_implementation: WaffleFlag +# .. toggle_default: False +# .. toggle_description: If waffle flag disabled +# Discussions or Notifications sidebar shouldn't be displayed at all on Learning MFE. +# If waffle flag enabled - Discussions opens always on the pages with discussions, +# if user is in Audit and course has verified mode - show Notifications.# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2024-04-28 +# .. toggle_target_removal_date: None +# .. toggle_tickets: FC-0056 +# .. toggle_warning: None. +COURSEWARE_SHOW_DEFAULT_RIGHT_SIDEBAR = CourseWaffleFlag( + f'{WAFFLE_FLAG_NAMESPACE}.show_default_right_sidebar', __name__ +) + # .. toggle_name: courseware.mfe_progress_milestones_streak_discount_enabled # .. toggle_implementation: CourseWaffleFlag # .. toggle_default: False @@ -192,3 +207,10 @@ def courseware_disable_navigation_sidebar_blocks_caching(course_key=None): Return whether the courseware.disable_navigation_sidebar_blocks_caching flag is on. """ return COURSEWARE_MICROFRONTEND_NAVIGATION_SIDEBAR_BLOCKS_DISABLE_CACHING.is_enabled(course_key) + + +def courseware_show_default_right_sidebar_is_enabled(course_key=None): + """ + Return whether the courseware.show_default_right_sidebar flag is on. + """ + return COURSEWARE_SHOW_DEFAULT_RIGHT_SIDEBAR.is_enabled(course_key) diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index 4c3fa982ca69..e7ba9342dcc0 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -88,7 +88,11 @@ from lms.djangoapps.courseware.model_data import FieldDataCache from lms.djangoapps.courseware.models import BaseStudentModuleHistory, StudentModule 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_search_is_enabled +from lms.djangoapps.courseware.toggles import ( + course_is_invitation_only, + courseware_mfe_search_is_enabled, + courseware_show_default_right_sidebar_is_enabled, +) from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient from lms.djangoapps.courseware.utils import ( _use_new_financial_assistance_flow, @@ -2282,3 +2286,19 @@ def courseware_mfe_search_enabled(request, course_id=None): payload = {"enabled": courseware_mfe_search_is_enabled(course_key) if enabled else False} return JsonResponse(payload) + + +@api_view(['GET']) +def courseware_mfe_show_default_right_sidebar_is_enabled(request, course_id=None): + """ + Simple GET endpoint to expose whether the course may open discussion sidebar by default. + """ + try: + course_key = CourseKey.from_string(course_id) if course_id else None + except InvalidKeyError: + return JsonResponse({"error": "Invalid course_id"}) + + return JsonResponse({ + "enabled": courseware_show_default_right_sidebar_is_enabled(course_key) + }) + diff --git a/lms/urls.py b/lms/urls.py index c7a0d49da4d7..4d4afacd4a42 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -749,6 +749,11 @@ courseware_views.courseware_mfe_search_enabled, name='courseware_search_enabled_view', ), + re_path( + fr'^courses/{settings.COURSE_ID_PATTERN}/discussion-sidebar/enabled/$', + courseware_views.courseware_mfe_show_default_right_sidebar_is_enabled, + name='show_default_right_sidebar_enabled_view', + ), ] urlpatterns += [