feat: new actions menu for copy/pasting units in Studio (behind waffle flag) (#32891)
This commit is contained in:
@@ -214,6 +214,22 @@ ENABLE_COPY_PASTE_FEATURE = WaffleFlag(
|
||||
)
|
||||
|
||||
|
||||
# .. toggle_name: contentstore.enable_copy_paste_units
|
||||
# .. toggle_implementation: WaffleFlag
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Moves most unit-level actions into a submenu and adds new "Copy Unit" and "Paste
|
||||
# Unit" actions which can be used to copy units within or among courses.
|
||||
# .. toggle_use_cases: temporary
|
||||
# .. toggle_creation_date: 2023-08-01
|
||||
# .. toggle_target_removal_date: 2023-10-01
|
||||
# .. toggle_tickets: https://github.com/openedx/modular-learning/issues/11 https://github.com/openedx/modular-learning/issues/50
|
||||
ENABLE_COPY_PASTE_UNITS = WaffleFlag(
|
||||
f'{CONTENTSTORE_NAMESPACE}.enable_copy_paste_units',
|
||||
__name__,
|
||||
CONTENTSTORE_LOG_PREFIX,
|
||||
)
|
||||
|
||||
|
||||
# .. toggle_name: contentstore.enable_studio_content_api
|
||||
# .. toggle_implementation: WaffleFlag
|
||||
# .. toggle_default: False
|
||||
|
||||
@@ -28,11 +28,7 @@ from common.djangoapps.xblock_django.models import XBlockStudioConfigurationFlag
|
||||
from cms.djangoapps.contentstore.toggles import use_new_problem_editor
|
||||
from openedx.core.lib.xblock_utils import get_aside_from_xblock, is_xblock_aside
|
||||
from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration
|
||||
try:
|
||||
# Technically this is a django app plugin, so we should not error if it's not installed:
|
||||
import openedx.core.djangoapps.content_staging.api as content_staging_api
|
||||
except ImportError:
|
||||
content_staging_api = None
|
||||
from openedx.core.djangoapps.content_staging import api as content_staging_api
|
||||
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from ..toggles import use_new_unit_page
|
||||
@@ -198,10 +194,7 @@ def container_handler(request, usage_key_string):
|
||||
index += 1
|
||||
|
||||
# Get the status of the user's clipboard so they can paste components if they have something to paste
|
||||
if content_staging_api:
|
||||
user_clipboard = content_staging_api.get_user_clipboard_json(request.user.id, request)
|
||||
else:
|
||||
user_clipboard = {"content": None}
|
||||
user_clipboard = content_staging_api.get_user_clipboard_json(request.user.id, request)
|
||||
return render_to_response('container.html', {
|
||||
'language_code': request.LANGUAGE_CODE,
|
||||
'context_course': course, # Needed only for display of menus at top of page.
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
"""
|
||||
Views related to operations on course objects
|
||||
"""
|
||||
|
||||
|
||||
import copy
|
||||
import json
|
||||
import logging
|
||||
@@ -60,6 +58,7 @@ from common.djangoapps.util.json_request import JsonResponse, JsonResponseBadReq
|
||||
from common.djangoapps.util.string_utils import _has_non_ascii_characters
|
||||
from common.djangoapps.xblock_django.api import deprecated_xblocks
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.content_staging import api as content_staging_api
|
||||
from openedx.core.djangoapps.credit.tasks import update_credit_course_requirements
|
||||
from openedx.core.djangoapps.models.course_details import CourseDetails
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
@@ -747,6 +746,8 @@ def course_index(request, course_key):
|
||||
advanced_dict = CourseMetadata.fetch(course_block)
|
||||
proctoring_errors = CourseMetadata.validate_proctoring_settings(course_block, advanced_dict, request.user)
|
||||
|
||||
user_clipboard = content_staging_api.get_user_clipboard_json(request.user.id, request)
|
||||
|
||||
return render_to_response('course_outline.html', {
|
||||
'language_code': request.LANGUAGE_CODE,
|
||||
'context_course': course_block,
|
||||
@@ -754,6 +755,7 @@ def course_index(request, course_key):
|
||||
'sections': sections,
|
||||
'course_structure': course_structure,
|
||||
'initial_state': course_outline_initial_state(locator_to_show, course_structure) if locator_to_show else None, # lint-amnesty, pylint: disable=line-too-long
|
||||
'initial_user_clipboard': user_clipboard,
|
||||
'rerun_notification_id': current_action.id if current_action else None,
|
||||
'course_release_date': course_release_date,
|
||||
'settings_url': settings_url,
|
||||
|
||||
@@ -38,6 +38,7 @@ from xblock.core import XBlock
|
||||
from xblock.fields import Scope
|
||||
|
||||
from cms.djangoapps.contentstore.config.waffle import SHOW_REVIEW_RULES_FLAG
|
||||
from cms.djangoapps.contentstore.toggles import ENABLE_COPY_PASTE_UNITS
|
||||
from cms.djangoapps.models.settings.course_grading import CourseGradingModel
|
||||
from common.djangoapps.edxmako.services import MakoService
|
||||
from common.djangoapps.static_replace import replace_static_urls
|
||||
@@ -1346,6 +1347,9 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
|
||||
else:
|
||||
xblock_info["staff_only_message"] = False
|
||||
|
||||
# If the ENABLE_COPY_PASTE_UNITS feature flag is enabled, we show the newer menu that allows copying/pasting
|
||||
xblock_info["enable_copy_paste_units"] = ENABLE_COPY_PASTE_UNITS.is_enabled()
|
||||
|
||||
xblock_info[
|
||||
"has_partition_group_components"
|
||||
] = has_children_visible_to_specific_partition_groups(xblock)
|
||||
|
||||
Reference in New Issue
Block a user