diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 63e1a6b792..528b2714c9 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -17,6 +17,7 @@ from xmodule.exceptions import NotFoundError, ProcessingError from xmodule.library_tools import LibraryToolsService from xmodule.modulestore.django import modulestore, ModuleI18nService from opaque_keys.edx.keys import UsageKey +from opaque_keys.edx.locator import LibraryUsageLocator from xmodule.x_module import ModuleSystem from xblock.runtime import KvsFieldData from xblock.django.request import webob_to_django_response, django_to_webob_request @@ -242,6 +243,7 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False): # Only add the Studio wrapper when on the container page. The "Pages" page will remain as is for now. if not context.get('is_pages_view', None) and view in PREVIEW_VIEWS: root_xblock = context.get('root_xblock') + can_edit_visibility = not isinstance(xblock.location, LibraryUsageLocator) is_root = root_xblock and xblock.location == root_xblock.location is_reorderable = _is_xblock_reorderable(xblock, context) template_context = { @@ -251,6 +253,7 @@ 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': can_edit_visibility, } html = render_to_string('studio_xblock_wrapper.html', template_context) frag = wrap_fragment(frag, html) diff --git a/cms/envs/common.py b/cms/envs/common.py index 30657f0a5a..3aea5b983b 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -122,6 +122,12 @@ FEATURES = { # for consistency in user-experience, keep the value of this feature flag # in sync with the one in lms/envs/common.py 'ENABLE_EDXNOTES': False, + + # Enable support for content libraries. Note that content libraries are + # only supported in courses using split mongo. Change the setting + # DEFAULT_STORE_FOR_NEW_COURSE to be 'split' to have future courses + # and libraries created with split. + 'ENABLE_CONTENT_LIBRARIES': False, } ENABLE_JASMINE = False diff --git a/cms/static/js/spec/views/pages/container_spec.js b/cms/static/js/spec/views/pages/container_spec.js index b7e2b6facb..37025ee838 100644 --- a/cms/static/js/spec/views/pages/container_spec.js +++ b/cms/static/js/spec/views/pages/container_spec.js @@ -594,6 +594,7 @@ define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_hel }); } + // Create a suite for a non-paged container that includes 'edit visibility' buttons parameterized_suite("Non paged", { }, { @@ -603,6 +604,8 @@ define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_hel has_visibility_editor: true } ); + + // Create a suite for a paged container that does not include 'edit visibility' buttons parameterized_suite("Paged", { page_size: 42 }, { @@ -610,5 +613,6 @@ define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_hel initial: 'mock/mock-container-paged-xblock.underscore', add_response: 'mock/mock-xblock-paged.underscore', has_visibility_editor: false - }); + } + ); }); diff --git a/cms/templates/studio_xblock_wrapper.html b/cms/templates/studio_xblock_wrapper.html index 11beba2c9a..8f22f245ae 100644 --- a/cms/templates/studio_xblock_wrapper.html +++ b/cms/templates/studio_xblock_wrapper.html @@ -68,6 +68,14 @@ messages = json.dumps(xblock.validate().to_json()) ${_("Edit")} + % if can_edit_visibility: +
  • + + + ${_("Visibility")} + +
  • + % endif
  • @@ -81,18 +89,6 @@ messages = json.dumps(xblock.validate().to_json()) ${_("Delete")}
  • -
  • - - - ${_("Visibility")} - -
  • -
  • - - - ${_("Duplicate")} - -
  • % if is_reorderable:
  • diff --git a/common/test/acceptance/pages/studio/container.py b/common/test/acceptance/pages/studio/container.py index c3b4d7f94c..d03c6bac98 100644 --- a/common/test/acceptance/pages/studio/container.py +++ b/common/test/acceptance/pages/studio/container.py @@ -406,6 +406,14 @@ class XBlockWrapper(PageObject): def has_group_visibility_set(self): return self.q(css=self._bounded_selector('.wrapper-xblock.has-group-visibility-set')).is_present() + @property + def has_edit_visibility_button(self): + """ + Returns true if this xblock has an 'edit visibility' button + :return: + """ + return self.q(css=self._bounded_selector('.visibility-button')).is_present() + def go_to_container(self): """ Open the container page linked to by this xblock, and return diff --git a/common/test/acceptance/tests/studio/test_studio_library.py b/common/test/acceptance/tests/studio/test_studio_library.py index c27c69e9bb..f1afdb6ae1 100644 --- a/common/test/acceptance/tests/studio/test_studio_library.py +++ b/common/test/acceptance/tests/studio/test_studio_library.py @@ -69,6 +69,18 @@ class LibraryEditPageTest(StudioLibraryTest): self.assertEqual(len(self.lib_page.xblocks), 1) self.assertEqual(self.lib_page.xblocks[0].locator, second_block_id) + def test_no_edit_visibility_button(self): + """ + Scenario: Ensure that library xblocks do not have 'edit visibility' buttons. + Given I have a library in Studio with no XBlocks + And I navigate to Library Page in Studio + When I add Text XBlock + Then one XBlock is displayed + And no 'edit visibility' button is shown + """ + add_component(self.lib_page, "html", "Text") + self.assertFalse(self.lib_page.xblocks[0].has_edit_visibility_button) + def test_add_edit_xblock(self): """ Scenario: Ensure that we can add an XBlock, edit it, then see the resulting changes.