This can be done by creating a new class for MassActions:
<?php
namespace YourVendor\YourModule\Ui;
class MassAction extends \Magento\Ui\Component\MassAction
{
private $authorization;
public function __construct(
\Magento\Framework\View\Element\UiComponent\ContextInterface $context,
\Magento\Framework\AuthorizationInterface $authorization,
$components,
array $data
) {
$this->authorization = $authorization;
parent::__construct($context, $components, $data);
}
public function prepare()
{
parent::prepare();
$config = $this->getConfiguration();
if (!$this->authorization->isAllowed('YourVendor_YourModule::the_acl_youd_like_to_use')) {
$allowedActions = [];
foreach ($config['actions'] as $action) {
if ('delete' != $action['type']) {
$allowedActions[] = $action;
}
}
$config['actions'] = $allowedActions;
}
$this->setData('config', (array)$config);
}
}
Add setting it to customer listing with help of app/code/YourVendor/YourModule/view/adminhtml/ui_component/customer_listing.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<massaction name="listing_massaction" class="YourVendor\YourModule\Ui\MassAction"/>
</listingToolbar>
</listing>