Skip to content

Commit 8ee5027

Browse files
authored
Merge pull request #1 from magento-performance/CABPI-364
CABPI-364: AdobeStock UI changes
2 parents 74acfc7 + 0a797f2 commit 8ee5027

File tree

7 files changed

+145
-8
lines changed

7 files changed

+145
-8
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AdobeStockAdminUi\Block\Adminhtml\System\Config;
10+
11+
use Magento\Config\Block\System\Config\Form\Field;
12+
use Magento\Framework\Data\Form\Element\AbstractElement;
13+
14+
/**
15+
* Hide Admin Adobe IMS status in admin system config
16+
*/
17+
class HideAdminAdobeImsStatus extends Field
18+
{
19+
/**
20+
* Hide Admin Adobe IMS enabled/disabled status
21+
*
22+
* @param AbstractElement $element
23+
* @param string $html
24+
* @return string
25+
*/
26+
protected function _decorateRowHtml(AbstractElement $element, $html)
27+
{
28+
$style = ' style="display: none"';
29+
30+
return '<tr id="row_' . $element->getHtmlId() . '"' . $style .'>' . $html . '</tr>';
31+
}
32+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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\AdobeStockAdminUi\Block\Adminhtml\System\Config;
9+
10+
use Magento\AdminAdobeIms\Service\ImsConfig;
11+
use Magento\Backend\Block\Template\Context;
12+
use Magento\Config\Block\System\Config\Form\Field;
13+
use Magento\Framework\Data\Form\Element\AbstractElement;
14+
use Magento\Framework\View\Helper\SecureHtmlRenderer;
15+
16+
/**
17+
* Renderer of notice for IMS integration for Adobe Stock
18+
*/
19+
class ImsIntegrationNotice extends Field
20+
{
21+
/**
22+
* @var ImsConfig
23+
*/
24+
private ImsConfig $adminAdobeImsConfig;
25+
26+
/**
27+
* Template path
28+
*
29+
* @var string
30+
*/
31+
protected $_template = 'Magento_AdobeStockAdminUi::system/config/ims_integration_notice.phtml';
32+
33+
/**
34+
* @param Context $context
35+
* @param ImsConfig $adminAdobeImsConfig
36+
* @param array $data
37+
* @param SecureHtmlRenderer|null $secureRenderer
38+
*/
39+
public function __construct(
40+
Context $context,
41+
ImsConfig $adminAdobeImsConfig,
42+
array $data = [],
43+
?SecureHtmlRenderer $secureRenderer = null
44+
) {
45+
$this->adminAdobeImsConfig = $adminAdobeImsConfig;
46+
parent::__construct($context, $data, $secureRenderer);
47+
}
48+
49+
/**
50+
* Render field html
51+
*
52+
* @param AbstractElement $element
53+
* @return string
54+
*/
55+
public function render(AbstractElement $element)
56+
{
57+
if (!$this->adminAdobeImsConfig->enabled()) {
58+
return $this->_decorateRowHtml($element, "<td colspan='4'>" . $this->toHtml() . '</td>');
59+
}
60+
61+
return '';
62+
}
63+
}

AdobeStockAdminUi/Block/Adminhtml/System/Config/TestConnection.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
namespace Magento\AdobeStockAdminUi\Block\Adminhtml\System\Config;
1010

11+
use Magento\AdminAdobeIms\Service\ImsConfig;
1112
use Magento\AdobeImsApi\Api\ConfigInterface;
1213
use Magento\AdobeStockClientApi\Api\ClientInterface;
1314
use Magento\Backend\Block\Template\Context;
1415
use Magento\Config\Block\System\Config\Form\Field;
16+
use Magento\Framework\App\ObjectManager;
1517
use Magento\Framework\Data\Form\Element\AbstractElement;
1618

1719
/**
@@ -22,7 +24,7 @@ class TestConnection extends Field
2224
private const TEST_CONNECTION_PATH = 'adobe_stock/system_config/testconnection';
2325

2426
/**
25-
* @inheritdoc
27+
* @var string
2628
*/
2729
protected $_template = 'Magento_AdobeStockAdminUi::system/config/connection.phtml';
2830

@@ -37,21 +39,28 @@ class TestConnection extends Field
3739
private $config;
3840

3941
/**
40-
* TestConnection constructor.
41-
*
42+
* @var ImsConfig
43+
*/
44+
private ImsConfig $adminAdobeImsConfig;
45+
46+
/**
4247
* @param ClientInterface $client
4348
* @param ConfigInterface $config
44-
* @param Context $context
45-
* @param array $data
49+
* @param Context $context
50+
* @param array $data
51+
* @param ImsConfig|null $adminAdobeImsConfig
4652
*/
4753
public function __construct(
4854
ClientInterface $client,
4955
ConfigInterface $config,
5056
Context $context,
51-
array $data = []
57+
array $data = [],
58+
?ImsConfig $adminAdobeImsConfig = null
5259
) {
5360
$this->client = $client;
5461
$this->config = $config;
62+
$this->adminAdobeImsConfig = $adminAdobeImsConfig
63+
?? ObjectManager::getInstance()->get(ImsConfig::class);
5564
parent::__construct($context, $data);
5665
}
5766

@@ -63,8 +72,13 @@ public function __construct(
6372
*/
6473
public function render(AbstractElement $element): string
6574
{
66-
$element->setData('scope', null);
67-
return parent::render($element);
75+
// render Test Connection button only if Admin Adobe IMS is disabled
76+
if (!$this->adminAdobeImsConfig->enabled()) {
77+
$element->setData('scope', null);
78+
return parent::render($element);
79+
}
80+
81+
return '';
6882
}
6983

7084
/**

AdobeStockAdminUi/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"require": {
55
"php": "~7.4.0||~8.1.0",
66
"magento/framework": "*",
7+
"magento/module-admin-adobe-ims": "*",
78
"magento/module-adobe-ims-api": "*",
89
"magento/module-adobe-stock-client-api": "*",
910
"magento/module-backend": "*",

AdobeStockAdminUi/etc/adminhtml/system.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,27 @@
1010
<section id="system">
1111
<group id="adobe_stock_integration" translate="label" type="text" sortOrder="1100" showInDefault="1" showInWebsite="0" showInStore="0">
1212
<label>Adobe Stock Integration</label>
13+
<field id="ims_integration_notice" translate="label" type="note" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
14+
<frontend_model>Magento\AdobeStockAdminUi\Block\Adminhtml\System\Config\ImsIntegrationNotice</frontend_model>
15+
</field>
1316
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
1417
<label>Enabled Adobe Stock</label>
1518
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1619
<config_path>adobe_stock/integration/enabled</config_path>
1720
</field>
21+
<field id="admin_adobe_ims_enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
22+
<label>Enabled Admin Adobe Ims</label>
23+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
24+
<config_path>adobe_ims/integration/admin_enabled</config_path>
25+
<frontend_model>Magento\AdobeStockAdminUi\Block\Adminhtml\System\Config\HideAdminAdobeImsStatus</frontend_model>
26+
</field>
1827
<field id="api_key" translate="label" type="obscure" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
1928
<label>API Key (Client ID)</label>
2029
<config_path>adobe_ims/integration/api_key</config_path>
2130
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
2231
<depends>
2332
<field id="enabled">1</field>
33+
<field id="admin_adobe_ims_enabled">0</field>
2434
</depends>
2535
</field>
2636
<field id="private_key" translate="label comment" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
@@ -29,6 +39,7 @@
2939
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
3040
<depends>
3141
<field id="enabled">1</field>
42+
<field id="admin_adobe_ims_enabled">0</field>
3243
</depends>
3344
<comment><![CDATA[Configure an Adobe Stock account on <a href="https://console.adobe.io" target="_blank">adobe.io</a> to get the API Key (Client ID) and Client Secret. You will not be able to use the integration without both the API Key and Client Secret.]]></comment>
3445
</field>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/**
8+
* @var \Magento\AdobeStockAdminUi\Block\Adminhtml\System\Config\ImsIntegrationNotice $block
9+
*/
10+
11+
?>
12+
<div class="message message-warning">
13+
<?= $block->escapeHtml(__('If you have Adobe IMS Organization, follow <a href="%1">these steps</a>'
14+
. ' to setup integration.', 'https://devdocs.magento.com/'), ['a']) ?>
15+
</div>

AdobeStockImageAdminUi/view/adminhtml/web/template/signIn.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
class="adobe-sign-out-button"
4848
id="adobeImsSignOut"
4949
click="logout"
50+
data-bind="visible: !isGlobalSignInEnabled"
5051
data-role="signOutBtn"
5152
type="button">
5253
<span>Sign Out</span>

0 commit comments

Comments
 (0)