Skip to content

Commit 692b0fd

Browse files
ihor-romaniukirtazaakram
authored andcommitted
feat: [FC-0070] add events and style for rendering Split xblock in chromeless template (#35813)
This feature introduces functionalities to improve XBlock interactions within iframes: * Add styles that adopt default styles for Split Test which renders chromless template via iframe in MFE Authoring. * When the isIframeEmbed option is enabled, the XBlock sends a postMessage to the parent window. When sending such a message, the standard link transition is cancelled and the transition is carried out in MFE Authoring.
1 parent 4a6fdf1 commit 692b0fd

19 files changed

Lines changed: 495 additions & 167 deletions

cms/djangoapps/contentstore/helpers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ def is_unit(xblock, parent_xblock=None):
8282
return False
8383

8484

85+
def is_library_content(xblock):
86+
"""
87+
Returns true if the specified xblock is library content.
88+
"""
89+
return xblock.category == 'library_content'
90+
91+
92+
def get_parent_if_split_test(xblock):
93+
"""
94+
Returns the parent of the specified xblock if it is a split test, otherwise returns None.
95+
"""
96+
parent_xblock = get_parent_xblock(xblock)
97+
if parent_xblock and parent_xblock.category == 'split_test':
98+
return parent_xblock
99+
100+
85101
def xblock_has_own_studio_page(xblock, parent_xblock=None):
86102
"""
87103
Returns true if the specified xblock has an associated Studio page. Most xblocks do

cms/djangoapps/contentstore/views/component.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
from common.djangoapps.student.auth import has_course_author_access
2626
from common.djangoapps.xblock_django.api import authorable_xblocks, disabled_xblocks
2727
from common.djangoapps.xblock_django.models import XBlockStudioConfigurationFlag
28-
from cms.djangoapps.contentstore.helpers import is_unit
28+
from cms.djangoapps.contentstore.helpers import (
29+
get_parent_if_split_test,
30+
is_unit,
31+
is_library_content,
32+
)
2933
from cms.djangoapps.contentstore.toggles import (
3034
libraries_v1_enabled,
3135
libraries_v2_enabled,
@@ -148,11 +152,12 @@ def container_handler(request, usage_key_string): # pylint: disable=too-many-st
148152
except ItemNotFoundError:
149153
return HttpResponseBadRequest()
150154

151-
is_unit_page = is_unit(xblock)
152-
unit = xblock if is_unit_page else None
155+
if use_new_unit_page(course.id):
156+
if is_unit(xblock) or is_library_content(xblock):
157+
return redirect(get_unit_url(course.id, xblock.location))
153158

154-
if is_unit_page and use_new_unit_page(course.id):
155-
return redirect(get_unit_url(course.id, unit.location))
159+
if split_xblock := get_parent_if_split_test(xblock):
160+
return redirect(get_unit_url(course.id, split_xblock.location))
156161

157162
container_handler_context = get_container_handler_context(request, usage_key, course, xblock)
158163
container_handler_context.update({

cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ def _create_block(request):
611611
modulestore().update_item(created_block, request.user.id)
612612
response["upstreamRef"] = upstream_ref
613613
response["static_file_notices"] = asdict(static_file_notices)
614+
response["parent_locator"] = parent_locator
614615

615616
return JsonResponse(response)
616617

Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

cms/static/images/library-icon.svg

Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading

cms/static/images/problem-icon.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)