Skip to content

Commit f8e407d

Browse files
committed
Add the ability to disable/remove an action from Mass(Tree)Action
1 parent ba5bf0d commit f8e407d

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

app/code/Magento/Ui/Component/MassAction.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ public function prepare()
2121
$config = $this->getConfiguration();
2222

2323
foreach ($this->getChildComponents() as $actionComponent) {
24-
$config['actions'][] = $actionComponent->getConfiguration();
24+
$actionComponentConfig = $actionComponent->getConfiguration();
25+
$disabledAction = $actionComponentConfig['actionDisable'] ?? false;
26+
if ($disabledAction) {
27+
continue;
28+
}
29+
$config['actions'][] = $actionComponentConfig;
2530
}
2631

2732
$origConfig = $this->getConfiguration();

app/code/Magento/Ui/view/base/ui_component/etc/definition.map.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<item name="label" type="string" translate="true" xsi:type="xpath">settings/label</item>
1515
<item name="type" type="string" xsi:type="xpath">settings/type</item>
1616
<item name="url" type="url" xsi:type="converter">settings/url</item>
17+
<item name="actionDisable" type="boolean" xsi:type="xpath">settings/actionDisable</item>
1718
<item name="confirm" xsi:type="array">
1819
<item name="title" type="string" translate="true" xsi:type="xpath">settings/confirm/title</item>
1920
<item name="message" type="string" translate="true" xsi:type="xpath">settings/confirm/message</item>

app/code/Magento/Ui/view/base/ui_component/etc/definition/action.xsd

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
</xs:documentation>
5050
</xs:annotation>
5151
</xs:element>
52+
<xs:element name="actionDisable" type="xs:boolean">
53+
<xs:annotation>
54+
<xs:documentation>
55+
Disable and remove this action.
56+
</xs:documentation>
57+
</xs:annotation>
58+
</xs:element>
5259
</xs:choice>
5360
<xs:attribute name="name" use="required"/>
5461
</xs:complexType>
@@ -82,6 +89,13 @@
8289
</xs:documentation>
8390
</xs:annotation>
8491
</xs:element>
92+
<xs:element name="actionDisable" type="xs:boolean">
93+
<xs:annotation>
94+
<xs:documentation>
95+
Disable and remove this action.
96+
</xs:documentation>
97+
</xs:annotation>
98+
</xs:element>
8599
<xs:element name="confirm" type="confirmType">
86100
<xs:annotation>
87101
<xs:documentation>

0 commit comments

Comments
 (0)