Skip to content

Commit

Permalink
Merge pull request #101 from ihorvansach/refactor-code-loginascustome…
Browse files Browse the repository at this point in the history
…r-ui

Moved all UI from LoginAsCustomer to new LoginAsCustomerUi module
  • Loading branch information
naydav authored Apr 27, 2020
2 parents 60bf50a + 6103998 commit bf65ffc
Show file tree
Hide file tree
Showing 49 changed files with 125 additions and 64 deletions.
1 change: 0 additions & 1 deletion app/code/Magento/LoginAsCustomer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"magento/module-customer": "*",
"magento/module-sales": "*",
"magento/module-store": "*",
"magento/module-ui": "*",
"magento/module-user": "*"
},
"suggest": {
Expand Down
3 changes: 0 additions & 3 deletions app/code/Magento/LoginAsCustomer/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Backend\Block\Widget\Button\Toolbar">
<plugin name="Magento_LoginAsCustomer::toolbar_button" type="Magento\LoginAsCustomer\Plugin\Button\ToolbarPlugin" />
</type>
<type name="Magento\Sales\Model\Order">
<plugin name="lac-admin-order-placement-comment" type="Magento\LoginAsCustomer\Plugin\AdminAddCommentOnOrderPlacementPlugin"/>
</type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Block\Adminhtml;
namespace Magento\LoginAsCustomerUi\Block\Adminhtml;

/**
* Login as customer log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Controller\Adminhtml\Login;
namespace Magento\LoginAsCustomerUi\Controller\Adminhtml\Login;

use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Controller\ResultInterface;
Expand All @@ -22,7 +22,7 @@ class Grid extends Action implements HttpPostActionInterface
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'Magento_LoginAsCustomer::login_log';
const ADMIN_RESOURCE = 'Magento_LoginAsCustomerUi::login_log';

/**
* Login as customer log ajax grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Controller\Adminhtml\Login;
namespace Magento\LoginAsCustomerUi\Controller\Adminhtml\Login;

use Magento\Backend\Model\View\Result\Page;
use Magento\Framework\Controller\ResultFactory;
Expand All @@ -25,7 +25,7 @@ class Index extends Action implements HttpGetActionInterface, HttpPostActionInte
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'Magento_LoginAsCustomer::login_log';
const ADMIN_RESOURCE = 'Magento_LoginAsCustomerUi::login_log';

/**
* Login As Customer log grid action
Expand All @@ -42,7 +42,7 @@ public function execute():ResultInterface

/** @var Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage->setActiveMenu('Magento_LoginAsCustomer::login_log')
$resultPage->setActiveMenu('Magento_LoginAsCustomerUi::login_log')
->addBreadcrumb(__('Customer'), __('Login As Customer Log'));
$resultPage->getConfig()->getTitle()->prepend(__('Login As Customer Log'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Controller\Adminhtml\Login;
namespace Magento\LoginAsCustomerUi\Controller\Adminhtml\Login;

use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\App\Action\HttpGetActionInterface;
Expand All @@ -28,7 +28,7 @@ class Login extends Action implements HttpGetActionInterface, HttpPostActionInte
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'Magento_LoginAsCustomer::login_button';
const ADMIN_RESOURCE = 'Magento_LoginAsCustomerUi::login_button';

/**
* @var \Magento\Backend\Model\Auth\Session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Controller\Adminhtml\Login;
namespace Magento\LoginAsCustomerUi\Controller\Adminhtml\Login;

use Magento\Backend\Model\View\Result\Page;
use Magento\Framework\Controller\ResultFactory;
Expand All @@ -23,7 +23,7 @@ class Manual extends Action implements HttpGetActionInterface
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'Magento_LoginAsCustomer::login_button';
const ADMIN_RESOURCE = 'Magento_LoginAsCustomerUi::login_button';

/**
* Chose store view for Login as customer
Expand All @@ -34,7 +34,7 @@ public function execute():ResultInterface
{
/** @var Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage->setActiveMenu('Magento_LoginAsCustomer::login_button')
$resultPage->setActiveMenu('Magento_LoginAsCustomerUi::login_button')
->addBreadcrumb(__('Customer'), __('Login As Customer Log'), __('Store View To Login In'));
$resultPage->getConfig()->getTitle()->prepend(__('Store View To Login In'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Controller\Login;
namespace Magento\LoginAsCustomerUi\Controller\Login;

use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\Result\Redirect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Controller\Login;
namespace Magento\LoginAsCustomerUi\Controller\Login;

use Magento\Backend\Model\View\Result\Page;
use Magento\Framework\Controller\ResultFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\CustomerData;
namespace Magento\LoginAsCustomerUi\CustomerData;

use Magento\Customer\CustomerData\SectionSourceInterface;
use Magento\Customer\Model\Session;
Expand All @@ -16,7 +16,7 @@
*
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class LoginAsCustomer implements SectionSourceInterface
class LoginAsCustomerUi implements SectionSourceInterface
{
/**
* @var Session
Expand All @@ -29,7 +29,7 @@ class LoginAsCustomer implements SectionSourceInterface
private $storeManager;

/**
* LoginAsCustomer constructor.
* LoginAsCustomerUi constructor.
* @param Session $customerSession
* @param StoreManagerInterface $storeManager
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Model\Config\Source;
namespace Magento\LoginAsCustomerUi\Model\Config\Source;

/**
* Class StoreViewLogin
* @package Magento\LoginAsCustomer\Model\Config\Source
*/
class StoreViewLogin implements \Magento\Framework\Data\OptionSourceInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Model;
namespace Magento\LoginAsCustomerUi\Model;

/**
* Login model
Expand All @@ -19,6 +19,6 @@ class Login extends \Magento\Framework\Model\AbstractModel
*/
protected function _construct()
{
$this->_init(\Magento\LoginAsCustomer\Model\ResourceModel\Login::class);
$this->_init(\Magento\LoginAsCustomerUi\Model\ResourceModel\Login::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Model\PageCache;
namespace Magento\LoginAsCustomerUi\Model\PageCache;

/**
* Page cache config plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Model\ResourceModel;
namespace Magento\LoginAsCustomerUi\Model\ResourceModel;

/**
* LoginAsCustomer resource model
* LoginAsCustomerUi resource model
*/
class Login extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Model\ResourceModel\Login;
namespace Magento\LoginAsCustomerUi\Model\ResourceModel\Login;

/**
* LoginAsCustomer collection
* LoginAsCustomerUi collection
*/
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
Expand All @@ -21,6 +21,6 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
protected function _construct()
{
parent::_construct();
$this->_init(\Magento\LoginAsCustomer\Model\Login::class, \Magento\LoginAsCustomer\Model\ResourceModel\Login::class);
$this->_init(\Magento\LoginAsCustomerUi\Model\Login::class, \Magento\LoginAsCustomerUi\Model\ResourceModel\Login::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Model\ResourceModel\Login\Grid;
namespace Magento\LoginAsCustomerUi\Model\ResourceModel\Login\Grid;

/**
* LoginAsCustomer collection
* LoginAsCustomerUi collection
*/
class Collection extends \Magento\LoginAsCustomer\Model\ResourceModel\Login\Collection
class Collection extends \Magento\LoginAsCustomerUi\Model\ResourceModel\Login\Collection
{
/**
* Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Plugin\Button;
namespace Magento\LoginAsCustomerUi\Plugin\Button;

use Magento\Backend\Block\Widget\Button\ButtonList;
use Magento\Backend\Block\Widget\Button\Toolbar;
Expand Down Expand Up @@ -91,6 +91,6 @@ public function beforePushButtons(
*/
private function isAllowed(): bool
{
return (bool)$this->authorization->isAllowed('Magento_LoginAsCustomer::login_button');
return (bool)$this->authorization->isAllowed('Magento_LoginAsCustomerUi::login_button');
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/LoginAsCustomerUi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Magento_LoginAsCustomerSales module

The Magento_LoginAsCustomerUi module provides UI for Magento_LoginAsCustomerUi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Ui\Customer\Component\Control;
namespace Magento\LoginAsCustomerUi\Ui\Customer\Component\Control;

use Magento\Customer\Block\Adminhtml\Edit\GenericButton;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
Expand Down Expand Up @@ -39,7 +39,7 @@ public function getButtonData(): array
{
$customerId = $this->getCustomerId();
$data = [];
$canModify = $customerId && $this->authorization->isAllowed('Magento_LoginAsCustomer::login_button');
$canModify = $customerId && $this->authorization->isAllowed('Magento_LoginAsCustomerUi::login_button');
if ($canModify) {
$data = [
'label' => __('Login As Customer'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Ui\Store\Component\Control;
namespace Magento\LoginAsCustomerUi\Ui\Store\Component\Control;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\Ui\Store\DataProvider\Form;
namespace Magento\LoginAsCustomerUi\Ui\Store\DataProvider\Form;

use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
use Magento\Ui\DataProvider\AbstractDataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\LoginAsCustomer\ViewModel;
namespace Magento\LoginAsCustomerUi\ViewModel;

use Magento\Customer\Model\Context;

Expand Down
26 changes: 26 additions & 0 deletions app/code/Magento/LoginAsCustomerUi/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "magento/module-login-as-customer-ui",
"description": "",
"require": {
"php": "~7.1.3||~7.2.0||~7.3.0",
"magento/framework": "*",
"magento/module-login-as-customer": "*",
"magento/module-backend": "*",
"magento/module-customer": "*",
"magento/module-sales": "*",
"magento/module-store": "*",
"magento/module-ui": "*",
"magento/module-user": "*"
},
"type": "magento2-module",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Magento\\LoginAsCustomerUi\\": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Customer::customer">
<resource id="Magento_LoginAsCustomer::login" title="Login as Customer" sortOrder="50">
<resource id="Magento_LoginAsCustomer::login_button" title="Allow Login as Customer Button" sortOrder="10" />
<resource id="Magento_LoginAsCustomer::login_log" title="View Login as Customer Log" sortOrder="20" />
<resource id="Magento_LoginAsCustomerUi::login" title="Login as Customer" sortOrder="50">
<resource id="Magento_LoginAsCustomerUi::login_button" title="Allow Login as Customer Button" sortOrder="10" />
<resource id="Magento_LoginAsCustomerUi::login_log" title="View Login as Customer Log" sortOrder="20" />
</resource>
</resource>
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Magento_LoginAsCustomer::config_section" title="Login as Customer Section" />
<resource id="Magento_LoginAsCustomerUi::config_section" title="Login as Customer Section" />
</resource>
</resource>
</resource>
Expand Down
12 changes: 12 additions & 0 deletions app/code/Magento/LoginAsCustomerUi/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" ?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Backend\Block\Widget\Button\Toolbar">
<plugin name="login_as_customer_button_toolbar" type="Magento\LoginAsCustomerUi\Plugin\Button\ToolbarPlugin" />
</type>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Magento_LoginAsCustomer::login_log" title="Login As Customer Log" module="Magento_LoginAsCustomer" parent="Magento_Customer::customer" sortOrder="40" resource="Magento_LoginAsCustomer::login_log" action="loginascustomer/login/" />
<add id="Magento_LoginAsCustomerUi::login_log" title="Login As Customer Log" module="Magento_LoginAsCustomerUi" parent="Magento_Customer::customer" sortOrder="40" resource="Magento_LoginAsCustomerUi::login_log" action="loginascustomer/login/" />
</menu>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="loginascustomer" frontName="loginascustomer">
<module name="Magento_LoginAsCustomer" />
<module name="Magento_LoginAsCustomerUi" />
</route>
</router>
</config>
Loading

0 comments on commit bf65ffc

Please sign in to comment.