Skip to content

Commit 36ebbdd

Browse files
authored
Merge pull request #17 from itsrcrowell/main
Add ACL for the AI Assistant on the dashboard page
2 parents c302032 + baa3cba commit 36ebbdd

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

Block/Adminhtml/AIAssistant.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Magento\Backend\Block\Template;
66
use Magento\Backend\Block\Template\Context;
7+
use Magento\Framework\AuthorizationInterface;
78
use Magento\Framework\App\Config\ScopeConfigInterface;
89
use Magento\Store\Model\ScopeInterface;
910

@@ -13,13 +14,17 @@ class AIAssistant extends Template
1314

1415
protected $scopeConfig;
1516

17+
protected $authorization;
18+
1619
public function __construct(
1720
Context $context,
1821
ScopeConfigInterface $scopeConfig,
22+
AuthorizationInterface $authorization,
1923
array $data = []
2024
) {
2125
parent::__construct($context, $data);
2226
$this->scopeConfig = $scopeConfig;
27+
$this->authorization = $authorization;
2328
}
2429

2530
public function getFormAction()
@@ -34,4 +39,9 @@ public function getApiKey()
3439
ScopeInterface::SCOPE_STORE
3540
);
3641
}
37-
}
42+
43+
public function isAllowed(): bool
44+
{
45+
return $this->authorization->isAllowed('Genaker_MagentoMcpAi::mcpai_dashboard_page');
46+
}
47+
}

etc/acl.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<resource id="Magento_Backend::content">
77
<resource id="Genaker_MagentoMcpAi::ai_assistant" title="AI Assistant" sortOrder="100">
88
<resource id="Genaker_MagentoMcpAi::mcpai" title="MCP AI Assistant" sortOrder="10"/>
9+
<resource id="Genaker_MagentoMcpAi::mcpai_dashboard_page" title="MCP AI Assistant Dashboard Page" sortOrder="20"/>
910
<resource id="Genaker_MagentoMcpAi::product_chat" title="Product Chat" sortOrder="30"/>
1011
</resource>
1112
</resource>

view/adminhtml/templates/ai_assistant.phtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<?php
2+
/** @var Genaker\MagentoMcpAi\Block\Adminhtml\AIAssistant $block */
3+
4+
if (!$block->isAllowed()) {
5+
return;
6+
}
7+
?>
18
<style>
29
.message.message:before {
310
position: absolute;

0 commit comments

Comments
 (0)