From 777bb633c5b2e1c54eb61d9bcd2bdf13436aaef4 Mon Sep 17 00:00:00 2001 From: Daniel Francis <33784039+spokerman12@users.noreply.github.com> Date: Mon, 22 Mar 2021 13:39:09 -0400 Subject: [PATCH] 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 --- cms/djangoapps/contentstore/views/preview.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index ab301de5ef..28f53f249e 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -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) }