From 39e042cfbd56accf5c1d5330da358faa9909575c Mon Sep 17 00:00:00 2001 From: Yusuf Musleh Date: Fri, 18 Aug 2023 17:54:48 +0100 Subject: [PATCH] feat: Remove component-level copy/paste feature flag (#32980) This is so that the feature is on by default. --- cms/djangoapps/contentstore/toggles.py | 16 --- cms/djangoapps/contentstore/views/preview.py | 5 +- .../views/tests/test_unit_page.py | 8 +- .../contentstore/views/tests/utils.py | 29 +++-- cms/templates/studio_xblock_wrapper.html | 111 ++++++------------ 5 files changed, 60 insertions(+), 109 deletions(-) diff --git a/cms/djangoapps/contentstore/toggles.py b/cms/djangoapps/contentstore/toggles.py index 9ae4b0271c..a2a8055b5a 100644 --- a/cms/djangoapps/contentstore/toggles.py +++ b/cms/djangoapps/contentstore/toggles.py @@ -198,22 +198,6 @@ def individualize_anonymous_user_id(course_id): return INDIVIDUALIZE_ANONYMOUS_USER_ID.is_enabled(course_id) -# .. toggle_name: contentstore.enable_copy_paste_feature -# .. toggle_implementation: WaffleFlag -# .. toggle_default: False -# .. toggle_description: Moves most component-level actions into a submenu and adds new "Copy Component" and "Paste -# Component" actions which can be used to copy components (XBlocks) within or among courses. -# .. toggle_use_cases: temporary -# .. toggle_creation_date: 2023-02-28 -# .. toggle_target_removal_date: 2023-05-01 -# .. toggle_tickets: https://github.com/openedx/modular-learning/issues/11 https://github.com/openedx/modular-learning/issues/50 -ENABLE_COPY_PASTE_FEATURE = WaffleFlag( - f'{CONTENTSTORE_NAMESPACE}.enable_copy_paste_feature', - __name__, - CONTENTSTORE_LOG_PREFIX, -) - - # .. toggle_name: contentstore.enable_copy_paste_units # .. toggle_implementation: WaffleFlag # .. toggle_default: False diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index cdfe08966e..5ee2740abe 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -27,7 +27,7 @@ from xmodule.util.sandboxing import SandboxService from xmodule.util.builtin_assets import add_webpack_js_to_fragment from xmodule.x_module import AUTHOR_VIEW, PREVIEW_VIEWS, STUDENT_VIEW, XModuleMixin from cms.djangoapps.xblock_config.models import StudioConfig -from cms.djangoapps.contentstore.toggles import individualize_anonymous_user_id, ENABLE_COPY_PASTE_FEATURE +from cms.djangoapps.contentstore.toggles import individualize_anonymous_user_id from cms.lib.xblock.field_data import CmsFieldData from common.djangoapps.static_replace.services import ReplaceURLService from common.djangoapps.static_replace.wrapper import replace_urls_wrapper @@ -301,8 +301,6 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False): can_edit = context.get('can_edit', True) # Is this a course or a library? is_course = xblock.scope_ids.usage_id.context_key.is_course - # Copy-paste is a new feature; while we are beta-testing it, only beta users with the Waffle flag enabled see it - enable_copy_paste = can_edit and is_course and ENABLE_COPY_PASTE_FEATURE.is_enabled() template_context = { 'xblock_context': context, 'xblock': xblock, @@ -311,7 +309,6 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False): 'is_root': is_root, 'is_reorderable': is_reorderable, 'can_edit': can_edit, - 'enable_copy_paste': enable_copy_paste, 'can_edit_visibility': context.get('can_edit_visibility', is_course), 'selected_groups_label': selected_groups_label, 'can_add': context.get('can_add', True), diff --git a/cms/djangoapps/contentstore/views/tests/test_unit_page.py b/cms/djangoapps/contentstore/views/tests/test_unit_page.py index 1d445725d8..932f9515a5 100644 --- a/cms/djangoapps/contentstore/views/tests/test_unit_page.py +++ b/cms/djangoapps/contentstore/views/tests/test_unit_page.py @@ -28,13 +28,13 @@ class UnitPageTestCase(StudioPageTestCase): Verify that a public xblock's preview returns the expected HTML. """ published_video = self.store.publish(self.video.location, self.user.id) # lint-amnesty, pylint: disable=unused-variable - self.validate_preview_html(self.video, STUDENT_VIEW, can_add=False) + self.validate_preview_html(self.video, STUDENT_VIEW, in_unit=True, can_add=False) def test_draft_component_preview_html(self): """ Verify that a draft xblock's preview returns the expected HTML. """ - self.validate_preview_html(self.video, STUDENT_VIEW, can_add=False) + self.validate_preview_html(self.video, STUDENT_VIEW, in_unit=True, can_add=False) def test_public_child_container_preview_html(self): """ @@ -46,7 +46,7 @@ class UnitPageTestCase(StudioPageTestCase): BlockFactory.create(parent_location=child_container.location, category='html', display_name='grandchild') published_child_container = self.store.publish(child_container.location, self.user.id) - self.validate_preview_html(published_child_container, STUDENT_VIEW, can_add=False) + self.validate_preview_html(published_child_container, STUDENT_VIEW, in_unit=True, can_add=False) def test_draft_child_container_preview_html(self): """ @@ -58,4 +58,4 @@ class UnitPageTestCase(StudioPageTestCase): BlockFactory.create(parent_location=child_container.location, category='html', display_name='grandchild') draft_child_container = self.store.get_item(child_container.location) - self.validate_preview_html(draft_child_container, STUDENT_VIEW, can_add=False) + self.validate_preview_html(draft_child_container, STUDENT_VIEW, in_unit=True, can_add=False) diff --git a/cms/djangoapps/contentstore/views/tests/utils.py b/cms/djangoapps/contentstore/views/tests/utils.py index 3f1e292ee5..c1a745f2e2 100644 --- a/cms/djangoapps/contentstore/views/tests/utils.py +++ b/cms/djangoapps/contentstore/views/tests/utils.py @@ -43,7 +43,7 @@ class StudioPageTestCase(CourseTestCase): resp_content = json.loads(resp.content.decode('utf-8')) return resp_content['html'] - def validate_preview_html(self, xblock, view_name, can_add=True, can_reorder=True, can_move=True, + def validate_preview_html(self, xblock, view_name, in_unit=False, can_add=True, can_reorder=True, can_move=True, can_edit=True, can_duplicate=True, can_delete=True): """ Verify that the specified xblock's preview has the expected HTML elements. @@ -59,9 +59,20 @@ class StudioPageTestCase(CourseTestCase): '', can_reorder ) + + if in_unit: + move_action_html = ' - % if can_edit_visibility and not enable_copy_paste: -
  • - -
  • - % endif - % if can_add and not enable_copy_paste: -
  • - -
  • - % endif - % if can_move and not enable_copy_paste: -
  • - -
  • - % endif % endif - % if can_add and not enable_copy_paste: - -
  • - -
  • - % endif - % if enable_copy_paste: - - % if is_reorderable: