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
28
28
/**
29
29
* Url path
30
30
*/
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 ' ;
33
33
34
34
/**
35
35
* @var GroupManagementInterface
@@ -99,7 +99,7 @@ public function prepareDataSource(array $dataSource)
99
99
],
100
100
];
101
101
102
- if (!$ this ->groupManagement -> isReadonly ( $ item ['customer_group_id ' ])) {
102
+ if (!$ this ->canHideDeleteButton (( int ) $ item ['customer_group_id ' ])) {
103
103
$ item [$ this ->getData ('name ' )]['delete ' ] = [
104
104
'href ' => $ this ->urlBuilder ->getUrl (
105
105
static ::URL_PATH_DELETE ,
@@ -124,4 +124,17 @@ public function prepareDataSource(array $dataSource)
124
124
125
125
return $ dataSource ;
126
126
}
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
+ }
127
140
}
Original file line number Diff line number Diff line change 13
13
</argument >
14
14
<settings >
15
15
<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" />
21
17
</buttons >
22
18
<spinner >customer_group_columns</spinner >
23
19
<deps >
You can’t perform that action at this time.
0 commit comments