Skip to content

Commit 64da3e2

Browse files
committed
feat: add legacy libraries deprecation warnings
1 parent 7c86626 commit 64da3e2

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed

cms/djangoapps/contentstore/utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,20 @@ def get_taxonomy_list_url() -> str | None:
547547
return f'{mfe_base_url}/taxonomies'
548548

549549

550+
def get_libraries_list_url() -> str:
551+
"""
552+
Gets course authoring microfrontend URL for libraries list view.
553+
"""
554+
mfe_base_url = settings.COURSE_AUTHORING_MICROFRONTEND_URL
555+
if mfe_base_url:
556+
return f'{mfe_base_url}/libraries'
557+
558+
raise ImproperlyConfigured(
559+
"The COURSE_AUTHORING_MICROFRONTEND_URL must be configured. "
560+
"Please set it to the base url for your authoring MFE."
561+
)
562+
563+
550564
def get_taxonomy_tags_widget_url(course_locator=None) -> str | None:
551565
"""
552566
Gets course authoring microfrontend URL for taxonomy tags drawer widget view.

cms/static/sass/elements/_modal-window.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
padding: 5%;
2929
}
3030

31-
.title {
31+
.title:not(.deprecated-title) {
3232
@extend %t-title5;
3333
@extend %t-demi-strong;
3434

cms/templates/library.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</%def>
66
<%!
77
from cms.djangoapps.contentstore.helpers import xblock_studio_url, xblock_type_display_name
8+
from cms.djangoapps.contentstore.utils import get_libraries_list_url
89
from django.utils.translation import gettext as _
910
from openedx.core.djangolib.js_utils import dump_js_escaped_json
1011
from openedx.core.djangolib.markup import HTML, Text
@@ -77,6 +78,25 @@ <h3 class="sr">${_("Page Actions")}</h3>
7778
<div class="content-area">
7879

7980
<div class="content-primary">
81+
<div class="wrapper wrapper-alert wrapper-alert-warning is-shown" role="alert">
82+
<div class="alert announcement">
83+
<span class="feedback-symbol fa fa-warning" aria-hidden="true"></span>
84+
<span class="sr">${_("Warning")}</span>
85+
<div class="copy">
86+
<h2 class="title title-3 warning-heading-text">
87+
${_("You are creating content in a deprecated format.")}
88+
</h2>
89+
<p>
90+
${_(
91+
"Legacy libraries will be unsupported in Willow. Any content you create in a"
92+
" legacy library will soon need to be migrated. Consider using the "
93+
)}
94+
<a href="${get_libraries_list_url()}" target="_blank">${_("Libraries feature")}</a>
95+
${_(" instead.")}
96+
</p>
97+
</div>
98+
</div>
99+
</div>
80100
<div class="container-message wrapper-message"></div>
81101
<div class="wrapper-xblock level-page is-hidden studio-xblock-wrapper" data-locator="${context_library.location}" data-course-key="${context_library.location.library_key}">
82102
</div>

cms/templates/widgets/metadata-edit.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,28 @@
3636
<%include file="source-edit.html" />
3737
% endif
3838

39+
## It is used to display a warning if a block (i.e. a LibraryContentBlock) uses the deprecated
40+
## legacy libraries feature.
41+
% if show_deprecated_warning:
42+
<div class="wrapper wrapper-alert wrapper-alert-warning is-shown" role="alert">
43+
<div class="alert announcement">
44+
<span class="feedback-symbol fa fa-warning" aria-hidden="true"></span>
45+
<span class="sr">${_("Warning")}</span>
46+
<div class="copy">
47+
<h2 class="title deprecated-title title-3 warning-heading-text">
48+
${_("You are creating content in a deprecated format.")}
49+
</h2>
50+
<p>
51+
${_(
52+
"Legacy libraries will be unsupported in Willow. Any content you create in a"
53+
" legacy library will soon need to be migrated. Consider using the "
54+
)}
55+
<a href="${library_url}" target="_blank">${_("Libraries feature")}</a>
56+
${_(" instead.")}
57+
</p>
58+
</div>
59+
</div>
60+
</div>
61+
% endif
62+
3963
<div class="wrapper-comp-settings metadata_edit" id="settings-tab" data-metadata='${json.dumps(metadata_field_copy, cls=EdxJSONEncoder) | h}'></div>

xmodule/library_content_block.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,20 @@ def is_ready_to_migrate_to_v2(self) -> bool:
142142
"""
143143
return self.is_source_lib_migrated_to_v2 and not self.is_migrated_to_v2
144144

145+
def get_context(self):
146+
"""
147+
Extend context adding `show_deprecated_warning` flag
148+
"""
149+
from cms.djangoapps.contentstore.utils import get_libraries_list_url
150+
151+
library_url = get_libraries_list_url()
152+
153+
context = super().get_context()
154+
context["show_deprecated_warning"] = True
155+
context["library_url"] = library_url
156+
157+
return context
158+
145159
def author_view(self, context):
146160
"""
147161
Renders the Studio views.

0 commit comments

Comments
 (0)