Skip to content

Commit 47fbaa8

Browse files
committed
Merge remote-tracking branch 'magento-l3/ACP2E-1646' into APR222023_PR_sarmistha
2 parents 0715b07 + c147926 commit 47fbaa8

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

app/code/Magento/PageBuilder/Component/Form/Element/Wysiwyg.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\PageBuilder\Model\Config as PageBuilderConfig;
1919
use Magento\PageBuilder\Model\State as PageBuilderState;
2020
use Magento\PageBuilder\Model\Stage\Config as Config;
21+
use Magento\Framework\AuthorizationInterface;
2122

2223
/**
2324
* Updates wysiwyg element with Page Builder specific config
@@ -26,11 +27,19 @@
2627
*/
2728
class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
2829
{
30+
31+
private const ADMIN_RESOURCE = 'Magento_Backend::content';
32+
2933
/**
3034
* @var Repository
3135
*/
3236
private $assetRepo;
3337

38+
/**
39+
* @var AuthorizationInterface
40+
*/
41+
private $authorization;
42+
3443
/**
3544
* WYSIWYG Constructor
3645
*
@@ -46,6 +55,7 @@ class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
4655
* @param PageBuilderConfig|null $pageBuilderConfig
4756
* @param bool $overrideSnapshot
4857
* @param Repository|null $assetRepo
58+
* @param AuthorizationInterface|null $authorization
4959
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5060
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
5161
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -62,9 +72,11 @@ public function __construct(
6272
array $config = [],
6373
PageBuilderConfig $pageBuilderConfig = null,
6474
bool $overrideSnapshot = false,
65-
Repository $assetRepo = null
75+
Repository $assetRepo = null,
76+
AuthorizationInterface $authorization = null
6677
) {
6778
$this->assetRepo = $assetRepo ?: ObjectManager::getInstance()->get(Repository::class);
79+
$this->authorization = $authorization ?: ObjectManager::getInstance()->get(AuthorizationInterface::class);
6880
$wysiwygConfigData = $config['wysiwygConfigData'] ?? [];
6981

7082
// If a dataType is present we're dealing with an attribute
@@ -79,11 +91,11 @@ public function __construct(
7991
$config['wysiwyg'] = true;
8092
}
8193
}
82-
94+
$isAllowed = $this->authorization->isAllowed(self::ADMIN_RESOURCE);
8395
$isEnablePageBuilder = isset($wysiwygConfigData['is_pagebuilder_enabled'])
8496
&& !$wysiwygConfigData['is_pagebuilder_enabled']
8597
|| false;
86-
if (!$pageBuilderState->isPageBuilderInUse($isEnablePageBuilder)) {
98+
if (!$pageBuilderState->isPageBuilderInUse($isEnablePageBuilder) && $isAllowed) {
8799
// This is not done using definition.xml due to https://github.com/magento/magento2/issues/5647
88100
$data['config']['component'] = 'Magento_PageBuilder/js/form/element/wysiwyg';
89101

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="SpecificACLAdminUserCheckProductContentEditWithPageBuilderTest">
11+
<annotations>
12+
<features value="PageBuilder"/>
13+
<stories value="Catalog Products"/>
14+
<title value="Specific ACL Admin user verify product content modify with Page Builder"/>
15+
<description value="This test is designed to make sure that a limited admin user can effectively save the basic product content using PageBuilder.."/>
16+
<severity value="MAJOR"/>
17+
<useCaseId value="ACP2E-1646"/>
18+
<testCaseId value="AC-8107"/>
19+
</annotations>
20+
<before>
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
22+
<createData entity="_defaultCategory" stepKey="createCategory"/>
23+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
24+
<requiredEntity createDataKey="createCategory"/>
25+
</createData>
26+
</before>
27+
<after>
28+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsLimitedAdmin"/>
29+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/>
30+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
31+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
32+
<actionGroup ref="AdminDeleteCreatedUserActionGroup" stepKey="deleteAdminUser">
33+
<argument name="user" value="Admin3"/>
34+
</actionGroup>
35+
<actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteRole">
36+
<argument name="roleName" value="{{limitedAccessRole.name}}"/>
37+
</actionGroup>
38+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsAdmin1"/>
39+
</after>
40+
<!-- Create a restricted role with access only to Catalog -->
41+
<actionGroup ref="AdminCreateRoleWithoutScopeSelectionActionGroup" stepKey="createRestrictedRole">
42+
<argument name="restrictedRole" value="Catalog"/>
43+
<argument name="User" value="limitedAccessRole"/>
44+
</actionGroup>
45+
<actionGroup ref="AdminCreateUserWithRoleActionGroup" stepKey="createRestrictedAdmin">
46+
<argument name="role" value="limitedAccessRole"/>
47+
<argument name="user" value="Admin3"/>
48+
</actionGroup>
49+
<!-- Logout and login with newly created restricted user -->
50+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsAdmin"/>
51+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsLimitedAdmin">
52+
<argument name="username" value="{{Admin3.username}}"/>
53+
<argument name="password" value="{{Admin3.password}}"/>
54+
</actionGroup>
55+
<actionGroup ref="NavigateToCreatedProductEditPageActionGroup" stepKey="navigateToProductPage" >
56+
<argument name="product" value="$$createSimpleProduct$$"/>
57+
</actionGroup>
58+
<actionGroup ref="AdminOpenContentSectionOnProductPageActionGroup" stepKey="openContentSection"/>
59+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct"/>
60+
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="checkProductSavedMessage"/>
61+
</test>
62+
</tests>

0 commit comments

Comments
 (0)