diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 5ee2740abe..48c323c1aa 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -313,7 +313,8 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False): 'selected_groups_label': selected_groups_label, 'can_add': context.get('can_add', True), 'can_move': context.get('can_move', is_course), - 'language': getattr(course, 'language', None) + 'language': getattr(course, 'language', None), + 'is_course': is_course } add_webpack_js_to_fragment(frag, "js/factories/xblock_validation") diff --git a/cms/static/js/views/pages/container.js b/cms/static/js/views/pages/container.js index 122556c76a..8f296ebb6b 100644 --- a/cms/static/js/views/pages/container.js +++ b/cms/static/js/views/pages/container.js @@ -48,6 +48,7 @@ function($, _, Backbone, gettext, BasePage, ViewUtils, ContainerView, XBlockView BasePage.prototype.initialize.call(this, options); this.viewClass = options.viewClass || this.defaultViewClass; this.isLibraryPage = (this.model.attributes.category === 'library'); + this.isLibraryContentPage = (this.model.attributes.category === 'library_content'); this.nameEditor = new XBlockStringFieldEditor({ el: this.$('.wrapper-xblock-field'), model: this.model @@ -154,7 +155,7 @@ function($, _, Backbone, gettext, BasePage, ViewUtils, ContainerView, XBlockView self.delegateEvents(); // Show/hide the paste button - if (!self.isLibraryPage) { + if (!self.isLibraryPage && !self.isLibraryContentPage) { self.initializePasteButton(); } }, @@ -208,32 +209,36 @@ function($, _, Backbone, gettext, BasePage, ViewUtils, ContainerView, XBlockView * Given the latest information about the user's clipboard, hide or show the Paste button as appropriate. */ refreshPasteButton(data) { - // 'data' is the same data returned by the "get clipboard status" API endpoint - // i.e. /api/content-staging/v1/clipboard/ - if (this.options.canEdit && data.content) { - if (["vertical", "sequential", "chapter", "course"].includes(data.content.block_type)) { - // This is not suitable for pasting into a unit. - this.$(".paste-component").hide(); - } else if (data.content.status === "expired") { - // This has expired and can no longer be pasted. - this.$(".paste-component").hide(); - } else { - // The thing in the clipboard can be pasted into this unit: - const detailsPopupEl = this.$(".clipboard-details-popup")[0]; - detailsPopupEl.querySelector(".detail-block-name").innerText = data.content.display_name; - detailsPopupEl.querySelector(".detail-block-type").innerText = data.content.block_type_display; - detailsPopupEl.querySelector(".detail-course-name").innerText = data.source_context_title; - if (data.source_edit_url) { - detailsPopupEl.setAttribute("href", data.source_edit_url); - detailsPopupEl.classList.remove("no-edit-link"); + // Do not perform any changes on paste button since they are not + // rendered on Library or LibraryContent pages + if (!this.isLibraryPage && !this.isLibraryContentPage) { + // 'data' is the same data returned by the "get clipboard status" API endpoint + // i.e. /api/content-staging/v1/clipboard/ + if (this.options.canEdit && data.content) { + if (["vertical", "sequential", "chapter", "course"].includes(data.content.block_type)) { + // This is not suitable for pasting into a unit. + this.$(".paste-component").hide(); + } else if (data.content.status === "expired") { + // This has expired and can no longer be pasted. + this.$(".paste-component").hide(); } else { - detailsPopupEl.setAttribute("href", "#"); - detailsPopupEl.classList.add("no-edit-link"); + // The thing in the clipboard can be pasted into this unit: + const detailsPopupEl = this.$(".clipboard-details-popup")[0]; + detailsPopupEl.querySelector(".detail-block-name").innerText = data.content.display_name; + detailsPopupEl.querySelector(".detail-block-type").innerText = data.content.block_type_display; + detailsPopupEl.querySelector(".detail-course-name").innerText = data.source_context_title; + if (data.source_edit_url) { + detailsPopupEl.setAttribute("href", data.source_edit_url); + detailsPopupEl.classList.remove("no-edit-link"); + } else { + detailsPopupEl.setAttribute("href", "#"); + detailsPopupEl.classList.add("no-edit-link"); + } + this.$(".paste-component").show(); } - this.$(".paste-component").show(); + } else { + this.$(".paste-component").hide(); } - } else { - this.$(".paste-component").hide(); } }, diff --git a/cms/templates/studio_xblock_wrapper.html b/cms/templates/studio_xblock_wrapper.html index fa48a905cc..a027cc764b 100644 --- a/cms/templates/studio_xblock_wrapper.html +++ b/cms/templates/studio_xblock_wrapper.html @@ -104,9 +104,15 @@ block_is_unit = is_unit(xblock)