Skip to content

Commit 1fef35d

Browse files
authored
ENGCOM-4084: Add the ability to disable/remove an action from Mass(Tree)Action #20881
2 parents 6da7fbf + ed95f81 commit 1fef35d

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Ui\Component;
77

88
/**
9+
* Mass action UI component.
10+
*
911
* @api
1012
* @since 100.0.2
1113
*/
@@ -21,7 +23,12 @@ public function prepare()
2123
$config = $this->getConfiguration();
2224

2325
foreach ($this->getChildComponents() as $actionComponent) {
24-
$config['actions'][] = $actionComponent->getConfiguration();
26+
$componentConfig = $actionComponent->getConfiguration();
27+
$disabledAction = $componentConfig['actionDisable'] ?? false;
28+
if ($disabledAction) {
29+
continue;
30+
}
31+
$config['actions'][] = $componentConfig;
2532
}
2633

2734
$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)