Skip to content

Commit cd2263a

Browse files
committed
chore: Adds studio_view for the compatibility with auth-mfe
1 parent a019756 commit cd2263a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

xblocks_contrib/video/video.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from xblock.utils.resources import ResourceLoader
3232
from xblock.utils.studio_editable import StudioEditableXBlockMixin
3333

34-
from xblocks_contrib.common.xml_utils import LegacyXmlMixin, is_pointer_tag, name_to_pathname
34+
from xblocks_contrib.common.xml_utils import EdxJSONEncoder, LegacyXmlMixin, is_pointer_tag, name_to_pathname
3535
from xblocks_contrib.video.ajax_handler_mixin import AjaxHandlerMixin
3636
from xblocks_contrib.video.bumper_utils import bumperize
3737
from xblocks_contrib.video.cache_utils import request_cached
@@ -104,7 +104,7 @@
104104
@XBlock.needs('i18n', 'user')
105105
class VideoBlock(
106106
VideoFields, VideoTranscriptsMixin, VideoStudioViewHandlers, VideoStudentViewHandlers,
107-
StudioEditableXBlockMixin, LegacyXmlMixin, XBlock,
107+
LegacyXmlMixin, XBlock,
108108
AjaxHandlerMixin, StudioMetadataMixin,
109109
LicenseMixin):
110110
"""
@@ -279,6 +279,21 @@ def prioritize_hls(self, youtube_streams, html5_sources):
279279

280280
return False
281281

282+
def studio_view(self, context): # pylint: disable=unused-argument
283+
"""
284+
Returns a fragment having ``data-metadata`` attribute containing
285+
``editable_metadata_fields`` as JSON. The authoring MFE (frontend-app-authoring)
286+
reads this attribute from the block's HTML to power the video editor UI
287+
(e.g. transcript parsing via ``parseTranscripts``and related thunk actions).
288+
See: https://github.com/openedx/frontend-app-authoring/blob/master/src/editors/data/redux/thunkActions/video.js#L163
289+
290+
This matches the contract of the built-in video block:
291+
edx-platform's ``mako_block.studio_view`` (xmodule/mako_block.py) uses
292+
cms/templates/widgets/metadata-edit.html, which also serializes
293+
``editable_metadata_fields`` to JSON in a ``data-metadata`` attribute.
294+
"""
295+
return Fragment(f'<div data-metadata="{json.dumps(self.editable_metadata_fields, cls=EdxJSONEncoder)}"></div>')
296+
282297
def student_view(self, context=None):
283298
"""
284299
Return the student view.

0 commit comments

Comments
 (0)