Skip to content

Commit bf234dc

Browse files
committed
AC-11642:Sales order sidebar fix
1 parent aa571b3 commit bf234dc

File tree

6 files changed

+72
-22
lines changed

6 files changed

+72
-22
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
declare(strict_types=1);
7-
86
namespace Magento\Sales\Block\Adminhtml\Order\Create;
97

10-
use Magento\Backend\Block\Widget\Button;
11-
use Magento\Framework\DataObject;
12-
138
/**
149
* Adminhtml sales order create sidebar
1510
*
1611
* @api
12+
* @author Magento Core Team <[email protected]>
1713
* @since 100.0.2
1814
*/
19-
class Sidebar extends AbstractCreate
15+
class Sidebar extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate
2016
{
2117
/**
2218
* Preparing global layout
@@ -27,7 +23,7 @@ protected function _prepareLayout()
2723
{
2824
if ($this->getCustomerId()) {
2925
$button = $this->getLayout()->createBlock(
30-
Button::class
26+
\Magento\Backend\Block\Widget\Button::class
3127
)->setData(
3228
[
3329
'label' => __('Update Changes'),
@@ -38,7 +34,9 @@ protected function _prepareLayout()
3834
]
3935
);
4036
$this->setChild('top_button', $button);
37+
}
4138

39+
if ($this->getCustomerId()) {
4240
$button = clone $button;
4341
$button->unsId();
4442
$this->setChild('bottom_button', $button);
@@ -49,7 +47,7 @@ protected function _prepareLayout()
4947
/**
5048
* Check if can display
5149
*
52-
* @param DataObject $child
50+
* @param \Magento\Framework\DataObject $child
5351
* @return true
5452
*/
5553
public function canDisplay($child)
@@ -59,14 +57,4 @@ public function canDisplay($child)
5957
}
6058
return true;
6159
}
62-
63-
/**
64-
* To check customer permission
65-
*
66-
* @return bool
67-
*/
68-
public function isAllowedAction(): bool
69-
{
70-
return $this->_authorization->isAllowed('Magento_Customer::customer');
71-
}
7260
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\ViewModel\Order\Create;
9+
10+
use Magento\Framework\AuthorizationInterface;
11+
use Magento\Framework\View\Element\Block\ArgumentInterface;
12+
13+
/**
14+
* Sidebar block permission check
15+
*/
16+
class SidebarPermissionCheck implements ArgumentInterface
17+
{
18+
/**
19+
* @var AuthorizationInterface
20+
*/
21+
private $authorization;
22+
23+
/**
24+
* Permissions constructor.
25+
*
26+
* @param AuthorizationInterface $authorization
27+
*/
28+
public function __construct(AuthorizationInterface $authorization)
29+
{
30+
$this->authorization = $authorization;
31+
}
32+
33+
/**
34+
* To check customer permission
35+
*
36+
* @return bool
37+
*/
38+
public function isAllowedAction(): bool
39+
{
40+
return $this->authorization->isAllowed('Magento_Customer::customer');
41+
}
42+
}

app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_index.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
</block>
3737
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Data" template="Magento_Sales::order/create/data.phtml" name="data">
3838
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar" template="Magento_Sales::order/create/sidebar.phtml" name="sidebar">
39+
<arguments>
40+
<argument name="sideBarPermissionCheck" xsi:type="object">Magento\Sales\ViewModel\Order\Create\SidebarPermissionCheck</argument>
41+
</arguments>
3942
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Cart" template="Magento_Sales::order/create/sidebar/items.phtml" name="cart"/>
4043
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Wishlist" template="Magento_Sales::order/create/sidebar/items.phtml" name="wishlist"/>
4144
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Reorder" template="Magento_Sales::order/create/sidebar/items.phtml" name="reorder"/>

app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_data.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<referenceContainer name="content">
1212
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Data" template="Magento_Sales::order/create/data.phtml" name="data">
1313
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar" template="Magento_Sales::order/create/sidebar.phtml" name="sidebar">
14+
<arguments>
15+
<argument name="sideBarPermissionCheck" xsi:type="object">Magento\Sales\ViewModel\Order\Create\SidebarPermissionCheck</argument>
16+
</arguments>
1417
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Cart" template="Magento_Sales::order/create/sidebar/items.phtml" name="cart"/>
1518
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Wishlist" template="Magento_Sales::order/create/sidebar/items.phtml" name="wishlist"/>
1619
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Reorder" template="Magento_Sales::order/create/sidebar/items.phtml" name="reorder"/>

app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_sidebar.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<body>
1010
<referenceContainer name="content">
1111
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar" template="Magento_Sales::order/create/sidebar.phtml" name="sidebar">
12+
<arguments>
13+
<argument name="sideBarPermissionCheck" xsi:type="object">Magento\Sales\ViewModel\Order\Create\SidebarPermissionCheck</argument>
14+
</arguments>
1215
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Cart" template="Magento_Sales::order/create/sidebar/items.phtml" name="cart"/>
1316
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Wishlist" template="Magento_Sales::order/create/sidebar/items.phtml" name="wishlist"/>
1417
<block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Reorder" template="Magento_Sales::order/create/sidebar/items.phtml" name="reorder"/>

app/code/Magento/Sales/view/adminhtml/templates/order/create/sidebar.phtml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
use Magento\Framework\Escaper;
8+
use Magento\Framework\View\Helper\SecureHtmlRenderer;
9+
use Magento\Sales\Block\Adminhtml\Order\Create\Sidebar;
10+
use Magento\Sales\ViewModel\Order\Create\SidebarPermissionCheck;
11+
712
/**
8-
* @var \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar $block
9-
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
10-
* @var \Magento\Framework\Escaper $escaper
13+
* @var Sidebar $block
14+
* @var SecureHtmlRenderer $secureRenderer
15+
* @var Escaper $escaper
1116
*/
17+
18+
/**
19+
* @var SidebarPermissionCheck $sideBarPermissionCheck
20+
*/
21+
$sideBarPermissionCheck = $block->getData('sideBarPermissionCheck');
22+
1223
?>
13-
<?php if ($block->isAllowedAction()): ?>
24+
<?php if ($sideBarPermissionCheck->isAllowedAction()): ?>
1425
<div class="customer-current-activity-inner">
1526
<h4 class="customer-activity-title"><?= $escaper->escapeHtml(__('Customer\'s Activities')) ?></h4>
1627
<div class="create-order-sidebar-container">

0 commit comments

Comments
 (0)