fix: Hide Copy menu button in ContentLibrary (#33276)
Since the Copy/Paste functionality has not been implemented for ContentLibraries yet, the "Copy to Clipboard" button should not appear in both the ContentLibrary page.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -104,9 +104,15 @@ block_is_unit = is_unit(xblock)
|
||||
<div class="nav-sub">
|
||||
<ul>
|
||||
% if not show_inline:
|
||||
<li class="nav-item">
|
||||
<a class="copy-button" href="#" role="button">${_("Copy to Clipboard")}</a>
|
||||
</li>
|
||||
% if is_course:
|
||||
<!--
|
||||
Only show the "Copy to Clipboard" button for xblocks inside courses since
|
||||
the copy/paste functionality is not yet implemented for LibraryContent.
|
||||
-->
|
||||
<li class="nav-item">
|
||||
<a class="copy-button" href="#" role="button">${_("Copy to Clipboard")}</a>
|
||||
</li>
|
||||
% endif
|
||||
% if can_add:
|
||||
<li class="nav-item">
|
||||
<a class="duplicate-button" href="#" role="button">${_("Duplicate")}</a>
|
||||
|
||||
Reference in New Issue
Block a user