Skip to content

Commit 2aed65a

Browse files
committed
Merge branch '2.3-develop-main' into MAGETWO-42047-banner-MFTF-updated
# Conflicts: # app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js # dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsNewPagePageContentSection.xml # dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/AdminAddImageToWYSIWYGBlockCest.xml # dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/AdminAddVariableToWYSIWYGBlockCest.xml # dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/AdminAddVariableToWYSIWYGCMSCest.xml # dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/AdminAddWidgetToWYSIWYGBlockCest.xml # dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml # dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml # dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml # lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js
2 parents 1484130 + 0dce94d commit 2aed65a

File tree

21 files changed

+638
-474
lines changed

21 files changed

+638
-474
lines changed

app/code/Magento/Catalog/view/frontend/web/js/storage-manager.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ define([
161161
*/
162162
initUpdateStorageDataListener: function () {
163163
_.each(this.storagesNamespace, function (name) {
164-
this[name].data.subscribe(this.updateDataHandler.bind(this, name));
164+
if (this[name].data) {
165+
this[name].data.subscribe(this.updateDataHandler.bind(this, name));
166+
}
165167
}.bind(this));
166168
},
167169

app/code/Magento/Cms/Helper/Wysiwyg/Images.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Images extends \Magento\Framework\App\Helper\AbstractHelper
3030
*
3131
* @var int
3232
*/
33-
protected $_storeId = null;
33+
protected $_storeId;
3434

3535
/**
3636
* @var \Magento\Framework\Filesystem\Directory\Write
@@ -159,7 +159,7 @@ public function convertIdToPath($id)
159159
*/
160160
public function isUsingStaticUrlsAllowed()
161161
{
162-
$checkResult = new \StdClass();
162+
$checkResult = (object) [];
163163
$checkResult->isAllowed = false;
164164
$this->_eventManager->dispatch(
165165
'cms_wysiwyg_images_static_urls_allowed',

app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ define([
132132

133133
ed.onInit.add(self.onEditorInit.bind(self));
134134

135+
ed.onInit.add(function (editor) {
136+
varienGlobalEvents.fireEvent('wysiwygEditorInitialized', editor);
137+
});
138+
135139
ed.onSubmit.add(function (edi, e) {
136140
varienGlobalEvents.fireEvent('tinymceSubmit', e);
137141
});
@@ -244,6 +248,13 @@ define([
244248
return tinyMCE3.get(id);
245249
},
246250

251+
/**
252+
* @return {String|null}
253+
*/
254+
getId: function () {
255+
return this.id || (this.activeEditor() ? this.activeEditor().id : null) || tinyMceEditors.values()[0].id;
256+
},
257+
247258
/**
248259
* @return {Object}
249260
*/
@@ -261,6 +272,35 @@ define([
261272
this.activeEditor().execCommand('mceInsertContent', typeof ui !== 'undefined' ? ui : false, content);
262273
},
263274

275+
/**
276+
* Set the status of the toolbar to disabled or enabled (true for enabled, false for disabled)
277+
* @param {Boolean} enabled
278+
*/
279+
setToolbarStatus: function (enabled) {
280+
_.each(this.activeEditor().controlManager.controls, function (property, index, controls) {
281+
controls[property.id].setDisabled(!enabled);
282+
});
283+
},
284+
285+
/**
286+
* Set the status of the editor and toolbar
287+
*
288+
* @param {Boolean} enabled
289+
*/
290+
setEnabledStatus: function (enabled) {
291+
if (this.activeEditor()) {
292+
this.activeEditor().getBody().setAttribute('contenteditable', enabled);
293+
this.activeEditor().readonly = !enabled;
294+
this.setToolbarStatus(enabled);
295+
}
296+
297+
if (enabled) {
298+
this.getTextArea().removeProp('disabled');
299+
} else {
300+
this.getTextArea().prop('disabled', 'disabled');
301+
}
302+
},
303+
264304
/**
265305
* Set caret location in WYSIWYG editor.
266306
*
@@ -279,7 +319,7 @@ define([
279319
storeId = this.config['store_id'] !== null ? this.config['store_id'] : 0,
280320
frameDialog = jQuery(o.win.frameElement).parents('[role="dialog"]'),
281321
wUrl = this.config['files_browser_window_url'] +
282-
'target_element_id/' + this.id + '/' +
322+
'target_element_id/' + this.getId() + '/' +
283323
'store/' + storeId + '/';
284324

285325
this.mediaBrowserOpener = o.win;
@@ -331,14 +371,14 @@ define([
331371
* @return {jQuery|*|HTMLElement}
332372
*/
333373
getToggleButton: function () {
334-
return $('toggle' + this.id);
374+
return $('toggle' + this.getId());
335375
},
336376

337377
/**
338378
* Get plugins button.
339379
*/
340380
getPluginButtons: function () {
341-
return $$('#buttons' + this.id + ' > button.plugin');
381+
return jQuery('#buttons' + this.getId() + ' > button.plugin');
342382
},
343383

344384
/**
@@ -350,11 +390,9 @@ define([
350390

351391
this.setup(mode);
352392

353-
tinyMCE3.execCommand('mceAddControl', false, this.id);
393+
tinyMCE3.execCommand('mceAddControl', false, this.getId());
354394

355-
this.getPluginButtons().each(function (e) {
356-
e.hide();
357-
});
395+
this.getPluginButtons().hide();
358396

359397
return this;
360398
},
@@ -365,11 +403,9 @@ define([
365403
turnOff: function () {
366404
this.closePopups();
367405

368-
tinyMCE3.execCommand('mceRemoveControl', false, this.id);
406+
tinyMCE3.execCommand('mceRemoveControl', false, this.getId());
369407

370-
this.getPluginButtons().each(function (e) {
371-
e.show();
372-
});
408+
this.getPluginButtons().show();
373409

374410
return this;
375411
},
@@ -380,16 +416,16 @@ define([
380416
closePopups: function () {
381417
if (typeof closeEditorPopup == 'function') {
382418
// close all popups to avoid problems with updating parent content area
383-
closeEditorPopup('widget_window' + this.id);
384-
closeEditorPopup('browser_window' + this.id);
419+
closeEditorPopup('widget_window' + this.getId());
420+
closeEditorPopup('browser_window' + this.getId());
385421
}
386422
},
387423

388424
/**
389425
* @return {Boolean}
390426
*/
391427
toggle: function () {
392-
if (!tinyMCE3.get(this.id)) {
428+
if (!tinyMCE3.get(this.getId())) {
393429
this.turnOn();
394430

395431
return true;
@@ -415,8 +451,8 @@ define([
415451
* On form validation.
416452
*/
417453
onFormValidation: function () {
418-
if (tinyMCE3.get(this.id)) {
419-
$(this.id).value = tinyMCE3.get(this.id).getContent();
454+
if (tinyMCE3.get(this.getId())) {
455+
$(this.getId()).value = tinyMCE3.get(this.getId()).getContent();
420456
}
421457
},
422458

@@ -552,7 +588,7 @@ define([
552588
* Update text area.
553589
*/
554590
updateTextArea: function () {
555-
var editor = tinyMCE3.get(this.id),
591+
var editor = tinyMCE3.get(this.getId()),
556592
content;
557593

558594
if (!editor) {
@@ -562,7 +598,14 @@ define([
562598
content = editor.getContent();
563599
content = this.decodeContent(content);
564600

565-
jQuery('#' + this.id).val(content).trigger('change');
601+
this.getTextArea().val(content).trigger('change');
602+
},
603+
604+
/**
605+
* @return {Object} jQuery textarea element
606+
*/
607+
getTextArea: function () {
608+
return jQuery('#' + this.getId());
566609
},
567610

568611
/**

app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ define([
1212
'underscore',
1313
'ko',
1414
'./abstract',
15+
'mage/adminhtml/events',
1516
'Magento_Variable/variables'
16-
], function (wysiwyg, $, _, ko, Abstract) {
17+
], function (wysiwyg, $, _, ko, Abstract, varienGlobalEvents) {
1718
'use strict';
1819

1920
return Abstract.extend({
@@ -49,6 +50,13 @@ define([
4950
this.$wysiwygEditorButton = $(element);
5051
}.bind(this));
5152

53+
// disable editor completely after initialization is field is disabled
54+
varienGlobalEvents.attachEventHandler('wysiwygEditorInitialized', function () {
55+
if (this.disabled()) {
56+
this.setDisabled(true);
57+
}
58+
}.bind(this));
59+
5260
return this;
5361
},
5462

@@ -89,25 +97,22 @@ define([
8997
/**
9098
* Set disabled property to wysiwyg component
9199
*
92-
* @param {Boolean} status
100+
* @param {Boolean} disabled
93101
*/
94-
setDisabled: function (status) {
95-
if (this.$wysiwygEditorButton) {
96-
this.$wysiwygEditorButton.attr('disabled', status);
102+
setDisabled: function (disabled) {
103+
if (this.$wysiwygEditorButton && disabled) {
104+
this.$wysiwygEditorButton.prop('disabled', 'disabled');
105+
} else if (this.$wysiwygEditorButton) {
106+
this.$wysiwygEditorButton.removeProp('disabled');
97107
}
98108

99-
/* eslint-disable no-undef */
100-
if (typeof wysiwyg !== 'undefined' && wysiwyg.activeEditor()) {
101-
102-
if (typeof wysiwyg.activeEditor().controlManager !== 'undefined') {
103-
_.each(wysiwyg.activeEditor().controlManager.controls, function (property, index, controls) {
104-
controls[property.id].setDisabled(status);
105-
});
106-
}
107-
108-
wysiwyg.activeEditor().getBody().setAttribute('contenteditable', !status);
109+
if (wysiwyg && disabled) {
110+
wysiwyg.setEnabledStatus(false);
111+
wysiwyg.getPluginButtons().prop('disabled', 'disabled');
112+
} else if (wysiwyg) {
113+
wysiwyg.setEnabledStatus(true);
114+
wysiwyg.getPluginButtons().removeProp('disabled');
109115
}
110-
/* eslint-enable no-undef*/
111116
}
112117
});
113118
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="SortByIdDescendingActionGroup">
12+
<conditionalClick selector="//div[contains(@data-role, 'grid-wrapper')]/table/thead/tr/th/span[contains(text(), 'ID')]" dependentSelector="//span[contains(text(), 'ID')]/parent::th[not(contains(@class, '_descend'))]/parent::tr/parent::thead/parent::table/parent::div[contains(@data-role, 'grid-wrapper')]" stepKey="clickToAttemptSortByIdDescending" visible="true"/>
13+
<waitForLoadingMaskToDisappear stepKey="waitForFirstIdSortDescendingToFinish" />
14+
<!-- Conditional Click again in case it goes from default state to ascending on first click -->
15+
<conditionalClick selector="//div[contains(@data-role, 'grid-wrapper')]/table/thead/tr/th/span[contains(text(), 'ID')]" dependentSelector="//span[contains(text(), 'ID')]/parent::th[not(contains(@class, '_descend'))]/parent::tr/parent::thead/parent::table/parent::div[contains(@data-role, 'grid-wrapper')]" stepKey="secondClickToAttemptSortByIdDescending" visible="true"/>
16+
<waitForLoadingMaskToDisappear stepKey="waitForSecondIdSortDescendingToFinish" />
17+
</actionGroup>
18+
</actionGroups>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/AdminEditTextEditorProductAttributeCest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<waitForPageLoad stepKey="waitForPageLoad8"/>
6666
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="amOnProductGrid" />
6767
<waitForPageLoad stepKey="waitForPageLoad9"/>
68+
<actionGroup ref="SortByIdDescendingActionGroup" stepKey="sortByIdDescending" />
6869
<click selector="{{AdminProductGridActionSection.productName(_defaultProduct.name)}}" stepKey="navigateToEditProduct" />
6970
<waitForPageLoad stepKey="waitForPageLoad10" />
7071
<seeElement selector="{{ProductAttributeWYSIWYGSection.TinyMCE4($$myProductAttributeCreation.attribute_code$$)}}" stepKey="waitForPageLoad11"/>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/AdminAddImageToWYSIWYGBlockCest.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<description value="Admin should be able to add image to WYSIWYG content of Block"/>
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MAGETWO-84376"/>
19-
<group value="skip" />
2019
</annotations>
2120
<before>
2221
<createData entity="_defaultCmsPage" stepKey="createCMSPage" />
@@ -78,8 +77,8 @@
7877
<fillField selector="{{CmsPagesPageActionsSection.URLKey}}" userInput="$$createCMSPage.identifier$$" stepKey="fillOutURLKey" />
7978
<click selector="{{CmsPagesPageActionsSection.ApplyFiltersBtn}}" stepKey="clickApplyBtn" />
8079
<waitForLoadingMaskToDisappear stepKey="waitForLoading9" />
80+
<actionGroup ref="SortByIdDescendingActionGroup" stepKey="sortByIdDescending" />
8181
<waitForElementVisible selector="{{CmsPagesPageActionsSection.select('$$createCMSPage.identifier$$')}}" stepKey="waitForCMSPageGrid" />
82-
<scrollTo selector="{{CmsPagesPageActionsSection.select('$$createCMSPage.identifier$$')}}" stepKey="scrollToCMSPage" />
8382
<click selector="{{CmsPagesPageActionsSection.select('$$createCMSPage.identifier$$')}}" stepKey="clickSelect" />
8483
<waitForElementVisible selector="{{CmsPagesPageActionsSection.edit('$$createCMSPage.identifier$$')}}" stepKey="waitForEditLink" />
8584
<click selector="{{CmsPagesPageActionsSection.edit('$$createCMSPage.identifier$$')}}" stepKey="clickEdit" />
@@ -93,11 +92,13 @@
9392
<waitForLoadingMaskToDisappear stepKey="waitForLoading7" />
9493
<selectOption selector="{{WidgetSection.WidgetTemplate}}" userInput="CMS Static Block Default Template" stepKey="selectTemplate" />
9594
<click selector="{{WidgetSection.BtnChooser}}" stepKey="clickSelectPageBtn" />
95+
<waitForLoadingMaskToDisappear stepKey="waitForLoading8" />
96+
<actionGroup ref="SortByIdDescendingActionGroup" stepKey="sortByIdDescending2" />
9697
<waitForElementVisible selector="{{WidgetSection.BlockPage(_defaultBlock.identifier)}}" stepKey="waitForBlockTitle" />
9798
<click selector="{{WidgetSection.BlockPage(_defaultBlock.identifier)}}" stepKey="selectPreCreateBlock" />
9899
<wait time="3" stepKey="wait1" />
99100
<click selector="{{WidgetSection.InsertWidget}}" stepKey="clickInsertWidgetBtn" />
100-
<waitForLoadingMaskToDisappear stepKey="waitForLoading8" />
101+
<waitForLoadingMaskToDisappear stepKey="waitForLoading9" />
101102
<waitForPageLoad stepKey="waitForPageLoad9" />
102103
<click selector="{{CmsNewPagePageActionsSection.savePage}}" stepKey="clickSavePage"/>
103104
<waitForPageLoad stepKey="waitForPageLoad10"/>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/AdminAddImageToWYSIWYGCMSCest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<title value="Admin should be able to add image to WYSIWYG content of CMS Page"/>
1616
<description value="Admin should be able to add image to WYSIWYG content of CMS Page"/>
1717
<severity value="CRITICAL"/>
18-
<testCaseId value="MAGETWO-85825 "/>
18+
<testCaseId value="MAGETWO-85825"/>
1919
</annotations>
2020
<before>
2121
<actionGroup ref="LoginActionGroup" stepKey="login"/>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Test/AdminAddVariableToWYSIWYGBlockCest.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
<title value="Admin should be able to add variable to WYSIWYG content of Block"/>
1616
<description value="You should be able to add variable to WYSIWYG content Block"/>
1717
<testCaseId value="MAGETWO-84378"/>
18-
<group value="skip" />
19-
<!--Bug link MAGETWO-86383-->
2018
</annotations>
2119
<before>
2220
<createData entity="_defaultCmsPage" stepKey="createCMSPage" />
@@ -84,6 +82,8 @@
8482
<fillField selector="{{CmsPagesPageActionsSection.URLKey}}" userInput="$$createCMSPage.identifier$$" stepKey="fillOutURLKey" />
8583
<click selector="{{CmsPagesPageActionsSection.ApplyFiltersBtn}}" stepKey="clickApplyBtn" />
8684
<waitForLoadingMaskToDisappear stepKey="waitForLoading2" />
85+
<actionGroup ref="SortByIdDescendingActionGroup" stepKey="sortByIdDescending" />
86+
<waitForElementVisible selector="{{CmsPagesPageActionsSection.select('$$createCMSPage.identifier$$')}}" stepKey="waitForCMSPageGrid" />
8787
<click selector="{{CmsPagesPageActionsSection.select('$$createCMSPage.identifier$$')}}" stepKey="clickSelect" />
8888
<waitForElementVisible selector="{{CmsPagesPageActionsSection.edit('$$createCMSPage.identifier$$')}}" stepKey="waitForEditLink" />
8989
<click selector="{{CmsPagesPageActionsSection.edit('$$createCMSPage.identifier$$')}}" stepKey="clickEdit" />
@@ -97,13 +97,17 @@
9797
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear" />
9898
<selectOption selector="{{WidgetSection.WidgetTemplate}}" userInput="CMS Static Block Default Template" stepKey="selectTemplate" />
9999
<click selector="{{WidgetSection.BtnChooser}}" stepKey="clickSelectPageBtn" />
100+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappearAfterClickingBtnChooser" />
101+
<actionGroup ref="SortByIdDescendingActionGroup" stepKey="sortByIdDescending2" />
100102
<waitForElementVisible selector="{{WidgetSection.BlockPage(_defaultBlock.identifier)}}" stepKey="waitForBlockTitle" />
101103
<click selector="{{WidgetSection.BlockPage(_defaultBlock.identifier)}}" stepKey="selectPreCreateBlock" />
102104
<wait time="3" stepKey="wait1" />
103105
<click selector="{{WidgetSection.InsertWidget}}" stepKey="clickInsertWidgetBtn" />
104106
<waitForLoadingMaskToDisappear stepKey="waitForLoading" />
105107
<waitForPageLoad stepKey="waitForPageLoad10" />
108+
<waitForElementVisible selector="{{CmsNewPagePageActionsSection.savePage}}" stepKey="waitForSaveButtonVisible"/>
106109
<click selector="{{CmsNewPagePageActionsSection.savePage}}" stepKey="clickSavePage"/>
110+
<waitForPageLoad stepKey="waitForPageLoadAfterSaveCmsPage" />
107111
<see userInput="You saved the page." stepKey="seeSuccessMessage"/>
108112
<amOnPage url="$$createCMSPage.identifier$$" stepKey="amOnPageTestPage1"/>
109113
<waitForPageLoad stepKey="waitForPageLoad11" />

0 commit comments

Comments
 (0)