fix: Stop rendering Visibility and Move buttons on libraries (#26885)

We're fixing an error that appears when you click the "edit access"
button on an XBlock in the library page.

Libraries in the "Add library" page shouldn't have the accessibility
config icon. Access settings for libraries are changed at the top, on
Settings > User Access. When clicking the access-button (the cog) on a
Library, an error appears. This is known to happen on koa.master and
open-release/juniper.3.

This happens due to the way XBlocks are rendered; as they get rendered
initially, the previews are unaware of whether they're part of a
library. We can confirm this by refreshing the page, this makes the
button disappear.

This fix removes the cogwheel when the XBlock is part of a library.
This doesn't affect the XBlocks imported to courses because those are
rendered on a Randomized Content XBlock, which does have its access
options.

Authored by: Daniel Francis <daniel.francis@opencraft.com>
This commit is contained in:
Daniel Francis
2021-03-22 13:39:09 -04:00
committed by GitHub
parent 91b74b7fd3
commit 777bb633c5

View File

@@ -294,10 +294,10 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
'is_root': is_root,
'is_reorderable': is_reorderable,
'can_edit': context.get('can_edit', True),
'can_edit_visibility': context.get('can_edit_visibility', True),
'can_edit_visibility': context.get('can_edit_visibility', xblock.course_id.is_course),
'selected_groups_label': selected_groups_label,
'can_add': context.get('can_add', True),
'can_move': context.get('can_move', True),
'can_move': context.get('can_move', xblock.course_id.is_course),
'language': getattr(course, 'language', None)
}