File tree Expand file tree Collapse file tree 3 files changed +49
-8
lines changed
app/code/Magento/Customer
Ui/Component/Listing/Column
view/adminhtml/ui_component Expand file tree Collapse file tree 3 files changed +49
-8
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments