Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new library editor toggle #33628

19 changes: 19 additions & 0 deletions cms/djangoapps/contentstore/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,25 @@ def use_add_game_block():
return ENABLE_ADD_GAME_BLOCK_FLAG.is_enabled()


# .. toggle_name: new_core_editors.use_new_library_editor
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: This flag enables the use of the new library xblock editor
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2023-10-30
# .. toggle_target_removal_date: 2025-1-30
# .. toggle_tickets: TNL-11040
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to something public please

# .. toggle_warning:
ENABLE_NEW_LIBRARY_EDITOR_FLAG = WaffleFlag('new_core_editors.use_new_library_editor', __name__)


def use_new_library_editor():
"""
Returns a boolean if new library content block editor is enabled
"""
return ENABLE_NEW_LIBRARY_EDITOR_FLAG.is_enabled()


# .. toggle_name: contentstore.individualize_anonymous_user_id
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
Expand Down
5 changes: 5 additions & 0 deletions cms/static/js/views/pages/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,16 @@ function($, _, Backbone, gettext, BasePage,
var useNewTextEditor = primaryHeader.attr('use-new-editor-text'),
useNewVideoEditor = primaryHeader.attr('use-new-editor-video'),
useNewProblemEditor = primaryHeader.attr('use-new-editor-problem'),
useNewLibraryEditor = primaryHeader.attr('use-new-editor-library'),
blockType = primaryHeader.attr('data-block-type');

console.log(useNewLibraryEditor);
console.log(blockType);

if((useNewTextEditor === 'True' && blockType === 'html')
|| (useNewVideoEditor === 'True' && blockType === 'video')
|| (useNewProblemEditor === 'True' && blockType === 'problem')
|| (useNewLibraryEditor === 'True' && blockType === 'library_content')
) {
var destinationUrl = primaryHeader.attr('authoring_MFE_base_url') + '/' + blockType + '/' + encodeURI(primaryHeader.attr('data-usage-id'));
window.location.href = destinationUrl;
Expand Down
10 changes: 9 additions & 1 deletion cms/templates/studio_xblock_wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
from openedx.core.djangolib.js_utils import (
dump_js_escaped_json, js_escaped_string
)
from cms.djangoapps.contentstore.toggles import use_new_text_editor, use_new_problem_editor, use_new_video_editor, use_video_gallery_flow
from cms.djangoapps.contentstore.toggles import(
use_new_text_editor,
use_new_problem_editor,
use_new_video_editor,
use_new_library_editor,
use_video_gallery_flow,
)
%>
<%
use_new_editor_text = use_new_text_editor()
use_new_editor_video = use_new_video_editor()
use_new_editor_problem = use_new_problem_editor()
use_new_editor_library = use_new_library_editor()
use_new_video_gallery_flow = use_video_gallery_flow()
xblock_url = xblock_studio_url(xblock)
show_inline = xblock.has_children and not xblock_url
Expand Down Expand Up @@ -66,6 +73,7 @@
use-new-editor-text = ${use_new_editor_text}
use-new-editor-video = ${use_new_editor_video}
use-new-editor-problem = ${use_new_editor_problem}
use-new-editor-library = ${use_new_editor_library}
use-video-gallery-flow = ${use_new_video_gallery_flow}
authoring_MFE_base_url = ${get_editor_page_base_url(xblock.location.course_key)}
data-block-type = ${xblock.scope_ids.block_type}
Expand Down