diff --git a/cms/djangoapps/contentstore/rest_api/v1/serializers/course_waffle_flags.py b/cms/djangoapps/contentstore/rest_api/v1/serializers/course_waffle_flags.py
index b00f769b5754..5ae1d4c61d40 100644
--- a/cms/djangoapps/contentstore/rest_api/v1/serializers/course_waffle_flags.py
+++ b/cms/djangoapps/contentstore/rest_api/v1/serializers/course_waffle_flags.py
@@ -158,10 +158,15 @@ def get_use_new_course_outline_page(self, obj):
def get_use_new_unit_page(self, obj):
"""
- Method to get the use_new_unit_page switch
+ Method to get the use_new_unit_page switch.
+
+ Always returns True. The legacy unit editor has been removed and the
+ Authoring MFE never read this key; it goes when the other hard-coded
+ fields in this serializer are dropped.
+
+ See https://github.com/openedx/openedx-platform/issues/37497
"""
- course_key = self.get_course_key()
- return toggles.use_new_unit_page(course_key)
+ return True
def get_use_new_course_team_page(self, obj):
"""
diff --git a/cms/djangoapps/contentstore/rest_api/v1/views/course_waffle_flags.py b/cms/djangoapps/contentstore/rest_api/v1/views/course_waffle_flags.py
index 69b2898912aa..ffab81ef8a66 100644
--- a/cms/djangoapps/contentstore/rest_api/v1/views/course_waffle_flags.py
+++ b/cms/djangoapps/contentstore/rest_api/v1/views/course_waffle_flags.py
@@ -57,7 +57,7 @@ def get(self, request, course_id=None):
"use_new_files_uploads_page": true,
"use_new_video_uploads_page": false,
"use_new_course_outline_page": true,
- "use_new_unit_page": false,
+ "use_new_unit_page": true,
"use_new_course_team_page": true,
"use_new_certificates_page": true,
"use_new_textbooks_page": true,
diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py
index d09a40ba71ef..729474f334d2 100644
--- a/cms/djangoapps/contentstore/tests/test_contentstore.py
+++ b/cms/djangoapps/contentstore/tests/test_contentstore.py
@@ -1,10 +1,5 @@
# pylint: disable=missing-module-docstring
-# TODO: Rewrite several of these assertions so that they check the output of the REST or Python
-# APIs rather than parsing HTML from the deprecated legacy frontend pages. In particular, any
-# test case using override_waffle_flag(toggles.LEGACY_STUDIO_*, True) will need to be fixed.
-# Part of https://github.com/openedx/edx-platform/issues/36275.
-
import copy
import re
import shutil
@@ -21,7 +16,7 @@
from django.test import TestCase
from django.test.utils import override_settings
from django.urls import reverse
-from edx_toggles.toggles.testutils import override_waffle_flag, override_waffle_switch
+from edx_toggles.toggles.testutils import override_waffle_switch
from edxval.api import create_video, get_videos_for_course
from fs.osfs import OSFS
from lxml import etree
@@ -30,11 +25,9 @@
from opaque_keys.edx.locations import CourseLocator
from path import Path as path
-from cms.djangoapps.contentstore import toggles
from cms.djangoapps.contentstore.config import waffle
from cms.djangoapps.contentstore.tests.utils import AjaxEnabledTestClient, CourseTestCase, get_url, parse_json
-from cms.djangoapps.contentstore.utils import delete_course, reverse_course_url, reverse_url
-from cms.djangoapps.contentstore.views.component import ADVANCED_COMPONENT_TYPES
+from cms.djangoapps.contentstore.utils import delete_course, get_unit_url, reverse_course_url, reverse_url
from common.djangoapps.course_action_state.managers import CourseActionStateItemNotFoundError
from common.djangoapps.course_action_state.models import CourseRerunState, CourseRerunUIStateManager
from common.djangoapps.student import auth
@@ -568,44 +561,6 @@ def setUp(self):
)
self.course = self.store.publish(self.course.location, self.user.id)
- def check_components_on_page(self, component_types, expected_types):
- """
- Ensure that the right types end up on the page.
-
- component_types is the list of advanced components.
-
- expected_types is the list of elements that should appear on the page.
-
- expected_types and component_types should be similar, but not
- exactly the same -- for example, 'video' in
- component_types should cause 'Video' to be present.
- """
- self.course.advanced_modules = component_types
- self.store.update_item(self.course, self.user.id)
-
- # just pick one vertical
- resp = self.client.get_html(get_url('container_handler', self.vert_loc))
- for expected in expected_types:
- self.assertContains(resp, expected)
-
- @override_waffle_flag(toggles.LEGACY_STUDIO_UNIT_EDITOR, True)
- @ddt.data("", "alert('hi')", "")
- def test_container_handler_xss_prevent(self, malicious_code):
- """
- Test that XSS attack is prevented
- """
- resp = self.client.get_html(get_url('container_handler', self.vert_loc) + '?action=' + malicious_code)
- # Test that malicious code does not appear in html
- self.assertNotContains(resp, malicious_code)
-
- @override_waffle_flag(toggles.LEGACY_STUDIO_UNIT_EDITOR, True)
- def test_advanced_components_in_edit_unit(self):
- # This could be made better, but for now let's just assert that we see the advanced modules mentioned in the
- # page response HTML
- self.check_components_on_page(
- ADVANCED_COMPONENT_TYPES,
- ['Word cloud', 'Annotation', 'split_test'],
- )
@ddt.data('/Fake/asset/displayname', '\\Fake\\asset\\displayname')
def test_export_on_invalid_displayname(self, invalid_displayname):
@@ -700,14 +655,6 @@ def test_assets_overwrite(self):
# Remove tempdir
shutil.rmtree(root_dir)
- @override_waffle_flag(toggles.LEGACY_STUDIO_UNIT_EDITOR, True)
- def test_advanced_components_require_two_clicks(self):
- self.check_components_on_page(['word_cloud'], ['Word cloud'])
-
- @override_waffle_flag(toggles.LEGACY_STUDIO_UNIT_EDITOR, True)
- def test_edit_unit(self):
- """Verifies rendering the editor in all the verticals in the given test course"""
- self._check_verticals([self.vert_loc])
def _get_draft_counts(self, item): # pylint: disable=missing-function-docstring
cnt = 1 if not self.store.has_published_version(item) else 0
@@ -1035,15 +982,6 @@ def test_prefetch_children(self):
with check_mongo_calls(2):
self.store.get_course(self.course.id, depth=2)
- def _check_verticals(self, locations):
- """ Test getting the editing HTML for each vertical. """
- # Assert is here to make sure that the course being tested actually has verticals (units) to check.
- self.assertGreater(len(locations), 0) # noqa: PT009
- for loc in locations:
- resp = self.client.get_html(get_url('container_handler', loc))
- self.assertEqual(resp.status_code, 200) # noqa: PT009
-
-
@ddt.ddt
class ContentStoreTest(ContentStoreTestCase):
"""
@@ -1520,11 +1458,11 @@ def test_get_json(handler):
)
self.assertEqual(resp.status_code, 200) # noqa: PT009
- # go look at the Edit page
+ # go look at the Edit page — now redirects to MFE unit editor
unit_key = course_key.make_usage_key('vertical', 'test_vertical')
- with override_waffle_flag(toggles.LEGACY_STUDIO_UNIT_EDITOR, True):
- resp = self.client.get_html(get_url('container_handler', unit_key))
- self.assertEqual(resp.status_code, 200) # noqa: PT009
+ resp = self.client.get_html(get_url('container_handler', unit_key))
+ self.assertEqual(resp.status_code, 302) # noqa: PT009
+ self.assertEqual(resp.url, get_unit_url(course_key, unit_key)) # noqa: PT009
def delete_item(category, name):
""" Helper method for testing the deletion of an xblock item. """
diff --git a/cms/djangoapps/contentstore/tests/utils.py b/cms/djangoapps/contentstore/tests/utils.py
index 79d2a72e7f83..9d201bb09783 100644
--- a/cms/djangoapps/contentstore/tests/utils.py
+++ b/cms/djangoapps/contentstore/tests/utils.py
@@ -188,14 +188,6 @@ def assertCoursesEqual(self, course1_id, course2_id):
asset_son = asset.get('content_son', asset['_id'])
self.assertAssetsEqual(asset_son, course1_id, course2_id)
- def check_verticals(self, items):
- """ Test getting the editing HTML for each vertical. """
- # assert is here to make sure that the course being tested actually has verticals (units) to check.
- self.assertGreater(len(items), 0, "Course has no verticals (units) to check") # noqa: PT009
- for block in items:
- resp = self.client.get_html(get_url('container_handler', block.location))
- self.assertEqual(resp.status_code, 200) # noqa: PT009
-
def assertAssetsEqual(self, asset_son, course1_id, course2_id):
"""Verifies the asset of the given key has the same attributes in both given courses."""
content_store = contentstore()
diff --git a/cms/djangoapps/contentstore/toggles.py b/cms/djangoapps/contentstore/toggles.py
index 94960ba66ec0..0472111145e7 100644
--- a/cms/djangoapps/contentstore/toggles.py
+++ b/cms/djangoapps/contentstore/toggles.py
@@ -194,25 +194,6 @@ def use_new_video_uploads_page(course_key):
LEGACY_STUDIO_COURSE_OUTLINE = CourseWaffleFlag('legacy_studio.course_outline', __name__)
-# .. toggle_name: legacy_studio.unit_editor
-# .. toggle_implementation: WaffleFlag
-# .. toggle_default: False
-# .. toggle_description: Temporarily fall back to the old Studio unit editing page.
-# .. toggle_use_cases: temporary
-# .. toggle_creation_date: 2025-03-14
-# .. toggle_target_removal_date: 2025-09-14
-# .. toggle_tickets: https://github.com/openedx/edx-platform/issues/36275
-# .. toggle_warning: In Ulmo, this toggle will be removed. Only the new (React-based) experience will be available.
-LEGACY_STUDIO_UNIT_EDITOR = CourseWaffleFlag('legacy_studio.unit_editor', __name__)
-
-
-def use_new_unit_page(course_key):
- """
- Returns a boolean if new studio course outline mfe is enabled
- """
- return not LEGACY_STUDIO_UNIT_EDITOR.is_enabled(course_key)
-
-
# .. toggle_name: contentstore.mock_video_uploads
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py
index 306e96f999fe..94808829f066 100644
--- a/cms/djangoapps/contentstore/utils.py
+++ b/cms/djangoapps/contentstore/utils.py
@@ -42,7 +42,6 @@
libraries_v1_enabled,
libraries_v2_enabled,
split_library_view_on_dashboard,
- use_new_unit_page,
)
from cms.djangoapps.models.settings.course_grading import CourseGradingModel
from cms.djangoapps.models.settings.course_metadata import CourseMetadata
@@ -426,13 +425,10 @@ def get_unit_url(course_locator, unit_locator) -> str:
"""
Gets course authoring microfrontend URL for unit page view.
"""
- unit_url = None
- if use_new_unit_page(course_locator):
- mfe_base_url = get_course_authoring_url(course_locator)
- course_mfe_url = f'{mfe_base_url}/course/{course_locator}/container/{unit_locator}'
- if mfe_base_url:
- unit_url = course_mfe_url
- return unit_url
+ mfe_base_url = get_course_authoring_url(course_locator)
+ if mfe_base_url:
+ return f'{mfe_base_url}/course/{course_locator}/container/{unit_locator}'
+ return None
def get_certificates_url(course_locator) -> str:
diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py
index 2ab410392272..fb7e1ec42db9 100644
--- a/cms/djangoapps/contentstore/views/component.py
+++ b/cms/djangoapps/contentstore/views/component.py
@@ -22,8 +22,8 @@
from xblock.plugin import PluginMissingError
from xblock.runtime import Mixologist
-from cms.djangoapps.contentstore.helpers import get_parent_if_split_test, is_library_content, is_unit
-from cms.djangoapps.contentstore.toggles import libraries_v2_enabled, use_new_unit_page
+from cms.djangoapps.contentstore.helpers import get_parent_if_split_test, xblock_has_own_studio_page
+from cms.djangoapps.contentstore.toggles import libraries_v2_enabled
from cms.djangoapps.contentstore.xblock_storage_handlers.view_handlers import load_services_for_studio
from common.djangoapps.edxmako.shortcuts import render_to_response
from common.djangoapps.student.auth import has_course_author_access
@@ -71,7 +71,7 @@
"add-xblock-component", "add-xblock-component-button", "add-xblock-component-menu",
"add-xblock-component-support-legend", "add-xblock-component-support-level", "add-xblock-component-menu-problem",
"xblock-string-field-editor", "xblock-access-editor", "publish-xblock", "publish-history", "tag-list",
- "unit-outline", "container-message", "container-access", "license-selector", "copy-clipboard-button",
+ "container-message", "container-access", "license-selector", "copy-clipboard-button",
"edit-title-button", "edit-upstream-alert",
]
@@ -133,44 +133,36 @@ def _load_mixed_class(category):
@require_GET
@login_required
-def container_handler(request, usage_key_string): # pylint: disable=too-many-statements
+def container_handler(request, usage_key_string):
"""
- The restful handler for container xblock requests.
+ Redirects to the MFE unit editor.
- GET
- html: returns the HTML page for editing a container
- json: not currently supported
+ The legacy Django-template-based unit editor has been removed.
+ This view exists for backward compatibility with any existing links to /container/.
"""
+ from ..utils import get_unit_url
- from ..utils import get_container_handler_context, get_unit_url
+ if 'text/html' not in request.META.get('HTTP_ACCEPT', 'text/html'):
+ return HttpResponseBadRequest("Only supports HTML requests")
- if 'text/html' in request.META.get('HTTP_ACCEPT', 'text/html'):
+ try:
+ usage_key = UsageKey.from_string(usage_key_string)
+ except InvalidKeyError:
+ raise Http404 # pylint: disable=raise-missing-from # noqa: B904
+ with modulestore().bulk_operations(usage_key.course_key):
try:
- usage_key = UsageKey.from_string(usage_key_string)
- except InvalidKeyError: # Raise Http404 on invalid 'usage_key_string'
- raise Http404 # pylint: disable=raise-missing-from # noqa: B904
- with modulestore().bulk_operations(usage_key.course_key):
- try:
- course, xblock, lms_link, preview_lms_link = _get_item_in_course(request, usage_key)
- except ItemNotFoundError:
- return HttpResponseBadRequest()
-
- if use_new_unit_page(course.id):
- if is_unit(xblock) or is_library_content(xblock):
- return redirect(get_unit_url(course.id, xblock.location))
-
- if split_xblock := get_parent_if_split_test(xblock):
- return redirect(get_unit_url(course.id, split_xblock.location))
-
- container_handler_context = get_container_handler_context(request, usage_key, course, xblock)
- container_handler_context.update({
- 'draft_preview_link': preview_lms_link,
- 'published_preview_link': lms_link,
- })
- return render_to_response('container.html', container_handler_context)
- else:
- return HttpResponseBadRequest("Only supports HTML requests")
+ course, xblock, _, _ = _get_item_in_course(request, usage_key)
+ except ItemNotFoundError:
+ return HttpResponseBadRequest()
+
+ if xblock_has_own_studio_page(xblock):
+ return redirect(get_unit_url(course.id, xblock.location))
+
+ if split_xblock := get_parent_if_split_test(xblock):
+ return redirect(get_unit_url(course.id, split_xblock.location))
+
+ raise Http404
@require_GET
@@ -179,7 +171,8 @@ def container_handler(request, usage_key_string): # pylint: disable=too-many-st
def container_embed_handler(request, usage_key_string): # pylint: disable=too-many-statements
"""
Returns an HttpResponse with HTML content for the container XBlock.
- The returned HTML is a chromeless rendering of the XBlock.
+ The returned HTML is a chromeless rendering of the XBlock, used by the
+ Authoring MFE to display xblock content in iframes.
GET
html: returns the HTML page for editing a container
diff --git a/cms/djangoapps/contentstore/views/tests/test_container_page.py b/cms/djangoapps/contentstore/views/tests/test_container_page.py
index fbb14634820c..796cddc36f02 100644
--- a/cms/djangoapps/contentstore/views/tests/test_container_page.py
+++ b/cms/djangoapps/contentstore/views/tests/test_container_page.py
@@ -4,19 +4,15 @@
import datetime
-import re
-from unittest.mock import Mock, patch
-from urllib.parse import quote
from django.http import Http404
from django.test.client import RequestFactory
from django.urls import reverse
-from edx_toggles.toggles.testutils import override_waffle_flag
from pytz import UTC
import cms.djangoapps.contentstore.views.component as views
-from cms.djangoapps.contentstore import toggles
from cms.djangoapps.contentstore.tests.test_libraries import LibraryTestCase
+from cms.djangoapps.contentstore.utils import get_unit_url
from xmodule.modulestore import ModuleStoreEnum # pylint: disable=wrong-import-order
from xmodule.modulestore.django import modulestore # pylint: disable=wrong-import-order
from xmodule.modulestore.tests.factories import ( # pylint: disable=wrong-import-order
@@ -63,80 +59,32 @@ def setUp(self):
self.store.publish(self.vertical.location, self.user.id)
def test_container_html(self):
- assets_url = reverse(
- 'assets_handler', kwargs={'course_key_string': str(self.child_container.location.course_key)}
- )
- self._test_html_content(
- self.child_container,
- expected_section_tag=(
- ''.format(
- self.child_container.location, assets_url
- )
- ),
- expected_breadcrumbs=(
- '
\\s*Week 1<\\/a>.*'
- 'Lesson 1'
- ).format(
- course=re.escape(str(self.course.id)),
- section_parameters=re.escape('?show={}'.format(quote(
- str(self.chapter.location).encode()
- ))),
- subsection_parameters=re.escape('?show={}'.format(quote(
- str(self.sequential.location).encode()
- ))),
- ),
- )
-
- @override_waffle_flag(toggles.LEGACY_STUDIO_UNIT_EDITOR, True)
- def test_container_on_container_html(self):
"""
- Create the scenario of an xblock with children (non-vertical) on the container page.
- This should create a container page that is a child of another container page.
+ Verify the chromeless container page (what the Authoring MFE loads via
+ container_embed_handler) renders the expected section tag for a unit,
+ a split test, and a non-vertical container nested inside it.
"""
- draft_container = self._create_block(self.child_container, "wrapper", "Wrapper")
- self._create_block(draft_container, "html", "Child HTML")
+ wrapper = self._create_block(self.child_container, "wrapper", "Wrapper")
+ self._create_block(wrapper, "html", "Child HTML")
- def test_container_html(xblock):
+ for xblock in (self.vertical, self.child_container, wrapper):
assets_url = reverse(
- 'assets_handler', kwargs={'course_key_string': str(draft_container.location.course_key)}
+ 'assets_handler', kwargs={'course_key_string': str(xblock.location.course_key)}
)
- self._test_html_content(
- xblock,
- expected_section_tag=(
- ''.format(
- draft_container.location, assets_url
- )
- ),
- expected_breadcrumbs=(
- 'Lesson 1.*'
- 'Unit.*'
- ).format(
- course=re.escape(str(self.course.id)),
- unit_parameters=re.escape(str(self.vertical.location)),
- subsection_parameters=re.escape('?show={}'.format(quote(
- str(self.sequential.location).encode()
- ))),
- ),
+ expected_section_tag = (
+ ''.format(
+ xblock.location, assets_url
+ )
)
+ self._test_html_content(xblock, expected_section_tag)
- # Test the draft version of the container
- test_container_html(draft_container)
-
- # Now publish the unit and validate again
- self.store.publish(self.vertical.location, self.user.id)
- draft_container = self.store.get_item(draft_container.location)
- test_container_html(draft_container)
-
- def _test_html_content(self, xblock, expected_section_tag, expected_breadcrumbs):
+ def _test_html_content(self, xblock, expected_section_tag):
"""
- Get the HTML for a container page and verify the section tag is correct
- and the breadcrumbs trail is correct.
+ Get the HTML for a container page and verify the section tag is correct.
"""
html = self.get_page_html(xblock)
self.assertIn(expected_section_tag, html) # noqa: PT009
- self.assertRegex(html, re.compile(expected_breadcrumbs, re.DOTALL)) # noqa: PT009
def test_public_container_preview_html(self):
"""
@@ -223,17 +171,13 @@ def test_draft_child_container_preview_html(self):
empty_child_container = self._create_block(self.vertical, 'split_test', 'Split Test 1')
self.validate_preview_html(empty_child_container, self.reorderable_child_view, can_add=False)
- @patch(
- 'cms.djangoapps.contentstore.views.component.render_to_response',
- Mock(return_value=Mock(status_code=200, content=''))
- )
- @override_waffle_flag(toggles.LEGACY_STUDIO_UNIT_EDITOR, True)
def test_container_page_with_valid_and_invalid_usage_key_string(self):
"""
- Check that invalid 'usage_key_string' raises Http404.
+ Check that invalid 'usage_key_string' raises Http404 and valid key redirects to MFE.
"""
request = RequestFactory().get('foo')
request.user = self.user
+ request.META['HTTP_ACCEPT'] = 'text/html'
request.LANGUAGE_CODE = 'en'
# Check for invalid 'usage_key_strings'
@@ -243,68 +187,26 @@ def test_container_page_with_valid_and_invalid_usage_key_string(self):
usage_key_string='i4x://InvalidOrg/InvalidCourse/vertical/static/InvalidContent',
)
- # Check 200 response if 'usage_key_string' is correct
+ # Check redirect response if 'usage_key_string' is correct (now redirects to MFE)
response = views.container_handler(
request=request,
usage_key_string=str(self.vertical.location)
)
- self.assertEqual(response.status_code, 200) # noqa: PT009
-
-
-class ContainerEmbedPageTestCase(ContainerPageTestCase): # pylint: disable=test-inherits-tests
- """
- Unit tests for the container embed page.
- """
+ self.assertEqual(response.status_code, 302) # noqa: PT009
+ self.assertEqual(response.url, get_unit_url(self.course.id, self.vertical.location)) # noqa: PT009
- def test_container_html(self):
- assets_url = reverse(
- 'assets_handler', kwargs={'course_key_string': str(self.child_container.location.course_key)}
- )
- self._test_html_content(
- self.child_container,
- expected_section_tag=(
- ''.format(
- self.child_container.location, assets_url
- )
- ),
+ # A split_test block has children, so it has its own Studio page and also redirects.
+ response = views.container_handler(
+ request=request,
+ usage_key_string=str(self.child_container.location)
)
+ self.assertEqual(response.status_code, 302) # noqa: PT009
+ split_test_url = response.url
+ self.assertEqual(split_test_url, get_unit_url(self.course.id, self.child_container.location)) # noqa: PT009
- @override_waffle_flag(toggles.LEGACY_STUDIO_UNIT_EDITOR, True)
- def test_container_on_container_html(self):
- """
- Create the scenario of an xblock with children (non-vertical) on the container page.
- This should create a container page that is a child of another container page.
- """
- draft_container = self._create_block(self.child_container, "wrapper", "Wrapper")
- self._create_block(draft_container, "html", "Child HTML")
-
- def test_container_html(xblock):
- assets_url = reverse(
- 'assets_handler', kwargs={'course_key_string': str(draft_container.location.course_key)}
- )
- self._test_html_content(
- xblock,
- expected_section_tag=(
- ''.format(
- draft_container.location, assets_url
- )
- ),
- )
-
- # Test the draft version of the container
- test_container_html(draft_container)
-
- # Now publish the unit and validate again
- self.store.publish(self.vertical.location, self.user.id)
- draft_container = self.store.get_item(draft_container.location)
- test_container_html(draft_container)
-
- def _test_html_content(self, xblock, expected_section_tag): # pylint: disable=arguments-differ
- """
- Get the HTML for a container page and verify the section tag is correct
- and the breadcrumbs trail is correct.
- """
- html = self.get_page_html(xblock)
- self.assertIn(expected_section_tag, html) # noqa: PT009
+ response = views.container_handler(
+ request=request,
+ usage_key_string=str(self.child_vertical.location)
+ )
+ self.assertEqual(response.status_code, 302) # noqa: PT009
+ self.assertEqual(response.url, split_test_url) # noqa: PT009
diff --git a/cms/djangoapps/contentstore/views/tests/utils.py b/cms/djangoapps/contentstore/views/tests/utils.py
index cbc51c0acc63..9c1a72c916a4 100644
--- a/cms/djangoapps/contentstore/views/tests/utils.py
+++ b/cms/djangoapps/contentstore/views/tests/utils.py
@@ -5,11 +5,9 @@
import json
-from cms.djangoapps.contentstore.tests.utils import CourseTestCase
+from cms.djangoapps.contentstore.tests.utils import CourseTestCase, get_url
from xmodule.modulestore.tests.factories import BlockFactory # pylint: disable=wrong-import-order
-from ...helpers import xblock_studio_url
-
class StudioPageTestCase(CourseTestCase):
"""
@@ -25,10 +23,10 @@ def setUp(self):
def get_page_html(self, xblock):
"""
- Returns the HTML for the page representing the xblock.
+ Returns the HTML for the page representing the xblock, as rendered by
+ container_embed_handler (the chromeless container page the Authoring MFE loads).
"""
- url = xblock_studio_url(xblock)
- self.assertIsNotNone(url) # noqa: PT009
+ url = get_url('container_embed_handler', xblock.location)
resp = self.client.get_html(url)
self.assertEqual(resp.status_code, 200) # noqa: PT009
return resp.content.decode(resp.charset)
diff --git a/cms/static/cms/js/spec/main.js b/cms/static/cms/js/spec/main.js
index 8a164e720abc..1c701847320d 100644
--- a/cms/static/cms/js/spec/main.js
+++ b/cms/static/cms/js/spec/main.js
@@ -271,7 +271,6 @@
'js/spec/views/assets_spec',
'js/spec/views/baseview_spec',
'js/spec/views/paged_container_spec',
- 'js/spec/views/unit_outline_spec',
'js/spec/views/xblock_spec',
'js/spec/views/xblock_validation_spec',
'js/spec/views/license_spec',
diff --git a/cms/static/js/spec/views/pages/container_subviews_spec.js b/cms/static/js/spec/views/pages/container_subviews_spec.js
index 27175090f211..d850a74d77f7 100644
--- a/cms/static/js/spec/views/pages/container_subviews_spec.js
+++ b/cms/static/js/spec/views/pages/container_subviews_spec.js
@@ -40,7 +40,6 @@ describe('Container Subviews', function() {
TemplateHelpers.installTemplate('xblock-string-field-editor');
TemplateHelpers.installTemplate('publish-xblock');
TemplateHelpers.installTemplate('publish-history');
- TemplateHelpers.installTemplate('unit-outline');
TemplateHelpers.installTemplate('container-message');
appendSetFixtures(mockContainerPage);
});
diff --git a/cms/static/js/spec/views/unit_outline_spec.js b/cms/static/js/spec/views/unit_outline_spec.js
deleted file mode 100644
index 99eb7d5da399..000000000000
--- a/cms/static/js/spec/views/unit_outline_spec.js
+++ /dev/null
@@ -1,150 +0,0 @@
-define(['jquery', 'sinon', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'common/js/spec_helpers/template_helpers',
- 'common/js/spec_helpers/view_helpers', 'common/js/components/utils/view_utils', 'js/models/course',
- 'js/views/unit_outline', 'js/models/xblock_info'],
-function($, sinon, AjaxHelpers, TemplateHelpers, ViewHelpers, ViewUtils,
- Course, UnitOutlineView, XBlockInfo) {
- 'use strict';
-
- describe('UnitOutlineView', function() {
- // Preload before beforeEach installs fake XHR, so readFixtures uses real XHR
- // and the result is cached. See group_configuration_spec.js for full explanation.
- readFixtures('unit-outline.underscore');
-
- var createUnitOutlineView, createMockXBlockInfo,
- requests, xhrFactory, model, unitOutlineView;
-
- createUnitOutlineView = function(test, unitJSON, createOnly) {
- model = new XBlockInfo(unitJSON, {parse: true});
- unitOutlineView = new UnitOutlineView({
- model: model,
- el: $('.wrapper-unit-overview')
- });
- if (!createOnly) {
- unitOutlineView.render();
- }
- return unitOutlineView;
- };
-
- createMockXBlockInfo = function(displayName) {
- return {
- id: 'mock-unit',
- category: 'vertical',
- display_name: displayName,
- studio_url: '/container/mock-unit',
- visibility_state: 'unscheduled',
- ancestor_info: {
- ancestors: [{
- id: 'mock-subsection',
- category: 'sequential',
- display_name: 'Mock Subsection',
- studio_url: '/course/mock-course?show=mock-subsection',
- visibility_state: 'unscheduled',
- child_info: {
- category: 'vertical',
- display_name: 'Unit',
- children: [{
- id: 'mock-unit',
- category: 'vertical',
- display_name: displayName,
- studio_url: '/container/mock-unit',
- visibility_state: 'unscheduled'
- }, {
- id: 'mock-unit-2',
- category: 'vertical',
- display_name: 'Mock Unit 2',
- studio_url: '/container/mock-unit-2',
- visibility_state: 'unscheduled'
- }]
- }
- }, {
- id: 'mock-section',
- category: 'chapter',
- display_name: 'Section',
- studio_url: '/course/slashes:mock-course?show=mock-section',
- visibility_state: 'unscheduled'
- }, {
- id: 'mock-course',
- category: 'course',
- display_name: 'Mock Course',
- studio_url: '/course/mock-course',
- visibility_state: 'unscheduled'
- }]
- },
- metadata: {
- display_name: 'Mock Unit'
- }
- };
- };
-
- beforeEach(function() {
- xhrFactory = sinon.useFakeXMLHttpRequest();
- requests = [];
- requests.currentIndex = 0;
- requests.restore = function() { xhrFactory.restore(); };
- xhrFactory.onCreate = function(req) { requests.push(req); };
- window.course = new Course({
- id: '5',
- name: 'Course Name',
- url_name: 'course_name',
- org: 'course_org',
- num: 'course_num',
- revision: 'course_rev'
- });
- ViewHelpers.installMockAnalytics();
- ViewHelpers.installViewTemplates();
- TemplateHelpers.installTemplate('unit-outline');
- appendSetFixtures('');
- });
-
- afterEach(function() {
- requests.restore();
- delete window.course;
- ViewHelpers.removeMockAnalytics();
- });
-
- it('can render itself', function() {
- createUnitOutlineView(this, createMockXBlockInfo('Mock Unit'));
- expect(unitOutlineView.$('.list-sections')).toExist();
- expect(unitOutlineView.$('.list-subsections')).toExist();
- expect(unitOutlineView.$('.list-units')).toExist();
- });
-
- it('highlights the current unit', function() {
- createUnitOutlineView(this, createMockXBlockInfo('Mock Unit'));
- $('.outline-unit').each(function(i) {
- if ($(this).data('locator') === model.get('id')) {
- expect($(this)).toHaveClass('is-current');
- } else {
- expect($(this)).not.toHaveClass('is-current');
- }
- });
- });
-
- it('can add a unit', function() {
- var redirectSpy;
- createUnitOutlineView(this, createMockXBlockInfo('Mock Unit'));
- redirectSpy = spyOn(ViewUtils, 'redirect');
- unitOutlineView.$('.outline-subsection > .outline-content > .add-unit .button-new').click();
- AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
- category: 'vertical',
- display_name: 'Unit',
- parent_locator: 'mock-subsection'
- });
- AjaxHelpers.respondWithJson(requests, {
- locator: 'new-mock-unit',
- courseKey: 'slashes:MockCourse'
- });
- expect(redirectSpy).toHaveBeenCalledWith('/container/new-mock-unit?action=new');
- });
-
- it('refreshes when the XBlockInfo model syncs', function() {
- var updatedDisplayName = 'Mock Unit Updated';
- createUnitOutlineView(this, createMockXBlockInfo('Mock Unit'));
- unitOutlineView.refresh();
- AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/mock-unit');
- AjaxHelpers.respondWithJson(requests,
- createMockXBlockInfo(updatedDisplayName));
- expect(unitOutlineView.$('.outline-unit .unit-title').first().text().trim()).toBe(updatedDisplayName);
- });
- });
-});
diff --git a/cms/static/js/views/pages/container.js b/cms/static/js/views/pages/container.js
index d4afa4cab692..671c5bf83738 100644
--- a/cms/static/js/views/pages/container.js
+++ b/cms/static/js/views/pages/container.js
@@ -6,7 +6,7 @@ define(['jquery', 'underscore', 'backbone', 'gettext', 'js/views/pages/base_page
'common/js/components/utils/view_utils', 'js/views/container', 'js/views/xblock',
'js/views/components/add_xblock', 'js/views/modals/edit_xblock', 'js/views/modals/move_xblock_modal',
'js/models/xblock_info', 'js/views/xblock_string_field_editor', 'js/views/xblock_access_editor',
- 'js/views/pages/container_subviews', 'js/views/unit_outline', 'js/views/utils/xblock_utils',
+ 'js/views/pages/container_subviews', 'js/views/utils/xblock_utils',
'common/js/components/views/feedback_notification', 'common/js/components/views/feedback_prompt',
'js/views/utils/tagging_drawer_utils', 'js/utils/module', 'js/views/modals/preview_v2_library_changes',
'js/views/modals/select_v2_library_content'
@@ -15,7 +15,7 @@ function($, _, Backbone, gettext, BasePage,
ViewUtils, ContainerView, XBlockView,
AddXBlockComponent, EditXBlockModal, MoveXBlockModal,
XBlockInfo, XBlockStringFieldEditor, XBlockAccessEditor,
- ContainerSubviews, UnitOutlineView, XBlockUtils,
+ ContainerSubviews, XBlockUtils,
NotificationView, PromptView, TaggingDrawerUtils, ModuleUtils,
PreviewLibraryChangesModal, SelectV2LibraryContent) {
'use strict';
@@ -127,13 +127,6 @@ function($, _, Backbone, gettext, BasePage,
this.tagListView.setupMessageListener();
this.tagListView.render();
}
-
- this.unitOutlineView = new UnitOutlineView({
- el: this.$('.wrapper-unit-overview'),
- model: this.model
- });
- this.unitOutlineView.render();
-
}
if (this.options.isIframeEmbed) {
diff --git a/cms/static/js/views/unit_outline.js b/cms/static/js/views/unit_outline.js
deleted file mode 100644
index 8c6c4605af5b..000000000000
--- a/cms/static/js/views/unit_outline.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * The UnitOutlineView is used to render the Unit Outline component on the unit page. It shows
- * the ancestors of the unit along with its direct siblings. It also has a single "New Unit"
- * button to allow a new sibling unit to be added.
- */
-define(['underscore', 'js/views/xblock_outline', 'js/views/unit_outline_child'],
- function(_, XBlockOutlineView, UnitOutlineChildView) {
- var UnitOutlineView = XBlockOutlineView.extend({
- // takes XBlockInfo as a model
-
- templateName: 'unit-outline',
-
- render: function() {
- XBlockOutlineView.prototype.render.call(this);
- this.renderAncestors();
- return this;
- },
-
- renderAncestors: function() {
- var i, listElement,
- ancestors, ancestor,
- ancestorView = this,
- previousAncestor = null;
- if (this.model.get('ancestor_info')) {
- ancestors = this.model.get('ancestor_info').ancestors;
- listElement = this.getListElement();
- // Note: the ancestors are processed in reverse order because the tree wants to
- // start at the root, but the ancestors are ordered by closeness to the unit,
- // i.e. subsection and then section.
- for (i = ancestors.length - 1; i >= 0; i--) {
- ancestor = ancestors[i];
- ancestorView = this.createChildView(
- ancestor,
- previousAncestor,
- {parentView: ancestorView, currentUnitId: this.model.get('id')}
- );
- ancestorView.render();
- listElement.append(ancestorView.$el);
- previousAncestor = ancestor;
- listElement = ancestorView.getListElement();
- }
- }
- return ancestorView;
- },
-
- getChildViewClass: function() {
- return UnitOutlineChildView;
- },
-
- getTemplateContext: function() {
- return _.extend(
- XBlockOutlineView.prototype.getTemplateContext.call(this),
- {currentUnitId: this.model.get('id')}
- );
- }
- });
-
- return UnitOutlineView;
- }); // end define();
diff --git a/cms/static/js/views/unit_outline_child.js b/cms/static/js/views/unit_outline_child.js
deleted file mode 100644
index f327c6367ebf..000000000000
--- a/cms/static/js/views/unit_outline_child.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * The UnitOutlineChildView is used to render each Section,
- * Subsection, and Unit within the Unit Outline component on the unit
- * page.
- */
-define(['underscore', 'js/views/xblock_outline'],
- function(_, XBlockOutlineView) {
- var UnitOutlineChildView = XBlockOutlineView.extend({
- initialize: function() {
- XBlockOutlineView.prototype.initialize.call(this);
- this.currentUnitId = this.options.currentUnitId;
- },
-
- getTemplateContext: function() {
- return _.extend(
- XBlockOutlineView.prototype.getTemplateContext.call(this),
- {currentUnitId: this.currentUnitId}
- );
- },
-
- getChildViewClass: function() {
- return UnitOutlineChildView;
- },
-
- createChildView: function(childInfo, parentInfo, options) {
- options = _.isUndefined(options) ? {} : options;
- return XBlockOutlineView.prototype.createChildView.call(
- this, childInfo, parentInfo, _.extend(options, {currentUnitId: this.currentUnitId})
- );
- }
- });
-
- return UnitOutlineChildView;
- }); // end define()
diff --git a/cms/templates/container.html b/cms/templates/container.html
deleted file mode 100644
index e1995de4ba58..000000000000
--- a/cms/templates/container.html
+++ /dev/null
@@ -1,276 +0,0 @@
-<%page expression_filter="h"/>
-<%inherit file="base.html" />
-<%def name="online_help_token()">
-<%
-if is_unit_page:
- return "unit"
-else:
- return "container"
-%>
-%def>
-<%!
-from django.urls import reverse
-from django.utils.translation import gettext as _
-
-from cms.djangoapps.contentstore.helpers import xblock_studio_url, xblock_type_display_name
-from cms.djangoapps.contentstore.toggles import use_new_pdf_editor, use_video_gallery_flow
-from cms.djangoapps.contentstore.utils import get_editor_page_base_url
-from openedx.core.djangolib.js_utils import (
- dump_js_escaped_json, js_escaped_string
-)
-from openedx.core.djangolib.markup import HTML, Text
-%>
-
-<%block name="title">${xblock.display_name_with_default} ${xblock_type_display_name(xblock)}%block>
-<%block name="bodyclass">is-signedin course container view-container%block>
-
-<%namespace name='static' file='static_content.html'/>
-
-<%block name="header_extras">
-% for template_name in templates:
-
-% endfor
-
-
-%block>
-
-<%block name="page_bundle">
- <%static:webpack entry="js/factories/container">
- ContainerFactory(
- ${component_templates | n, dump_js_escaped_json},
- ${xblock_info | n, dump_js_escaped_json},
- "${action | n, js_escaped_string}",
- {
- isUnitPage: ${is_unit_page | n, dump_js_escaped_json},
- canEdit: true,
- outlineURL: "${outline_url | n, js_escaped_string}",
- libraryContentPickerUrl: "${library_content_picker_url | n, js_escaped_string}",
- clipboardData: ${user_clipboard | n, dump_js_escaped_json},
- }
- );
-
- require(["js/models/xblock_info", "js/views/xblock", "js/views/utils/xblock_utils", "common/js/components/utils/view_utils", "gettext"], function (XBlockInfo, XBlockView, XBlockUtils, ViewUtils, gettext) {
- var model = new XBlockInfo({
- id: '${subsection.location|n, decode.utf8}'
- });
- var xblockView = new XBlockView({
- model: model,
- el: $('#sequence-nav'),
- view: 'author_view?position=${position|n, decode.utf8}&next_url=${next_url|n, decode.utf8}&prev_url=${prev_url|n, decode.utf8}',
- clipboardData: ${user_clipboard | n, dump_js_escaped_json},
- });
-
- xblockView.xblockReady = function() {
-
- var toggleCaretButton = function(clipboardData) {
- if (clipboardData && clipboardData.content && clipboardData.source_usage_key.includes("vertical")) {
- $('.dropdown-toggle-button').show();
- } else {
- $('.dropdown-toggle-button').hide();
- $('.dropdown-options').hide();
- }
- };
- this.clipboardBroadcastChannel = new BroadcastChannel("studio_clipboard_channel");
- this.clipboardBroadcastChannel.onmessage = (event) => {
- toggleCaretButton(event.data);
- };
- toggleCaretButton(this.options.clipboardData);
-
- $('#new-unit-button').on('click', function(event) {
- event.preventDefault();
- XBlockUtils.addXBlock($(this)).done(function(locator) {
- ViewUtils.redirect('/container/' + locator + '?action=new');
- });
- });
-
- $('.custom-dropdown .dropdown-toggle-button').on('click', function(event) {
- event.stopPropagation(); // Prevent the event from closing immediately when we open it
- $(this).next('.dropdown-options').slideToggle('fast'); // This toggles the dropdown visibility
- var isExpanded = $(this).attr('aria-expanded') === 'true';
- $(this).attr('aria-expanded', !isExpanded);
- });
-
- $('.seq_paste_unit').on('click', function(event) {
- event.preventDefault();
- $('.dropdown-options').hide();
- XBlockUtils.pasteXBlock($(this)).done(function(data) {
- ViewUtils.redirect('/container/' + data.locator + '?action=new');
- });
- });
- };
-
- xblockView.render();
- });
- %static:webpack>
-%block>
-
-<%block name="content">
-
-<%
-use_new_editor_pdf = use_new_pdf_editor()
-use_new_video_gallery_flow = use_video_gallery_flow()
-%>
-
-
-
-
-
-
-
-
-%block>
diff --git a/cms/templates/js/mock/mock-container-page.underscore b/cms/templates/js/mock/mock-container-page.underscore
index 620f8995f0a6..cd1acd3815d9 100644
--- a/cms/templates/js/mock/mock-container-page.underscore
+++ b/cms/templates/js/mock/mock-container-page.underscore
@@ -75,11 +75,6 @@
Tip: Use this ID when you create links to this unit from other course content. You enter the ID in the URL field.