fix: infinite load for library content block view (#34412)

* fix: hide view button when block is not configured

* fix: remove script for load timer if no children or library

* fix: remove print message

* fix: NoneType error is tests
This commit is contained in:
Kristin Aoki
2024-03-25 11:04:16 -04:00
committed by GitHub
parent 6d13b77495
commit 6c54c8fd15
2 changed files with 8 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ show_inline = xblock.has_children and not xblock_url
section_class = "level-nesting" if show_inline else "level-element"
label = determine_label(xblock.display_name_with_default, xblock.scope_ids.block_type)
messages = xblock.validate().to_json()
has_not_configured_message = messages.get('summary',{}).get('type', None) == 'not-configured'
block_is_unit = is_unit(xblock)
%>
@@ -190,7 +191,7 @@ block_is_unit = is_unit(xblock)
</div>
% if not is_root:
<div class="wrapper-xblock-message xblock-validation-messages" data-locator="${xblock.location}"/>
% if xblock_url:
% if xblock_url and not has_not_configured_message:
<div class="xblock-header-secondary">
<div class="meta-info">${_('This block contains multiple components.')}</div>
<ul class="actions-list">

View File

@@ -451,7 +451,12 @@ class LibraryContentBlock(
context['is_loading'] = is_updating
# The following JS is used to make the "Update now" button work on the unit page and the container view:
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/library_content_edit.js'))
if root_xblock and 'library' in root_xblock.category:
if root_xblock.source_library_id and len(root_xblock.children) > 0:
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/library_content_edit.js'))
else:
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/library_content_edit.js'))
fragment.initialize_js('LibraryContentAuthorView')
return fragment