Skip to content

Commit 3f1a3a9

Browse files
committed
Merge branch 'ACP2E-2146' of https://github.com/magento-l3/magento2ce into PR2-L3-09132023
2 parents 794d65a + 3f5f9d2 commit 3f1a3a9

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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\Customer\Block\Adminhtml\Group;
9+
10+
use Magento\Customer\Block\Adminhtml\Edit\GenericButton;
11+
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
12+
13+
/**
14+
* Class to get button details of AddCustomerGroup button
15+
*/
16+
class AddCustomerGroupButton extends GenericButton implements ButtonProviderInterface
17+
{
18+
/**
19+
* Get button data for AddCustomerGroup button
20+
*
21+
* @return array
22+
*/
23+
public function getButtonData(): array
24+
{
25+
return [
26+
'label' => __('Add New Customer Group'),
27+
'class' => 'primary',
28+
'url' => $this->getUrl('*/*/new'),
29+
'sort_order' => 80,
30+
];
31+
}
32+
}

app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class GroupActions extends Column
2828
/**
2929
* Url path
3030
*/
31-
const URL_PATH_EDIT = 'customer/group/edit';
32-
const URL_PATH_DELETE = 'customer/group/delete';
31+
public const URL_PATH_EDIT = 'customer/group/edit';
32+
public const URL_PATH_DELETE = 'customer/group/delete';
3333

3434
/**
3535
* @var GroupManagementInterface
@@ -99,7 +99,7 @@ public function prepareDataSource(array $dataSource)
9999
],
100100
];
101101

102-
if (!$this->groupManagement->isReadonly($item['customer_group_id'])) {
102+
if (!$this->canHideDeleteButton((int) $item['customer_group_id'])) {
103103
$item[$this->getData('name')]['delete'] = [
104104
'href' => $this->urlBuilder->getUrl(
105105
static::URL_PATH_DELETE,
@@ -124,4 +124,17 @@ public function prepareDataSource(array $dataSource)
124124

125125
return $dataSource;
126126
}
127+
128+
/**
129+
* Check if delete button can visible
130+
*
131+
* @param int $customer_group_id
132+
* @return bool
133+
* @throws LocalizedException
134+
* @throws NoSuchEntityException
135+
*/
136+
public function canHideDeleteButton(int $customer_group_id): bool
137+
{
138+
return $this->groupManagement->isReadonly($customer_group_id);
139+
}
127140
}

app/code/Magento/Customer/view/adminhtml/ui_component/customer_group_listing.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
</argument>
1414
<settings>
1515
<buttons>
16-
<button name="add">
17-
<url path="*/*/new"/>
18-
<class>primary</class>
19-
<label translate="true">Add New Customer Group</label>
20-
</button>
16+
<button name="add" class="Magento\Customer\Block\Adminhtml\Group\AddCustomerGroupButton"/>
2117
</buttons>
2218
<spinner>customer_group_columns</spinner>
2319
<deps>

0 commit comments

Comments
 (0)