Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cms/static/js/spec/views/pages/container_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ function parameterized_suite(label, globalPageOptions) {
});
});

describe('Add component buttons when embedded in the authoring MFE', function() {
it('removes the buttons for a unit, since the MFE renders its own', function() {
renderContainerPage(this, mockContainerXBlockHtml, {isIframeEmbed: true});
expect(containerPage.$('.add-xblock-component').length).toBe(0);
});

it('keeps the buttons for a content experiment, where the MFE renders none', function() {
model.set('category', 'split_test');
renderContainerPage(this, mockContainerXBlockHtml, {isIframeEmbed: true});
// One panel per experiment group, each with its own component buttons.
expect(containerPage.$('.add-xblock-component').length).toBe(2);
expect(containerPage.$('.add-xblock-component-button').length).toBeGreaterThan(0);
});
});

describe('Editing the container', function() {
var updatedDisplayName = 'Updated Test Container',
getDisplayNameWrapper;
Expand Down
11 changes: 7 additions & 4 deletions cms/static/js/views/pages/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,13 @@ function($, _, Backbone, gettext, BasePage,

renderAddXBlockComponents: function() {
var self = this;
// When rendered inside the authoring MFE iframe, add buttons are always rendered
// natively by the MFE (for every container type, not just verticals), so the
// legacy add-button widgets must never be initialised here.
if (self.options.canEdit && !self.options.isIframeEmbed) {
// When rendered inside the authoring MFE iframe, add buttons are normally rendered
// natively by the MFE, so the legacy add-button widgets must not be initialised here.
// Content experiments (split_test) are the exception: the MFE renders no add buttons
// for them, because each group needs its own set of buttons next to its children,
// which only this page can place. The rest of that flow is already iframe-aware --
// see the split_test branches in createComponent() and in add_xblock.js.
if (self.options.canEdit && (!self.options.isIframeEmbed || self.isSplitTestContentPage)) {
this.$('.add-xblock-component').each(function(index, element) {
var component = new AddXBlockComponent({
el: element,
Expand Down
Loading