feat: added flag to enable discussions mfe for everyone (#30292)

* feat: added flag to enable discussions mfe for everyone

* refactor: refactord condition

* refactor: refactor condition
This commit is contained in:
AsadAzam
2022-04-22 15:14:09 +05:00
committed by GitHub
parent 8bcec1a7c9
commit 0338aab681
2 changed files with 17 additions and 3 deletions

View File

@@ -14,6 +14,17 @@ WAFFLE_FLAG_NAMESPACE = "discussions"
# .. toggle_target_removal_date: 2022-03-05
ENABLE_DISCUSSIONS_MFE = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'enable_discussions_mfe', __name__)
# .. toggle_name: discussions.enable_discussions_mfe_for_everyone
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
# .. toggle_description: Waffle flag to use the new MFE experience for discussions in the course tab and in-context
# .. toggle_use_cases: temporary, open_edx
# .. toggle_creation_date: 2021-04-21
# .. toggle_target_removal_date: 2022-03-05
ENABLE_DISCUSSIONS_MFE_FOR_EVERYONE = CourseWaffleFlag(
WAFFLE_FLAG_NAMESPACE, 'enable_discussions_mfe_for_everyone', __name__
)
# .. toggle_name: discussions.enable_new_structure_discussions
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False

View File

@@ -47,7 +47,7 @@ from lms.djangoapps.discussion.django_comment_client.utils import (
strip_none,
)
from lms.djangoapps.discussion.exceptions import TeamDiscussionHiddenFromUserException
from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE
from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE, ENABLE_DISCUSSIONS_MFE_FOR_EVERYONE
from lms.djangoapps.experiments.utils import get_experiment_user_metadata_context
from lms.djangoapps.teams import api as team_api
from openedx.core.djangoapps.discussions.url_helpers import get_discussions_mfe_url
@@ -722,12 +722,15 @@ def _discussions_mfe_context(query_params: Dict,
if not mfe_url:
return {"show_banner": False, "show_mfe": False}
discussions_mfe_enabled = ENABLE_DISCUSSIONS_MFE.is_enabled(course_key)
discussions_mfe_enabled_for_everyone = ENABLE_DISCUSSIONS_MFE_FOR_EVERYONE.is_enabled(course_key)
enabled_for_educator_or_staff = is_educator_or_staff and discussions_mfe_enabled
enable_mfe = enabled_for_educator_or_staff or discussions_mfe_enabled_for_everyone
# Show the MFE if the new MFE is enabled,
# and if the legacy experience is not requested via query param
# and if the current view isn't only that's only supported by the legacy view
show_mfe = (
query_params.get("discussions_experience", "").lower() != "legacy"
and (discussions_mfe_enabled and is_educator_or_staff)
and enable_mfe
and not legacy_only_view
)
forum_url = reverse("forum_form_discussion", args=[course_key])
@@ -737,7 +740,7 @@ def _discussions_mfe_context(query_params: Dict,
"mfe_url": f"{forum_url}?discussions_experience=new",
"share_feedback_url": settings.DISCUSSIONS_MFE_FEEDBACK_URL,
"course_key": course_key,
"show_banner": (discussions_mfe_enabled and is_educator_or_staff),
"show_banner": enable_mfe,
"discussions_mfe_url": mfe_url,
}