Skip to content

Commit bd9181b

Browse files
authored
Merge pull request #436 from adobe-commerce-tier-4/PR_2025_05_28
[Support Tier-4 chittima] 05-28-2025 Regular delivery of bugfixes and improvements
2 parents e95a2b4 + b005f94 commit bd9181b

File tree

9 files changed

+343
-15
lines changed

9 files changed

+343
-15
lines changed

app/code/Magento/PageBuilder/Model/Stage/Config.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ private function getAcl()
223223
{
224224
return [
225225
'template_save' => $this->authorization->isAllowed(self::TEMPLATE_SAVE_RESOURCE),
226-
'template_apply' => $this->authorization->isAllowed(self::TEMPLATE_APPLY_RESOURCE)
226+
'template_apply' => $this->authorization->isAllowed(self::TEMPLATE_APPLY_RESOURCE),
227+
'widget' => $this->authorization->isAllowed('Magento_Widget::widget_instance')
227228
];
228229
}
229230

app/code/Magento/PageBuilder/Test/Mftf/Data/TemplateData.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<item name="Magento_Cms::page">Magento_Cms::page</item>
8383
<item name="Magento_Cms::save">Magento_Cms::save</item>
8484
<item name="Magento_PageBuilder::templates">Magento_PageBuilder::templates</item>
85+
<item name="Magento_Widget::widget_instance">Magento_Widget::widget_instance</item>
8586
</array>
8687
</entity>
8788
<entity name="rolePageBuilderSaveTemplates" type="user_role" extends="adminRestrictedProductRole">
@@ -101,6 +102,7 @@
101102
<item name="Magento_Cms::save">Magento_Cms::save</item>
102103
<item name="Magento_PageBuilder::templates">Magento_PageBuilder::templates</item>
103104
<item name="Magento_PageBuilder::template_save">Magento_PageBuilder::template_save</item>
105+
<item name="Magento_Widget::widget_instance">Magento_Widget::widget_instance</item>
104106
</array>
105107
</entity>
106108
<entity name="rolePageBuilderApplyTemplates" type="user_role" extends="adminRestrictedProductRole">
@@ -120,6 +122,7 @@
120122
<item name="Magento_Cms::save">Magento_Cms::save</item>
121123
<item name="Magento_PageBuilder::templates">Magento_PageBuilder::templates</item>
122124
<item name="Magento_PageBuilder::template_apply">Magento_PageBuilder::template_apply</item>
125+
<item name="Magento_Widget::widget_instance">Magento_Widget::widget_instance</item>
123126
</array>
124127
</entity>
125128
<entity name="rolePageBuilderDeleteTemplates" type="user_role" extends="adminRestrictedProductRole">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminPageBuilderProductsForbiddenEditTest">
11+
<annotations>
12+
<features value="PageBuilder"/>
13+
<stories value="Products"/>
14+
<title value="Can't edit products widget"/>
15+
<description value="Clicking products edit widget will display an error."/>
16+
<severity value="MINOR"/>
17+
<useCaseId value="AC-14344"/>
18+
<testCaseId value="ACP2E-3664"/>
19+
<group value="pagebuilder"/>
20+
<group value="pagebuilder-products"/>
21+
<group value="cloud"/>
22+
</annotations>
23+
<before>
24+
<createData entity="_defaultCmsPage" stepKey="createCmsPage"/>
25+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
26+
<createData entity="PageBuilderProductsSubCategory" stepKey="createPreReqCategory"/>
27+
<createData entity="_defaultProduct" stepKey="createPreReqProduct1">
28+
<requiredEntity createDataKey="createPreReqCategory"/>
29+
</createData>
30+
<createData entity="_defaultProduct" stepKey="createPreReqProduct2">
31+
<requiredEntity createDataKey="createPreReqCategory"/>
32+
</createData>
33+
<amOnPage url="{{AdminCmsPageEditPage.url($$createCmsPage.id$$)}}" stepKey="openEditCmsPage"/>
34+
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage"/>
35+
<actionGroup ref="dragContentTypeToStage" stepKey="dragRowToRootContainer">
36+
<argument name="contentType" value="PageBuilderRowContentType"/>
37+
<argument name="containerTargetType" value="PageBuilderRootContainerContentType"/>
38+
</actionGroup>
39+
</before>
40+
<after>
41+
<deleteData createDataKey="createPreReqProduct1" stepKey="deletePreReqProduct1"/>
42+
<deleteData createDataKey="createPreReqProduct2" stepKey="deletePreReqProduct2"/>
43+
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
44+
<deleteData createDataKey="createCmsPage" stepKey="deleteCreateCmsPage"/>
45+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutExistingUser"/>
46+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdminClean"/>
47+
<!--Delete created user-->
48+
<actionGroup ref="AdminDeleteUserActionGroup" stepKey="deleteRestrictedAdmin">
49+
<argument name="user" value="NewAdminUser"/>
50+
</actionGroup>
51+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilterAfterDeletingNewAdminUser"/>
52+
<!--Delete created user role-->
53+
<actionGroup ref="AdminDeleteCreatedRoleActionGroup" stepKey="deleteRestrictedRole">
54+
<argument name="role" value="adminRole"/>
55+
</actionGroup>
56+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
57+
</after>
58+
<actionGroup ref="addPageBuilderPageTitle" stepKey="enterPageTitle">
59+
<argument name="contentType" value="PageBuilderProductsContentType"/>
60+
</actionGroup>
61+
<actionGroup ref="expandPageBuilderPanelMenuSection" stepKey="expandMenuSectionAddContent">
62+
<argument name="contentType" value="PageBuilderProductsContentType"/>
63+
</actionGroup>
64+
<actionGroup ref="dragContentTypeToStage" stepKey="dragProductsIntoStage">
65+
<argument name="contentType" value="PageBuilderProductsContentType"/>
66+
</actionGroup>
67+
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditAfterDrop">
68+
<argument name="contentType" value="PageBuilderProductsContentType"/>
69+
</actionGroup>
70+
<actionGroup ref="chooseVisualSelectOption" stepKey="chooseSelectProductsBy">
71+
<argument name="property" value="PageBuilderProductsSelectProductsByCondition"/>
72+
</actionGroup>
73+
<actionGroup ref="addConditionToProductConditions" stepKey="addCategory">
74+
<argument name="conditionInput" value="$$createPreReqCategory.id$$"/>
75+
</actionGroup>
76+
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings"/>
77+
<actionGroup ref="exitPageBuilderFullScreen" stepKey="exitPageBuilderFullScreen"/>
78+
<actionGroup ref="SaveAndContinueEditCmsPageActionGroup" stepKey="saveAndContinueEditCmsPage"/>
79+
80+
<!--Create user role with resource access-->
81+
<actionGroup ref="AdminStartCreateUserRoleActionGroup" stepKey="startCreateUserRole">
82+
<argument name="roleName" value="{{adminRole.name}}"/>
83+
<argument name="userPassword" value="{{_CREDS.magento/MAGENTO_ADMIN_PASSWORD}}"/>
84+
<argument name="resourceAccess" value="Custom"/>
85+
<argument name="storeName" value="{{_defaultWebsite.name}}"/>
86+
</actionGroup>
87+
<actionGroup ref="AdminSelectUserRoleResourceActionGroup" stepKey="addCategoryAccess">
88+
<argument name="resourceId" value="Magento_Catalog::categories_anchor"/>
89+
</actionGroup>
90+
<actionGroup ref="AdminSelectUserRoleResourceActionGroup" stepKey="addPageAccess">
91+
<argument name="resourceId" value="Magento_Cms::page_anchor"/>
92+
</actionGroup>
93+
<actionGroup ref="AdminSaveUserRoleActionGroup" stepKey="saveRole"/>
94+
95+
<!--Create user role-->
96+
<actionGroup ref="AdminCreateUserWithRoleActionGroup" stepKey="createRestrictedAdmin">
97+
<argument name="role" value="adminRole"/>
98+
<argument name="user" value="NewAdminUser"/>
99+
</actionGroup>
100+
101+
<!-- Login as newly created admin user -->
102+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
103+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsRestrictedAdmin">
104+
<argument name="username" value="{{NewAdminUser.username}}"/>
105+
<argument name="password" value="{{NewAdminUser.password}}"/>
106+
</actionGroup>
107+
108+
<amOnPage url="{{AdminCmsPageEditPage.url($$createCmsPage.id$$)}}" stepKey="openEditCmsPageSecond"/>
109+
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage2"/>
110+
<waitForElementVisible selector="{{AdminGridConfirmActionSection.message}}" stepKey="waitForConfirmModal"/>
111+
<see selector="{{AdminGridConfirmActionSection.message}}" userInput="Sorry, you need permissions to view this content." stepKey="seeForbiddenMessage"/>
112+
</test>
113+
</tests>

app/code/Magento/PageBuilder/etc/graphql/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
<type name="Magento\Framework\Filter\Template">
1010
<plugin name="convertBackgroundImages" type="Magento\PageBuilder\Plugin\Filter\TemplatePlugin" disabled="true"/>
1111
</type>
12+
<type name="Magento\CatalogWidget\Block\Product\ProductsList">
13+
<plugin name="pagebuilder_product_list" type="Magento\PageBuilder\Plugin\Catalog\Block\Product\ProductsListPlugin" sortOrder="1"/>
14+
</type>
1215
</config>

app/code/Magento/PageBuilder/i18n/en_US.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,5 @@ OK,OK
323323
"Save Content as Template","Save Content as Template"
324324
"Template Name","Template Name"
325325
"Could not delete the Template: %1","Could not delete the Template: %1"
326+
"Forbidden. You do not have permission to perform this action.","Forbidden. You do not have permission to perform this action."
327+
"Permission Error","Permission Error"

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/conditions-loader.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
/**
2+
* Copyright 2018 Adobe
3+
* All Rights Reserved.
4+
*/
15
define([
26
'jquery',
37
'Magento_Rule/rules',
48
'uiRegistry',
59
'mage/utils/objects'
610
], function ($, RulesForm, uiRegistry, objectUtils) {
7-
'use strict';
11+
'use strict'; // eslint-disable-line strict
812

913
return function (config, conditionsFormPlaceholder) {
1014
var $conditionsFormPlaceholder = $(conditionsFormPlaceholder),
@@ -18,11 +22,28 @@ define([
1822
data: {
1923
conditions: conditions
2024
}
21-
})
22-
.done(function (response) {
25+
}).done(function (response) {
2326
$conditionsFormPlaceholder.html(response);
2427
window[config.jsObjectName] = new RulesForm(config.jsObjectName, config.childComponentUrl);
2528
$('body').trigger('processStop');
29+
}).fail(function (response) {
30+
if (response.status === 403) {
31+
$('body').notification('clear');
32+
$('body').notification('add', {
33+
error: true,
34+
message: $.mage.__(
35+
'Forbidden. You do not have permission to perform this action.'
36+
),
37+
insertMethod: function (message) {
38+
var $wrapper = $('<div></div>').html(message);
39+
40+
$('.page-main-actions').after($wrapper);
41+
}
42+
});
43+
$('.save.primary').attr('disabled', true);
44+
$('body').trigger('processStop');
45+
}
46+
this.loading(false);
2647
});
2748
};
2849
});

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/product-totals.js

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2019 Adobe
3+
* All Rights Reserved.
44
*/
55

66
define([
@@ -10,7 +10,7 @@ define([
1010
'Magento_PageBuilder/js/form/provider/conditions-data-processor',
1111
'Magento_Ui/js/form/element/abstract'
1212
], function (_, $, $t, conditionsDataProcessor, Abstract) {
13-
'use strict';
13+
'use strict'; // eslint-disable-line strict
1414

1515
return Abstract.extend({
1616
defaults: {
@@ -62,12 +62,37 @@ define([
6262
* @param {Object} jqXHR
6363
*/
6464
callSuperError: function (jqXHR) {
65-
// eslint-disable-next-line jquery-no-bind-unbind
65+
/* eslint-disable */
6666
var superError = $.ajaxSettings.error.bind(window, jqXHR);
67+
/* eslint-enable */
6768

6869
superError();
6970
},
7071

72+
/**
73+
* Show upload error message
74+
*/
75+
showForbiddenErrorMessage: function () {
76+
let bodyObj = $('body');
77+
78+
bodyObj.notification('clear');
79+
bodyObj.notification('add', {
80+
error: true,
81+
message: $.mage.__(
82+
'Forbidden. You do not have permission to perform this action.'
83+
),
84+
85+
/**
86+
* @param {String} message
87+
*/
88+
insertMethod: function (message) {
89+
let $wrapper = $('<div></div>').html(message);
90+
91+
$('.page-main-actions').after($wrapper);
92+
}
93+
});
94+
},
95+
7196
/**
7297
* Update product count.
7398
*/
@@ -128,7 +153,13 @@ define([
128153
this.loading(false);
129154
}.bind(this)).fail(function () {
130155
if (this.jqXHR.statusText !== 'abort') {
131-
this.value($t('An unknown error occurred. Please try again.'));
156+
if (this.jqXHR.status === 403) {
157+
this.showForbiddenErrorMessage();
158+
$('.save.primary').attr('disabled', true);
159+
$('body').trigger('processStop');
160+
} else {
161+
this.value($t('An unknown error occurred. Please try again.'));
162+
}
132163
}
133164
this.loading(false);
134165
}.bind(this));

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/wysiwyg.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2017 Adobe
3+
* All Rights Reserved.
44
*/
55

66
define([
@@ -11,9 +11,10 @@ define([
1111
'Magento_PageBuilder/js/events',
1212
'Magento_Ui/js/lib/view/utils/dom-observer',
1313
'Magento_PageBuilder/js/page-builder',
14+
'Magento_Ui/js/modal/alert',
1415
'Magento_Ui/js/lib/view/utils/async'
15-
], function ($, _, Wysiwyg, $t, events, domObserver, PageBuilder) {
16-
'use strict';
16+
], function ($, _, Wysiwyg, $t, events, domObserver, PageBuilder, alertDialog) {
17+
'use strict'; // eslint-disable-line strict
1718

1819
/**
1920
* Extend the original WYSIWYG with added PageBuilder functionality
@@ -67,6 +68,15 @@ define([
6768
* Handle button click, init the Page Builder application
6869
*/
6970
pageBuilderEditButtonClick: function (context, event) {
71+
let aclResource = this.pageBuilder.config && this.pageBuilder.config.acl;
72+
73+
if (aclResource !== undefined && aclResource.widget === false) {
74+
return alertDialog({
75+
content: $t('Sorry, you need permissions to view this content.'),
76+
title: $t('Permission Error')
77+
});
78+
}
79+
7080
this.determineIfWithinModal(event.currentTarget);
7181
this.transition(false);
7282

@@ -85,8 +95,8 @@ define([
8595
if (!this.isComponentInitialized()) {
8696
this.loading(true);
8797
this.pageBuilder = new PageBuilder(
88-
this.wysiwygConfigData(),
89-
this.initialValue
98+
this.wysiwygConfigData(),
99+
this.initialValue
90100
);
91101
if (!this.source.get('pageBuilderInstances')) {
92102
this.source.set('pageBuilderInstances', []);

0 commit comments

Comments
 (0)